def test_0000_setup(self): """Setup the gateway required for the other tests in this module. Create a gateway as per the configuration stated above. This test passes if the gateway is created successfully. """ TestGateway._client = Environment.get_sys_admin_client() TestGateway._vdc = Environment.get_test_vdc(TestGateway._client) TestGateway._org_client = Environment.get_client_in_default_org( CommonRoles.ORGANIZATION_ADMINISTRATOR) TestGateway._config = Environment.get_config() TestGateway._gateway = Environment.get_test_gateway( TestGateway._client) if TestGateway._gateway is not None: task = TestGateway._vdc.delete_gateway(self._name) result = TestGateway._client.get_task_monitor().wait_for_success( task=task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) external_network = Environment.get_test_external_network( TestGateway._client) ext_net_resource = external_network.get_resource() ip_scopes = ext_net_resource.xpath( 'vcloud:Configuration/vcloud:IpScopes/vcloud:IpScope', namespaces=NSMAP) first_ipscope = ip_scopes[0] gateway_ip = first_ipscope.Gateway.text prefix_len = netmask_to_cidr_prefix_len(gateway_ip, first_ipscope.Netmask.text) subnet_addr = gateway_ip + '/' + str(prefix_len) ext_net_to_participated_subnet_with_ip_settings = { ext_net_resource.get('name'): { subnet_addr: 'Auto' } } gateway_ip_arr = gateway_ip.split('.') last_ip_digit = int(gateway_ip_arr[-1]) + 1 gateway_ip_arr[-1] = str(last_ip_digit) next_ip = '.'.join(gateway_ip_arr) ext_net_to_subnet_with_ip_range = { ext_net_resource.get('name'): { subnet_addr: [next_ip + '-' + next_ip] } } ext_net_to_rate_limit = {ext_net_resource.get('name'): {100: 100}} TestGateway._gateway = TestGateway._vdc.create_gateway( self._name, [ext_net_resource.get('name')], 'compact', None, True, ext_net_resource.get('name'), gateway_ip, True, False, False, False, True, ext_net_to_participated_subnet_with_ip_settings, True, ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit) result = TestGateway._client.get_task_monitor().wait_for_success( task=TestGateway._gateway.Tasks.Task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
def test_0000_setup(self): """Setup the gateway required for the other tests in this module. Create a gateway as per the configuration stated above. This test passes if the gateway is created successfully. """ TestGateway._client = Environment.get_sys_admin_client() TestGateway._vdc = Environment.get_test_vdc(TestGateway._client) TestGateway._org_client = Environment.get_client_in_default_org( CommonRoles.ORGANIZATION_ADMINISTRATOR) TestGateway._config = Environment.get_config() TestGateway._api_version = TestGateway._config['vcd']['api_version'] external_network = Environment.get_test_external_network( TestGateway._client) ext_net_resource = external_network.get_resource() ip_scopes = ext_net_resource.xpath( 'vcloud:Configuration/vcloud:IpScopes/vcloud:IpScope', namespaces=NSMAP) first_ipscope = ip_scopes[0] gateway_ip = first_ipscope.Gateway.text prefix_len = netmask_to_cidr_prefix_len(gateway_ip, first_ipscope.Netmask.text) subnet_addr = gateway_ip + '/' + str(prefix_len) ext_net_to_participated_subnet_with_ip_settings = { ext_net_resource.get('name'): { subnet_addr: self._ip_address_for_config_ip_setting } } ext_net_to_subnet_with_ip_range = { ext_net_resource.get('name'): { subnet_addr: [self._ip_address_for_ip_range] } } ext_net_to_rate_limit = {ext_net_resource.get('name'): {100: 100}} if float(TestGateway._api_version) <= float( ApiVersion.VERSION_30.value): TestGateway._gateway = \ TestGateway._vdc.create_gateway_api_version_30( self._name, [ext_net_resource.get('name')], 'compact', None, True, ext_net_resource.get('name'), gateway_ip, True, False, False, False, True, ext_net_to_participated_subnet_with_ip_settings, True, ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit) elif float(TestGateway._api_version) == float( ApiVersion.VERSION_31.value): TestGateway._gateway = \ TestGateway._vdc.create_gateway_api_version_31( self._name, [ext_net_resource.get('name')], 'compact', None, True, ext_net_resource.get('name'), gateway_ip, True, False, False, False, True, ext_net_to_participated_subnet_with_ip_settings, True, ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit) elif float(TestGateway._api_version) >= float( ApiVersion.VERSION_32.value): TestGateway._gateway = \ TestGateway._vdc.create_gateway_api_version_32( self._name, [ext_net_resource.get('name')], 'compact', None, True, ext_net_resource.get('name'), gateway_ip, True, False, False, False, True, ext_net_to_participated_subnet_with_ip_settings, True, ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit) result = TestGateway._client.get_task_monitor().wait_for_success( task=TestGateway._gateway.Tasks.Task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) TestGateway._extension = Extension(TestGateway._client) TestGateway._extension.get_resource() link = find_link(TestGateway._extension.resource, RelationType.DOWN, EntityType.SYSTEM_SETTINGS.value) settings = TestGateway._client.get_resource(link.href) syslog_server_settings = settings.GeneralSettings.SyslogServerSettings if hasattr(syslog_server_settings, '{' + NSMAP['vcloud'] + '}SyslogServerIp1'): return syslog_server_settings.append( E.SyslogServerIp1(TestGateway._syslog_server_ip1)) TestGateway._client.put_resource(link.href, settings, EntityType.SYSTEM_SETTINGS.value) TestGateway._extension.reload() settings = TestGateway._client.get_resource(link.href) self.assertTrue( hasattr(syslog_server_settings, '{' + NSMAP['vcloud'] + '}SyslogServerIp1'))
def test_0000_setup(self): """Setup the gateway required for the other tests in this module. Create a gateway as per the configuration stated above. This test passes if the gateway is created successfully. """ TestGateway._client = Environment.get_sys_admin_client() TestGateway._vdc = Environment.get_test_vdc(TestGateway._client) TestGateway._org_client = Environment.get_client_in_default_org( CommonRoles.ORGANIZATION_ADMINISTRATOR) TestGateway._config = Environment.get_config() TestGateway._api_version = TestGateway._config['vcd']['api_version'] external_network = Environment.get_test_external_network( TestGateway._client) ext_net_resource = external_network.get_resource() ip_scopes = ext_net_resource.xpath( 'vcloud:Configuration/vcloud:IpScopes/vcloud:IpScope', namespaces=NSMAP) first_ipscope = ip_scopes[0] gateway_ip = first_ipscope.Gateway.text prefix_len = netmask_to_cidr_prefix_len(gateway_ip, first_ipscope.Netmask.text) subnet_addr = gateway_ip + '/' + str(prefix_len) ext_net_to_participated_subnet_with_ip_settings = { ext_net_resource.get('name'): { subnet_addr: 'Auto' } } gateway_ip_arr = gateway_ip.split('.') last_ip_digit = int(gateway_ip_arr[-1]) + 1 gateway_ip_arr[-1] = str(last_ip_digit) next_ip = '.'.join(gateway_ip_arr) ext_net_to_subnet_with_ip_range = { ext_net_resource.get('name'): { subnet_addr: [next_ip + '-' + next_ip] } } ext_net_to_rate_limit = {ext_net_resource.get('name'): {100: 100}} if float(TestGateway._api_version) <= float( ApiVersion.VERSION_30.value): TestGateway._gateway = \ TestGateway._vdc.create_gateway_api_version_30( self._name, [ext_net_resource.get('name')], 'compact', None, True, ext_net_resource.get('name'), gateway_ip, True, False, False, False, True, ext_net_to_participated_subnet_with_ip_settings, True, ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit) elif float(TestGateway._api_version) == float( ApiVersion.VERSION_31.value): TestGateway._gateway = \ TestGateway._vdc.create_gateway_api_version_31( self._name, [ext_net_resource.get('name')], 'compact', None, True, ext_net_resource.get('name'), gateway_ip, True, False, False, False, True, ext_net_to_participated_subnet_with_ip_settings, True, ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit) elif float(TestGateway._api_version) >= float( ApiVersion.VERSION_32.value): TestGateway._gateway = \ TestGateway._vdc.create_gateway_api_version_32( self._name, [ext_net_resource.get('name')], 'compact', None, True, ext_net_resource.get('name'), gateway_ip, True, False, False, False, True, ext_net_to_participated_subnet_with_ip_settings, True, ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit) result = TestGateway._client.get_task_monitor().wait_for_success( task=TestGateway._gateway.Tasks.Task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) TestGateway._extension = Extension(TestGateway._client) TestGateway._extension.get_resource() link = find_link(TestGateway._extension.resource, RelationType.DOWN, EntityType.SYSTEM_SETTINGS.value) settings = TestGateway._client.get_resource(link.href) syslog_server_settings = settings.GeneralSettings.SyslogServerSettings if hasattr(syslog_server_settings, '{' + NSMAP['vcloud'] + '}SyslogServerIp1'): return syslog_server_settings.append( E.SyslogServerIp1(TestGateway._syslog_server_ip1)) TestGateway._client.put_resource(link.href, settings, EntityType.SYSTEM_SETTINGS.value) TestGateway._extension.reload() settings = TestGateway._client.get_resource(link.href) self.assertTrue( hasattr(syslog_server_settings, '{' + NSMAP['vcloud'] + '}SyslogServerIp1'))