コード例 #1
0
ファイル: plugin.py プロジェクト: mshabdiz/neutron
 def delete_router(self, context, id):
     session = context.session
     ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(session, id)
     if ent_rtr_mapping:
         nuage_router_id = ent_rtr_mapping['nuage_router_id']
         self.nuageclient.delete_router(nuage_router_id)
     router_zone = nuagedb.get_rtr_zone_mapping(session, id)
     super(NuagePlugin, self).delete_router(context, id)
     if router_zone and not self._check_router_subnet_for_tenant(context):
         self.nuageclient.delete_user(router_zone['nuage_user_id'])
         self.nuageclient.delete_group(router_zone['nuage_group_id'])
コード例 #2
0
ファイル: plugin.py プロジェクト: kavonm/neutron
 def delete_router(self, context, id):
     session = context.session
     ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(session, id)
     if ent_rtr_mapping:
         nuage_router_id = ent_rtr_mapping["nuage_router_id"]
         self.nuageclient.delete_router(nuage_router_id)
     router_zone = nuagedb.get_rtr_zone_mapping(session, id)
     super(NuagePlugin, self).delete_router(context, id)
     if router_zone and not self._check_router_subnet_for_tenant(context):
         self.nuageclient.delete_user(router_zone["nuage_user_id"])
         self.nuageclient.delete_group(router_zone["nuage_group_id"])
コード例 #3
0
ファイル: plugin.py プロジェクト: kavonm/neutron
    def add_router_interface(self, context, router_id, interface_info):
        session = context.session
        with session.begin(subtransactions=True):
            rtr_if_info = super(NuagePlugin, self).add_router_interface(context, router_id, interface_info)
            subnet_id = rtr_if_info["subnet_id"]
            subn = self.get_subnet(context, subnet_id)

            rtr_zone_mapping = nuagedb.get_rtr_zone_mapping(session, router_id)
            ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(session, router_id)
            subnet_l2dom = nuagedb.get_subnet_l2dom_by_id(session, subnet_id)
            if not rtr_zone_mapping or not ent_rtr_mapping:
                super(NuagePlugin, self).remove_router_interface(context, router_id, interface_info)
                msg = (
                    _("Router %s does not hold default zone OR " "net_partition mapping. Router-IF add failed")
                    % router_id
                )
                raise q_exc.BadRequest(resource="router", msg=msg)

            if not subnet_l2dom:
                super(NuagePlugin, self).remove_router_interface(context, router_id, interface_info)
                msg = _("Subnet %s does not hold Nuage VSD reference. " "Router-IF add failed") % subnet_id
                raise q_exc.BadRequest(resource="subnet", msg=msg)

            if subnet_l2dom["net_partition_id"] != ent_rtr_mapping["net_partition_id"]:
                super(NuagePlugin, self).remove_router_interface(context, router_id, interface_info)
                msg = _(
                    "Subnet %(subnet)s and Router %(router)s belong to "
                    "different net_partition Router-IF add "
                    "not permitted"
                ) % {"subnet": subnet_id, "router": router_id}
                raise q_exc.BadRequest(resource="subnet", msg=msg)
            nuage_subnet_id = subnet_l2dom["nuage_subnet_id"]
            nuage_l2dom_tmplt_id = subnet_l2dom["nuage_l2dom_tmplt_id"]
            if self.nuageclient.vms_on_l2domain(nuage_subnet_id):
                super(NuagePlugin, self).remove_router_interface(context, router_id, interface_info)
                msg = _("Subnet %s has one or more active VMs " "Router-IF add not permitted") % subnet_id
                raise q_exc.BadRequest(resource="subnet", msg=msg)
            self.nuageclient.delete_subnet(nuage_subnet_id, nuage_l2dom_tmplt_id)
            net = netaddr.IPNetwork(subn["cidr"])
            params = {"net": net, "zone_id": rtr_zone_mapping["nuage_zone_id"]}
            if not attributes.is_attr_set(subn["gateway_ip"]):
                subn["gateway_ip"] = str(netaddr.IPAddress(net.first + 1))
            try:
                nuage_subnet = self.nuageclient.create_domain_subnet(subn, params)
            except Exception:
                with excutils.save_and_reraise_exception():
                    super(NuagePlugin, self).remove_router_interface(context, router_id, interface_info)
            if nuage_subnet:
                ns_dict = {}
                ns_dict["nuage_subnet_id"] = nuage_subnet["nuage_subnetid"]
                ns_dict["nuage_l2dom_tmplt_id"] = None
                nuagedb.update_subnetl2dom_mapping(subnet_l2dom, ns_dict)
        return rtr_if_info
コード例 #4
0
ファイル: plugin.py プロジェクト: insequent/calico-neutron
 def delete_router(self, context, id):
     session = context.session
     ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(session, id)
     if ent_rtr_mapping:
         filters = {
             'device_id': [id],
             'device_owner': [os_constants.DEVICE_OWNER_ROUTER_INTF]
         }
         ports = self.get_ports(context, filters)
         if ports:
             raise l3.RouterInUse(router_id=id)
         nuage_router_id = ent_rtr_mapping['nuage_router_id']
         self.nuageclient.delete_router(nuage_router_id)
     router_zone = nuagedb.get_rtr_zone_mapping(session, id)
     super(NuagePlugin, self).delete_router(context, id)
     if router_zone and not self._check_router_subnet_for_tenant(context):
         self.nuageclient.delete_user(router_zone['nuage_user_id'])
         self.nuageclient.delete_group(router_zone['nuage_group_id'])
コード例 #5
0
ファイル: plugin.py プロジェクト: PFZheng/neutron
 def delete_router(self, context, id):
     session = context.session
     ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(session,
                                                            id)
     if ent_rtr_mapping:
         filters = {
             'device_id': [id],
             'device_owner': [os_constants.DEVICE_OWNER_ROUTER_INTF]
         }
         ports = self.get_ports(context, filters)
         if ports:
             raise l3.RouterInUse(router_id=id)
         nuage_router_id = ent_rtr_mapping['nuage_router_id']
         self.nuageclient.delete_router(nuage_router_id)
     router_zone = nuagedb.get_rtr_zone_mapping(session, id)
     super(NuagePlugin, self).delete_router(context, id)
     if router_zone and not self._check_router_subnet_for_tenant(context):
         self.nuageclient.delete_user(router_zone['nuage_user_id'])
         self.nuageclient.delete_group(router_zone['nuage_group_id'])
コード例 #6
0
ファイル: plugin.py プロジェクト: mshabdiz/neutron
    def add_router_interface(self, context, router_id, interface_info):
        session = context.session
        with session.begin(subtransactions=True):
            rtr_if_info = super(NuagePlugin, self).add_router_interface(
                context, router_id, interface_info)
            subnet_id = rtr_if_info['subnet_id']
            subn = self.get_subnet(context, subnet_id)

            rtr_zone_mapping = nuagedb.get_rtr_zone_mapping(session, router_id)
            ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(
                session, router_id)
            subnet_l2dom = nuagedb.get_subnet_l2dom_by_id(session, subnet_id)
            if not rtr_zone_mapping or not ent_rtr_mapping:
                super(NuagePlugin,
                      self).remove_router_interface(context, router_id,
                                                    interface_info)
                msg = (_("Router %s does not hold default zone OR "
                         "net_partition mapping. Router-IF add failed") %
                       router_id)
                raise q_exc.BadRequest(resource='router', msg=msg)

            if not subnet_l2dom:
                super(NuagePlugin,
                      self).remove_router_interface(context, router_id,
                                                    interface_info)
                msg = (_("Subnet %s does not hold Nuage VSD reference. "
                         "Router-IF add failed") % subnet_id)
                raise q_exc.BadRequest(resource='subnet', msg=msg)

            if (subnet_l2dom['net_partition_id'] !=
                    ent_rtr_mapping['net_partition_id']):
                super(NuagePlugin,
                      self).remove_router_interface(context, router_id,
                                                    interface_info)
                msg = (_("Subnet %(subnet)s and Router %(router)s belong to "
                         "different net_partition Router-IF add "
                         "not permitted") % {
                             'subnet': subnet_id,
                             'router': router_id
                         })
                raise q_exc.BadRequest(resource='subnet', msg=msg)
            nuage_subnet_id = subnet_l2dom['nuage_subnet_id']
            nuage_l2dom_tmplt_id = subnet_l2dom['nuage_l2dom_tmplt_id']
            if self.nuageclient.vms_on_l2domain(nuage_subnet_id):
                super(NuagePlugin,
                      self).remove_router_interface(context, router_id,
                                                    interface_info)
                msg = (_("Subnet %s has one or more active VMs "
                         "Router-IF add not permitted") % subnet_id)
                raise q_exc.BadRequest(resource='subnet', msg=msg)
            self.nuageclient.delete_subnet(nuage_subnet_id,
                                           nuage_l2dom_tmplt_id)
            net = netaddr.IPNetwork(subn['cidr'])
            params = {'net': net, 'zone_id': rtr_zone_mapping['nuage_zone_id']}
            if not attributes.is_attr_set(subn['gateway_ip']):
                subn['gateway_ip'] = str(netaddr.IPAddress(net.first + 1))
            try:
                nuage_subnet = self.nuageclient.create_domain_subnet(
                    subn, params)
            except Exception:
                with excutils.save_and_reraise_exception():
                    super(NuagePlugin, self).remove_router_interface(
                        context, router_id, interface_info)
            if nuage_subnet:
                ns_dict = {}
                ns_dict['nuage_subnet_id'] = nuage_subnet['nuage_subnetid']
                ns_dict['nuage_l2dom_tmplt_id'] = None
                nuagedb.update_subnetl2dom_mapping(subnet_l2dom, ns_dict)
        return rtr_if_info