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 __create_network_wan(self, job_input): # Get JOB Input Parameters iaas_region_id = job_input['IaaS_region_id'] iaas_tenant_id = job_input['IaaS_tenant_id'] operation_id = job_input['operation_id'] tenant_name = job_input['tenant_name'] nal_tenant_id = job_input['nal_tenant_id'] nal_tenant_name = job_input['nal_tenant_name'] pod_id = job_input['pod_id'] dc_id = job_input['dc_id'] dc_name = job_input['dc_name'] dc_vlan_id = job_input.get('dc_vlan_id', None) # Get Endpoint(OpenStack:VIM) os_endpoint_vim = self.get_os_endpoint_vim(pod_id, '', nal_tenant_id, dc_id) # Create Instance(OpenStack Client) osc_networks = networks.OscQuantumNetworks(self.job_config) vim_iaas_with_flg = self.get_vim_iaas_with_flg(job_input) if vim_iaas_with_flg == 0: physical_network_name = None else: physical_network_name = self.get_os_physical_network_name() # Create Network(OpenStack:VIM) network_name_vim = dc_name + nal_tenant_name os_network_res = osc_networks.create_network(os_endpoint_vim, network_name_vim, True, False, dc_vlan_id, physical_network_name) wan_network_id = os_network_res['network']['id'] wan_segmentation_id \ = os_network_res['network']['provider:segmentation_id'] # Create NAL_VIRTUAL_LAN_MNG(DB Client) params = {} params['create_id'] = operation_id params['update_id'] = operation_id params['delete_flg'] = 0 params['tenant_name'] = tenant_name params['pod_id'] = pod_id params['tenant_id'] = nal_tenant_id params['IaaS_region_id'] = iaas_region_id params['IaaS_tenant_id'] = iaas_tenant_id params['IaaS_network_id'] = '' params['IaaS_network_type'] = '' params['IaaS_segmentation_id'] = '' params['vlan_id'] = wan_segmentation_id params['network_id'] = wan_network_id params['rule_id'] = '' params['nal_vlan_info'] = json.dumps(os_network_res['network']) return params
def get_os_network_info(self, pod_id, tenant_id, vlan_type, ip_version='', dc_id='system'): network_name = self.get_os_vlan_name(vlan_type, dc_id) if len(ip_version) == 0: ip_version = self.utils.IP_VER_V4 # Get Endpoint(OpenStack:VIM) os_endpoint = self.get_os_endpoint_vim(pod_id, '', tenant_id, dc_id) # Create Instance (OpenStack Client) osc_networks = networks.OscQuantumNetworks(self.job_config) osc_subnets = subnets.OscQuantumSubnets(self.job_config) # List Networks (OpenStack Client) result = osc_networks.list_networks(os_endpoint) for rec in result['networks']: if rec['name'] == network_name: network_id = rec['id'] subnet_list = rec['subnets'] vlan_id = rec['provider:segmentation_id'] network_type = rec['provider:network_type'] break network_info = {} subnet_info = {} for subnet_id in subnet_list: # Get Subnet (OpenStack Client) subnets_res = osc_subnets.get_subnet(os_endpoint, subnet_id) if str(subnets_res['subnet']['ip_version']) == ip_version: # get first record subnet_info = subnets_res['subnet'] break if len(subnet_info) > 0: array = subnet_info['cidr'].split('/') network_info = { 'network_name': network_name, 'network_id': network_id, 'subnet_id': subnet_info['id'], 'cidr': subnet_info['cidr'], 'network_address': array[0], 'subnet_mask': array[1], 'vlan_id': vlan_id, 'network_type': network_type } return network_info
def __delete_network_wan(self, job_input): # Get JOB Input Parameters wan_lan_list = job_input['wan_lan_list'] nal_tenant_id = job_input['nal_tenant_id'] pod_id = job_input['pod_id'] dc_id = job_input['dc_id'] operation_id = job_input['operation_id'] job_cleaning_mode = job_input.get('job_cleaning_mode', '0') logical_delete_vlan_list = [] if len(wan_lan_list) > 0: # Get Endpoint(OpenStack:VIM) os_endpoint_vim = self.get_os_endpoint_vim(pod_id, '', nal_tenant_id, dc_id) # Create Instance(OpenStack Client) osc_networks = networks.OscQuantumNetworks(self.job_config) # Delete Network(OpenStack:VIM) wan_network_id = wan_lan_list[0]['network_id'] try: osc_networks.delete_network(os_endpoint_vim, wan_network_id) except: if job_cleaning_mode == '1': self.output_log_fatal(__name__, traceback.format_exc()) else: raise logical_delete_vlan_list.append({ 'search': { 'delete_flg': 0, 'tenant_id': nal_tenant_id, 'network_id': wan_network_id, }, 'params': { 'update_id': operation_id, 'delete_flg': 1, } }) return logical_delete_vlan_list
def __assign_msa_network(self, tenant_name, pod_id, nal_tenant_id, operation_id, job_input): IaaS_tenant_id = job_input['IaaS_tenant_id'] vim_iaas_with_flg = self.get_vim_iaas_with_flg(job_input) # Get Endpoint(DB Client) db_endpoint_msa_vlan = self.get_db_endpoint( self.job_config.REST_URI_MSA_VLAN) # Get Endpoint(OpenStack:VIM) os_endpoint_vim = self.get_os_endpoint_vim(pod_id, '', nal_tenant_id) # Create Instance(OpenStack Client) osc_networks = networks.OscQuantumNetworks(self.job_config) os_subnets_instance = subnets.OscQuantumSubnets(self.job_config) os_ports_instance = ports.OscQuantumPorts(self.job_config) # Create Instance(DB Client) db_list = list.ListClient(self.job_config) db_update = update.UpdateClient(self.job_config) # List NAL_MSA_VLAN_MNG(DB Client) params = {} params['delete_flg'] = 0 params['status'] = 0 db_list.set_context(db_endpoint_msa_vlan, params) db_list.execute() msa_vlan_list = db_list.get_return_param() msa_network_info = {} if len(msa_vlan_list) != 0: rec = msa_vlan_list[0] # Update NAL_MSA_VLAN_MNG(DB Client) keys = [rec['ID']] params = {} params['update_id'] = operation_id params['pod_id'] = pod_id params['tenant_name'] = tenant_name params['status'] = 1 params['tenant_id'] = nal_tenant_id db_update.set_context(db_endpoint_msa_vlan, keys, params) db_update.execute() cidr = rec['network_address'] + '/' + rec['netmask'] if vim_iaas_with_flg == 0: # Create Network(OpenStack:VIM) network_name = 'MSA_for_' + nal_tenant_id physical_network_name = None else: # Create Network(OpenStack:VIM) network_name = 'MSA_for_' + IaaS_tenant_id physical_network_name = self.get_os_physical_network_name() os_cre_network_vim = osc_networks.create_network( os_endpoint_vim, network_name, True, False, rec['vlan_id'], physical_network_name) network_info = os_cre_network_vim['network'] network_id = network_info['id'] # Get Network Data(id) ret = self.utils.get_network_range_from_cidr(cidr) gatewy_ip = \ socket.inet_ntoa(struct.pack('!L', ret['network'] + 1)) os_cre_subnet_vim = os_subnets_instance.create_subnet( os_endpoint_vim, network_id, cidr, '', nal_tenant_id, '4', gatewy_ip) subnet_info = os_cre_subnet_vim['subnet'] subnet_id = subnet_info['id'] # Create Port(OpenStack:VIM) os_cre_port_vim = os_ports_instance.create_port( os_endpoint_vim, network_id) # Get Port Info port_info = os_cre_port_vim['port'] port_id = port_info['id'] ip_address = port_info['fixed_ips'][0]['ip_address'] # MSA setup self.__setup_msa_network_vlan(pod_id, rec['vlan_id'], ip_address, rec['netmask']) # Update NAL_MSA_VLAN_MNG(DB Client) keys = [rec['ID']] params = {} params['update_id'] = operation_id params['msa_ip_address'] = ip_address params['network_id'] = network_id params['subnet_id'] = subnet_id params['port_id'] = port_id params['network_info'] = json.dumps(network_info) params['subnet_info'] = json.dumps(subnet_info) params['port_info'] = json.dumps(port_info) db_update.set_context(db_endpoint_msa_vlan, keys, params) db_update.execute() # List NAL_MSA_VLAN_MNG(DB Client) params = {} params['delete_flg'] = 0 params['pod_id'] = pod_id params['tenant_name'] = tenant_name db_list.set_context(db_endpoint_msa_vlan, params) db_list.execute() msa_network_info = db_list.get_return_param() else: raise SystemError('vlan for MSA not Found.') return msa_network_info
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 __delete_vlan(self, job_input, target_network_list): # Get JOB Input Parameters nal_tenant_id = job_input['data']['nal_tenant_id'] operation_id = job_input['data']['operation_id'] pod_id = job_input['data']['pod_id'] dc_id = job_input['data'].get('dc_id', 'system') job_cleaning_mode = job_input['data'].get('job_cleaning_mode', '0') # Get MSA Info(network_id) msa_network_id = job_input['data']['msa_network_id'] # Get Network Info pub_network_info = self.get_os_network_info( pod_id, nal_tenant_id, self.job_config.NW_NAME_PUB, '', dc_id) ext_network_info = self.get_os_network_info( pod_id, nal_tenant_id, self.job_config.NW_NAME_EXT, '', dc_id) network_id_list = [ msa_network_id, pub_network_info['network_id'], ext_network_info['network_id'] ] if job_input['data']['group_type'] in [ str(self.job_config.GROUP_TYPE_CSRV_TUNNEL_ESP), str(self.job_config.GROUP_TYPE_CSRV_TUNNEL_AH), ]: idc_network_info = self.get_os_network_info( pod_id, nal_tenant_id, self.job_config.NW_NAME_IDC, '', dc_id) network_id_list.append(idc_network_info['network_id']) # Get Endpoint(OpenStack:VIM) os_endpoint_vim = self.get_os_endpoint_vim(pod_id, '', nal_tenant_id, dc_id) # Get Endpoint(DB Client) db_endpoint_vlan = self.get_db_endpoint(self.job_config.REST_URI_VLAN) db_endpoint_port = self.get_db_endpoint(self.job_config.REST_URI_PORT) # Create Instance(OpenStack Client) osc_networks = networks.OscQuantumNetworks(self.job_config) # Create Instance(VXLAN-GW) vxlangw_instance = vxlangw.VxlanGwClient(self.job_config) # Create Instance(DB Client) db_list_instance = list.ListClient(self.job_config) db_update_instance = update.UpdateClient(self.job_config) # List NAL_VIRTUAL_LAN_MNG(DB) params = {} params['delete_flg'] = 0 params['pod_id'] = pod_id params['nal_tenant_id'] = nal_tenant_id db_list_instance.set_context(db_endpoint_vlan, params) db_list_instance.execute() vlan_list = db_list_instance.get_return_param() for vlan_res in vlan_list: vlan_rec_id = vlan_res['ID'] vlan_network_id = vlan_res['network_id'] iaas_network_type = vlan_res['IaaS_network_type'] rule_id = vlan_res['rule_id'] if vlan_network_id in network_id_list: continue if vlan_network_id not in target_network_list: continue # List NAL_PORT_MNG(DB) params = {} params['delete_flg'] = 0 params['pod_id'] = pod_id params['nal_tenant_id'] = nal_tenant_id params['network_id'] = vlan_network_id db_list_instance.set_context(db_endpoint_port, params) db_list_instance.execute() port_list = db_list_instance.get_return_param() if len(port_list) == 0: try: # Delete Network(OpenStack:VIM) osc_networks.delete_network(os_endpoint_vim, vlan_network_id) except: if job_cleaning_mode == '1': self.output_log_fatal(__name__, traceback.format_exc()) else: raise # Delete VXLAN-GW Rule if iaas_network_type.upper() == self.job_config.NW_TYPE_VXLAN: params = [rule_id, self.job_config.PROV_TIMEOUT] try: vxlangw_instance.delete_vxlan_gw(params) except: if job_cleaning_mode == '1': self.output_log_fatal(__name__, traceback.format_exc()) else: raise # Update NAL_VIRTUAL_LAN_MNG(DB) params = {} params['update_id'] = operation_id params['delete_flg'] = 1 keys = [vlan_rec_id] db_update_instance.set_context(db_endpoint_vlan, keys, params) db_update_instance.execute()
def __create_vlan(self, job_input): # Get JOB Input Parameters iaas_region_id = job_input['IaaS_region_id'] iaas_tenant_id = job_input['IaaS_tenant_id'] iaas_network_id = job_input['IaaS_network_id'] iaas_network_type = job_input['IaaS_network_type'] iaas_segmentation_id = job_input['IaaS_segmentation_id'] network_name = job_input['network_name'] operation_id = job_input['operation_id'] tenant_name = job_input['tenant_name'] nal_tenant_id = job_input['nal_tenant_id'] pod_id = job_input['pod_id'] dc_id = job_input['dc_id'] # Get Endpoint(OpenStack:VIM) os_endpoint_vim = self.get_os_endpoint_vim(pod_id, '', nal_tenant_id, dc_id) # Get Endpoint(DB Client) db_endpoint_vlan = self.get_db_endpoint(self.job_config.REST_URI_VLAN) # Create Instance(OpenStack Client) osc_networks = networks.OscQuantumNetworks(self.job_config) # Create Instance(VXLAN-GW) vxlangw_pod_instance = routingpod.RoutingPod() vxlangw_instance = vxlangw.VxlanGwClient(self.job_config) # Create Instance(DB Client) db_create_instance = create.CreateClient(self.job_config) vxlangw_pod_id = '' rule_id = '' os_cre_network_vim = {} if iaas_network_type.upper() == self.job_config.NW_TYPE_VXLAN: vxlangw_endpoint = self.get_os_endpoint_vxlangw(iaas_region_id) # Create Network(OpenStack:VIM) os_cre_network_vim = osc_networks.create_network( os_endpoint_vim, network_name) vxlangw_pod_id = vxlangw_pod_instance.\ routing_vxlangw_pod(job_input) params = [ vxlangw_endpoint['endpoint'], vxlangw_endpoint['user_id'], vxlangw_endpoint['user_password'], os_cre_network_vim['network']['provider:segmentation_id'], vxlangw_pod_id, iaas_network_id, vxlangw_endpoint['timeout'], ] vxlan_gw_res = vxlangw_instance.create_vxlan_gw(params) pattern = re.compile('\|\s+id\s+\|\s+(.*)\s+\|') for vxlan_gw in vxlan_gw_res: matchOB = pattern.match(vxlan_gw) if matchOB: rule_id = matchOB.group(1) break elif iaas_network_type.upper() == self.job_config.NW_TYPE_VLAN: vim_iaas_with_flg = self.get_vim_iaas_with_flg(job_input) if vim_iaas_with_flg == 0: physical_network_name = None else: physical_network_name = self.get_os_physical_network_name() # Create Network(OpenStack:VIM) os_cre_network_vim = osc_networks.create_network( os_endpoint_vim, network_name, True, False, iaas_segmentation_id, physical_network_name) # Get Network Data(id) network_id = os_cre_network_vim['network']['id'] vlan_id = os_cre_network_vim['network']['provider:segmentation_id'] # Create NAL_VIRTUAL_LAN_MNG(DB Client) params = {} params['create_id'] = operation_id params['update_id'] = operation_id params['delete_flg'] = 0 params['tenant_name'] = tenant_name params['pod_id'] = pod_id params['tenant_id'] = nal_tenant_id params['IaaS_region_id'] = iaas_region_id params['IaaS_tenant_id'] = iaas_tenant_id params['IaaS_network_id'] = iaas_network_id params['IaaS_network_type'] = iaas_network_type params['IaaS_segmentation_id'] = iaas_segmentation_id params['vlan_id'] = vlan_id params['network_id'] = network_id params['rule_id'] = rule_id params['nal_vlan_info'] = json.dumps(os_cre_network_vim['network']) db_create_instance.set_context(db_endpoint_vlan, params) db_create_instance.execute() return {'network_id': network_id, 'vlan_id': vlan_id}
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)