Exemplo n.º 1
0
 def test_plug_lrouter_port_patch_attachment(self):
     tenant_id = 'pippo'
     transport_zones_config = [{'zone_uuid': _uuid(),
                                'transport_type': 'stt'}]
     lswitch = switchlib.create_lswitch(self.fake_cluster,
                                        _uuid(),
                                        tenant_id, 'fake-switch',
                                        transport_zones_config)
     lport = switchlib.create_lport(self.fake_cluster, lswitch['uuid'],
                                    tenant_id, 'xyz',
                                    'name', 'device_id', True)
     lrouter = routerlib.create_lrouter(self.fake_cluster,
                                        uuidutils.generate_uuid(),
                                        tenant_id,
                                        'fake-lrouter',
                                        '10.0.0.1')
     lrouter_port = routerlib.create_router_lport(
         self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
         'name', True, ['192.168.0.1'], '00:11:22:33:44:55:66')
     result = routerlib.plug_router_port_attachment(
         self.fake_cluster, lrouter['uuid'],
         lrouter_port['uuid'],
         lport['uuid'], 'PatchAttachment')
     self.assertEqual(lport['uuid'],
                      result['LogicalPortAttachment']['peer_port_uuid'])
Exemplo n.º 2
0
 def test_plug_lrouter_port_patch_attachment(self):
     tenant_id = 'pippo'
     transport_zones_config = [{'zone_uuid': _uuid(),
                                'transport_type': 'stt'}]
     lswitch = switchlib.create_lswitch(self.fake_cluster,
                                        _uuid(),
                                        tenant_id, 'fake-switch',
                                        transport_zones_config)
     lport = switchlib.create_lport(self.fake_cluster, lswitch['uuid'],
                                    tenant_id, 'xyz',
                                    'name', 'device_id', True)
     lrouter = routerlib.create_lrouter(self.fake_cluster,
                                        uuidutils.generate_uuid(),
                                        tenant_id,
                                        'fake-lrouter',
                                        '10.0.0.1')
     lrouter_port = routerlib.create_router_lport(
         self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
         'name', True, ['192.168.0.1'], '00:11:22:33:44:55:66')
     result = routerlib.plug_router_port_attachment(
         self.fake_cluster, lrouter['uuid'],
         lrouter_port['uuid'],
         lport['uuid'], 'PatchAttachment')
     self.assertEqual(lport['uuid'],
                      result['LogicalPortAttachment']['peer_port_uuid'])
Exemplo n.º 3
0
 def lsn_port_metadata_setup(self, context, lsn_id, subnet):
     """Connect subnet to specified LSN."""
     data = {
         "mac_address": const.METADATA_MAC,
         "ip_address": subnet['cidr'],
         "subnet_id": subnet['id']
     }
     network_id = subnet['network_id']
     tenant_id = subnet['tenant_id']
     lswitch_port_id = None
     try:
         lswitch_port_id = switch_api.create_lport(
             self.cluster, network_id, tenant_id,
             const.METADATA_PORT_ID, const.METADATA_PORT_NAME,
             const.METADATA_DEVICE_ID, True)['uuid']
         lsn_port_id = self.lsn_port_create(self.cluster, lsn_id, data)
     except (n_exc.NotFound, p_exc.NvpPluginException,
             nsxlib.NvpApiClient.NvpApiException):
         raise p_exc.PortConfigurationError(
             net_id=network_id, lsn_id=lsn_id, port_id=lswitch_port_id)
     else:
         try:
             lsn_api.lsn_port_plug_network(
                 self.cluster, lsn_id, lsn_port_id, lswitch_port_id)
         except p_exc.LsnConfigurationConflict:
             self.lsn_port_delete(self.cluster, lsn_id, lsn_port_id)
             switch_api.delete_port(
                 self.cluster, network_id, lswitch_port_id)
             raise p_exc.PortConfigurationError(
                 net_id=network_id, lsn_id=lsn_id, port_id=lsn_port_id)
Exemplo n.º 4
0
 def lsn_port_metadata_setup(self, context, lsn_id, subnet):
     """Connect subnet to specified LSN."""
     data = {
         "mac_address": const.METADATA_MAC,
         "ip_address": subnet['cidr'],
         "subnet_id": subnet['id']
     }
     network_id = subnet['network_id']
     tenant_id = subnet['tenant_id']
     lswitch_port_id = None
     try:
         lswitch_port_id = switch_api.create_lport(self.cluster, network_id,
                                                   tenant_id,
                                                   const.METADATA_PORT_ID,
                                                   const.METADATA_PORT_NAME,
                                                   const.METADATA_DEVICE_ID,
                                                   True)['uuid']
         lsn_port_id = self.lsn_port_create(self.cluster, lsn_id, data)
     except (n_exc.NotFound, p_exc.NvpPluginException,
             nsxlib.NvpApiClient.NvpApiException):
         raise p_exc.PortConfigurationError(net_id=network_id,
                                            lsn_id=lsn_id,
                                            port_id=lswitch_port_id)
     else:
         try:
             lsn_api.lsn_port_plug_network(self.cluster, lsn_id,
                                           lsn_port_id, lswitch_port_id)
         except p_exc.LsnConfigurationConflict:
             self.lsn_port_delete(self.cluster, lsn_id, lsn_port_id)
             switch_api.delete_port(self.cluster, network_id,
                                    lswitch_port_id)
             raise p_exc.PortConfigurationError(net_id=network_id,
                                                lsn_id=lsn_id,
                                                port_id=lsn_port_id)
Exemplo n.º 5
0
 def _create_switch_and_port(self, tenant_id='pippo',
                             neutron_port_id='whatever',
                             name='name', device_id='device_id'):
     transport_zones_config = [{'zone_uuid': _uuid(),
                                'transport_type': 'stt'}]
     lswitch = switchlib.create_lswitch(self.fake_cluster,
                                        _uuid(), tenant_id, 'fake-switch',
                                        transport_zones_config)
     lport = switchlib.create_lport(self.fake_cluster, lswitch['uuid'],
                                    tenant_id, neutron_port_id,
                                    name, device_id, True)
     return lswitch, lport
Exemplo n.º 6
0
 def test_query_lswitch_ports(self):
     lswitch, lport = self._create_switch_and_port()
     switch_port_uuids = [
         switchlib.create_lport(
             self.fake_cluster, lswitch['uuid'], 'pippo', 'qportid-%s' % k,
             'port-%s' % k, 'deviceid-%s' % k, True)['uuid']
         for k in range(2)]
     switch_port_uuids.append(lport['uuid'])
     ports = switchlib.query_lswitch_lports(
         self.fake_cluster, lswitch['uuid'])
     self.assertEqual(len(ports), 3)
     for res_port in ports:
         self.assertIn(res_port['uuid'], switch_port_uuids)
Exemplo n.º 7
0
 def test_plug_l2_gw_port_attachment(self):
     tenant_id = 'pippo'
     node_uuid = _uuid()
     transport_zones_config = [{'zone_uuid': _uuid(),
                                'transport_type': 'stt'}]
     lswitch = switchlib.create_lswitch(
         self.fake_cluster, _uuid(), tenant_id,
         'fake-switch', transport_zones_config)
     gw_id = self._create_gw_service(node_uuid, 'fake-gw')['uuid']
     lport = switchlib.create_lport(
         self.fake_cluster, lswitch['uuid'], tenant_id, _uuid(),
         'fake-gw-port', gw_id, True)
     l2gwlib.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 = nvplib.do_request("GET", uri,
                                  cluster=self.fake_cluster)
     self.assertIn('LogicalPortAttachment', resp_obj)
     self.assertEqual(resp_obj['LogicalPortAttachment']['type'],
                      'L2GatewayAttachment')
Exemplo n.º 8
0
 def test_plug_l2_gw_port_attachment(self):
     tenant_id = 'pippo'
     node_uuid = _uuid()
     transport_zones_config = [{
         'zone_uuid': _uuid(),
         'transport_type': 'stt'
     }]
     lswitch = switchlib.create_lswitch(self.fake_cluster, _uuid(),
                                        tenant_id, 'fake-switch',
                                        transport_zones_config)
     gw_id = self._create_gw_service(node_uuid, 'fake-gw')['uuid']
     lport = switchlib.create_lport(self.fake_cluster, lswitch['uuid'],
                                    tenant_id, _uuid(), 'fake-gw-port',
                                    gw_id, True)
     l2gwlib.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 = nvplib.do_request("GET", uri, cluster=self.fake_cluster)
     self.assertIn('LogicalPortAttachment', resp_obj)
     self.assertEqual(resp_obj['LogicalPortAttachment']['type'],
                      'L2GatewayAttachment')