Fix delete buttons
This commit fixes the delete buttons in all of the GBPUI panels where checked items were deleted even when using individual (row) delete actions. Change-Id: I4ac44bda1baf28b5056d07adf1236b9a43fbad4c Closes-Bug: 1707896
This commit is contained in:
parent
739852105a
commit
f4deab2aae
|
@ -15,6 +15,8 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
from horizon import tables
|
||||
|
||||
from gbpui import client
|
||||
|
||||
|
||||
class AddAppPolicyLink(tables.LinkAction):
|
||||
name = "addpolicy_rule_set"
|
||||
|
@ -35,13 +37,16 @@ class UpdateAppPolicyLink(tables.LinkAction):
|
|||
return base_url
|
||||
|
||||
|
||||
class DeleteAppPolicyLink(tables.DeleteAction):
|
||||
class DeletePolicyRuleSetLink(tables.DeleteAction):
|
||||
name = "deletepolicyruleset"
|
||||
action_present = _("Delete")
|
||||
action_past = _("Scheduled deletion of %(data_type)s")
|
||||
data_type_singular = _("Policy Rule Set")
|
||||
data_type_plural = _("Policy Rule Sets")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.policy_rule_set_delete(request, object_id)
|
||||
|
||||
|
||||
class AddPolicyRuleLink(tables.LinkAction):
|
||||
name = "addpolicyrules"
|
||||
|
@ -69,6 +74,9 @@ class DeletePolicyRuleLink(tables.DeleteAction):
|
|||
data_type_singular = _("Policy Rule")
|
||||
data_type_plural = _("Policy Rules")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.policyrule_delete(request, object_id)
|
||||
|
||||
|
||||
class AddPolicyClassifierLink(tables.LinkAction):
|
||||
name = "addpolicyclassifiers"
|
||||
|
@ -96,6 +104,9 @@ class DeletePolicyClassifierLink(tables.DeleteAction):
|
|||
data_type_singular = _("Policy Classifier")
|
||||
data_type_plural = _("Policy Classifiers")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.policyclassifier_delete(request, object_id)
|
||||
|
||||
|
||||
class AddPolicyActionLink(tables.LinkAction):
|
||||
name = "addpolicyactions"
|
||||
|
@ -123,6 +134,9 @@ class DeletePolicyActionLink(tables.DeleteAction):
|
|||
data_type_singular = _("Policy Action")
|
||||
data_type_plural = _("Policy Actions")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.policyaction_delete(request, object_id)
|
||||
|
||||
|
||||
class ApplicationPoliciesTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
|
@ -137,8 +151,8 @@ class ApplicationPoliciesTable(tables.DataTable):
|
|||
class Meta(object):
|
||||
name = "application_policies_table"
|
||||
verbose_name = _("Policy Rule Set")
|
||||
table_actions = (AddAppPolicyLink, DeleteAppPolicyLink)
|
||||
row_actions = (UpdateAppPolicyLink, DeleteAppPolicyLink)
|
||||
table_actions = (AddAppPolicyLink, DeletePolicyRuleSetLink)
|
||||
row_actions = (UpdateAppPolicyLink, DeletePolicyRuleSetLink)
|
||||
|
||||
|
||||
class PolicyRulesTable(tables.DataTable):
|
||||
|
|
|
@ -9,20 +9,12 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import re
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import messages
|
||||
from horizon import tabs
|
||||
from horizon import workflows
|
||||
|
||||
from gbpui import client
|
||||
|
||||
import forms as policy_rule_set_forms
|
||||
import tabs as policy_rule_set_tabs
|
||||
import workflows as policy_rule_set_workflows
|
||||
|
@ -37,54 +29,10 @@ AddPolicyRule = policy_rule_set_workflows.AddPolicyRule
|
|||
AddPolicyClassifier = policy_rule_set_workflows.AddPolicyClassifier
|
||||
|
||||
|
||||
class IndexView(tabs.TabView):
|
||||
class IndexView(tabs.TabbedTableView):
|
||||
tab_group_class = (PolicyRuleSetTabs)
|
||||
template_name = 'project/application_policy/details_tabs.html'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
obj_ids = request.POST.getlist('object_ids')
|
||||
action = request.POST['action']
|
||||
obj_type = re.search('delete([a-z]+)', action).group(1)
|
||||
if not obj_ids:
|
||||
obj_ids.append(re.search('([0-9a-z-]+)$', action).group(1))
|
||||
if obj_type == 'policyaction':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.policyaction_delete(request, obj_id)
|
||||
messages.success(request, _('Deleted action %s') % obj_id)
|
||||
except Exception as e:
|
||||
msg = _('Unable to delete action. %s') % (str(e))
|
||||
exceptions.handle(request, msg)
|
||||
if obj_type == 'policyclassifier':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.policyclassifier_delete(request, obj_id)
|
||||
messages.success(
|
||||
request, _('Deleted classifer %s') % obj_id)
|
||||
except Exception as e:
|
||||
msg = _('Unable to delete action. %s') % (str(e))
|
||||
exceptions.handle(request, msg)
|
||||
if obj_type == 'policyrule':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.policyrule_delete(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted rule %s') % obj_id)
|
||||
except Exception as e:
|
||||
msg = _('Unable to delete action. %s') % (str(e))
|
||||
exceptions.handle(request, msg)
|
||||
if obj_type == 'policyruleset':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.policy_rule_set_delete(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted rule %s') % obj_id)
|
||||
except Exception as e:
|
||||
msg = _('Unable to delete action. %s') % (str(e))
|
||||
exceptions.handle(request, msg)
|
||||
|
||||
return self.get(request, *args, **kwargs)
|
||||
|
||||
|
||||
class AddPolicyRuleSetView(workflows.WorkflowView):
|
||||
workflow_class = AddPolicyRuleSet
|
||||
|
|
|
@ -15,6 +15,8 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
from horizon import tables
|
||||
|
||||
from gbpui import client
|
||||
|
||||
|
||||
class CreateL2PolicyLink(tables.LinkAction):
|
||||
name = "create_l2policy"
|
||||
|
@ -30,7 +32,7 @@ class EditL2PolicyLink(tables.LinkAction):
|
|||
|
||||
def get_link_url(self, l2policy):
|
||||
base_url = reverse("horizon:project:network_policy:update_l2policy",
|
||||
kwargs={'l2policy_id': l2policy.id})
|
||||
kwargs={'l2policy_id': l2policy.id})
|
||||
return base_url
|
||||
|
||||
|
||||
|
@ -41,11 +43,16 @@ class DeleteL2PolicyLink(tables.DeleteAction):
|
|||
data_type_singular = _("L2Policy")
|
||||
data_type_plural = _("L2Policies")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.l2policy_delete(request, object_id)
|
||||
|
||||
|
||||
class L2PolicyTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_policy:l2policy_details")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_policy:l2policy_details"
|
||||
)
|
||||
description = tables.Column("description", verbose_name=_("Description"))
|
||||
id = tables.Column("id", verbose_name=_("ID"))
|
||||
l3_policy_id = tables.Column(
|
||||
|
@ -74,7 +81,7 @@ class EditL3PolicyLink(tables.LinkAction):
|
|||
|
||||
def get_link_url(self, l3policy):
|
||||
base_url = reverse("horizon:project:network_policy:update_l3policy",
|
||||
kwargs={'l3policy_id': l3policy.id})
|
||||
kwargs={'l3policy_id': l3policy.id})
|
||||
return base_url
|
||||
|
||||
|
||||
|
@ -85,11 +92,16 @@ class DeleteL3PolicyLink(tables.DeleteAction):
|
|||
data_type_singular = _("L3 Policy")
|
||||
data_type_plural = _("L3 Policies")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.l3policy_delete(request, object_id)
|
||||
|
||||
|
||||
class L3PolicyTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_policy:l3policy_details")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_policy:l3policy_details"
|
||||
)
|
||||
description = tables.Column("description", verbose_name=_("Description"))
|
||||
id = tables.Column("id", verbose_name=_("ID"))
|
||||
ip_version = tables.Column("ip_version", verbose_name=_("IP Version"))
|
||||
|
@ -97,7 +109,7 @@ class L3PolicyTable(tables.DataTable):
|
|||
subnet_prefix_length = tables.Column(
|
||||
"subnet_prefix_length", verbose_name=_("Subnet Prefix Length"))
|
||||
external_segments = tables.Column("external_segments",
|
||||
verbose_name=_("External Segment"))
|
||||
verbose_name=_("External Segment"))
|
||||
|
||||
class Meta(object):
|
||||
name = "l3policy_table"
|
||||
|
@ -131,13 +143,20 @@ class DeleteServicePolicyLink(tables.DeleteAction):
|
|||
data_type_singular = _("ServicePolicy")
|
||||
data_type_plural = _("ServicePolicies")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.delete_networkservice_policy(request, object_id)
|
||||
|
||||
|
||||
class ServicePolicyTable(tables.DataTable):
|
||||
name = tables.Column("name", verbose_name=_("Name"),
|
||||
link="horizon:project:network_policy:service_policy_details")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_policy:service_policy_details"
|
||||
)
|
||||
description = tables.Column("description", verbose_name=_("Description"))
|
||||
network_service_params = tables.Column('network_service_params',
|
||||
verbose_name=_("Network Service Params"))
|
||||
verbose_name=_(
|
||||
"Network Service Params"))
|
||||
|
||||
class Meta(object):
|
||||
name = "service_policy_table"
|
||||
|
@ -161,8 +180,12 @@ class EditExternalConnectivityLink(tables.LinkAction):
|
|||
def get_link_url(self, external_connectivity):
|
||||
urlstring = \
|
||||
"horizon:project:network_policy:update_externalconnectivity"
|
||||
base_url = reverse(urlstring,
|
||||
kwargs={'external_connectivity_id': external_connectivity.id})
|
||||
base_url = reverse(
|
||||
urlstring,
|
||||
kwargs={
|
||||
'external_connectivity_id': external_connectivity.id
|
||||
}
|
||||
)
|
||||
return base_url
|
||||
|
||||
|
||||
|
@ -173,10 +196,16 @@ class DeleteExternalConnectivityLink(tables.DeleteAction):
|
|||
data_type_singular = _("ExternalConnectivity")
|
||||
data_type_plural = _("ExternalConnectivities")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.delete_externalconnectivity(request, object_id)
|
||||
|
||||
|
||||
class ExternalConnectivityTable(tables.DataTable):
|
||||
name = tables.Column("name", verbose_name=_("Name"),
|
||||
link="horizon:project:network_policy:external_connectivity_details")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_policy:external_connectivity_details"
|
||||
)
|
||||
description = tables.Column("description", verbose_name=_("Description"))
|
||||
ip_version = tables.Column("ip_version", verbose_name=_("IP Version"))
|
||||
cidr = tables.Column("cidr", verbose_name=_("CIDR"))
|
||||
|
@ -185,9 +214,9 @@ class ExternalConnectivityTable(tables.DataTable):
|
|||
name = "external_connectivity_table"
|
||||
verbose_name = _("External Connectivity")
|
||||
table_actions = (CreateExternalConnectivityLink,
|
||||
DeleteExternalConnectivityLink,)
|
||||
DeleteExternalConnectivityLink,)
|
||||
row_actions = (EditExternalConnectivityLink,
|
||||
DeleteExternalConnectivityLink,)
|
||||
DeleteExternalConnectivityLink,)
|
||||
|
||||
|
||||
class CreateNATPoolLink(tables.LinkAction):
|
||||
|
@ -204,6 +233,9 @@ class DeleteNATPoolLink(tables.DeleteAction):
|
|||
data_type_singular = _("NAT Pool")
|
||||
data_type_plural = _("NAT Pools")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.delete_natpool(request, object_id)
|
||||
|
||||
|
||||
class EditNATPoolLink(tables.LinkAction):
|
||||
name = "update_nat_pool"
|
||||
|
@ -214,13 +246,16 @@ class EditNATPoolLink(tables.LinkAction):
|
|||
urlstring = \
|
||||
"horizon:project:network_policy:update_natpool"
|
||||
base_url = reverse(urlstring,
|
||||
kwargs={'nat_pool_id': nat_pool.id})
|
||||
kwargs={'nat_pool_id': nat_pool.id})
|
||||
return base_url
|
||||
|
||||
|
||||
class NATPoolTable(tables.DataTable):
|
||||
name = tables.Column("name", verbose_name=_("Name"),
|
||||
link="horizon:project:network_policy:nat_pool_details")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_policy:nat_pool_details"
|
||||
)
|
||||
description = tables.Column("description", verbose_name=_("Description"))
|
||||
ip_version = tables.Column("ip_version", verbose_name=_("IP Version"))
|
||||
cidr = tables.Column("ip_pool", verbose_name=_("IP Pool"))
|
||||
|
|
|
@ -9,15 +9,11 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import re
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import messages
|
||||
from horizon import tables
|
||||
from horizon import tabs
|
||||
|
||||
|
@ -28,54 +24,10 @@ import tables as np_tables
|
|||
import tabs as np_tabs
|
||||
|
||||
|
||||
class IndexView(tabs.TabView):
|
||||
class IndexView(tabs.TabbedTableView):
|
||||
tab_group_class = (np_tabs.L3PolicyTabs)
|
||||
template_name = 'project/network_policy/details_tabs.html'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
obj_ids = request.POST.getlist('object_ids')
|
||||
action = request.POST['action']
|
||||
obj_type = re.search('delete([0-9a-z]+)', action).group(1)
|
||||
if not obj_ids:
|
||||
obj_ids.append(re.search('([0-9a-z-]+)$', action).group(1))
|
||||
if obj_type == 'spolicy':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.delete_networkservice_policy(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted service policy %s') % obj_id)
|
||||
except Exception as e:
|
||||
msg = _('Unable to delete action. %s') % (str(e))
|
||||
exceptions.handle(request, msg)
|
||||
if obj_type == 'l3policy':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.l3policy_delete(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted L3 policy %s') % obj_id)
|
||||
except Exception as e:
|
||||
msg = _('Unable to delete action. %s') % (str(e))
|
||||
exceptions.handle(request, msg)
|
||||
if obj_type == 'externalconnectivity':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.delete_externalconnectivity(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted External Connectivity %s') % obj_id)
|
||||
except Exception as e:
|
||||
msg = _('Unable to delete action. %s') % (str(e))
|
||||
exceptions.handle(request, msg)
|
||||
if obj_type == 'natpool':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.delete_natpool(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted NAT Pool %s') % obj_id)
|
||||
except Exception as e:
|
||||
msg = _('Unable to delete action. %s') % (str(e))
|
||||
exceptions.handle(request, msg)
|
||||
return self.get(request, *args, **kwargs)
|
||||
|
||||
|
||||
class AddL3policyView(forms.ModalFormView):
|
||||
form_class = np_forms.AddL3PolicyForm
|
||||
|
@ -106,23 +58,6 @@ class L3PolicyDetailsView(tables.MultiTableView):
|
|||
table_classes = (np_tables.L2PolicyTable,)
|
||||
template_name = 'project/network_policy/l3policy_details.html'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
obj_ids = request.POST.getlist('object_ids')
|
||||
action = request.POST['action']
|
||||
obj_type = re.search('delete([0-9a-z]+)', action).group(1)
|
||||
if not obj_ids:
|
||||
obj_ids.append(re.search('([0-9a-z-]+)$', action).group(1))
|
||||
if obj_type == 'l2policy':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.l2policy_delete(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted L2 policy %s') % obj_id)
|
||||
except Exception as e:
|
||||
msg = _('Unable to delete action. %s') % (str(e))
|
||||
exceptions.handle(request, msg)
|
||||
return self.get(request, *args, **kwargs)
|
||||
|
||||
def get_l2policy_table_data(self):
|
||||
l2_policies = []
|
||||
try:
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from gbpui import client
|
||||
from horizon import tables
|
||||
|
||||
|
||||
|
@ -30,7 +31,7 @@ class EditServiceChainSpecLink(tables.LinkAction):
|
|||
|
||||
def get_link_url(self, scspec):
|
||||
base_url = reverse("horizon:project:network_services:update_sc_spec",
|
||||
kwargs={'scspec_id': scspec.id})
|
||||
kwargs={'scspec_id': scspec.id})
|
||||
return base_url
|
||||
|
||||
|
||||
|
@ -41,23 +42,27 @@ class DeleteServiceChainSpecLink(tables.DeleteAction):
|
|||
data_type_singular = _("Service Chain Spec")
|
||||
data_type_plural = _("Service Chain Specs")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.delete_servicechain_spec(request, object_id)
|
||||
|
||||
|
||||
class ServiceChainSpecTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_services:sc_spec_details")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_services:sc_spec_details"
|
||||
)
|
||||
description = tables.Column("description",
|
||||
verbose_name=_("Description"))
|
||||
nodes = tables.Column("nodes", verbose_name=_("Nodes"))
|
||||
status = tables.Column("status", verbose_name=_("Status"))
|
||||
|
||||
class Meta(object):
|
||||
name = "service_chain_spec_table"
|
||||
verbose_name = _("Service Chain Specs")
|
||||
table_actions = (CreateServiceChainSpecLink,
|
||||
DeleteServiceChainSpecLink,)
|
||||
DeleteServiceChainSpecLink,)
|
||||
row_actions = (EditServiceChainSpecLink,
|
||||
DeleteServiceChainSpecLink,)
|
||||
DeleteServiceChainSpecLink,)
|
||||
|
||||
|
||||
class CreateServiceChainNodeLink(tables.LinkAction):
|
||||
|
@ -74,7 +79,7 @@ class EditServiceChainNodeLink(tables.LinkAction):
|
|||
|
||||
def get_link_url(self, scnode):
|
||||
base_url = reverse("horizon:project:network_services:update_sc_node",
|
||||
kwargs={'scnode_id': scnode.id})
|
||||
kwargs={'scnode_id': scnode.id})
|
||||
return base_url
|
||||
|
||||
|
||||
|
@ -85,24 +90,28 @@ class DeleteServiceChainNodeLink(tables.DeleteAction):
|
|||
data_type_singular = _("Service Chain Node")
|
||||
data_type_plural = _("Service Chain Nodes")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.delete_servicechain_node(request, object_id)
|
||||
|
||||
|
||||
class ServiceChainNodeTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_services:sc_node_details")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_services:sc_node_details"
|
||||
)
|
||||
description = tables.Column("description",
|
||||
verbose_name=_("Description"))
|
||||
service_profile = tables.Column("service_profile",
|
||||
verbose_name=_("Service Profile"))
|
||||
status = tables.Column("status", verbose_name=_("Status"))
|
||||
verbose_name=_("Service Profile"))
|
||||
|
||||
class Meta(object):
|
||||
name = "service_chain_node_table"
|
||||
verbose_name = _("Service Chain Node")
|
||||
table_actions = (CreateServiceChainNodeLink,
|
||||
DeleteServiceChainNodeLink,)
|
||||
DeleteServiceChainNodeLink,)
|
||||
row_actions = (EditServiceChainNodeLink,
|
||||
DeleteServiceChainNodeLink,)
|
||||
DeleteServiceChainNodeLink,)
|
||||
|
||||
|
||||
class CreateServiceChainInstanceLink(tables.LinkAction):
|
||||
|
@ -130,11 +139,16 @@ class DeleteServiceChainInstanceLink(tables.DeleteAction):
|
|||
data_type_singular = _("ServiceChainInstance")
|
||||
data_type_plural = _("ServiceChainInstances")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.delete_servicechain_instance(request, object_id)
|
||||
|
||||
|
||||
class ServiceChainInstanceTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_services:sc_instance_details")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_services:sc_instance_details"
|
||||
)
|
||||
description = tables.Column("description",
|
||||
verbose_name=_("Description"))
|
||||
provider_ptg = tables.Column(
|
||||
|
@ -146,7 +160,6 @@ class ServiceChainInstanceTable(tables.DataTable):
|
|||
servicechain_spec = tables.Column(
|
||||
"servicechain_spec", verbose_name=_("Service Chain Spec"))
|
||||
classifier = tables.Column("classifier", verbose_name=_("Classifier"))
|
||||
status = tables.Column("status", verbose_name=_("Status"))
|
||||
|
||||
class Meta(object):
|
||||
name = "service_chain_instance_table"
|
||||
|
@ -167,21 +180,27 @@ class DeleteServiceProfileLink(tables.DeleteAction):
|
|||
data_type_singular = _("ServiceProfile")
|
||||
data_type_plural = _("ServiceProfiles")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.delete_service_profile(request, object_id)
|
||||
|
||||
|
||||
class ServiceProfileTable(tables.DataTable):
|
||||
name = tables.Column("name", verbose_name=_("Name"),
|
||||
link="horizon:project:network_services:service_profile_details")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:network_services:service_profile_details"
|
||||
)
|
||||
description = tables.Column("description",
|
||||
verbose_name=_("Description"))
|
||||
verbose_name=_("Description"))
|
||||
service_type = tables.Column("service_type",
|
||||
verbose_name=_("Service Type"))
|
||||
verbose_name=_("Service Type"))
|
||||
insertion_mode = tables.Column("insertion_mode",
|
||||
verbose_name=_("Insertion Mode"))
|
||||
verbose_name=_("Insertion Mode"))
|
||||
vendor = tables.Column("vendor", verbose_name=_("Vendor"))
|
||||
|
||||
class Meta(object):
|
||||
name = "service_profile_table"
|
||||
verbose_name = _("Service Profile")
|
||||
table_actions = (CreateServiceProfileLink,
|
||||
DeleteServiceProfileLink,)
|
||||
DeleteServiceProfileLink,)
|
||||
row_actions = (DeleteServiceProfileLink,)
|
||||
|
|
|
@ -9,68 +9,17 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import re
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import messages
|
||||
from horizon import tabs
|
||||
|
||||
import forms as ns_forms
|
||||
import tabs as ns_tabs
|
||||
|
||||
from gbpui import client
|
||||
|
||||
|
||||
class IndexView(tabs.TabView):
|
||||
class IndexView(tabs.TabbedTableView):
|
||||
tab_group_class = (ns_tabs.ServiceChainTabs)
|
||||
template_name = 'project/network_services/details_tabs.html'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
obj_ids = request.POST.getlist('object_ids')
|
||||
action = request.POST['action']
|
||||
obj_type = re.search('delete([a-z]+)', action).group(1)
|
||||
if not obj_ids:
|
||||
obj_ids.append(re.search('([0-9a-z-]+)$', action).group(1))
|
||||
if obj_type == 'scnode':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.delete_servicechain_node(request, obj_id)
|
||||
messages.success(request, _('Deleted %s') % obj_id)
|
||||
except Exception as e:
|
||||
exceptions.handle(request,
|
||||
_('Unable to delete . %s') % e)
|
||||
if obj_type == 'scinstance':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.delete_servicechain_instance(request, obj_id)
|
||||
messages.success(
|
||||
request, _('Deleted %s') % obj_id)
|
||||
except Exception as e:
|
||||
exceptions.handle(request,
|
||||
_('Unable to delete . %s') % e)
|
||||
if obj_type == 'scspec':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.delete_servicechain_spec(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted %s') % obj_id)
|
||||
except Exception as e:
|
||||
exceptions.handle(request,
|
||||
_('Unable to delete . %s') % e)
|
||||
if obj_type == 'serviceprofile':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.delete_service_profile(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted %s') % obj_id)
|
||||
except Exception as e:
|
||||
exceptions.handle(request,
|
||||
_('Unable to delete . %s') % e)
|
||||
return self.get(request, *args, **kwargs)
|
||||
|
||||
|
||||
class ServiceProfileDetailsView(tabs.TabView):
|
||||
tab_group_class = (ns_tabs.ServiceProfileDetailsTabGroup)
|
||||
|
@ -147,8 +96,8 @@ class ServiceChainSpecDetailsView(tabs.TabView):
|
|||
|
||||
class CreateServiceChainInstanceView(forms.ModalFormView):
|
||||
form_class = ns_forms.CreateServiceChainInstanceForm
|
||||
template_name = "project/network_services/"\
|
||||
"create_service_chain_instance.html"
|
||||
template_name = "project/network_services/" \
|
||||
"create_service_chain_instance.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(
|
||||
|
@ -158,8 +107,8 @@ class CreateServiceChainInstanceView(forms.ModalFormView):
|
|||
|
||||
class UpdateServiceChainInstanceView(forms.ModalFormView):
|
||||
form_class = ns_forms.UpdateServiceChainInstanceForm
|
||||
template_name = "project/network_services/"\
|
||||
"update_service_chain_instance.html"
|
||||
template_name = "project/network_services/" \
|
||||
"update_service_chain_instance.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(
|
||||
|
|
|
@ -46,6 +46,9 @@ class DeletePTGLink(tables.DeleteAction):
|
|||
data_type_singular = _("Group")
|
||||
data_type_plural = _("Groups")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.policy_target_delete(request, object_id)
|
||||
|
||||
|
||||
class AddPTGLink(tables.LinkAction):
|
||||
name = "addpolicy_target"
|
||||
|
@ -55,12 +58,14 @@ class AddPTGLink(tables.LinkAction):
|
|||
|
||||
|
||||
class PTGsTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:policytargets:policy_targetdetails")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:policytargets:policy_targetdetails"
|
||||
)
|
||||
description = tables.Column("description", verbose_name=_("Description"))
|
||||
provided_policy_rule_sets = tables.Column("provided_policy_rule_sets",
|
||||
sortable=False,
|
||||
sortable=False,
|
||||
verbose_name=_("Provided Rule Sets"))
|
||||
consumed_policy_rule_sets = tables.Column("consumed_policy_rule_sets",
|
||||
sortable=False,
|
||||
|
@ -102,14 +107,19 @@ class DeleteExternalPTGLink(tables.DeleteAction):
|
|||
data_type_singular = _("Group")
|
||||
data_type_plural = _("Groups")
|
||||
|
||||
def action(self, request, object_id):
|
||||
client.ext_policy_target_delete(request, object_id)
|
||||
|
||||
|
||||
class ExternalPTGsTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:policytargets:ext_policy_targetdetails")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:policytargets:ext_policy_targetdetails"
|
||||
)
|
||||
description = tables.Column("description", verbose_name=_("Description"))
|
||||
provided_policy_rule_sets = tables.Column("provided_policy_rule_sets",
|
||||
sortable=False,
|
||||
sortable=False,
|
||||
verbose_name=_("Provided Rule Sets"))
|
||||
consumed_policy_rule_sets = tables.Column("consumed_policy_rule_sets",
|
||||
sortable=False,
|
||||
|
@ -231,9 +241,11 @@ class RemoveProvidedLink(tables.LinkAction):
|
|||
|
||||
|
||||
class ProvidedContractsTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
link="horizon:project:application_policy:policy_rule_set_details",
|
||||
verbose_name=_("Name"))
|
||||
name = tables.Column(
|
||||
"name",
|
||||
link="horizon:project:application_policy:policy_rule_set_details",
|
||||
verbose_name=_("Name")
|
||||
)
|
||||
description = tables.Column("description", verbose_name=_("Description"))
|
||||
policy_rules = tables.Column("policy_rules",
|
||||
sortable=False,
|
||||
|
@ -290,9 +302,11 @@ class RemoveConsumedLink(tables.LinkAction):
|
|||
|
||||
|
||||
class ConsumedContractsTable(tables.DataTable):
|
||||
name = tables.Column("name",
|
||||
link="horizon:project:application_policy:policy_rule_set_details",
|
||||
verbose_name=_("Name"))
|
||||
name = tables.Column(
|
||||
"name",
|
||||
link="horizon:project:application_policy:policy_rule_set_details",
|
||||
verbose_name=_("Name")
|
||||
)
|
||||
description = tables.Column("description",
|
||||
verbose_name=_("Description"))
|
||||
policy_rules = tables.Column("policy_rules",
|
||||
|
|
|
@ -11,15 +11,14 @@
|
|||
# under the License.
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.http import HttpResponse # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import messages
|
||||
from horizon import tabs
|
||||
from horizon.utils import memoized
|
||||
from horizon import workflows
|
||||
|
@ -42,40 +41,14 @@ AddPTG = policy_target_workflows.AddPTG
|
|||
AddExternalPTG = policy_target_workflows.AddExternalPTG
|
||||
|
||||
|
||||
class IndexView(tabs.TabView):
|
||||
class IndexView(tabs.TabbedTableView):
|
||||
tab_group_class = (PTGTabs)
|
||||
template_name = 'project/policytargets/details_tabs.html'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
obj_ids = request.POST.getlist('object_ids')
|
||||
action = request.POST['action']
|
||||
obj_type = re.search('delete([a-z]+)', action).group(1)
|
||||
if not obj_ids:
|
||||
obj_ids.append(re.search('([0-9a-z-]+)$', action).group(1))
|
||||
if obj_type == 'policytarget':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.policy_target_delete(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted Group %s') % obj_id)
|
||||
except Exception as e:
|
||||
exceptions.handle(request,
|
||||
_('Unable to delete Group. %s') % e)
|
||||
if obj_type == 'externalpolicytarget':
|
||||
for obj_id in obj_ids:
|
||||
try:
|
||||
client.ext_policy_target_delete(request, obj_id)
|
||||
messages.success(request,
|
||||
_('Deleted External Group %s') % obj_id)
|
||||
except Exception as e:
|
||||
exceptions.handle(request,
|
||||
_('Unable to delete External Group. %s') % e)
|
||||
return self.get(request, *args, **kwargs)
|
||||
page_title = _("Groups")
|
||||
|
||||
|
||||
class AddPTGView(workflows.WorkflowView):
|
||||
workflow_class = AddPTG
|
||||
template_name = "project/policytargets/addpolicy_target.html"
|
||||
|
||||
|
||||
class AddExternalPTGView(workflows.WorkflowView):
|
||||
|
@ -85,6 +58,7 @@ class AddExternalPTGView(workflows.WorkflowView):
|
|||
class PTGDetailsView(tabs.TabbedTableView):
|
||||
tab_group_class = (policy_target_tabs.PTGMemberTabs)
|
||||
template_name = 'project/policytargets/group_details.html'
|
||||
page_title = _("Group: {{ policy_target.name }}")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(PTGDetailsView, self).get_context_data(**kwargs)
|
||||
|
@ -100,6 +74,7 @@ class PTGDetailsView(tabs.TabbedTableView):
|
|||
class ExternalPTGDetailsView(tabs.TabbedTableView):
|
||||
tab_group_class = (policy_target_tabs.ExternalPTGMemberTabs)
|
||||
template_name = 'project/policytargets/group_details.html'
|
||||
page_title = _("Group: {{ policy_target.name }}")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ExternalPTGDetailsView, self).get_context_data(
|
||||
|
@ -126,16 +101,25 @@ class LaunchVMView(workflows.WorkflowView):
|
|||
|
||||
class UpdatePTGView(forms.ModalFormView):
|
||||
form_class = policy_target_forms.UpdatePolicyTargetForm
|
||||
template_name = "project/policytargets/update_policy_target.html"
|
||||
form_id = "update_policy_target_form"
|
||||
modal_header = _("Edit Group")
|
||||
template_name = "gbpui/form_with_description.html"
|
||||
context_object_name = 'policy_target'
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:policytargets:updatepolicy_target"
|
||||
success_url = reverse_lazy("horizon:project:policytargets:index")
|
||||
page_title = _("Edit Group")
|
||||
help_text = _("You may update policy details here.")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UpdatePTGView, self).get_context_data(**kwargs)
|
||||
context["policy_target_id"] = self.kwargs['policy_target_id']
|
||||
obj_id = self.kwargs['policy_target_id']
|
||||
context["policy_target_id"] = obj_id
|
||||
obj = self._get_object()
|
||||
if obj:
|
||||
context['name'] = obj.name
|
||||
context["submit_url"] = reverse(self.submit_url, args=(obj_id,))
|
||||
context["help_text"] = self.help_text
|
||||
return context
|
||||
|
||||
@memoized.memoized_method
|
||||
|
@ -157,16 +141,25 @@ class UpdatePTGView(forms.ModalFormView):
|
|||
|
||||
class UpdateExternalPTGView(forms.ModalFormView):
|
||||
form_class = policy_target_forms.UpdateExternalPolicyTargetForm
|
||||
template_name = "project/policytargets/update_external_policy_target.html"
|
||||
form_id = "update_policy_target_form"
|
||||
modal_header = _("Edit Group")
|
||||
template_name = "gbpui/form_with_description.html"
|
||||
context_object_name = 'external_policy_target'
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:policytargets:update_ext_policy_target"
|
||||
success_url = reverse_lazy("horizon:project:policytargets:index")
|
||||
page_title = _("Edit Group")
|
||||
help_text = _("You may update external policy details here.")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UpdateExternalPTGView, self).get_context_data(**kwargs)
|
||||
context["ext_policy_target_id"] = self.kwargs['ext_policy_target_id']
|
||||
obj_id = self.kwargs['ext_policy_target_id']
|
||||
context["ext_policy_target_id"] = obj_id
|
||||
obj = self._get_object()
|
||||
if obj:
|
||||
context['name'] = obj.name
|
||||
context["submit_url"] = reverse(self.submit_url, args=(obj_id,))
|
||||
context["help_text"] = self.help_text
|
||||
return context
|
||||
|
||||
@memoized.memoized_method
|
||||
|
@ -188,7 +181,15 @@ class UpdateExternalPTGView(forms.ModalFormView):
|
|||
|
||||
class ExtAddProvidedPRSView(forms.ModalFormView):
|
||||
form_class = policy_target_forms.ExtAddProvidedPRSForm
|
||||
template_name = "project/policytargets/ext_add_provided_prs.html"
|
||||
form_id = "ext_add_provided_form"
|
||||
modal_header = _("Add Provided PRS")
|
||||
template_name = "gbpui/form_with_description.html"
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:policytargets:ext_add_provided_prs"
|
||||
page_title = _("Add Provided PRS")
|
||||
help_text = _(
|
||||
"Add provided policy rule set. Press Ctrl to select multiple items."
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ExtAddProvidedPRSView, self).get_context_data(**kwargs)
|
||||
|
@ -201,8 +202,15 @@ class ExtAddProvidedPRSView(forms.ModalFormView):
|
|||
|
||||
class ExtRemoveProvidedPRSView(forms.ModalFormView):
|
||||
form_class = policy_target_forms.ExtRemoveProvidedPRSForm
|
||||
template_name = \
|
||||
"project/policytargets/ext_remove_provided_prs.html"
|
||||
form_id = "ext_remove_provided_form"
|
||||
modal_header = _("Remove Provided PRS")
|
||||
template_name = "gbpui/form_with_description.html"
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:policytargets:ext_remove_provided_prs"
|
||||
page_title = _("Remove Provided PRS")
|
||||
help_text = _(
|
||||
"Remove provided policy rule set. Press Ctrl to select multiple items."
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ExtRemoveProvidedPRSView, self).get_context_data(
|
||||
|
@ -216,7 +224,15 @@ class ExtRemoveProvidedPRSView(forms.ModalFormView):
|
|||
|
||||
class AddProvidedPRSView(forms.ModalFormView):
|
||||
form_class = policy_target_forms.AddProvidedPRSForm
|
||||
template_name = "project/policytargets/add_provided_prs.html"
|
||||
form_id = "add_provided_form"
|
||||
modal_header = _("Add Provided PRS")
|
||||
template_name = "gbpui/form_with_description.html"
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:policytargets:add_provided_prs"
|
||||
page_title = _("Add Provided PRS")
|
||||
help_text = _(
|
||||
"Add provided policy rule set. Press Ctrl to select multiple items."
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(AddProvidedPRSView, self).get_context_data(**kwargs)
|
||||
|
@ -229,7 +245,15 @@ class AddProvidedPRSView(forms.ModalFormView):
|
|||
|
||||
class RemoveProvidedPRSView(forms.ModalFormView):
|
||||
form_class = policy_target_forms.RemoveProvidedPRSForm
|
||||
template_name = "project/policytargets/remove_provided_prs.html"
|
||||
form_id = "remove_provided_form"
|
||||
modal_header = _("Remove Provided PRS")
|
||||
template_name = "gbpui/form_with_description.html"
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:policytargets:remove_provided_prs"
|
||||
page_title = _("Remove Provided PRS")
|
||||
help_text = _(
|
||||
"Remove provided policy rule set. Press Ctrl to select multiple items."
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(RemoveProvidedPRSView, self).get_context_data(**kwargs)
|
||||
|
@ -242,7 +266,15 @@ class RemoveProvidedPRSView(forms.ModalFormView):
|
|||
|
||||
class ExtAddConsumedPRSView(forms.ModalFormView):
|
||||
form_class = policy_target_forms.ExtAddConsumedPRSForm
|
||||
template_name = "project/policytargets/ext_add_consumed_prs.html"
|
||||
form_id = "ext_add_consumed_form"
|
||||
modal_header = _("Add Policy Rule Set")
|
||||
template_name = "gbpui/form_with_description.html"
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:policytargets:ext_add_consumed_prs"
|
||||
page_title = _("Add Policy Rule Set")
|
||||
help_text = _(
|
||||
"Add consumed policy rule set. Press Ctrl to select multiple items."
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ExtAddConsumedPRSView, self).get_context_data(**kwargs)
|
||||
|
@ -255,8 +287,15 @@ class ExtAddConsumedPRSView(forms.ModalFormView):
|
|||
|
||||
class ExtRemoveConsumedPRSView(forms.ModalFormView):
|
||||
form_class = policy_target_forms.ExtRemoveConsumedPRSForm
|
||||
template_name = \
|
||||
"project/policytargets/ext_remove_consumed_prs.html"
|
||||
form_id = "remove_contract_form"
|
||||
modal_header = _("Remove Policy Rule Set")
|
||||
template_name = "gbpui/form_with_description.html"
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:policytargets:ext_remove_consumed_prs"
|
||||
page_title = _("Remove Policy Rule Set")
|
||||
help_text = _(
|
||||
"Remove consumed policy rule set. Press Ctrl to select multiple items."
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ExtRemoveConsumedPRSView, self).get_context_data(
|
||||
|
@ -270,7 +309,15 @@ class ExtRemoveConsumedPRSView(forms.ModalFormView):
|
|||
|
||||
class AddConsumedPRSView(forms.ModalFormView):
|
||||
form_class = policy_target_forms.AddConsumedPRSForm
|
||||
template_name = "project/policytargets/add_consumed_prs.html"
|
||||
form_id = "add_consumed_form"
|
||||
modal_header = _("Add ")
|
||||
template_name = "gbpui/form_with_description.html"
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:policytargets:add_consumed_prs"
|
||||
page_title = _("Add ")
|
||||
help_text = _(
|
||||
"Add consumed policy rule set. Press Ctrl to select multiple items."
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(AddConsumedPRSView, self).get_context_data(**kwargs)
|
||||
|
@ -283,7 +330,15 @@ class AddConsumedPRSView(forms.ModalFormView):
|
|||
|
||||
class RemoveConsumedPRSView(forms.ModalFormView):
|
||||
form_class = policy_target_forms.RemoveConsumedPRSForm
|
||||
template_name = "project/policytargets/remove_consumed_prs.html"
|
||||
form_id = "remove_contract_form"
|
||||
modal_header = _("Remove Policy Rule Set")
|
||||
template_name = "gbpui/form_with_description.html"
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:policytargets:remove_consumed_prs"
|
||||
page_title = _("Remove Policy Rule Set")
|
||||
help_text = _(
|
||||
"Remove consumed policy rule set. Press Ctrl to select multiple items."
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(RemoveConsumedPRSView, self).get_context_data(**kwargs)
|
||||
|
|
Loading…
Reference in New Issue