コード例 #1
0
ファイル: plugin.py プロジェクト: mshabdiz/neutron
    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)
コード例 #2
0
ファイル: plugin.py プロジェクト: PFZheng/neutron
    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)
コード例 #3
0
ファイル: plugin.py プロジェクト: mshabdiz/neutron
    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)
コード例 #4
0
ファイル: plugin.py プロジェクト: PFZheng/neutron
    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)
コード例 #5
0
ファイル: plugin.py プロジェクト: kavonm/neutron
    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)
コード例 #6
0
ファイル: plugin.py プロジェクト: kavonm/neutron
 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)
コード例 #7
0
ファイル: syncmanager.py プロジェクト: rodis/neutron
    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)
コード例 #8
0
ファイル: plugin.py プロジェクト: yangxu2014/neutron
    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)
コード例 #9
0
ファイル: syncmanager.py プロジェクト: CiscoSystems/neutron
    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)
コード例 #10
0
ファイル: plugin.py プロジェクト: mshabdiz/neutron
 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)
コード例 #11
0
ファイル: plugin.py プロジェクト: RenatoArmani/neutron
    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)
コード例 #12
0
ファイル: plugin.py プロジェクト: kavonm/neutron
    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)
コード例 #13
0
ファイル: plugin.py プロジェクト: mshabdiz/neutron
 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)
コード例 #14
0
ファイル: plugin.py プロジェクト: PFZheng/neutron
 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)