Esempio n. 1
0
 def test_create_and_get_lswitches_multiple(self):
     tenant_id = 'pippo'
     transport_zones_config = [{'zone_uuid': _uuid(),
                                'transport_type': 'stt'}]
     network_id = _uuid()
     main_lswitch = switchlib.create_lswitch(
         self.fake_cluster, network_id,
         tenant_id, 'fake-switch', transport_zones_config,
         tags=[{'scope': 'multi_lswitch', 'tag': 'True'}])
     # Create secondary lswitch
     second_lswitch = switchlib.create_lswitch(
         self.fake_cluster, network_id,
         tenant_id, 'fake-switch-2', transport_zones_config)
     res_lswitch = switchlib.get_lswitches(self.fake_cluster,
                                           network_id)
     self.assertEqual(len(res_lswitch), 2)
     switch_uuids = [ls['uuid'] for ls in res_lswitch]
     self.assertIn(main_lswitch['uuid'], switch_uuids)
     self.assertIn(second_lswitch['uuid'], switch_uuids)
     for ls in res_lswitch:
         if ls['uuid'] == main_lswitch['uuid']:
             main_ls = ls
         else:
             second_ls = ls
     main_ls_tags = self._build_tag_dict(main_ls['tags'])
     second_ls_tags = self._build_tag_dict(second_ls['tags'])
     self.assertIn('multi_lswitch', main_ls_tags)
     self.assertNotIn('multi_lswitch', second_ls_tags)
     self.assertIn('quantum_net_id', main_ls_tags)
     self.assertIn('quantum_net_id', second_ls_tags)
     self.assertEqual(main_ls_tags['quantum_net_id'],
                      network_id)
     self.assertEqual(second_ls_tags['quantum_net_id'],
                      network_id)
Esempio 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'])
Esempio n. 3
0
 def test_get_port_by_tag_not_found_returns_None(self):
     tenant_id = 'pippo'
     neutron_port_id = 'whatever'
     transport_zones_config = [{'zone_uuid': _uuid(),
                                'transport_type': 'stt'}]
     lswitch = switchlib.create_lswitch(
         self.fake_cluster, tenant_id, _uuid(),
         'fake-switch', transport_zones_config)
     lport = switchlib.get_port_by_neutron_tag(
         self.fake_cluster, lswitch['uuid'], neutron_port_id)
     self.assertIsNone(lport)
Esempio n. 4
0
 def test_delete_networks(self):
     transport_zones_config = [{
         'zone_uuid': _uuid(),
         'transport_type': 'stt'
     }]
     lswitch = switchlib.create_lswitch(self.fake_cluster, _uuid(), 'pippo',
                                        'fake-switch',
                                        transport_zones_config)
     switchlib.delete_networks(self.fake_cluster, lswitch['uuid'],
                               [lswitch['uuid']])
     self.assertRaises(exceptions.NotFound, switchlib.get_lswitches,
                       self.fake_cluster, lswitch['uuid'])
Esempio 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
Esempio n. 6
0
 def test_create_and_get_lswitches_multiple(self):
     tenant_id = 'pippo'
     transport_zones_config = [{
         'zone_uuid': _uuid(),
         'transport_type': 'stt'
     }]
     network_id = _uuid()
     main_lswitch = switchlib.create_lswitch(self.fake_cluster,
                                             network_id,
                                             tenant_id,
                                             'fake-switch',
                                             transport_zones_config,
                                             tags=[{
                                                 'scope': 'multi_lswitch',
                                                 'tag': 'True'
                                             }])
     # Create secondary lswitch
     second_lswitch = switchlib.create_lswitch(self.fake_cluster,
                                               network_id, tenant_id,
                                               'fake-switch-2',
                                               transport_zones_config)
     res_lswitch = switchlib.get_lswitches(self.fake_cluster, network_id)
     self.assertEqual(len(res_lswitch), 2)
     switch_uuids = [ls['uuid'] for ls in res_lswitch]
     self.assertIn(main_lswitch['uuid'], switch_uuids)
     self.assertIn(second_lswitch['uuid'], switch_uuids)
     for ls in res_lswitch:
         if ls['uuid'] == main_lswitch['uuid']:
             main_ls = ls
         else:
             second_ls = ls
     main_ls_tags = self._build_tag_dict(main_ls['tags'])
     second_ls_tags = self._build_tag_dict(second_ls['tags'])
     self.assertIn('multi_lswitch', main_ls_tags)
     self.assertNotIn('multi_lswitch', second_ls_tags)
     self.assertIn('quantum_net_id', main_ls_tags)
     self.assertIn('quantum_net_id', second_ls_tags)
     self.assertEqual(main_ls_tags['quantum_net_id'], network_id)
     self.assertEqual(second_ls_tags['quantum_net_id'], network_id)
Esempio n. 7
0
 def test_create_and_get_lswitches_single(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)
     res_lswitch = switchlib.get_lswitches(self.fake_cluster,
                                           lswitch['uuid'])
     self.assertEqual(len(res_lswitch), 1)
     self.assertEqual(res_lswitch[0]['uuid'], lswitch['uuid'])
Esempio n. 8
0
 def test_create_and_get_lswitches_single_name_exceeds_40_chars(self):
     tenant_id = 'pippo'
     transport_zones_config = [{
         'zone_uuid': _uuid(),
         'transport_type': 'stt'
     }]
     lswitch = switchlib.create_lswitch(self.fake_cluster, tenant_id,
                                        _uuid(), '*' * 50,
                                        transport_zones_config)
     res_lswitch = switchlib.get_lswitches(self.fake_cluster,
                                           lswitch['uuid'])
     self.assertEqual(len(res_lswitch), 1)
     self.assertEqual(res_lswitch[0]['uuid'], lswitch['uuid'])
     self.assertEqual(res_lswitch[0]['display_name'], '*' * 40)
Esempio n. 9
0
 def test_get_port_by_tag_not_found_returns_None(self):
     tenant_id = 'pippo'
     neutron_port_id = 'whatever'
     transport_zones_config = [{
         'zone_uuid': _uuid(),
         'transport_type': 'stt'
     }]
     lswitch = switchlib.create_lswitch(self.fake_cluster, tenant_id,
                                        _uuid(), 'fake-switch',
                                        transport_zones_config)
     lport = switchlib.get_port_by_neutron_tag(self.fake_cluster,
                                               lswitch['uuid'],
                                               neutron_port_id)
     self.assertIsNone(lport)
Esempio n. 10
0
 def test_create_and_get_lswitches_single_name_exceeds_40_chars(self):
     tenant_id = 'pippo'
     transport_zones_config = [{'zone_uuid': _uuid(),
                                'transport_type': 'stt'}]
     lswitch = switchlib.create_lswitch(self.fake_cluster,
                                        tenant_id,
                                        _uuid(),
                                        '*' * 50,
                                        transport_zones_config)
     res_lswitch = switchlib.get_lswitches(self.fake_cluster,
                                           lswitch['uuid'])
     self.assertEqual(len(res_lswitch), 1)
     self.assertEqual(res_lswitch[0]['uuid'], lswitch['uuid'])
     self.assertEqual(res_lswitch[0]['display_name'], '*' * 40)
Esempio n. 11
0
 def test_create_and_get_lswitches_single(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)
     res_lswitch = switchlib.get_lswitches(self.fake_cluster,
                                           lswitch['uuid'])
     self.assertEqual(len(res_lswitch), 1)
     self.assertEqual(res_lswitch[0]['uuid'],
                      lswitch['uuid'])
Esempio n. 12
0
 def test_delete_networks(self):
     transport_zones_config = [{'zone_uuid': _uuid(),
                                'transport_type': 'stt'}]
     lswitch = switchlib.create_lswitch(self.fake_cluster,
                                        _uuid(),
                                        'pippo',
                                        'fake-switch',
                                        transport_zones_config)
     switchlib.delete_networks(self.fake_cluster, lswitch['uuid'],
                               [lswitch['uuid']])
     self.assertRaises(exceptions.NotFound,
                       switchlib.get_lswitches,
                       self.fake_cluster,
                       lswitch['uuid'])
Esempio n. 13
0
 def test_update_lswitch(self):
     new_name = 'new-name'
     new_tags = [{'scope': 'new_tag', 'tag': 'xxx'}]
     transport_zones_config = [{'zone_uuid': _uuid(),
                                'transport_type': 'stt'}]
     lswitch = switchlib.create_lswitch(self.fake_cluster,
                                        _uuid(),
                                        'pippo',
                                        'fake-switch',
                                        transport_zones_config)
     switchlib.update_lswitch(self.fake_cluster, lswitch['uuid'],
                              new_name, tags=new_tags)
     res_lswitch = switchlib.get_lswitches(self.fake_cluster,
                                           lswitch['uuid'])
     self.assertEqual(len(res_lswitch), 1)
     self.assertEqual(res_lswitch[0]['display_name'], new_name)
     switch_tags = self._build_tag_dict(res_lswitch[0]['tags'])
     self.assertIn('new_tag', switch_tags)
     self.assertEqual(switch_tags['new_tag'], 'xxx')
Esempio n. 14
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')
Esempio n. 15
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')