def test_keystone_endpoint_not_found(self): endpoint = self.ENDPOINT_URL admin_user_name = 'admin' admin_password = '******' tenant_id = self.ADMIN_TENANT_ID job_config = config.JobConfig() # Create Token token = tokens.OscTokens(job_config)\ .create_token(admin_user_name, admin_password, endpoint) # Get Endpoints endpoint_array = tokens.OscTokens(job_config).get_endpoints( endpoint, token, admin_user_name, admin_password, tenant_id) endpoint_array['region_id'] = 'regionNotfound' # Create Server try: tenants.OscTenants(job_config)\ .create_tenant(endpoint_array, 'tenant_name_new1') except SystemError as e: if e.args[0] != tenants.OscTenants.EXCEPT_MSG08: raise
def test_quantum_endpoint_not_found(self): endpoint = self.ENDPOINT_URL tenant_id = self.ADMIN_TENANT_ID admin_user_name = 'admin' admin_password = '******' nw_name = 'nw_ksp' job_config = config.JobConfig() token = tokens.OscTokens(job_config).create_token( admin_user_name, admin_password, endpoint) endpoint_array = tokens.OscTokens(job_config).get_endpoints( endpoint, token, admin_user_name, admin_password, tenant_id) endpoint_array['region_id'] = 'regionNotfound' nw_name_new = nw_name \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') # Create Network try: networks.OscQuantumNetworks(job_config)\ .create_network(endpoint_array, nw_name_new) except SystemError as e: if e.args[0] != networks.OscQuantumNetworks.EXCEPT_MSG08: raise
def test_tokens_create_token_validation_error(self): endpoint = self.ENDPOINT_URL admin_user_name = 'admin' admin_password = '******' job_config = config.JobConfig() try: tokens.OscTokens(job_config)\ .create_token('', admin_password, endpoint) except SystemError as e: if e.args[0] != tokens.OscTokens.EXCEPT_MSG01: raise try: tokens.OscTokens(job_config)\ .create_token(admin_user_name, '', endpoint) except SystemError as e: if e.args[0] != tokens.OscTokens.EXCEPT_MSG01: raise try: tokens.OscTokens(job_config)\ .create_token(admin_user_name, admin_password, '') except SystemError as e: if e.args[0] != tokens.OscTokens.EXCEPT_MSG01: raise
def test_glance_endpoint_not_found(self): endpoint = self.ENDPOINT_URL tenant_id = self.ADMIN_TENANT_ID admin_user_name = 'admin' admin_password = '******' job_config = config.JobConfig() # Create Token token = tokens.OscTokens(job_config)\ .create_token(admin_user_name, admin_password, endpoint) # Assertion self.assertGreaterEqual(len(token), 1) # Get Endpoints endpoint_array = tokens.OscTokens(job_config).get_endpoints( endpoint, token, admin_user_name, admin_password, tenant_id) endpoint_array['region_id'] = 'regionNotfound' # Create Server try: images.OscGlanceImages(job_config).list_images(endpoint_array) except SystemError as e: if e.args[0] != images.OscGlanceImages.EXCEPT_MSG08: raise
def test_nova_endpoint_not_found(self): endpoint = self.ENDPOINT_URL tenant_id = self.ADMIN_TENANT_ID admin_user_name = 'admin' admin_password = '******' imageRef = '55f7012b-4c5b-4fb8-90c7-2e1e1205e128' flavorRef = '2' network_list = [ { 'uuid': '6141844163e191152455519bc83d2bda', 'port': 'b411cd48241a5d2bc11b02cac16e2f91', } ] job_config = config.JobConfig() token = tokens.OscTokens(job_config).create_token( admin_user_name, admin_password, endpoint) endpoint_array = tokens.OscTokens(job_config).get_endpoints( endpoint, token, admin_user_name, admin_password, tenant_id) endpoint_array['region_id'] = 'regionNotfound' # Create Server try: servers.OscServers(job_config).create_server(endpoint_array, 'sv_name_new', imageRef, flavorRef, network_list) except SystemError as e: if e.args[0] != servers.OscServers.EXCEPT_MSG08: raise
def test_tokens_get_endpoints_validation_error(self): endpoint = self.ENDPOINT_URL admin_user_name = 'admin' admin_password = '******' tenant_id = self.ADMIN_TENANT_ID token = 'aaa' job_config = config.JobConfig() try: tokens.OscTokens(job_config).get_endpoints('', token, admin_user_name, admin_password, tenant_id) except SystemError as e: if e.args[0] != tokens.OscTokens.EXCEPT_MSG01: raise try: tokens.OscTokens(job_config).get_endpoints(endpoint, '', admin_user_name, admin_password, tenant_id) except SystemError as e: if e.args[0] != tokens.OscTokens.EXCEPT_MSG01: raise try: tokens.OscTokens(job_config).get_endpoints(endpoint, token, '', admin_password, tenant_id) except SystemError as e: if e.args[0] != tokens.OscTokens.EXCEPT_MSG01: raise try: tokens.OscTokens(job_config).get_endpoints(endpoint, token, admin_user_name, '', tenant_id) except SystemError as e: if e.args[0] != tokens.OscTokens.EXCEPT_MSG01: raise try: tokens.OscTokens(job_config).get_endpoints(endpoint, token, admin_user_name, admin_password, '') except SystemError as e: if e.args[0] != tokens.OscTokens.EXCEPT_MSG01: raise
def test_glance(self): endpoint = self.ENDPOINT_URL tenant_id = self.ADMIN_TENANT_ID admin_user_name = 'admin' admin_password = '******' job_config = config.JobConfig() # Create Token token = tokens.OscTokens(job_config)\ .create_token(admin_user_name, admin_password, endpoint) print('create_token') print(token) # Assertion self.assertGreaterEqual(len(token), 1) # Get Endpoints endpoint_array = tokens.OscTokens(job_config).get_endpoints( endpoint, token, admin_user_name, admin_password, tenant_id) print('get_endpoints') print(json.dumps(endpoint_array)) endpoint_array['region_id'] = self.REGION_ID # Assertion self.assertGreaterEqual(len(endpoint_array), 1) # List Images res = images.OscGlanceImages(job_config).list_images(endpoint_array) print('list_images') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1)
def get_os_endpoint_iaas(self, region_id, tenant_name='', tenant_id='', dc_id='system'): osc_tokens = tokens.OscTokens(self.job_config) user_name = \ self.nal_endpoint_config[dc_id]['iaas'][region_id]['user_id'] user_pass = \ self.nal_endpoint_config[dc_id]['iaas'][region_id]['user_password'] endpoint_url = \ self.nal_endpoint_config[dc_id]['iaas'][region_id]['endpoint'] token = osc_tokens.create_token(user_name, user_pass, endpoint_url) endpoint_array = osc_tokens.get_endpoints( endpoint_url, token, user_name, user_pass, tenant_id) endpoint_array['region_id'] = region_id return endpoint_array
def get_os_endpoint_vim(self, pod_id, tenant_name='', tenant_id='', dc_id='system'): osc_tokens = tokens.OscTokens(self.job_config) user_name = \ self.nal_endpoint_config[dc_id]['vim'][pod_id]['user_id'] user_pass = \ self.nal_endpoint_config[dc_id]['vim'][pod_id]['user_password'] endpoint_url = \ self.nal_endpoint_config[dc_id]['vim'][pod_id]['endpoint'] region_id = \ self.nal_endpoint_config[dc_id]['vim'][pod_id]['region_id'] token = osc_tokens.create_token(user_name, user_pass, endpoint_url) endpoint_array = osc_tokens.get_endpoints( endpoint_url, token, user_name, user_pass, tenant_id) if dc_id != 'system': endpoint_array['wim_fig'] = True endpoint_array['region_id'] = region_id return endpoint_array
def test_quantum(self): endpoint = self.ENDPOINT_URL tenant_id = self.ADMIN_TENANT_ID admin_user_name = 'admin' admin_password = '******' nw_name = 'nw_ksp' subnet_name = 'subnet_ksp' port_name = 'port_ksp' cidr_ipv4 = '10.0.0.0/24' cidr_ipv6 = '2001:db8::/48' fixed_ips_ip_address_ipv4 = '10.0.0.1' fixed_ips_ip_address_ipv6 = '2001:DB8::10' port_id_list = [] job_config = config.JobConfig() token = tokens.OscTokens(job_config).create_token( admin_user_name, admin_password, endpoint) print('create_token') print(token) endpoint_array = tokens.OscTokens(job_config).get_endpoints( endpoint, token, admin_user_name, admin_password, tenant_id) print('get_endpoints') print(json.dumps(endpoint_array)) endpoint_array['region_id'] = self.REGION_ID # Create Network nw_name_new = nw_name \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = networks.OscQuantumNetworks(job_config)\ .create_network(endpoint_array, nw_name_new, True, False, None, None ) print('create_network') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Get Network nw_id_new = res['network']['id'] res = networks.OscQuantumNetworks(job_config)\ .get_network(endpoint_array, nw_id_new) print('get_network') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # List Networks res = networks.OscQuantumNetworks(job_config)\ .list_networks(endpoint_array) print('list_networks') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Create Subnet subnet_name_new = subnet_name \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = subnets.OscQuantumSubnets(job_config)\ .create_subnet( endpoint_array, nw_id_new, cidr_ipv4, subnet_name_new, tenant_id, '4', fixed_ips_ip_address_ipv4) print('create_subnet') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Get Subnet subnet_id_new_ipv4 = res['subnet']['id'] res = subnets.OscQuantumSubnets(job_config)\ .get_subnet(endpoint_array, subnet_id_new_ipv4) print('get_subnet') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Create Subnet subnet_name_new = subnet_name \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = subnets.OscQuantumSubnets(job_config)\ .create_subnet( endpoint_array, nw_id_new, cidr_ipv6, subnet_name_new, '', '6') print('create_subnet') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) subnet_id_new_ipv6 = res['subnet']['id'] # List Subnets res = subnets.OscQuantumSubnets(job_config)\ .list_subnets(endpoint_array) print('list_subnets') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Create Port port_name_new = port_name + '-1-' \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = ports.OscQuantumPorts(job_config)\ .create_port(endpoint_array, nw_id_new, port_name_new, True ) print('create_port') print(json.dumps(res)) port_id_list.append(res['port']['id']) # Assertion self.assertGreaterEqual(len(res), 1) # Get Port res = ports.OscQuantumPorts(job_config)\ .get_port(endpoint_array, port_id_list[0]) print('get_port') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Create Port port_name_new = port_name + '-2-' \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = ports.OscQuantumPorts(job_config)\ .create_port(endpoint_array, nw_id_new, port_name_new, True, subnet_id_new_ipv4 ) print('create_port') print(json.dumps(res)) port_id_list.append(res['port']['id']) # Create Port port_name_new = port_name + '-3-' \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = ports.OscQuantumPorts(job_config)\ .create_port(endpoint_array, nw_id_new, port_name_new, True, subnet_id_new_ipv6 ) print('create_port') print(json.dumps(res)) port_id_list.append(res['port']['id']) # Create Port port_name_new = port_name + '-4-' \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = ports.OscQuantumPorts(job_config)\ .create_port(endpoint_array, nw_id_new, port_name_new, True, '', '10.0.0.10' ) print('create_port') print(json.dumps(res)) port_id_list.append(res['port']['id']) # Assertion self.assertGreaterEqual(len(res), 1) # List Ports res = ports.OscQuantumPorts(job_config).list_ports(endpoint_array) print('list_ports') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) for port_id in port_id_list: # Detach Port res = ports.OscQuantumPorts(job_config)\ .detach_port_device(endpoint_array, port_id) print('detach_port_device') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Delete Port res = ports.OscQuantumPorts(job_config)\ .delete_port(endpoint_array, port_id) print('delete_port') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Create Port(Dual Stack) fixed_ips = [{ 'subnet_id': subnet_id_new_ipv4, 'ip_address': fixed_ips_ip_address_ipv4, }, { 'subnet_id': subnet_id_new_ipv6, 'ip_address': fixed_ips_ip_address_ipv6, }] port_name_new = port_name \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = ports.OscQuantumPorts(job_config)\ .create_port_dual_stack( endpoint_array, nw_id_new, port_name_new, True, fixed_ips) print('create_port_dual_stack') print(json.dumps(res)) port_id_new = res['port']['id'] # Get Port res = ports.OscQuantumPorts(job_config)\ .get_port(endpoint_array, port_id_new) print('get_port(create_port_dual_stack)') print(json.dumps(res)) # Update Port fixed_ips = [ { 'subnet_id': subnet_id_new_ipv4, 'ip_address': fixed_ips_ip_address_ipv4, }, { 'subnet_id': subnet_id_new_ipv6, 'ip_address': fixed_ips_ip_address_ipv6, }, ] res = ports.OscQuantumPorts(job_config)\ .update_port(endpoint_array, port_id_new, port_name_new + 'upd', False, fixed_ips) print('update_port') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Get Port res = ports.OscQuantumPorts(job_config)\ .get_port(endpoint_array, port_id_new) print('get_port(update_port)') print(json.dumps(res)) # Delete Port res = ports.OscQuantumPorts(job_config)\ .delete_port(endpoint_array, port_id_new) print('delete_port') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # List Ports res = ports.OscQuantumPorts(job_config).list_ports(endpoint_array) print('list_ports') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Delete Subnet res = subnets.OscQuantumSubnets(job_config)\ .delete_subnet(endpoint_array, subnet_id_new_ipv4) print('delete_subnet') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) res = subnets.OscQuantumSubnets(job_config)\ .delete_subnet(endpoint_array, subnet_id_new_ipv6) print('delete_subnet') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Delete Network res = networks.OscQuantumNetworks(job_config)\ .delete_network(endpoint_array, nw_id_new) print('delete_network') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0)
def test_keystone(self): endpoint = self.ENDPOINT_URL admin_user_name = 'admin' admin_password = '******' tenant_name = 'test_tenant' tenant_id = self.ADMIN_TENANT_ID user_name = 'test_user' user_password = '******' role_id = self.ADMIN_ROLE_ID job_config = config.JobConfig() # Create Token token = tokens.OscTokens(job_config)\ .create_token(admin_user_name, admin_password, endpoint, tokens.OscTokens.DOMAIN_NAME_DEFAULT) print('create_token') print(token) # Assertion self.assertGreaterEqual(len(token), 1) # Get Endpoints endpoint_array = tokens.OscTokens(job_config).get_endpoints( endpoint, token, admin_user_name, admin_password, tenant_id, tokens.OscTokens.DOMAIN_NAME_DEFAULT) print('get_endpoints') print(json.dumps(endpoint_array)) # Assertion self.assertGreaterEqual(len(endpoint_array), 1) # Create Token token = tokens.OscTokens(job_config)\ .create_token(admin_user_name, admin_password, endpoint) print('create_token') print(token) # Assertion self.assertGreaterEqual(len(token), 1) # Get Endpoints endpoint_array = tokens.OscTokens(job_config).get_endpoints( endpoint, token, admin_user_name, admin_password, tenant_id) print('get_endpoints') print(json.dumps(endpoint_array)) # Assertion self.assertGreaterEqual(len(endpoint_array), 1) endpoint_array['region_id'] = self.REGION_ID # Create Tenant tenant_name_new1 = tenant_name + '1-' + datetime.datetime.today( ).strftime('%Y%m%d%H%M%S') res = tenants.OscTenants(job_config)\ .create_tenant(endpoint_array, tenant_name_new1) print('create_tenant') print(json.dumps(res)) tenant_id_new1 = res['project']['id'] # Assertion self.assertGreaterEqual(len(res), 1) tenant_name_new2 = tenant_name + '2-' + datetime.datetime.today( ).strftime('%Y%m%d%H%M%S') res = tenants.OscTenants(job_config)\ .create_tenant(endpoint_array, tenant_name_new2, 'test KeystoneV3', False, tenants.OscTenants.DOMAIN_ID_DEFAULT, False) print('create_tenant') print(json.dumps(res)) tenant_id_new2 = res['project']['id'] # Assertion self.assertGreaterEqual(len(res), 1) # Get Tenant res = tenants.OscTenants(job_config)\ .get_tenant(endpoint_array, tenant_id_new1) print('get_tenant') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Update Tenant res = tenants.OscTenants(job_config).update_tenant( endpoint_array, tenant_id_new1, tenant_name_new1 + 'upd') print('update_tenant') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) res = tenants.OscTenants(job_config).update_tenant( endpoint_array, tenant_id_new2, tenant_name_new2 + 'upd', 'update', True, tenants.OscTenants.DOMAIN_ID_DEFAULT, False) print('update_tenant') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # List Tenants res = tenants.OscTenants(job_config).list_tenants(endpoint_array) print('list_tenants') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Create User user_name_new1 = user_name + '1-' + datetime.datetime.today().strftime( '%Y%m%d%H%M%S') res = users.OscUsers(job_config).create_user(endpoint_array, user_name_new1, user_password, tenant_id_new1) print('create_user') print(json.dumps(res)) user_id_new1 = res['user']['id'] # Assertion self.assertGreaterEqual(len(res), 1) # Create User user_name_new2 = user_name + '2-' + datetime.datetime.today().strftime( '%Y%m%d%H%M%S') res = users.OscUsers(job_config).create_user( endpoint_array, user_name_new2, user_password, tenant_id_new2, '*****@*****.**', True, users.OscUsers.DOMAIN_ID_DEFAULT) print('create_user') print(json.dumps(res)) user_id_new2 = res['user']['id'] # Assertion self.assertGreaterEqual(len(res), 1) # Get User res = users.OscUsers(job_config).get_user(endpoint_array, user_id_new1) print('get_user') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Get User res = users.OscUsers(job_config).get_user(endpoint_array, user_id_new2) print('get_user') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # List Role For User res = roles.OscRoles(job_config)\ .list_roles_for_user(endpoint_array, user_id_new1, tenant_id_new1) print('list_roles_for_user') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Update User res = users.OscUsers(job_config).update_user(endpoint_array, user_id_new1, None, user_name_new1 + 'upd') print('update_user') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Update User res = users.OscUsers(job_config).update_user( endpoint_array, user_id_new2, tenant_id, user_name_new2 + 'upd', '*****@*****.**', 'pass-update', False, users.OscUsers.DOMAIN_ID_DEFAULT) print('update_user') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Get User res = users.OscUsers(job_config).get_user(endpoint_array, user_id_new1) print('get_user') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Get User res = users.OscUsers(job_config).get_user(endpoint_array, user_id_new2) print('get_user') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # List Users res = users.OscUsers(job_config).list_users(endpoint_array) print('list_users') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # List Role res = roles.OscRoles(job_config).list_roles(endpoint_array) print('list_roles') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Add Role To User res = roles.OscRoles(job_config).add_role_to_user( endpoint_array, user_id_new1, tenant_id_new1, role_id) print('add_role_to_user') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # List Role For User res = roles.OscRoles(job_config)\ .list_roles_for_user(endpoint_array, user_id_new1, tenant_id_new1) print('list_roles_for_user') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Remove Role From User res = roles.OscRoles(job_config).remove_role_from_user( endpoint_array, user_id_new1, tenant_id_new1, role_id) print('remove_role_from_user') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # List Role For User res = roles.OscRoles(job_config)\ .list_roles_for_user(endpoint_array, user_id_new1, tenant_id_new1) print('list_roles_for_user') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Delete User res = users.OscUsers(job_config)\ .delete_user(endpoint_array, user_id_new1) print('delete_user') print(json.dumps(res)) # Delete User res = users.OscUsers(job_config)\ .delete_user(endpoint_array, user_id_new2) print('delete_user') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # List Users res = users.OscUsers(job_config).list_users( endpoint_array, users.OscUsers.DOMAIN_ID_DEFAULT) print('list_users') print(json.dumps(res)) # Delete Tenant res = tenants.OscTenants(job_config)\ .delete_tenant(endpoint_array, tenant_id_new1) print('delete_tenant') print(json.dumps(res)) res = tenants.OscTenants(job_config)\ .delete_tenant(endpoint_array, tenant_id_new2) print('delete_tenant') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0)
def test_nova(self): import random mac_address = [] for i in range(6): mac_address.append('%02x' % random.choice(range(1, 256))) print(':'.join(mac_address)) endpoint = self.ENDPOINT_URL tenant_id = self.ADMIN_TENANT_ID admin_user_name = 'admin' admin_password = '******' sv_name = 'sv_ksp' nw_name = 'nw_ksp' subnet_name = 'subnet_ksp' port_name = 'port_ksp' cidr = '0.0.0.0/27' imageRef = self.IMAGE_ID flavorRef = '1' network_list = [ { 'uuid': '', 'port': '', } ] job_config = config.JobConfig() token = tokens.OscTokens(job_config).create_token( admin_user_name, admin_password, endpoint) print('create_token') print(token) endpoint_array = tokens.OscTokens(job_config).get_endpoints( endpoint, token, admin_user_name, admin_password, tenant_id) print('get_endpoints') print(json.dumps(endpoint_array)) endpoint_array['region_id'] = self.REGION_ID # Create Network nw_name_new = nw_name \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = networks.OscQuantumNetworks(job_config)\ .create_network(endpoint_array, nw_name_new) print('create_network') print(json.dumps(res)) # Create Subnet nw_id_new = res['network']['id'] subnet_name_new = subnet_name \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = subnets.OscQuantumSubnets(job_config)\ .create_subnet(endpoint_array, nw_id_new, cidr, subnet_name_new) print('create_subnet') print(json.dumps(res)) # Create Port subnet_id_new = res['subnet']['id'] port_name_new = port_name \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') res = ports.OscQuantumPorts(job_config)\ .create_port(endpoint_array, nw_id_new, port_name_new) port_id_new = res['port']['id'] print('create_port') print(json.dumps(res)) # List Server res = servers.OscServers(job_config)\ .list_servers(endpoint_array) print('list_servers') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # List Flavors res = flavors.OscNovaFlavors(job_config)\ .list_flavors(endpoint_array) print('list_flavors') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Create Server sv_name_new = sv_name \ + datetime.datetime.today().strftime('%Y%m%d%H%M%S') network_list[0]['uuid'] = nw_id_new network_list[0]['port'] = port_id_new res = servers.OscServers(job_config).create_server( endpoint_array, sv_name_new, imageRef, flavorRef, network_list) print('create_server') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) time.sleep(self.WAIT_TIME_CREATE_SERVER) # Get Server server_id_new = res['server']['id'] res = servers.OscServers(job_config)\ .get_server(endpoint_array, server_id_new) print('get_server') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Action Server(Resume) actionkey = servers.OscServers(job_config).SERVER_ACTION_RESUME res = servers.OscServers(job_config)\ .action_server(endpoint_array, server_id_new, actionkey) print('action_server(resume)') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Action Server(Reset Network) actionkey = servers.OscServers(job_config).SERVER_ACTION_RESETNETWORK res = servers.OscServers(job_config)\ .action_server(endpoint_array, server_id_new, actionkey) print('action_server(reset network)') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Action Server(Suspend) actionkey = servers.OscServers(job_config).SERVER_ACTION_SUSPEND res = servers.OscServers(job_config)\ .action_server(endpoint_array, server_id_new, actionkey) print('action_server(suspend)') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Action Server(Reboot) actionkey = servers.OscServers(job_config).SERVER_ACTION_REBOOT boottype = servers.OscServers(job_config).SERVER_REBOOT_TYPE_SOFT res = servers.OscServers(job_config).action_server( endpoint_array, server_id_new, actionkey, boottype) print('action_server(reboot)') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Action Server(Resize) actionkey = servers.OscServers(job_config).SERVER_ACTION_RESIZE res = servers.OscServers(job_config)\ .action_server(endpoint_array, server_id_new, None, '2') print('action_server(resize)') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Action Server(Confirm Resize) actionkey = servers.OscServers(job_config).SERVER_ACTION_CONFIRMRESIZE res = servers.OscServers(job_config)\ .action_server(endpoint_array, server_id_new, actionkey) print('action_server(confirm resize)') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Action Server(OS Start) actionkey = servers.OscServers(job_config).SERVER_ACTION_OS_START res = servers.OscServers(job_config)\ .action_server(endpoint_array, server_id_new, actionkey) print('action_server(os start)') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Action Server(OS Stop) actionkey = servers.OscServers(job_config).SERVER_ACTION_OS_STOP res = servers.OscServers(job_config)\ .action_server(endpoint_array, server_id_new, actionkey) print('action_server(os stop)') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Action Server(Get Console) actionkey = servers.OscServers(job_config).SERVER_ACTION_GETCONSOLE res = servers.OscServers(job_config).action_server( endpoint_array, server_id_new, actionkey, None, None, 'xvpvnc') print('action_server(get console)') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Action Server(Status Pause) actionkey = servers.OscServers(job_config).SERVER_STATUS_PAUSE res = servers.OscServers(job_config)\ .action_server(endpoint_array, server_id_new, actionkey) print('action_server(status pause)') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # Attach Interface res = servers.OscServers(job_config)\ .attach_interface(endpoint_array, server_id_new, port_id_new) print('attach_interface') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # List Interfaces res = servers.OscServers(job_config)\ .list_interfaces(endpoint_array, server_id_new) print('list_interfaces') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # List Flavors res = flavors.OscNovaFlavors(job_config).list_flavors(endpoint_array) print('list_flavors') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Detach Interface res = servers.OscServers(job_config)\ .detach_interface(endpoint_array, server_id_new, port_id_new) print('detach_interface') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0) # List Server res = servers.OscServers(job_config)\ .list_servers(endpoint_array) print('list_servers') print(json.dumps(res)) # Assertion self.assertGreaterEqual(len(res), 1) # Delete Port res = ports.OscQuantumPorts(job_config)\ .delete_port(endpoint_array, port_id_new) print('delete_port') print(json.dumps(res)) # Delete Subnet res = subnets.OscQuantumSubnets(job_config)\ .delete_subnet(endpoint_array, subnet_id_new) print('delete_subnet') print(json.dumps(res)) # Delete Network res = networks.OscQuantumNetworks(job_config)\ .delete_network(endpoint_array, nw_id_new) print('delete_network') print(json.dumps(res)) # Delete Server res = servers.OscServers(job_config)\ .delete_server(endpoint_array, server_id_new) print('delete_server') print(json.dumps(res)) # Assertion self.assertEqual(len(res), 0)