def test_get_hosting_device_resources_by_complementary_id(self):
     tenant_id = "some_tenant_id"
     ctx = context.Context("", tenant_id, is_admin=True)
     plugging_driver = HwVLANTrunkingPlugDriver()
     mgmt_context = {"mgmt_nw_id": None}
     res = plugging_driver.create_hosting_device_resources(ctx, "some_id", tenant_id, mgmt_context, 1)
     # ports that should not be returned
     with self.port(), self.port(device_id="uuid2"), self.port(tenant_id=tenant_id):
         res_get = plugging_driver.get_hosting_device_resources(ctx, "", "some_id", tenant_id, None)
         self.assertIsNone(res_get["mgmt_port"])
         self.assertEqual(len(res), 1)
Esempio n. 2
0
 def test_get_hosting_device_resources_by_complementary_id(self):
     tenant_id = 'some_tenant_id'
     ctx = context.Context('', tenant_id, is_admin=True)
     plugging_driver = HwVLANTrunkingPlugDriver()
     mgmt_context = {'mgmt_nw_id': None}
     res = plugging_driver.create_hosting_device_resources(
         ctx, "some_id", tenant_id, mgmt_context, 1)
     # ports that should not be returned
     with self.port(), self.port(device_id='uuid2'), self.port(
             tenant_id=tenant_id):
         res_get = plugging_driver.get_hosting_device_resources(
             ctx, '', 'some_id', tenant_id, None)
         self.assertIsNone(res_get['mgmt_port'])
         self.assertEqual(len(res), 1)
 def test_get_hosting_device_resources_by_device_id(self):
     tenant_id = "some_tenant_id"
     ctx = context.Context("", tenant_id, is_admin=True)
     plugging_driver = HwVLANTrunkingPlugDriver()
     mgmt_context = {"mgmt_nw_id": None}
     res = plugging_driver.create_hosting_device_resources(ctx, "some_id", tenant_id, mgmt_context, 1)
     # update attributes of created ports to fake what Nova updates
     hd_uuid = "hd_uuid1"
     update_spec = {"port": {"device_id": hd_uuid, "device_owner": "nova"}}
     for hd_port in self._list("ports")["ports"]:
         self._update("ports", hd_port["id"], update_spec)
     # ports that should not be returned
     with self.port(), self.port(device_id="uuid2"), self.port(tenant_id=tenant_id), self.port(
         tenant_id=tenant_id, device_owner="other_uuid"
     ):
         res_get = plugging_driver.get_hosting_device_resources(ctx, hd_uuid, "some_id", tenant_id, None)
         self.assertIsNone(res_get["mgmt_port"])
         self.assertEqual(len(res), 1)
Esempio n. 4
0
 def test_get_hosting_device_resources_by_device_id(self):
     tenant_id = 'some_tenant_id'
     ctx = context.Context('', tenant_id, is_admin=True)
     plugging_driver = HwVLANTrunkingPlugDriver()
     mgmt_context = {'mgmt_nw_id': None}
     res = plugging_driver.create_hosting_device_resources(
         ctx, "some_id", tenant_id, mgmt_context, 1)
     # update attributes of created ports to fake what Nova updates
     hd_uuid = 'hd_uuid1'
     update_spec = {'port': {'device_id': hd_uuid, 'device_owner': 'nova'}}
     for hd_port in self._list('ports')['ports']:
         self._update('ports', hd_port['id'], update_spec)
     # ports that should not be returned
     with self.port(), self.port(device_id='uuid2'), self.port(
             tenant_id=tenant_id), self.port(tenant_id=tenant_id,
                                             device_owner='other_uuid'):
         res_get = plugging_driver.get_hosting_device_resources(
             ctx, hd_uuid, 'some_id', tenant_id, None)
         self.assertIsNone(res_get['mgmt_port'])
         self.assertEqual(len(res), 1)
 def test_get_hosting_device_resources_by_device_id(self):
     tenant_id = 'some_tenant_id'
     ctx = context.Context('', tenant_id, is_admin=True)
     plugging_driver = HwVLANTrunkingPlugDriver()
     mgmt_context = {'mgmt_nw_id': None}
     res = plugging_driver.create_hosting_device_resources(
         ctx, "some_id", tenant_id, mgmt_context, 1)
     # update attributes of created ports to fake what Nova updates
     hd_uuid = 'hd_uuid1'
     update_spec = {'port': {'device_id': hd_uuid,
                             'device_owner': 'nova'}}
     for hd_port in self._list('ports')['ports']:
         self._update('ports', hd_port['id'], update_spec)
     # ports that should not be returned
     with self.port(), self.port(device_id='uuid2'), self.port(
             tenant_id=tenant_id), self.port(tenant_id=tenant_id,
                                             device_owner='other_uuid'):
         res_get = plugging_driver.get_hosting_device_resources(
             ctx, hd_uuid, 'some_id', tenant_id, None)
         self.assertIsNone(res_get['mgmt_port'])
         self.assertEqual(len(res), 1)