def test_update_port_mixed_ops_integrity(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        extra = {'key1': 'value1', 'key2': 'value2'}

        _, port = self.create_port(node_id=node_id, address=address,
                                   extra=extra)
        port_id = port['uuid']

        new_address = data_utils.rand_mac_address()
        new_extra = {'key1': 'new-value1', 'key3': 'new-value3'}

        patch = [{'path': '/address',
                  'op': 'replace',
                  'value': new_address},
                 {'path': '/extra/key1',
                  'op': 'replace',
                  'value': new_extra['key1']},
                 {'path': '/extra/key2',
                  'op': 'remove'},
                 {'path': '/extra/key3',
                  'op': 'add',
                  'value': new_extra['key3']},
                 {'path': '/nonexistent',
                  'op': 'replace',
                  'value': 'value'}]

        self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,
                          patch)

        # patch should not be applied
        _, body = self.client.show_port(port_id)
        self.assertEqual(address, body['address'])
        self.assertEqual(extra, body['extra'])
    def test_update_ports_in_portgroup_with_physical_network(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, portgroup = self.create_portgroup(node_id, address=address)

        _, port1 = self.create_port(node_id=node_id,
                                    address=address,
                                    portgroup_uuid=portgroup['uuid'],
                                    physical_network='physnet1')

        address = data_utils.rand_mac_address()
        _, port2 = self.create_port(node_id=node_id,
                                    address=address,
                                    physical_network='physnet1')

        patch = [{
            'path': '/portgroup_uuid',
            'op': 'replace',
            'value': portgroup['uuid']
        }]

        self.client.update_port(port2['uuid'], patch)

        _, body = self.client.show_port(port1['uuid'])
        self.assertEqual('physnet1', body['physical_network'])
        self.assertEqual(portgroup['uuid'], body['portgroup_uuid'])

        _, body = self.client.show_port(port2['uuid'])
        self.assertEqual('physnet1', body['physical_network'])
        self.assertEqual(portgroup['uuid'], body['portgroup_uuid'])
Example #3
0
    def test_update_ports_in_portgroup_with_inconsistent_physical_network_2(
            self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, portgroup = self.create_portgroup(node_id, address=address)

        _, _ = self.create_port(node_id=node_id,
                                address=address,
                                portgroup_uuid=portgroup['uuid'],
                                physical_network='physnet1')

        address = data_utils.rand_mac_address()
        _, port2 = self.create_port(node_id=node_id,
                                    address=address,
                                    portgroup_uuid=portgroup['uuid'],
                                    physical_network='physnet1')

        patch = [{
            'path': '/physical_network',
            'op': 'replace',
            'value': 'physnet2'
        }]

        self.assertRaises(lib_exc.Conflict, self.client.update_port,
                          port2['uuid'], patch)
Example #4
0
    def test_update_port_mixed_ops(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        extra = {'key1': 'value1', 'key2': 'value2'}

        _, port = self.create_port(node_id=node_id, address=address,
                                   extra=extra)

        new_address = data_utils.rand_mac_address()
        new_extra = {'key1': 0.123, 'key3': {'cat': 'meow'}}

        patch = [{'path': '/address',
                  'op': 'replace',
                  'value': new_address},
                 {'path': '/extra/key1',
                  'op': 'replace',
                  'value': new_extra['key1']},
                 {'path': '/extra/key2',
                  'op': 'remove'},
                 {'path': '/extra/key3',
                  'op': 'add',
                  'value': new_extra['key3']}]

        self.client.update_port(port['uuid'], patch)

        _, body = self.client.show_port(port['uuid'])
        self.assertEqual(new_address, body['address'])
        self.assertEqual(new_extra, body['extra'])
Example #5
0
    def test_update_ports_in_portgroup_with_physical_network(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, portgroup = self.create_portgroup(node_id, address=address)

        _, port1 = self.create_port(node_id=node_id, address=address,
                                    portgroup_uuid=portgroup['uuid'],
                                    physical_network='physnet1')

        address = data_utils.rand_mac_address()
        _, port2 = self.create_port(node_id=node_id, address=address,
                                    physical_network='physnet1')

        patch = [{'path': '/portgroup_uuid',
                  'op': 'replace',
                  'value': portgroup['uuid']}]

        self.client.update_port(port2['uuid'], patch)

        _, body = self.client.show_port(port1['uuid'])
        self.assertEqual('physnet1', body['physical_network'])
        self.assertEqual(portgroup['uuid'], body['portgroup_uuid'])

        _, body = self.client.show_port(port2['uuid'])
        self.assertEqual('physnet1', body['physical_network'])
        self.assertEqual(portgroup['uuid'], body['portgroup_uuid'])
Example #6
0
    def test_rand_mac_address(self):
        actual = data_utils.rand_mac_address()
        self.assertIsInstance(actual, str)
        self.assertRegex(actual, "^([0-9a-f][0-9a-f]:){5}" "[0-9a-f][0-9a-f]$")

        actual2 = data_utils.rand_mac_address()
        self.assertNotEqual(actual, actual2)
Example #7
0
    def test_rand_mac_address(self):
        actual = data_utils.rand_mac_address()
        self.assertIsInstance(actual, str)
        self.assertRegex(actual, "^([0-9a-f][0-9a-f]:){5}" "[0-9a-f][0-9a-f]$")

        actual2 = data_utils.rand_mac_address()
        self.assertNotEqual(actual, actual2)
Example #8
0
    def test_list_ports_details_with_address(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        self.create_port(node_id=node_id, address=address)
        for i in range(0, 5):
            self.create_port(node_id=node_id,
                             address=data_utils.rand_mac_address())

        _, body = self.client.list_ports_detail(address=address)
        self.assertEqual(1, len(body['ports']))
        self.assertEqual(address, body['ports'][0]['address'])
    def test_update_port_malformed_port_uuid(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        self.create_port(node_id=node_id, address=address)

        new_address = data_utils.rand_mac_address()
        self.assertRaises(lib_exc.BadRequest, self.client.update_port,
                          uuid='malformed:uuid',
                          patch=[{'path': '/address', 'op': 'replace',
                                  'value': new_address}])
Example #10
0
    def test_update_port_replace_mac_with_duplicated(self):
        node_id = self.node['uuid']
        address1 = data_utils.rand_mac_address()
        address2 = data_utils.rand_mac_address()

        _, port1 = self.create_port(node_id=node_id, address=address1)

        _, port2 = self.create_port(node_id=node_id, address=address2)
        port_id = port2['uuid']

        patch = [{'path': '/address', 'op': 'replace', 'value': address1}]
        self.assertRaises(lib_exc.Conflict, self.client.update_port, port_id,
                          patch)
Example #11
0
    def test_update_port_replace_mac_with_duplicated(self):
        node_id = self.node['uuid']
        address1 = data_utils.rand_mac_address()
        address2 = data_utils.rand_mac_address()

        _, port1 = self.create_port(node_id=node_id, address=address1)

        _, port2 = self.create_port(node_id=node_id, address=address2)
        port_id = port2['uuid']

        patch = [{'path': '/address',
                  'op': 'replace',
                  'value': address1}]
        self.assertRaises(lib_exc.Conflict,
                          self.client.update_port, port_id, patch)
Example #12
0
 def _get_ips_from_subnet(self, **kwargs):
     subnet = self.create_subnet(self.network, **kwargs)
     port_mac = data_utils.rand_mac_address()
     port = self.create_port(self.network, mac_address=port_mac)
     real_ip = next(iter(port['fixed_ips']), None)['ip_address']
     eui_ip = str(netutils.get_ipv6_addr_by_EUI64(subnet['cidr'], port_mac))
     return real_ip, eui_ip
Example #13
0
    def test_create_port_no_mandatory_field_node_id(self):
        address = data_utils.rand_mac_address()

        self.assertRaises(lib_exc.BadRequest,
                          self.create_port,
                          node_id=None,
                          address=address)
 def test_create_port_duplicated_mac(self):
     node_id = self.node['uuid']
     address = data_utils.rand_mac_address()
     self.create_port(node_id=node_id, address=address)
     self.assertRaises(lib_exc.Conflict,
                       self.create_port, node_id=node_id,
                       address=address)
Example #15
0
    def test_update_port_remove(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        extra = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}

        _, port = self.create_port(node_id=node_id, address=address,
                                   extra=extra)

        # Removing one item from the collection
        self.client.update_port(port['uuid'],
                                [{'path': '/extra/key2',
                                 'op': 'remove'}])
        extra.pop('key2')
        _, body = self.client.show_port(port['uuid'])
        self.assertEqual(extra, body['extra'])

        # Removing the collection
        self.client.update_port(port['uuid'], [{'path': '/extra',
                                               'op': 'remove'}])
        _, body = self.client.show_port(port['uuid'])
        self.assertEqual({}, body['extra'])

        # Assert nothing else was changed
        self.assertEqual(node_id, body['node_uuid'])
        self.assertEqual(address, body['address'])
    def test_create_port_malformed_port_uuid(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        uuid = 'malformed:uuid'

        self.assertRaises(lib_exc.BadRequest, self.create_port,
                          node_id=node_id, address=address, uuid=uuid)
Example #17
0
    def setUp(self):
        super(TestPorts, self).setUp()

        _, self.chassis = self.create_chassis()
        _, self.node = self.create_node(self.chassis['uuid'])
        _, self.port = self.create_port(self.node['uuid'],
                                        data_utils.rand_mac_address())
Example #18
0
    def test_vif_on_port(self):
        """Test attachment and detachment of VIFs on the node with port.

        Test steps:
        1) Create chassis and node in setUp.
        2) Create port for the node.
        3) Attach VIF to the node.
        4) Check VIF info in VIFs list and port internal_info.
        5) Detach VIF from the node.
        6) Check that no more VIF info in VIFs list and port internal_info.
        """
        self.useFixture(
            api_microversion_fixture.APIMicroversionFixture('1.28'))
        _, self.port = self.create_port(self.node['uuid'],
                                        data_utils.rand_mac_address())
        self.client.vif_attach(self.node['uuid'], 'test-vif')
        _, body = self.client.vif_list(self.node['uuid'])
        self.assertEqual({'vifs': [{'id': 'test-vif'}]}, body)
        _, port = self.client.show_port(self.port['uuid'])
        self.assertEqual('test-vif',
                         port['internal_info']['tenant_vif_port_id'])
        self.client.vif_detach(self.node['uuid'], 'test-vif')
        _, body = self.client.vif_list(self.node['uuid'])
        self.assertEqual({'vifs': []}, body)
        _, port = self.client.show_port(self.port['uuid'])
        self.assertNotIn('tenant_vif_port_id', port['internal_info'])
Example #19
0
    def test_vif_on_port(self):
        """Test attachment and detachment of VIFs on the node with port.

        Test steps:
        1) Create chassis and node in setUp.
        2) Create port for the node.
        3) Attach VIF to the node.
        4) Check VIF info in VIFs list and port internal_info.
        5) Detach VIF from the node.
        6) Check that no more VIF info in VIFs list and port internal_info.
        """
        self.useFixture(
            api_microversion_fixture.APIMicroversionFixture('1.28'))
        _, self.port = self.create_port(self.node['uuid'],
                                        data_utils.rand_mac_address())
        self.client.vif_attach(self.node['uuid'], self.nport_id)
        _, body = self.client.vif_list(self.node['uuid'])
        self.assertEqual({'vifs': [{'id': self.nport_id}]}, body)
        _, port = self.client.show_port(self.port['uuid'])
        self.assertEqual(self.nport_id,
                         port['internal_info']['tenant_vif_port_id'])
        self.client.vif_detach(self.node['uuid'], self.nport_id)
        _, body = self.client.vif_list(self.node['uuid'])
        self.assertEqual({'vifs': []}, body)
        _, port = self.client.show_port(self.port['uuid'])
        self.assertNotIn('tenant_vif_port_id', port['internal_info'])
Example #20
0
 def test_create_port_nonexsistent_node_id(self):
     node_id = str(data_utils.rand_uuid())
     address = data_utils.rand_mac_address()
     self.assertRaises(lib_exc.BadRequest,
                       self.create_port,
                       node_id=node_id,
                       address=address)
Example #21
0
    def test_create_port_mac_address(self):

        post_body = {'network': self.network,
                     'mac_address': data_utils.rand_mac_address()}

        with self.rbac_utils.override_role(self):
            self.create_port(**post_body)
Example #22
0
    def test_update_port_mac_address(self):
        original_mac_address = self.port['mac_address']

        with self.rbac_utils.override_role(self):
            self.ports_client.update_port(
                self.port['id'], mac_address=data_utils.rand_mac_address())
        self.addCleanup(self.ports_client.update_port, self.port['id'],
                        mac_address=original_mac_address)
Example #23
0
    def test_list_with_limit(self):
        for i in range(2):
            self.create_port(self.node['uuid'], data_utils.rand_mac_address())

        _, body = self.client.list_ports(limit=3)

        next_marker = body['ports'][-1]['uuid']
        self.assertIn(next_marker, body['next'])
Example #24
0
 def _get_ips_from_subnet(self, **kwargs):
     subnet = self.create_subnet(self.network, **kwargs)
     port_mac = data_utils.rand_mac_address()
     port = self.create_port(self.network, mac_address=port_mac)
     real_ip = next(iter(port['fixed_ips']), None)['ip_address']
     eui_ip = str(netutils.get_ipv6_addr_by_EUI64(
         subnet['cidr'], port_mac))
     return real_ip, eui_ip
    def test_create_port_with_physical_network_old_api(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        self.assertRaises((lib_exc.BadRequest, lib_exc.UnexpectedResponseCode),
                          self.create_port,
                          node_id=node_id, address=address,
                          physical_network='physnet1')
Example #26
0
 def setUp(self):
     super(TestPortGroups, self).setUp()
     self.useFixture(
         api_microversion_fixture.APIMicroversionFixture('1.25'))
     _, self.chassis = self.create_chassis()
     _, self.node = self.create_node(self.chassis['uuid'])
     _, self.portgroup = self.create_portgroup(
         self.node['uuid'], address=data_utils.rand_mac_address())
    def test_create_ports_in_portgroup_with_inconsistent_physical_network(
            self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, portgroup = self.create_portgroup(node_id, address=address)

        _, _ = self.create_port(node_id=node_id, address=address,
                                portgroup_uuid=portgroup['uuid'],
                                physical_network='physnet1')

        address = data_utils.rand_mac_address()
        self.assertRaises(lib_exc.Conflict,
                          self.create_port,
                          node_id=node_id, address=address,
                          portgroup_uuid=portgroup['uuid'],
                          physical_network='physnet2')
Example #28
0
    def test_create_port_specifying_uuid(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        uuid = data_utils.rand_uuid()

        _, port = self.create_port(node_id=node_id, address=address, uuid=uuid)

        _, body = self.client.show_port(uuid)
        self._assertExpected(port, body)
    def test_update_port_remove_nonexistent_property(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, port = self.create_port(node_id=node_id, address=address)
        port_id = port['uuid']

        self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,
                          [{'path': '/nonexistent', 'op': 'remove'}])
Example #30
0
    def test_update_port_mac_address(self):
        original_mac_address = self.port['mac_address']

        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
        self.ports_client.update_port(
            self.port['id'], mac_address=data_utils.rand_mac_address())
        self.addCleanup(self.ports_client.update_port,
                        self.port['id'],
                        mac_address=original_mac_address)
Example #31
0
 def test_vifs(self):
     self.useFixture(
         api_microversion_fixture.APIMicroversionFixture('1.28'))
     _, self.port = self.create_port(self.node['uuid'],
                                     data_utils.rand_mac_address())
     self.client.vif_attach(self.node['uuid'], 'test-vif')
     _, body = self.client.vif_list(self.node['uuid'])
     self.assertEqual(body, {'vifs': [{'id': 'test-vif'}]})
     self.client.vif_detach(self.node['uuid'], 'test-vif')
    def test_create_port_mac_address(self):

        post_body = {
            'network_id': self.network['id'],
            'mac_address': data_utils.rand_mac_address()
        }

        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
        self._create_port(**post_body)
Example #33
0
    def test_create_port(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, port = self.create_port(node_id=node_id, address=address)

        _, body = self.client.show_port(port['uuid'])

        self._assertExpected(port, body)
Example #34
0
    def test_delete_port(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        _, port = self.create_port(node_id=node_id, address=address)

        self.delete_port(port['uuid'])

        self.assertRaises(lib_exc.NotFound, self.client.show_port,
                          port['uuid'])
    def test_vif_on_portgroup(self):
        """Test attachment and detachment of VIFs on the node with port group.

        Test steps:
        1) Create chassis and node in setUp.
        2) Create port for the node.
        3) Create port group for the node.
        4) Plug port into port group.
        5) Attach VIF to the node.
        6) Check VIF info in VIFs list and port group internal_info, but
           not in port internal_info.
        7) Detach VIF from the node.
        8) Check that no VIF info in VIFs list and port group internal_info.
        """
        self.useFixture(
            api_microversion_fixture.APIMicroversionFixture('1.28'))
        _, self.port = self.create_port(self.node['uuid'],
                                        data_utils.rand_mac_address())
        _, self.portgroup = self.create_portgroup(
            self.node['uuid'], address=data_utils.rand_mac_address())

        patch = [{
            'path': '/portgroup_uuid',
            'op': 'add',
            'value': self.portgroup['uuid']
        }]
        self.client.update_port(self.port['uuid'], patch)

        self.client.vif_attach(self.node['uuid'], 'test-vif')
        _, body = self.client.vif_list(self.node['uuid'])
        self.assertEqual({'vifs': [{'id': 'test-vif'}]}, body)

        _, port = self.client.show_port(self.port['uuid'])
        self.assertNotIn('tenant_vif_port_id', port['internal_info'])
        _, portgroup = self.client.show_portgroup(self.portgroup['uuid'])
        self.assertEqual('test-vif',
                         portgroup['internal_info']['tenant_vif_port_id'])

        self.client.vif_detach(self.node['uuid'], 'test-vif')
        _, body = self.client.vif_list(self.node['uuid'])
        self.assertEqual({'vifs': []}, body)
        _, portgroup = self.client.show_portgroup(self.portgroup['uuid'])
        self.assertNotIn('tenant_vif_port_id', portgroup['internal_info'])
Example #36
0
    def test_create_port_specifying_uuid(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        uuid = data_utils.rand_uuid()

        _, port = self.create_port(node_id=node_id,
                                   address=address, uuid=uuid)

        _, body = self.client.show_port(uuid)
        self._assertExpected(port, body)
Example #37
0
 def setUp(self):
     super(TestPortGroups, self).setUp()
     self.useFixture(
         api_microversion_fixture.APIMicroversionFixture(
             self.min_microversion))
     _, self.chassis = self.create_chassis()
     _, self.node = self.create_node(self.chassis['uuid'])
     _, self.portgroup = self.create_portgroup(
         self.node['uuid'], address=data_utils.rand_mac_address(),
         name=data_utils.rand_name('portgroup'))
Example #38
0
    def test_create_port_with_physical_network(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, port = self.create_port(node_id=node_id, address=address,
                                   physical_network='physnet1')

        _, body = self.client.show_port(port['uuid'])

        self._assertExpected(port, body)
        self.assertEqual('physnet1', port['physical_network'])
Example #39
0
    def test_create_port_with_extra(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        extra = {'str': 'value', 'int': 123, 'float': 0.123,
                 'bool': True, 'list': [1, 2, 3], 'dict': {'foo': 'bar'}}

        _, port = self.create_port(node_id=node_id, address=address,
                                   extra=extra)

        _, body = self.client.show_port(port['uuid'])
        self._assertExpected(port, body)
Example #40
0
    def test_vif_on_portgroup(self):
        """Test attachment and detachment of VIFs on the node with port group.

        Test steps:
        1) Create chassis and node in setUp.
        2) Create port for the node.
        3) Create port group for the node.
        4) Plug port into port group.
        5) Attach VIF to the node.
        6) Check VIF info in VIFs list and port group internal_info, but
           not in port internal_info.
        7) Detach VIF from the node.
        8) Check that no VIF info in VIFs list and port group internal_info.
        """
        self.useFixture(
            api_microversion_fixture.APIMicroversionFixture('1.28'))
        _, self.port = self.create_port(self.node['uuid'],
                                        data_utils.rand_mac_address())
        _, self.portgroup = self.create_portgroup(
            self.node['uuid'], address=data_utils.rand_mac_address())

        patch = [{'path': '/portgroup_uuid',
                  'op': 'add',
                  'value': self.portgroup['uuid']}]
        self.client.update_port(self.port['uuid'], patch)

        self.client.vif_attach(self.node['uuid'], 'test-vif')
        _, body = self.client.vif_list(self.node['uuid'])
        self.assertEqual({'vifs': [{'id': 'test-vif'}]}, body)

        _, port = self.client.show_port(self.port['uuid'])
        self.assertNotIn('tenant_vif_port_id', port['internal_info'])
        _, portgroup = self.client.show_portgroup(self.portgroup['uuid'])
        self.assertEqual('test-vif',
                         portgroup['internal_info']['tenant_vif_port_id'])

        self.client.vif_detach(self.node['uuid'], 'test-vif')
        _, body = self.client.vif_list(self.node['uuid'])
        self.assertEqual({'vifs': []}, body)
        _, portgroup = self.client.show_portgroup(self.portgroup['uuid'])
        self.assertNotIn('tenant_vif_port_id', portgroup['internal_info'])
Example #41
0
    def test_update_port_replace_node_id_with_nonexistent(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, port = self.create_port(node_id=node_id, address=address)
        port_id = port['uuid']

        patch = [{'path': '/node_uuid',
                  'op': 'replace',
                  'value': data_utils.rand_uuid()}]
        self.assertRaises(lib_exc.BadRequest,
                          self.client.update_port, port_id, patch)
Example #42
0
 def test_dhcpv6_two_subnets(self):
     """When one IPv6 subnet configured with IPv6 SLAAC or DHCPv6 stateless
     and other IPv6 is with DHCPv6 stateful, port shall receive EUI-64 IP
     addresses from first subnet and DHCPv6 address from second one.
     Order of subnet creating should be unimportant.
     """
     for order in ("slaac_first", "dhcp_first"):
         for ra_mode, add_mode in (
                 ('slaac', 'slaac'),
                 ('dhcpv6-stateless', 'dhcpv6-stateless'),
         ):
             kwargs = {'ipv6_ra_mode': ra_mode,
                       'ipv6_address_mode': add_mode}
             kwargs_dhcp = {'ipv6_address_mode': 'dhcpv6-stateful'}
             if order == "slaac_first":
                 subnet_slaac = self.create_subnet(self.network, **kwargs)
                 subnet_dhcp = self.create_subnet(
                     self.network, **kwargs_dhcp)
             else:
                 subnet_dhcp = self.create_subnet(
                     self.network, **kwargs_dhcp)
                 subnet_slaac = self.create_subnet(self.network, **kwargs)
             port_mac = data_utils.rand_mac_address()
             dhcp_ip = subnet_dhcp["allocation_pools"][0]["start"]
             eui_ip = data_utils.get_ipv6_addr_by_EUI64(
                 subnet_slaac['cidr'],
                 port_mac
             ).format()
             # TODO(sergsh): remove this when 1219795 is fixed
             dhcp_ip = [dhcp_ip, (netaddr.IPAddress(dhcp_ip) + 1).format()]
             port = self.create_port(self.network, mac_address=port_mac)
             real_ips = dict([(k['subnet_id'], k['ip_address'])
                              for k in port['fixed_ips']])
             real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
                                          for sub in subnet_dhcp,
                                          subnet_slaac]
             self.client.delete_port(port['id'])
             self.ports.pop()
             body = self.client.list_ports()
             ports_id_list = [i['id'] for i in body['ports']]
             self.assertNotIn(port['id'], ports_id_list)
             self._clean_network()
             self.assertEqual(real_eui_ip,
                              eui_ip,
                              'Real IP is {0}, but shall be {1}'.format(
                                  real_eui_ip,
                                  eui_ip))
             self.assertIn(
                 real_dhcp_ip, dhcp_ip,
                 'Real IP is {0}, but shall be one from {1}'.format(
                     real_dhcp_ip,
                     str(dhcp_ip)))
Example #43
0
    def test_update_port_replace_physical_network_old_api(self):
        _, port = self.create_port(self.node['uuid'],
                                   data_utils.rand_mac_address())

        new_physnet = 'physnet1'

        patch = [{'path': '/physical_network',
                  'op': 'replace',
                  'value': new_physnet}]

        self.assertRaises((lib_exc.BadRequest, lib_exc.UnexpectedResponseCode),
                          self.client.update_port,
                          port['uuid'], patch)
Example #44
0
    def test_create_ports_in_portgroup_with_physical_network(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, portgroup = self.create_portgroup(node_id, address=address)

        _, port1 = self.create_port(node_id=node_id, address=address,
                                    portgroup_uuid=portgroup['uuid'],
                                    physical_network='physnet1')

        address = data_utils.rand_mac_address()
        _, port2 = self.create_port(node_id=node_id, address=address,
                                    portgroup_uuid=portgroup['uuid'],
                                    physical_network='physnet1')

        _, body = self.client.show_port(port1['uuid'])
        self.assertEqual('physnet1', body['physical_network'])
        self.assertEqual(portgroup['uuid'], body['portgroup_uuid'])

        _, body = self.client.show_port(port2['uuid'])
        self.assertEqual('physnet1', body['physical_network'])
        self.assertEqual(portgroup['uuid'], body['portgroup_uuid'])
    def test_create_with_address(self):
        """Check baremetal port group create command with address argument.

        Test steps:
        1) Create baremetal port group in setUp.
        2) Create baremetal port group with specific address argument.
        3) Check address of created port group.
        """
        mac_address = data_utils.rand_mac_address()
        port_group = self.port_group_create(
            self.node['uuid'],
            params='{0} --address {1}'.format(self.api_version, mac_address))
        self.assertEqual(mac_address, port_group['address'])
Example #46
0
    def test_update_ports_in_portgroup_with_inconsistent_physical_network(
            self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, portgroup = self.create_portgroup(node_id, address=address)

        _, _ = self.create_port(node_id=node_id, address=address,
                                portgroup_uuid=portgroup['uuid'],
                                physical_network='physnet1')

        address = data_utils.rand_mac_address()
        _, port2 = self.create_port(node_id=node_id, address=address,
                                    physical_network='physnet2')

        patch = [{'path': '/portgroup_uuid',
                  'op': 'replace',
                  'value': portgroup['uuid']}]

        self.assertRaises(lib_exc.Conflict,
                          self.client.update_port,
                          port2['uuid'], patch)
Example #47
0
    def test_update_port_replace_mac_with_malformed(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, port = self.create_port(node_id=node_id, address=address)
        port_id = port['uuid']

        patch = [{'path': '/address',
                  'op': 'replace',
                  'value': 'malformed:mac'}]

        self.assertRaises(lib_exc.BadRequest,
                          self.client.update_port, port_id, patch)