Example #1
0
    def delete_port(self, context, id, l3_port_check=True):
        if l3_port_check:
            self.prevent_l3_port_deletion(context, id)
        port = self._get_port(context, id)
        port_mapping = nuagedb.get_port_mapping_by_id(context.session, id)
        # This is required for to pass ut test_floatingip_port_delete
        self.disassociate_floatingips(context, id)
        if not port['fixed_ips']:
            return super(NuagePlugin, self).delete_port(context, id)

        sub_id = port['fixed_ips'][0]['subnet_id']
        subnet_mapping = nuagedb.get_subnet_l2dom_by_id(
            context.session, sub_id)
        if not subnet_mapping:
            return super(NuagePlugin, self).delete_port(context, id)

        netpart_id = subnet_mapping['net_partition_id']
        net_partition = nuagedb.get_net_partition_by_id(
            context.session, netpart_id)
        # Need to call this explicitly to delete vport_vporttag_mapping
        if constants.NOVA_PORT_OWNER_PREF in port['device_owner']:
            # This was a VM Port
            filters = {'device_id': [port['device_id']]}
            ports = self.get_ports(context, filters)
            params = {
                'no_of_ports': len(ports),
                'net_partition': net_partition,
                'tenant': port['tenant_id'],
                'mac': port['mac_address'],
                'nuage_vif_id': port_mapping['nuage_vif_id'],
                'id': port['device_id']
            }
            self.nuageclient.delete_vms(params)
        super(NuagePlugin, self).delete_port(context, id)
Example #2
0
    def _create_update_port(self, context, port,
                            port_mapping, subnet_mapping):
        filters = {'device_id': [port['device_id']]}
        ports = self.get_ports(context, filters)
        netpart_id = subnet_mapping['net_partition_id']
        net_partition = nuagedb.get_net_partition_by_id(context.session,
                                                        netpart_id)
        params = {
            'id': port['device_id'],
            'mac': port['mac_address'],
            'parent_id': subnet_mapping['nuage_subnet_id'],
            'net_partition': net_partition,
            'ip': None,
            'no_of_ports': len(ports),
            'tenant': port['tenant_id']
        }
        if port_mapping['static_ip']:
            params['ip'] = port['fixed_ips'][0]['ip_address']

        nuage_vm = self.nuageclient.create_vms(params)
        if nuage_vm:
            if port['fixed_ips'][0]['ip_address'] != str(nuage_vm['ip']):
                self._update_port_ip(context, port, nuage_vm['ip'])
            port_dict = {
                'nuage_vport_id': nuage_vm['vport_id'],
                'nuage_vif_id': nuage_vm['vif_id']
            }
            nuagedb.update_port_vport_mapping(port_mapping,
                                              port_dict)
Example #3
0
    def _create_update_port(self, context, port, port_mapping, subnet_mapping):
        filters = {'device_id': [port['device_id']]}
        ports = self.get_ports(context, filters)
        netpart_id = subnet_mapping['net_partition_id']
        net_partition = nuagedb.get_net_partition_by_id(
            context.session, netpart_id)
        params = {
            'id': port['device_id'],
            'mac': port['mac_address'],
            'parent_id': subnet_mapping['nuage_subnet_id'],
            'net_partition': net_partition,
            'ip': None,
            'no_of_ports': len(ports),
            'tenant': port['tenant_id']
        }
        if port_mapping['static_ip']:
            params['ip'] = port['fixed_ips'][0]['ip_address']

        nuage_vm = self.nuageclient.create_vms(params)
        if nuage_vm:
            if port['fixed_ips'][0]['ip_address'] != str(nuage_vm['ip']):
                self._update_port_ip(context, port, nuage_vm['ip'])
            port_dict = {
                'nuage_vport_id': nuage_vm['vport_id'],
                'nuage_vif_id': nuage_vm['vif_id']
            }
            nuagedb.update_port_vport_mapping(port_mapping, port_dict)
Example #4
0
    def delete_port(self, context, id, l3_port_check=True):
        if l3_port_check:
            self.prevent_l3_port_deletion(context, id)
        port = self._get_port(context, id)
        port_mapping = nuagedb.get_port_mapping_by_id(context.session,
                                                      id)
        # This is required for to pass ut test_floatingip_port_delete
        self.disassociate_floatingips(context, id)
        if not port['fixed_ips']:
            return super(NuagePlugin, self).delete_port(context, id)

        sub_id = port['fixed_ips'][0]['subnet_id']
        subnet_mapping = nuagedb.get_subnet_l2dom_by_id(context.session,
                                                        sub_id)
        if not subnet_mapping:
            return super(NuagePlugin, self).delete_port(context, id)

        netpart_id = subnet_mapping['net_partition_id']
        net_partition = nuagedb.get_net_partition_by_id(context.session,
                                                        netpart_id)
        # Need to call this explicitly to delete vport_vporttag_mapping
        if constants.NOVA_PORT_OWNER_PREF in port['device_owner']:
            # This was a VM Port
            filters = {'device_id': [port['device_id']]}
            ports = self.get_ports(context, filters)
            params = {
                'no_of_ports': len(ports),
                'net_partition': net_partition,
                'tenant': port['tenant_id'],
                'mac': port['mac_address'],
                'nuage_vif_id': port_mapping['nuage_vif_id'],
                'id': port['device_id']
            }
            self.nuageclient.delete_vms(params)
        super(NuagePlugin, self).delete_port(context, id)
Example #5
0
    def delete_port(self, context, id, l3_port_check=True):
        if l3_port_check:
            self.prevent_l3_port_deletion(context, id)
        port = self._get_port(context, id)
        port_mapping = nuagedb.get_port_mapping_by_id(context.session, id)
        # This is required for to pass ut test_floatingip_port_delete
        self.disassociate_floatingips(context, id)
        if not port["fixed_ips"]:
            return super(NuagePlugin, self).delete_port(context, id)

        sub_id = port["fixed_ips"][0]["subnet_id"]
        subnet_mapping = nuagedb.get_subnet_l2dom_by_id(context.session, sub_id)
        if not subnet_mapping:
            return super(NuagePlugin, self).delete_port(context, id)

        netpart_id = subnet_mapping["net_partition_id"]
        net_partition = nuagedb.get_net_partition_by_id(context.session, netpart_id)
        # Need to call this explicitly to delete vport_vporttag_mapping
        if constants.NOVA_PORT_OWNER_PREF in port["device_owner"]:
            # This was a VM Port
            filters = {"device_id": [port["device_id"]]}
            ports = self.get_ports(context, filters)
            params = {
                "no_of_ports": len(ports),
                "net_partition": net_partition,
                "tenant": port["tenant_id"],
                "mac": port["mac_address"],
                "nuage_vif_id": port_mapping["nuage_vif_id"],
                "id": port["device_id"],
            }
            self.nuageclient.delete_vms(params)
        super(NuagePlugin, self).delete_port(context, id)
Example #6
0
 def delete_net_partition(self, context, id):
     ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_entid(context.session, id)
     if ent_rtr_mapping:
         msg = _("One or more router still attached to " "net_partition %s.") % id
         raise q_exc.BadRequest(resource="net_partition", msg=msg)
     net_partition = nuagedb.get_net_partition_by_id(context.session, id)
     if not net_partition:
         msg = _("NetPartition with %s does not exist") % id
         raise q_exc.BadRequest(resource="net_partition", msg=msg)
     l3dom_tmplt_id = net_partition["l3dom_tmplt_id"]
     l2dom_tmplt_id = net_partition["l2dom_tmplt_id"]
     self.nuageclient.delete_net_partition(net_partition["id"], l3dom_id=l3dom_tmplt_id, l2dom_id=l2dom_tmplt_id)
     with context.session.begin(subtransactions=True):
         nuagedb.delete_net_partition(context.session, net_partition)
Example #7
0
    def sync_domains(self, net_partition_id_dict, resources):
        for domain_id in resources['domain']['add']:
            with self.context.session.begin(subtransactions=True):
                router, entrtr = self._get_router_data(domain_id)
                if router:
                    # if router exists, entrtr will exist
                    netpart_id = entrtr['net_partition_id']
                    if netpart_id in net_partition_id_dict.keys():
                        # Use the id of the newly created net_partition
                        netpart_id = net_partition_id_dict[netpart_id]

                    netpart = nuagedb.get_net_partition_by_id(
                        self.context.session, netpart_id)
                    result = self.nuageclient.create_domain(netpart, router)
                    if result:
                        nuagedb.get_update_entrtr_mapping(
                            self.context.session, result)
Example #8
0
    def _create_update_port(self, context, port, netpart_id, parent_id):
        filters = {'device_id': [port['device_id']]}
        ports = self.get_ports(context, filters)
        net_partition = nuagedb.get_net_partition_by_id(
            context.session, netpart_id)
        params = {
            'port_id': port['id'],
            'id': port['device_id'],
            'mac': port['mac_address'],
            'parent_id': parent_id,
            'net_partition': net_partition,
            'ip': port['fixed_ips'][0]['ip_address'],
            'no_of_ports': len(ports),
            'tenant': port['tenant_id']
        }

        self.nuageclient.create_vms(params)
Example #9
0
    def sync_domains(self, net_partition_id_dict, resources):
        for domain_id in resources['domain']['add']:
            with self.context.session.begin(subtransactions=True):
                router, entrtr = self._get_router_data(domain_id)
                if router:
                    # if router exists, entrtr will exist
                    netpart_id = entrtr['net_partition_id']
                    if netpart_id in net_partition_id_dict.keys():
                        # Use the id of the newly created net_partition
                        netpart_id = net_partition_id_dict[netpart_id]

                    netpart = nuagedb.get_net_partition_by_id(
                        self.context.session,
                        netpart_id)
                    result = self.nuageclient.create_domain(netpart, router)
                    if result:
                        nuagedb.get_update_entrtr_mapping(self.context.session,
                                                          result)
Example #10
0
 def delete_net_partition(self, context, id):
     ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_entid(
         context.session, id)
     if ent_rtr_mapping:
         msg = (_("One or more router still attached to "
                  "net_partition %s.") % id)
         raise q_exc.BadRequest(resource='net_partition', msg=msg)
     net_partition = nuagedb.get_net_partition_by_id(context.session, id)
     if not net_partition:
         msg = (_("NetPartition with %s does not exist") % id)
         raise q_exc.BadRequest(resource='net_partition', msg=msg)
     l3dom_tmplt_id = net_partition['l3dom_tmplt_id']
     l2dom_tmplt_id = net_partition['l2dom_tmplt_id']
     self.nuageclient.delete_net_partition(net_partition['id'],
                                           l3dom_id=l3dom_tmplt_id,
                                           l2dom_id=l2dom_tmplt_id)
     with context.session.begin(subtransactions=True):
         nuagedb.delete_net_partition(context.session, net_partition)
Example #11
0
    def _create_update_port(self, context, port,
                            netpart_id, parent_id):
        filters = {'device_id': [port['device_id']]}
        ports = self.get_ports(context, filters)
        net_partition = nuagedb.get_net_partition_by_id(context.session,
                                                        netpart_id)
        params = {
            'port_id': port['id'],
            'id': port['device_id'],
            'mac': port['mac_address'],
            'parent_id': parent_id,
            'net_partition': net_partition,
            'ip': port['fixed_ips'][0]['ip_address'],
            'no_of_ports': len(ports),
            'tenant': port['tenant_id']
        }

        self.nuageclient.create_vms(params)
Example #12
0
    def _create_update_port(self, context, port, port_mapping, subnet_mapping):
        filters = {"device_id": [port["device_id"]]}
        ports = self.get_ports(context, filters)
        netpart_id = subnet_mapping["net_partition_id"]
        net_partition = nuagedb.get_net_partition_by_id(context.session, netpart_id)
        params = {
            "id": port["device_id"],
            "mac": port["mac_address"],
            "parent_id": subnet_mapping["nuage_subnet_id"],
            "net_partition": net_partition,
            "ip": None,
            "no_of_ports": len(ports),
            "tenant": port["tenant_id"],
        }
        if port_mapping["static_ip"]:
            params["ip"] = port["fixed_ips"][0]["ip_address"]

        nuage_vm = self.nuageclient.create_vms(params)
        if nuage_vm:
            if port["fixed_ips"][0]["ip_address"] != str(nuage_vm["ip"]):
                self._update_port_ip(context, port, nuage_vm["ip"])
            port_dict = {"nuage_vport_id": nuage_vm["vport_id"], "nuage_vif_id": nuage_vm["vif_id"]}
            nuagedb.update_port_vport_mapping(port_mapping, port_dict)
Example #13
0
 def get_net_partition(self, context, id, fields=None):
     net_partition = nuagedb.get_net_partition_by_id(context.session, id)
     return self._make_net_partition_dict(net_partition)
Example #14
0
 def get_net_partition(self, context, id, fields=None):
     net_partition = nuagedb.get_net_partition_by_id(context.session,
                                                     id)
     return self._make_net_partition_dict(net_partition)