def test_plug_l2_gw_port_attachment(self): tenant_id = 'pippo' node_uuid = _uuid() lswitch = nvplib.create_lswitch(self.fake_cluster, tenant_id, 'fake-switch') gw_id = self._create_gw_service(node_uuid, 'fake-gw')['uuid'] lport = nvplib.create_lport(self.fake_cluster, lswitch['uuid'], tenant_id, _uuid(), 'fake-gw-port', gw_id, True) json.loads(nvplib.plug_l2_gw_service(self.fake_cluster, lswitch['uuid'], lport['uuid'], gw_id)) uri = nvplib._build_uri_path(nvplib.LSWITCHPORT_RESOURCE, lport['uuid'], lswitch['uuid'], is_attachment=True) resp_obj = json.loads( nvplib.do_single_request("GET", uri, cluster=self.fake_cluster)) self.assertIn('LogicalPortAttachment', resp_obj) self.assertEqual(resp_obj['LogicalPortAttachment']['type'], 'L2GatewayAttachment')
def test_get_port_by_tag(self): tenant_id = 'pippo' quantum_port_id = 'whatever' lswitch = nvplib.create_lswitch(self.fake_cluster, tenant_id, 'fake-switch') lport = nvplib.create_lport(self.fake_cluster, lswitch['uuid'], tenant_id, quantum_port_id, 'name', 'device_id', True) lport2 = nvplib.get_port_by_quantum_tag(self.fake_cluster, lswitch['uuid'], quantum_port_id) self.assertIsNotNone(lport2) self.assertEqual(lport['uuid'], lport2['uuid'])
def test_plug_l2_gw_port_attachment(self): tenant_id = 'pippo' node_uuid = _uuid() lswitch = nvplib.create_lswitch(self.fake_cluster, tenant_id, 'fake-switch') gw_id = self._create_gw_service(node_uuid, 'fake-gw')['uuid'] lport = nvplib.create_lport(self.fake_cluster, lswitch['uuid'], tenant_id, _uuid(), 'fake-gw-port', gw_id, True) json.loads( nvplib.plug_l2_gw_service(self.fake_cluster, lswitch['uuid'], lport['uuid'], gw_id)) uri = nvplib._build_uri_path(nvplib.LSWITCHPORT_RESOURCE, lport['uuid'], lswitch['uuid'], is_attachment=True) resp_obj = json.loads( nvplib.do_single_request("GET", uri, cluster=self.fake_cluster)) self.assertIn('LogicalPortAttachment', resp_obj) self.assertEqual(resp_obj['LogicalPortAttachment']['type'], 'L2GatewayAttachment')