Beispiel #1
0
 def handle(self, request, data, **kwargs):
     try:
         if 'rule_to_delete' in request.POST:
             rulemanager.remove_rules(request,
                                      [request.POST['rule_to_delete']],
                                      router_id=data['router_id'])
     except Exception:
         exceptions.handle(request, _('Unable to delete router rule.'))
     try:
         if 'nexthops' not in data:
             data['nexthops'] = ''
         if data['source'] == '0.0.0.0/0':
             data['source'] = 'any'
         if data['destination'] == '0.0.0.0/0':
             data['destination'] = 'any'
         rule = {
             'action': data['action'],
             'source': data['source'],
             'destination': data['destination'],
             'nexthops': data['nexthops'].split(',')
         }
         rulemanager.add_rule(request,
                              router_id=data['router_id'],
                              newrule=rule)
         msg = _('Router rule added')
         LOG.debug(msg)
         messages.success(request, msg)
         return True
     except Exception as e:
         msg = _('Failed to add router rule %s') % e.message
         LOG.info(msg)
         messages.error(request, msg)
         redirect = reverse(self.failure_url, args=[data['router_id']])
         exceptions.handle(request, msg, redirect=redirect)
Beispiel #2
0
 def handle(self, request, data, **kwargs):
     try:
         if "rule_to_delete" in request.POST:
             rulemanager.remove_rules(request, [request.POST["rule_to_delete"]], router_id=data["router_id"])
     except Exception:
         exceptions.handle(request, _("Unable to delete router rule."))
     try:
         if "nexthops" not in data:
             data["nexthops"] = ""
         if data["source"] == "0.0.0.0/0":
             data["source"] = "any"
         if data["destination"] == "0.0.0.0/0":
             data["destination"] = "any"
         rule = {
             "action": data["action"],
             "source": data["source"],
             "destination": data["destination"],
             "nexthops": data["nexthops"].split(","),
         }
         rulemanager.add_rule(request, router_id=data["router_id"], newrule=rule)
         msg = _("Router rule added")
         LOG.debug(msg)
         messages.success(request, msg)
         return True
     except Exception as e:
         msg = _("Failed to add router rule %s") % e
         LOG.info(msg)
         messages.error(request, msg)
         redirect = reverse(self.failure_url, args=[data["router_id"]])
         exceptions.handle(request, msg, redirect=redirect)
Beispiel #3
0
 def handle(self, request, data, **kwargs):
     try:
         if 'rule_to_delete' in request.POST:
             rulemanager.remove_rules(request,
                                      [request.POST['rule_to_delete']],
                                      router_id=data['router_id'])
     except Exception:
         exceptions.handle(request, _('Unable to delete router rule.'))
     try:
         if 'nexthops' not in data:
             data['nexthops'] = ''
         if data['source'] == '0.0.0.0/0':
             data['source'] = 'any'
         if data['destination'] == '0.0.0.0/0':
             data['destination'] = 'any'
         rule = {'action': data['action'],
                 'source': data['source'],
                 'destination': data['destination'],
                 'nexthops': data['nexthops'].split(',')}
         rulemanager.add_rule(request,
                              router_id=data['router_id'],
                              newrule=rule)
         msg = _('Router rule added')
         LOG.debug(msg)
         messages.success(request, msg)
         return True
     except Exception as e:
         msg = _('Failed to add router rule %s') % e
         LOG.info(msg)
         messages.error(request, msg)
         redirect = reverse(self.failure_url, args=[data['router_id']])
         exceptions.handle(request, msg, redirect=redirect)
Beispiel #4
0
 def post(self, request, *args, **kwargs):
     if request.POST['action'] == 'routerrules__resetrules':
         kwargs['reset_rules'] = True
         rulemanager.remove_rules(request, [], **kwargs)
         self.tab_group.router = api.neutron.router_get(request,
                                                        kwargs['router_id'])
Beispiel #5
0
 def post(self, request, *args, **kwargs):
     if request.POST["action"] == "routerrules__resetrules":
         kwargs["reset_rules"] = True
         rulemanager.remove_rules(request, [], **kwargs)
         self.tab_group.router = api.neutron.router_get(request, kwargs["router_id"])
Beispiel #6
0
 def delete(self, request, obj_id):
     router_id = self.table.kwargs['router_id']
     rulemanager.remove_rules(request, [obj_id],
                              router_id=router_id)
Beispiel #7
0
 def delete(self, request, obj_id):
     router_id = self.table.kwargs['router_id']
     rulemanager.remove_rules(request, [obj_id], router_id=router_id)
Beispiel #8
0
 def post(self, request, *args, **kwargs):
     if request.POST['action'] == 'routerrules__resetrules':
         kwargs['reset_rules'] = True
         rulemanager.remove_rules(request, [], **kwargs)
         self.tab_group.router = api.neutron.router_get(
             request, kwargs['router_id'])