Exemple #1
0
    def _create_nuage_subnet(self, context, neutron_subnet, net_partition):
        net = netaddr.IPNetwork(neutron_subnet['cidr'])
        params = {
            'net_partition': net_partition,
            'tenant_id': neutron_subnet['tenant_id'],
            'net': net
        }
        try:
            nuage_subnet = self.nuageclient.create_subnet(neutron_subnet,
                                                          params)
        except Exception:
            with excutils.save_and_reraise_exception():
                super(NuagePlugin, self).delete_subnet(context,
                                                       neutron_subnet['id'])

        if nuage_subnet:
            l2dom_id = str(nuage_subnet['nuage_l2template_id'])
            user_id = nuage_subnet['nuage_userid']
            group_id = nuage_subnet['nuage_groupid']
            id = nuage_subnet['nuage_l2domain_id']
            with context.session.begin(subtransactions=True):
                nuagedb.add_subnetl2dom_mapping(context.session,
                                                neutron_subnet['id'],
                                                id,
                                                net_partition['id'],
                                                l2dom_id=l2dom_id,
                                                nuage_user_id=user_id,
                                                nuage_group_id=group_id)
Exemple #2
0
    def _create_nuage_subnet(self, context, neutron_subnet, net_partition):
        net = netaddr.IPNetwork(neutron_subnet['cidr'])
        params = {
            'net_partition': net_partition,
            'tenant_id': neutron_subnet['tenant_id'],
            'net': net
        }
        try:
            nuage_subnet = self.nuageclient.create_subnet(
                neutron_subnet, params)
        except Exception:
            with excutils.save_and_reraise_exception():
                super(NuagePlugin, self).delete_subnet(context,
                                                       neutron_subnet['id'])

        if nuage_subnet:
            l2dom_id = str(nuage_subnet['nuage_l2template_id'])
            user_id = nuage_subnet['nuage_userid']
            group_id = nuage_subnet['nuage_groupid']
            id = nuage_subnet['nuage_l2domain_id']
            with context.session.begin(subtransactions=True):
                nuagedb.add_subnetl2dom_mapping(context.session,
                                                neutron_subnet['id'],
                                                id,
                                                net_partition['id'],
                                                l2dom_id=l2dom_id,
                                                nuage_user_id=user_id,
                                                nuage_group_id=group_id)
Exemple #3
0
    def create_subnet(self, context, subnet):
        subn = subnet['subnet']
        net_id = subn['network_id']

        if self._network_is_external(context, net_id):
            return super(NuagePlugin, self).create_subnet(context, subnet)

        self._validate_create_subnet(subn)

        net_partition = self._get_net_partition_for_subnet(context, subnet)
        neutron_subnet = super(NuagePlugin,
                               self).create_subnet(context, subnet)
        net = netaddr.IPNetwork(neutron_subnet['cidr'])
        params = {
            'net_partition': net_partition,
            'tenant_id': neutron_subnet['tenant_id'],
            'net': net
        }
        try:
            nuage_subnet = self.nuageclient.create_subnet(
                neutron_subnet, params)
        except Exception:
            with excutils.save_and_reraise_exception():
                super(NuagePlugin, self).delete_subnet(context,
                                                       neutron_subnet['id'])

        if nuage_subnet:
            l2dom_id = str(nuage_subnet['nuage_l2template_id'])
            user_id = nuage_subnet['nuage_userid']
            group_id = nuage_subnet['nuage_groupid']
            id = nuage_subnet['nuage_l2domain_id']
            session = context.session
            with session.begin(subtransactions=True):
                nuagedb.add_subnetl2dom_mapping(session,
                                                neutron_subnet['id'],
                                                id,
                                                net_partition['id'],
                                                l2dom_id=l2dom_id,
                                                nuage_user_id=user_id,
                                                nuage_group_id=group_id)
        return neutron_subnet
Exemple #4
0
    def create_subnet(self, context, subnet):
        subn = subnet['subnet']
        net_id = subn['network_id']

        if self._network_is_external(context, net_id):
            return super(NuagePlugin, self).create_subnet(context, subnet)

        self._validate_create_subnet(subn)

        net_partition = self._get_net_partition_for_subnet(context, subnet)
        neutron_subnet = super(NuagePlugin, self).create_subnet(context,
                                                                subnet)
        net = netaddr.IPNetwork(neutron_subnet['cidr'])
        params = {
            'net_partition': net_partition,
            'tenant_id': neutron_subnet['tenant_id'],
            'net': net
        }
        try:
            nuage_subnet = self.nuageclient.create_subnet(neutron_subnet,
                                                          params)
        except Exception:
            with excutils.save_and_reraise_exception():
                super(NuagePlugin, self).delete_subnet(context,
                                                       neutron_subnet['id'])

        if nuage_subnet:
            l2dom_id = str(nuage_subnet['nuage_l2template_id'])
            user_id = nuage_subnet['nuage_userid']
            group_id = nuage_subnet['nuage_groupid']
            id = nuage_subnet['nuage_l2domain_id']
            session = context.session
            with session.begin(subtransactions=True):
                nuagedb.add_subnetl2dom_mapping(session,
                                                neutron_subnet['id'],
                                                id,
                                                net_partition['id'],
                                                l2dom_id=l2dom_id,
                                                nuage_user_id=user_id,
                                                nuage_group_id=group_id)
        return neutron_subnet