def setUp(self): self.common_utils = MigrationUtil() tenant_ref = "/api/tenant/?name=admin" cloud_ref = "/api/cloud/?tenant=admin&name=Default-Cloud" tenant = "admin" vrf_ref = None self.empty_data = [] self.data = { "ApplicationPersistenceProfile": [ { "name": "test_sticky" } ], "HealthMonitor": [ { "name": "test_probe" } ], "SSLProfile": [ ] } self.vrf_ref_data = "/api/vrfcontext/?tenant=admin&name=testvrf1&cloud=Default-Cloud" self.pool_obj_app = PoolConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.pool_obj_app_vrf = PoolConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=self.vrf_ref_data) self.pool_obj_app_empty = PoolConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.MonitorConvertor_obj_app = MonitorConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.MonitorConvertor_empty = MonitorConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.PersistanceConvertor_obj_app = PersistanceConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.PersistanceConvertor_empty = PersistanceConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.sslConvertor_obj_app = SSLConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, in_path=None, tenant=tenant) self.sslConvertor_empty = SSLConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, in_path=None, tenant=tenant) self.vs = VSConverter(parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.vs_vrf = VSConverter(parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=self.vrf_ref_data) self.vs_empty = VSConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref)
def setUp(self): self.common_utils = MigrationUtil() tenant_ref = "/api/tenant/?name=admin" cloud_ref = "/api/cloud/?tenant=admin&name=Default-Cloud" tenant = "admin" vrf_ref = None self.empty_data = [] self.data = { "ApplicationPersistenceProfile": [ { "name": "test_sticky" } ], "HealthMonitor": [ { "name": "test_probe" } ], "SSLProfile": [ ] } self.vrf_ref_data = "/api/vrfcontext/?tenant=admin&name=testvrf1&cloud=Default-Cloud" self.pool_obj_app = PoolConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.pool_obj_app_vrf = PoolConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=self.vrf_ref_data) self.pool_obj_app_empty = PoolConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.MonitorConvertor_obj_app = MonitorConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.MonitorConvertor_empty = MonitorConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.PersistanceConvertor_obj_app = PersistanceConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.PersistanceConvertor_empty = PersistanceConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.sslConvertor_obj_app = SSLConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, in_path=None, tenant=tenant) self.sslConvertor_empty = SSLConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, in_path=None, tenant=tenant) self.vs = VSConverter(parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.vs_vrf = VSConverter(parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=self.vrf_ref_data) self.vs_empty = VSConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref)
def __init__(self, parsed_output, enable_vs=False, version='17.1.1', input_folder_loc=None, tenant=None, cloud=None, vrf=None, segroup=None): """ Create Some common Objects over here """ self.aviobj = AviConverter() self.parsed = parsed_output self.common_utils = MigrationUtil() self.version = version self.enable_vs = enable_vs self.input_file_loc = input_folder_loc self.tenant = tenant self.cloud = cloud self.vrf = vrf self.vrf_ref = None self.segroup = segroup self.tenant_ref = self.common_utils.get_object_ref( self.tenant, 'tenant') self.cloud_ref = self.common_utils.get_object_ref(self.cloud, 'cloud') if self.vrf: self.vrf_ref = self.common_utils.get_object_ref( object_name=self.vrf, object_type='vrfcontext', tenant=self.tenant, cloud_name=self.cloud, ) # creating objects for converters self.pool = PoolConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, cloud_ref=self.cloud_ref, tenant=self.tenant, vrf_ref=self.vrf_ref) self.monitor = MonitorConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, tenant=self.tenant) self.vs = VSConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, enable_vs=self.enable_vs, cloud_ref=self.cloud_ref, tenant=self.tenant, vrf_ref=self.vrf_ref, segroup=self.segroup, cloud=self.cloud) self.persistance = PersistanceConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, tenant=self.tenant) self.ssl = SSLConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, in_path=self.input_file_loc, tenant=self.tenant)
class ConfigConverter(object): """ Configuration conversion happens here """ def __init__(self, parsed_output, enable_vs=False, version='17.1.1', input_folder_loc=None, tenant=None, cloud=None, vrf=None, segroup=None): """ Create Some common Objects over here """ self.aviobj = AviConverter() self.parsed = parsed_output self.common_utils = MigrationUtil() self.version = version self.enable_vs = enable_vs self.input_file_loc = input_folder_loc self.tenant = tenant self.cloud = cloud self.vrf = vrf self.vrf_ref = None self.segroup = segroup self.tenant_ref = self.common_utils.get_object_ref( self.tenant, 'tenant') self.cloud_ref = self.common_utils.get_object_ref(self.cloud, 'cloud') if self.vrf: self.vrf_ref = self.common_utils.get_object_ref( object_name=self.vrf, object_type='vrfcontext', tenant=self.tenant, cloud_name=self.cloud, ) # creating objects for converters self.pool = PoolConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, cloud_ref=self.cloud_ref, tenant=self.tenant, vrf_ref=self.vrf_ref) self.monitor = MonitorConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, tenant=self.tenant) self.vs = VSConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, enable_vs=self.enable_vs, cloud_ref=self.cloud_ref, tenant=self.tenant, vrf_ref=self.vrf_ref, segroup=self.segroup, cloud=self.cloud) self.persistance = PersistanceConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, tenant=self.tenant) self.ssl = SSLConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, in_path=self.input_file_loc, tenant=self.tenant) def conversion(self): """ All conversion controller over here """ data = dict() data['HealthMonitor'] = self.monitor.healthmonitor_conversion() data[ 'ApplicationPersistenceProfile'] = self.persistance.app_persistance_conversion( ) data['Pool'] = self.pool.pool_conversion(data) data['SSLProfile'] = self.ssl.ssl_profile() data['SSLKeyAndCertificate'] = self.ssl.ssl_key_and_cert() data['VsVip'] = self.vs.vsvip_conversion() vs_list, cloned_pool_list, http_list = self.vs.virtual_service_conversion( data) data['httppolicyset'] = http_list data['VirtualService'] = vs_list data['Pool'].extend(cloned_pool_list) root_inter_certs = self.ssl.crypto_chaingroup() #Checking chaingroup present or not if root_inter_certs: data['SSLKeyAndCertificate'].extend(root_inter_certs) if self.tenant != 'admin': data['Tenant'] = [{ "local": True, "name": self.tenant }, { "local": True, "name": "admin" }] if self.vrf: vrf_context = [ { "name": 'global', "system_default": True, "tenant_ref": self.common_utils.get_object_ref(self.tenant, 'tenant'), "cloud_ref": self.common_utils.get_object_ref(self.cloud, 'cloud'), "static_routes": [] }, { "name": self.vrf, "system_default": True, "tenant_ref": self.common_utils.get_object_ref(self.tenant, 'tenant'), "cloud_ref": self.common_utils.get_object_ref(self.cloud, 'cloud'), "static_routes": [] }, ] data['VrfContext'] = vrf_context return data
class TestModulesAce(unittest2.TestCase): def setUp(self): self.common_utils = MigrationUtil() tenant_ref = "/api/tenant/?name=admin" cloud_ref = "/api/cloud/?tenant=admin&name=Default-Cloud" tenant = "admin" vrf_ref = None self.empty_data = [] self.data = { "ApplicationPersistenceProfile": [{ "name": "test_sticky" }], "HealthMonitor": [{ "name": "test_probe" }], "SSLProfile": [] } self.vrf_ref_data = "/api/vrfcontext/?tenant=admin&name=testvrf1&cloud=Default-Cloud" self.pool_obj_app = PoolConverter(parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.pool_obj_app_vrf = PoolConverter(parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=self.vrf_ref_data) self.pool_obj_app_empty = PoolConverter(parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.MonitorConvertor_obj_app = MonitorConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.MonitorConvertor_empty = MonitorConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.PersistanceConvertor_obj_app = PersistanceConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.PersistanceConvertor_empty = PersistanceConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.sslConvertor_obj_app = SSLConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, in_path=None, tenant=tenant) self.sslConvertor_empty = SSLConverter(parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, in_path=None, tenant=tenant) self.vs = VSConverter(parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.vs_vrf = VSConverter(parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=self.vrf_ref_data) self.vs_empty = VSConverter(parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) """ POOL CONVERTERS""" @pytest.mark.TCID1_48_1551_13_0 def test_pool_persistance_true(self): """Checking correct input and correct pool name expects proper sticky""" self.assertEqual( self.pool_obj_app.find_app_persistance(pool_name, self.data), sticky_name) @pytest.mark.TCID1_48_1551_12_0 def test_pool_persistance_failure(self): self.assertNotEquals( "invalid", self.pool_obj_app.find_app_persistance("invalid", self.data)) @pytest.mark.TCID1_48_1551_11_0 def test_pool_persistance_empty(self): self.assertFalse( self.pool_obj_app_empty.find_app_persistance( pool_name, self.empty_data)) @pytest.mark.TCID1_48_1551_8_0 def test_pool_conversion_true(self): self.assertEqual( self.pool_obj_app.pool_conversion(self.data)[0]['name'], pool_name) @pytest.mark.TCID1_48_1551_7_0 def test_pool_conversion_invalid(self): self.assertNotEquals( self.pool_obj_app.pool_conversion(self.data)[0]['name'], 'invalid') @pytest.mark.TCID1_48_1551_10_0 def test_pool_conversion_with_probe(self): self.assertEquals( len( self.pool_obj_app.pool_conversion( self.data)[0]['health_monitor_refs']), 1) @pytest.mark.TCID1_48_1551_9_0 def test_pool_conversion_with_mutiple_servers(self): self.assertEquals( len(self.pool_obj_app.pool_conversion(self.data)[0]['servers']), 2) @pytest.mark.TCID1_48_1551_17_0 def test_server_converter_true(self): self.assertTrue(self.pool_obj_app.server_converter(server_name, port)) @pytest.mark.TCID1_48_1551_16_0 def test_server_converter_invalid(self): self.assertFalse( self.pool_obj_app.server_converter({ "invalid:80": False, }, "invalid")) @pytest.mark.TCID1_48_1551_15_0 def test_server_converter_empty(self): self.assertNotEquals( self.pool_obj_app_empty.server_converter(server_name, port), server_name, port) @pytest.mark.TCID1_48_1551_14_0 def test_pool_with_vrf_ref(self): self.assert_( self.pool_obj_app_vrf.pool_conversion(self.data)[0]['vrf_ref'], self.vrf_ref_data) """ Monitor Converters """ @pytest.mark.TCID1_48_1551_2_0 def test_monitor_convertor_true(self): """ Giving data and asserting with the expected output """ self.assertTrue( self.MonitorConvertor_obj_app.healthmonitor_conversion()[0] ['name'], health_moniter_name) @pytest.mark.TCID1_48_1551_1_0 def test_monitor_convertor_empty(self): self.assertFalse( self.MonitorConvertor_empty.healthmonitor_conversion()) @pytest.mark.TCID1_48_1551_3_0 def test_monitor_https_support(self): self.assertEquals( self.MonitorConvertor_obj_app.healthmonitor_conversion()[0] ['type'], 'HEALTH_MONITOR_HTTPS') @pytest.mark.TCID1_48_1551_4_0 def test_monitor_port_support(self): self.assertTrue('monitor_port' in self.MonitorConvertor_obj_app. healthmonitor_conversion()[1]) """ Persistance Converter""" @pytest.mark.TCID1_48_1551_6_0 def test_persistance_convertor_true(self): self.assertTrue( self.PersistanceConvertor_obj_app.app_persistance_conversion()[0] ['name'], persistance_moniter_name) @pytest.mark.TCID1_48_1551_5_0 def test_persistance_convertor_empty(self): self.assertFalse( self.PersistanceConvertor_empty.app_persistance_conversion()) """SSL Convertor""" @pytest.mark.TCID1_48_1551_19_0 def test_sslConvertor_true(self): self.assertTrue(self.sslConvertor_obj_app.ssl_key_and_cert()) @pytest.mark.TCID1_48_1551_18_0 def test_sslConvertor_empty(self): self.assertFalse(self.sslConvertor_empty.ssl_key_and_cert()) """SSL Profile Convertor""" @pytest.mark.TCID1_48_1551_20_0 def test_sslProfileConvertorTrue(self): self.assertTrue(self.sslConvertor_obj_app.ssl_profile()) @pytest.mark.TCID1_48_1551_21_0 def test_sslProfileEmpty(self): self.assertFalse(self.sslConvertor_empty.ssl_profile()) """VS Converter""" @pytest.mark.TCID1_48_1551_24_0 def test_vsipConverterTrue(self): self.assertTrue(self.vs.vsvip_conversion()) @pytest.mark.TCID1_48_1551_25_0 def test_vsipConverter_Empty(self): self.assertFalse(self.vs_empty.vsvip_conversion()) @pytest.mark.TCID1_48_1551_23_0 def test_vsConverter_true(self): self.assertTrue(self.vs.virtual_service_conversion(self.data)) @pytest.mark.TCID1_48_1551_22_0 def test_vsConverter_False(self): self.assertEquals(self.vs_empty.virtual_service_conversion('{}'), ([], [], []))
class TestModulesAce(unittest2.TestCase): def setUp(self): self.common_utils = MigrationUtil() tenant_ref = "/api/tenant/?name=admin" cloud_ref = "/api/cloud/?tenant=admin&name=Default-Cloud" tenant = "admin" vrf_ref = None self.empty_data = [] self.data = { "ApplicationPersistenceProfile": [ { "name": "test_sticky" } ], "HealthMonitor": [ { "name": "test_probe" } ], "SSLProfile": [ ] } self.vrf_ref_data = "/api/vrfcontext/?tenant=admin&name=testvrf1&cloud=Default-Cloud" self.pool_obj_app = PoolConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.pool_obj_app_vrf = PoolConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=self.vrf_ref_data) self.pool_obj_app_empty = PoolConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.MonitorConvertor_obj_app = MonitorConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.MonitorConvertor_empty = MonitorConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.PersistanceConvertor_obj_app = PersistanceConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.PersistanceConvertor_empty = PersistanceConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, tenant=tenant) self.sslConvertor_obj_app = SSLConverter( parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, in_path=None, tenant=tenant) self.sslConvertor_empty = SSLConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, in_path=None, tenant=tenant) self.vs = VSConverter(parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) self.vs_vrf = VSConverter(parsed=data, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=self.vrf_ref_data) self.vs_empty = VSConverter( parsed={}, tenant_ref=tenant_ref, common_utils=self.common_utils, enable_vs=True, cloud_ref=cloud_ref, tenant=tenant, vrf_ref=vrf_ref) """ POOL CONVERTERS""" def test_pool_persistance_true(self): """Checking correct input and correct pool name expects proper sticky""" self.assertEqual(self.pool_obj_app.find_app_persistance( pool_name, self.data), sticky_name) def test_pool_persistance_failure(self): self.assertNotEquals("invalid", self.pool_obj_app.find_app_persistance("invalid", self.data)) def test_pool_persistance_empty(self): self.assertFalse( self.pool_obj_app_empty.find_app_persistance(pool_name, self.empty_data)) def test_pool_conversion_true(self): self.assertEqual(self.pool_obj_app.pool_conversion(self.data) [0]['name'], pool_name) def test_pool_conversion_invalid(self): self.assertNotEquals(self.pool_obj_app.pool_conversion(self.data)[ 0]['name'], 'invalid') def test_pool_conversion_with_probe(self): self.assertEquals(len(self.pool_obj_app.pool_conversion(self.data)[ 0]['health_monitor_refs']), 1) def test_pool_conversion_with_mutiple_servers(self): self.assertEquals(len(self.pool_obj_app.pool_conversion(self.data)[0]['servers']), 2) def test_server_converter_true(self): self.assertTrue(self.pool_obj_app.server_converter(server_name, port)) def test_server_converter_invalid(self): self.assertFalse(self.pool_obj_app.server_converter("invalid","invalid")) def test_server_converter_empty(self): self.assertNotEquals( self.pool_obj_app_empty.server_converter(server_name, port), server_name, port) def test_pool_with_vrf_ref(self): self.assert_(self.pool_obj_app_vrf.pool_conversion(self.data) [0]['vrf_ref'], self.vrf_ref_data) """ Monitor Converters """ def test_monitor_convertor_true(self): """ Giving data and asserting with the expected output """ self.assertTrue(self.MonitorConvertor_obj_app.healthmonitor_conversion()[ 0]['name'], health_moniter_name) def test_monitor_convertor_empty(self): self.assertFalse( self.MonitorConvertor_empty.healthmonitor_conversion()) def test_monitor_https_support(self): self.assertEquals(self.MonitorConvertor_obj_app.healthmonitor_conversion()[0]['type'], 'HEALTH_MONITOR_HTTPS') def test_monitor_port_support(self): self.assertTrue('monitor_port' in self.MonitorConvertor_obj_app.healthmonitor_conversion()[1]) """ Persistance Converter""" def test_persistance_convertor_true(self): self.assertTrue(self.PersistanceConvertor_obj_app.app_persistance_conversion()[ 0]['name'], persistance_moniter_name) def test_persistance_convertor_empty(self): self.assertFalse( self.PersistanceConvertor_empty.app_persistance_conversion()) """SSL Convertor""" def test_sslConvertor_true(self): self.assertTrue(self.sslConvertor_obj_app.ssl_key_and_cert()) def test_sslConvertor_empty(self): self.assertFalse(self.sslConvertor_empty.ssl_key_and_cert()) """SSL Profile Convertor""" def test_sslProfileConvertorTrue(self): self.assertTrue(self.sslConvertor_obj_app.ssl_profile()) def test_sslProfileEmpty(self): self.assertFalse(self.sslConvertor_empty.ssl_profile()) """VS Converter""" def test_vsipConverterTrue(self): self.assertTrue(self.vs.vsvip_conversion()) def test_vsipConverter_Empty(self): self.assertFalse(self.vs_empty.vsvip_conversion()) def test_vsConverter_true(self): self.assertTrue(self.vs.virtual_service_conversion(self.data)) def test_vsConverter_False(self): self.assertEquals( self.vs_empty.virtual_service_conversion('{}'), ([], [], []))
def __init__(self, parsed_output, enable_vs=False, version='17.1.1', input_folder_loc=None, tenant=None, cloud=None, vrf=None, segroup=None): """ Create Some common Objects over here """ self.aviobj = AviConverter() self.parsed = parsed_output self.common_utils = MigrationUtil() self.version = version self.enable_vs = enable_vs self.input_file_loc = input_folder_loc self.tenant = tenant self.cloud = cloud self.vrf = vrf self.vrf_ref = None self.segroup = segroup self.tenant_ref = self.common_utils.get_object_ref( self.tenant, 'tenant') self.cloud_ref = self.common_utils.get_object_ref(self.cloud, 'cloud') if self.vrf: self.vrf_ref = self.common_utils.get_object_ref(object_name=self.vrf, object_type='vrfcontext', tenant=self.tenant, cloud_name=self.cloud, ) # creating objects for converters self.pool = PoolConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, cloud_ref=self.cloud_ref, tenant=self.tenant, vrf_ref=self.vrf_ref ) self.monitor = MonitorConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, tenant=self.tenant ) self.vs = VSConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, enable_vs=self.enable_vs, cloud_ref=self.cloud_ref, tenant=self.tenant, vrf_ref=self.vrf_ref, segroup=self.segroup, cloud=self.cloud ) self.persistance = PersistanceConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, tenant=self.tenant ) self.ssl = SSLConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, in_path=self.input_file_loc, tenant=self.tenant )
class ConfigConverter(object): """ Configuration conversion happens here """ def __init__(self, parsed_output, enable_vs=False, version='17.1.1', input_folder_loc=None, tenant=None, cloud=None, vrf=None, segroup=None): """ Create Some common Objects over here """ self.aviobj = AviConverter() self.parsed = parsed_output self.common_utils = MigrationUtil() self.version = version self.enable_vs = enable_vs self.input_file_loc = input_folder_loc self.tenant = tenant self.cloud = cloud self.vrf = vrf self.vrf_ref = None self.segroup = segroup self.tenant_ref = self.common_utils.get_object_ref( self.tenant, 'tenant') self.cloud_ref = self.common_utils.get_object_ref(self.cloud, 'cloud') if self.vrf: self.vrf_ref = self.common_utils.get_object_ref(object_name=self.vrf, object_type='vrfcontext', tenant=self.tenant, cloud_name=self.cloud, ) # creating objects for converters self.pool = PoolConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, cloud_ref=self.cloud_ref, tenant=self.tenant, vrf_ref=self.vrf_ref ) self.monitor = MonitorConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, tenant=self.tenant ) self.vs = VSConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, enable_vs=self.enable_vs, cloud_ref=self.cloud_ref, tenant=self.tenant, vrf_ref=self.vrf_ref, segroup=self.segroup, cloud=self.cloud ) self.persistance = PersistanceConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, tenant=self.tenant ) self.ssl = SSLConverter(parsed=self.parsed, tenant_ref=self.tenant_ref, common_utils=self.common_utils, in_path=self.input_file_loc, tenant=self.tenant ) def conversion(self): """ All conversion controller over here """ data = dict() data['META'] = self.aviobj.meta( tenant=self.tenant, controller_version=self.version) data['HealthMonitor'] = self.monitor.healthmonitor_conversion() data['ApplicationPersistenceProfile'] = self.persistance.app_persistance_conversion() data['Pool'] = self.pool.pool_conversion(data) data['SSLProfile'] = self.ssl.ssl_profile() data['SSLKeyAndCertificate'] = self.ssl.ssl_key_and_cert() data['VsVip'] = self.vs.vsvip_conversion() vs_list, cloned_pool_list, http_list = self.vs.virtual_service_conversion( data) data['httppolicyset'] = http_list data['VirtualService'] = vs_list data['Pool'].extend(cloned_pool_list) root_inter_certs = self.ssl.crypto_chaingroup() #Checking chaingroup present or not if root_inter_certs: data['SSLKeyAndCertificate'].extend(root_inter_certs) if self.tenant != 'admin': data['Tenant'] = [ { "local": True, "name": self.tenant }, { "local": True, "name": "admin" } ] if self.vrf: vrf_context = [ { "name": 'global', "system_default": True, "tenant_ref": self.common_utils.get_object_ref(self.tenant, 'tenant'), "cloud_ref": self.common_utils.get_object_ref(self.cloud, 'cloud'), "static_routes": [] }, { "name": self.vrf, "system_default": True, "tenant_ref": self.common_utils.get_object_ref(self.tenant, 'tenant'), "cloud_ref": self.common_utils.get_object_ref(self.cloud, 'cloud'), "static_routes": [] }, ] data['VrfContext'] = vrf_context return data