def setUp(self):
        super(NuagePortTestsVSDManaged, self).setUp()

        # Create VSD managed subnet
        user_enterprise = self.session.user.enterprises.get_first(
            filter='name == "{}"'.format(utils.get_vsd_net_parition_name()))

        self.l3domain = utils.create_l3_domain(self, user_enterprise)

        zone = self.l3domain.create_child(
            vspk.NUZone(name=utils.get_random_name()))[0]

        subnet = zone.create_child(
            vspk.NUSubnet(name=utils.get_random_name(),
                          address='10.0.0.0',
                          netmask='255.255.255.0'))[0]

        cmd_create = ('subnet create -f json --network {network} '
                      '--net-partition {net_partition} --nuagenet {nuagenet} '
                      '--subnet-range {subnet_range} {subnet_name}'.format(
                          network=self.NETWORK_NAME,
                          net_partition=user_enterprise.id,
                          nuagenet=subnet.id,
                          subnet_range='10.0.0.0/24',
                          subnet_name=utils.get_random_name()))
        create_output = json.loads(self.openstack(cmd_create))
        self.addCleanup(self.openstack,
                        'subnet delete {}'.format(create_output['id']))
Example #2
0
    def _create_subnet(self, network, cidr):
        user_enterprise = self.session.user.enterprises.get_first(
            filter='name == "{}"'.format(utils.get_vsd_net_parition_name()))

        # Create VSD managed subnet
        l3domain = utils.create_l3_domain(self, user_enterprise)
        zone = l3domain.create_child(
            vspk.NUZone(name=utils.get_random_name()))[0]
        subnet = zone.create_child(
            vspk.NUSubnet(name=utils.get_random_name(),
                          address=str(cidr.ip),
                          netmask=str(cidr.netmask)))[0]

        cmd_create = ('subnet create -f json --network {network} '
                      '--net-partition {net_partition} --nuagenet {nuagenet} '
                      '--subnet-range {subnet_range} {subnet_name}'
                      .format(network=network,
                              net_partition=user_enterprise.id,
                              nuagenet=subnet.id,
                              subnet_range=cidr,
                              subnet_name=utils.get_random_name()))
        create_output = json.loads(self.openstack(cmd_create))
        self.addCleanup(self.openstack,
                        'subnet delete {}'.format(create_output['id']))

        return create_output, l3domain
Example #3
0
    def test_vsd_managed_crud(self):
        session = create_new_vspk_session()
        enterprise = session.user.enterprises.get_first(
            filter='name == "{}"'.format(get_vsd_net_parition_name()))

        subnet_name = get_random_name()
        ip_config = get_random_ipv4_subnet_config()
        l2domain = create_l2_domain(self, enterprise, ip_config['address'],
                                    ip_config['netmask'], ip_config['gateway'])

        # CREATE / READ
        cmd_create = ('subnet create -f json --network {network} '
                      '--net-partition {net_partition} --nuagenet {nuagenet} '
                      '--subnet-range {subnet_range} {subnet_name} '
                      '--gateway None'
                      .format(network=self.NETWORK_NAME,
                              net_partition=enterprise.id,
                              nuagenet=l2domain.id,
                              subnet_range=ip_config['cidr'],
                              subnet_name=subnet_name))
        cmd_show = 'subnet show -f json {}'.format(subnet_name)
        for cmd in [cmd_create, cmd_show]:
            cmd_output = json.loads(self.openstack(cmd))
            self.assertEqual(expected=True,
                             observed=cmd_output['vsd_managed'])
            self.assertEqual(expected=subnet_name,
                             observed=cmd_output['name'])
            self.assertEqual(expected=l2domain.id,
                             observed=cmd_output['nuagenet'])
            self.assertEqual(expected=enterprise.id,
                             observed=cmd_output['net_partition'])
            self.assertEqual(expected=ip_config['cidr'],
                             observed=cmd_output['cidr'])

        # UPDATE
        update_cmd = 'subnet set --nuage-underlay route {}'.format(subnet_name)
        try:
            self.openstack(update_cmd)
        except exceptions.CommandFailed as e:
            self.assertIn(needle='is a VSD-managed subnet. Update is not '
                                 'supported for attributes other than ',
                          haystack=str(e.stderr))
        else:
            self.assertIsNotNone(None, message="Update command should fail.")

        # DELETE
        delete_and_verify(self, 'subnet', subnet_name)
    def _create_topology(self, network, cidr, is_l3=True):
        user_enterprise = self.session.user.enterprises.get_first(
            filter='name == "{}"'.format(utils.get_vsd_net_parition_name()))

        # Create VSD managed subnet
        if is_l3:
            l3domain = utils.create_l3_domain(self, user_enterprise)
            zone = l3domain.create_child(
                vspk.NUZone(name=utils.get_random_name()))[0]
            vsd_subnet = zone.create_child(
                vspk.NUSubnet(name=utils.get_random_name(),
                              address=str(cidr.ip),
                              netmask=str(cidr.netmask)))[0]
        else:
            l3domain = None
            vsd_subnet = utils.create_l2_domain(self,
                                                user_enterprise,
                                                address=str(cidr.ip),
                                                netmask=str(cidr.netmask),
                                                gateway=str(cidr.ip + 1))
        subnet_create_str = ('subnet create -f json --network {network} '
                             '--net-partition {net_partition} '
                             '--nuagenet {nuagenet} '
                             '--subnet-range {subnet_range} {subnet_name}')
        if not is_l3:
            subnet_create_str += ' --gateway None'

        cmd_create = subnet_create_str.format(
            network=network,
            net_partition=user_enterprise.id,
            nuagenet=vsd_subnet.id,
            subnet_range=cidr,
            subnet_name=utils.get_random_name())
        subnet = json.loads(self.openstack(cmd_create))
        self.addCleanup(self.openstack,
                        'subnet delete {}'.format(subnet['id']))

        return subnet, l3domain or vsd_subnet
 def setUpClass(cls):
     super(NuageRouterTests, cls).setUpClass()
     cls.session = utils.create_new_vspk_session()
     cls.enterprise = cls.session.user.enterprises.get_first(
         filter='name == "{}"'.format(utils.get_vsd_net_parition_name()))