def test(): global vm # Create VM vm = test_stub.create_vm() vm.check() # Create Virtual BMC test_stub.create_vbmc(vm = vm, port = 6230) # Create Chassis chassis = os.environ.get('ipminame') test_stub.create_chassis(chassis_name = chassis) test_stub.hack_ks(port = 6230) chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid bare_operations.power_off_baremetal(chassis_uuid) status = bare_operations.get_power_status(chassis_uuid) if status.status == "Chassis Power is off": bare_operations.power_reset_baremetal(chassis_uuid) status = bare_operations.get_power_status(chassis_uuid) if status.status != "Chassis Power is on": test_util.test_fail('Failed to power reset chassis') else: test_util.test_fail('Failed to power off chassis') test_stub.delete_vbmc(vm = vm) bare_operations.delete_chassis(chassis_uuid) vm.destroy() test_util.test_pass('Test Power Reset Success')
def test(): global vm pxe_uuid = test_lib.lib_get_pxe_by_name(os.environ.get('pxename')).uuid # Create VM vm = test_stub.create_vm() vm.check() # Stop PXE bare_operations.stop_pxe(pxe_uuid) if test_lib.lib_get_pxe_by_name(os.environ.get('pxename')).status != "Stopped": test_util.test_fail('Fail to stop PXE') # Start PXE bare_operations.start_pxe(pxe_uuid) if test_lib.lib_get_pxe_by_name(os.environ.get('pxename')).status != "Running": test_util.test_fail('Fail to start PXE') # Create Virtual BMC test_stub.create_vbmc(vm = vm, port = 6230) # Create Chassis chassis = os.environ.get('ipminame') test_stub.create_chassis(chassis_name = chassis) test_stub.hack_ks(port = 6230) chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid # First time Provision bare_operations.provision_baremetal(chassis_uuid) hwinfo = test_stub.check_hwinfo(chassis_uuid) if not hwinfo: test_util.test_fail('Fail to get hardware info during the first provision') test_stub.delete_vbmc(vm = vm) bare_operations.delete_chassis(chassis_uuid) vm.destroy() test_util.test_pass('Start/Stop PXE Test Success')
def test(): global vm pxe_uuid = test_lib.lib_get_pxe_by_name(os.environ.get('pxename')).uuid # Create VM vm = test_stub.create_vm() vm.check() # Stop PXE bare_operations.stop_pxe(pxe_uuid) if test_lib.lib_get_pxe_by_name( os.environ.get('pxename')).status != "Stopped": test_util.test_fail('Fail to stop PXE') # Start PXE bare_operations.start_pxe(pxe_uuid) if test_lib.lib_get_pxe_by_name( os.environ.get('pxename')).status != "Running": test_util.test_fail('Fail to start PXE') # Create Virtual BMC test_stub.create_vbmc(vm=vm, port=6230) # Create Chassis chassis = os.environ.get('ipminame') test_stub.create_chassis(chassis_name=chassis) test_stub.hack_ks(port=6230) chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid # First time Provision bare_operations.provision_baremetal(chassis_uuid) hwinfo = test_stub.check_hwinfo(chassis_uuid) if not hwinfo: test_util.test_fail( 'Fail to get hardware info during the first provision') test_stub.delete_vbmc(vm=vm) bare_operations.delete_chassis(chassis_uuid) vm.destroy() test_util.test_pass('Start/Stop PXE Test Success')
def test(): global vm pxe_uuid = test_lib.lib_get_pxe_by_name(os.environ.get('pxename')).uuid # Create VM vm = test_stub.create_vm() vm.check() # Create Virtual BMC test_stub.create_vbmc(vm=vm, port=6230) # Create Chassis chassis = os.environ.get('ipminame') test_stub.create_chassis(chassis_name=chassis) test_stub.hack_ks(port=6230) chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid # First time Provision bare_operations.provision_baremetal(chassis_uuid) bare_operations.stop_pxe(pxe_uuid) if not test_stub.verify_chassis_status(chassis_uuid, "PxeBootFailed"): test_util.test_fail( 'Chassis failed to get PxeBootFailed after the first provision') bare_operations.start_pxe(pxe_uuid) if test_lib.lib_get_pxe_by_name(os.environ.get('pxename')).status != "Running": test_util.test_fail('Fail to start PXE') test_stub.delete_vbmc(vm=vm) bare_operations.delete_chassis(chassis_uuid) vm.destroy() test_util.test_pass('Create chassis Test Success')
def test(): global vm # Create VM vm = test_stub.create_vm() vm.check() # Create Virtual BMC test_stub.create_vbmc(vm=vm, port=6230) # Create Chassis chassis = os.environ.get('ipminame') test_stub.create_chassis(chassis_name=chassis) test_stub.hack_ks(port=6230) chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid bare_operations.power_off_baremetal(chassis_uuid) status = bare_operations.get_power_status(chassis_uuid) if status.status == "Chassis Power is off": bare_operations.power_reset_baremetal(chassis_uuid) status = bare_operations.get_power_status(chassis_uuid) if status.status != "Chassis Power is on": test_util.test_fail('Failed to power reset chassis') else: test_util.test_fail('Failed to power off chassis') test_stub.delete_vbmc(vm=vm) bare_operations.delete_chassis(chassis_uuid) vm.destroy() test_util.test_pass('Test Power Reset Success')
def test(): global vm # Create VM vm = test_stub.create_vm() vm.check() # Create Virtual BMC test_stub.create_vbmc(vm = vm, port = 6230) # Create Chassis chassis = os.environ.get('ipminame') test_stub.create_chassis(chassis_name = chassis) # Update Chassis chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid ipmiaddress = os.environ.get('ipmiaddress') ipmiuser = os.environ.get('ipmiusername') ipmipasswd = os.environ.get('ipmipassword') test_stub.delete_vbmc(vm = vm) test_stub.create_vbmc(vm = vm, port = 6231) bare_operations.update_chassis(chassis_uuid=chassis_uuid, address=ipmiaddress, username=ipmiuser, password=ipmipasswd, port=6231) test_stub.hack_ks(port = 6231) # First time Provision bare_operations.provision_baremetal(chassis_uuid) hwinfo = test_stub.check_hwinfo(chassis_uuid) if not hwinfo: test_util.test_fail('Fail to get hardware info during the first provision') new_port = test_lib.lib_get_chassis_by_name(chassis).ipmiPort if new_port != "6231": test_util.test_fail("Update Chassis's Port failed: port=%s" % new_port) test_stub.delete_vbmc(vm = vm) bare_operations.delete_chassis(chassis_uuid) vm.destroy() test_util.test_pass('Update Chassis Test Success')
def error_cleanup(): global vm if vm: test_stub.delete_vbmc(vm=vm) chassis = os.environ.get('ipminame') chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid bare_operations.delete_chassis(chassis_uuid) vm.destroy()
def error_cleanup(): global vm if vm: test_stub.delete_vbmc(vm = vm) chassis = os.environ.get('ipminame') chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid bare_operations.delete_chassis(chassis_uuid) vm.destroy()
def error_cleanup(): global vm1 global vm2 if vm1 or vm2: test_stub.delete_vbmc(vm = vm1) test_stub.delete_vbmc(vm = vm2) chassis1 = os.environ.get('ipminame') chassis2 = os.environ.get('ipminame2') chassis_uuid1 = test_lib.lib_get_chassis_by_name(chassis1).uuid chassis_uuid2 = test_lib.lib_get_chassis_by_name(chassis2).uuid bare_operations.delete_chassis(chassis_uuid1) bare_operations.delete_chassis(chassis_uuid2) vm1.destroy()
def error_cleanup(): global vm1 global vm2 if vm1 or vm2: test_stub.delete_vbmc(vm=vm1) test_stub.delete_vbmc(vm=vm2) chassis1 = os.environ.get('ipminame') chassis2 = os.environ.get('ipminame2') chassis_uuid1 = test_lib.lib_get_chassis_by_name(chassis1).uuid chassis_uuid2 = test_lib.lib_get_chassis_by_name(chassis2).uuid bare_operations.delete_chassis(chassis_uuid1) bare_operations.delete_chassis(chassis_uuid2) vm1.destroy()
def error_cleanup(): global vm, baremetal_cluster_uuid, pxe_uuid, host_ip if vm: test_stub.delete_vbmc(vm, host_ip) chassis = os.environ.get('ipminame') chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid baremetal_operations.delete_chassis(chassis_uuid) vm.destroy() if host_ip: test_stub.delete_vbmc(vm, host_ip) if baremetal_cluster_uuid: cluster_ops.delete_cluster(baremetal_cluster_uuid) if pxe_uuid: baremetal_ops.delete_pxe(pxe_uuid)
def test(): global vm # Create VM vm = test_stub.create_vm() vm.check() # Create Virtual BMC test_stub.create_vbmc(vm=vm, port=6230) # Create Chassis chassis = os.environ.get('ipminame') test_stub.create_chassis(chassis_name=chassis) test_stub.hack_ks(port=6230) chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid # First time Provision bare_operations.provision_baremetal(chassis_uuid) hwinfo = test_stub.check_hwinfo(chassis_uuid) if not hwinfo: test_util.test_fail( 'Fail to get hardware info during the first provision') #Generate cfgItems cfgItems, pxe_mac = test_stub.generate_cfgItems(chassis_uuid=chassis_uuid, nic_num=1, nic_flag=True, bond_num=2, slave_num=1, mode=4) host_cfg = test_stub.create_hostcfg(chassis_uuid=chassis_uuid, unattended=True, password="******", cfgItems=cfgItems) test_stub.hack_ks(port=6230, ks_file=str(pxe_mac.replace(':', '-'))) # Second time Provision to install system bare_operations.provision_baremetal(chassis_uuid) if not test_stub.verify_chassis_status(chassis_uuid, "Rebooting"): test_util.test_fail( 'Chassis failed to Rebooting after the second provision') if not test_stub.verify_chassis_status(chassis_uuid, "Provisioning"): test_util.test_fail( 'Chassis failed to Provisioning after the second provision') if not test_stub.verify_chassis_status(chassis_uuid, "Provisioned"): test_util.test_fail( 'Chassis failed to Provisioned after the second provision') vm.stop() vm.start() test_stub.delete_vbmc(vm=vm) bare_operations.delete_chassis(chassis_uuid) vm.destroy() test_util.test_pass('Create PXE Test Success')
def test(): global vm # Create VM vm = test_stub.create_vm() vm.check() # Create Virtual BMC test_stub.create_vbmc(vm = vm, port = 6230) # Create Chassis chassis = os.environ.get('ipminame') test_stub.create_chassis(chassis_name = chassis) test_stub.hack_ks(port = 6230) chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid # First time Provision bare_operations.provision_baremetal(chassis_uuid) hwinfo = test_stub.check_hwinfo(chassis_uuid) if not hwinfo: test_util.test_fail('Fail to get hardware info during the first provision') test_stub.delete_vbmc(vm = vm) bare_operations.delete_chassis(chassis_uuid) vm.destroy() test_util.test_pass('Create chassis Test Success')
def test(): global vm # Create VM vm = test_stub.create_vm() vm.check() # Create Virtual BMC test_stub.create_vbmc(vm=vm, port=6230) # Create Chassis chassis = os.environ.get('ipminame') test_stub.create_chassis(chassis_name=chassis) test_stub.hack_ks(port=6230) chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid # First time Provision bare_operations.provision_baremetal(chassis_uuid) hwinfo = test_stub.check_hwinfo(chassis_uuid) if not hwinfo: test_util.test_fail( 'Fail to get hardware info during the first provision') test_stub.delete_vbmc(vm=vm) bare_operations.delete_chassis(chassis_uuid) vm.destroy() test_util.test_pass('Create chassis Test Success')
def test(): global vm # Create VM vm = test_stub.create_vm() vm.check() # Create Virtual BMC test_stub.create_vbmc(vm = vm, port = 6230) # Create Chassis chassis = os.environ.get('ipminame') test_stub.create_chassis(chassis_name = chassis) test_stub.hack_ks(port = 6230) chassis_uuid = test_lib.lib_get_chassis_by_name(chassis).uuid # First time Provision bare_operations.provision_baremetal(chassis_uuid) hwinfo = test_stub.check_hwinfo(chassis_uuid) if not hwinfo: test_util.test_fail('Fail to get hardware info during the first provision') #Generate cfgItems cfgItems, pxe_mac = test_stub.generate_cfgItems(chassis_uuid=chassis_uuid, nic_num=1, nic_flag=True, bond_num=2, slave_num=1, mode=4) host_cfg = test_stub.create_hostcfg(chassis_uuid=chassis_uuid, unattended=True, password="******", cfgItems=cfgItems) test_stub.hack_ks(port = 6230, ks_file = str(pxe_mac.replace(':','-'))) # Second time Provision to install system bare_operations.provision_baremetal(chassis_uuid) if not test_stub.verify_chassis_status(chassis_uuid, "Rebooting"): test_util.test_fail('Chassis failed to Rebooting after the second provision') if not test_stub.verify_chassis_status(chassis_uuid, "Provisioning"): test_util.test_fail('Chassis failed to Provisioning after the second provision') if not test_stub.verify_chassis_status(chassis_uuid, "Provisioned"): test_util.test_fail('Chassis failed to Provisioned after the second provision') vm.stop() vm.start() test_stub.delete_vbmc(vm = vm) bare_operations.delete_chassis(chassis_uuid) vm.destroy() test_util.test_pass('Create PXE Test Success')
def test(): global vm, baremetal_cluster_uuid, pxe_uuid, host_ip test_util.test_dsc('Create baremetal cluster and attach network') zone_uuid = res_ops.query_resource(res_ops.ZONE)[0].uuid cond = res_ops.gen_query_conditions('type', '=', 'baremetal') cluster = res_ops.query_resource(res_ops.CLUSTER, cond) if not cluster: baremetal_cluster_uuid = test_stub.create_cluster(zone_uuid).uuid else: baremetal_cluster_uuid = cluster[0].uuid cond = res_ops.gen_query_conditions('name', '=', os.environ.get('l3NoVlanNetworkName1')) l3_network = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0] cidr = l3_network.ipRanges[0].networkCidr cond = res_ops.gen_query_conditions('l3Network.uuid', '=', l3_network.uuid) l2_uuid = res_ops.query_resource(res_ops.L2_NETWORK, cond)[0].uuid sys_tags = "l2NetworkUuid::%s::clusterUuid::%s::cidr::{%s}" %(l2_uuid, baremetal_cluster_uuid, cidr) net_ops.attach_l2(l2_uuid, baremetal_cluster_uuid, [sys_tags]) test_util.test_dsc('Create pxe server') pxe_servers = res_ops.query_resource(res_ops.PXE_SERVER) [pxe_ip, interface] = test_stub.get_pxe_info() if not pxe_servers: pxe_uuid = test_stub.create_pxe(dhcp_interface = interface, hostname = pxe_ip, zoneUuid = zone_uuid).uuid baremetal_operations.attach_pxe_to_cluster(pxe_uuid, baremetal_cluster_uuid) test_util.test_dsc('Create a vm to simulate baremetal host') #mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName #cond = res_ops.gen_query_conditions('managementIp', '=', mn_ip) #host = res_ops.query_resource(res_ops.HOST, cond)[0] host = res_ops.query_resource(res_ops.HOST)[0] host_uuid = host.uuid host_ip = host.managementIp cond = res_ops.gen_query_conditions('hypervisorType', '=', 'KVM') cluster_uuid = res_ops.query_resource(res_ops.CLUSTER, cond)[0].uuid vm = test_stub.create_vm(host_uuid = host_uuid, cluster_uuid = cluster_uuid) test_util.test_dsc('Create chassis') test_stub.create_vbmc(vm, host_ip, 623) chassis = test_stub.create_chassis(baremetal_cluster_uuid, address = host_ip) chassis_uuid = chassis.uuid #Hack inspect ks file to support vbmc, include ipmi device logic and ipmi addr to 127.0.0.1 test_stub.hack_inspect_ks(pxe_ip, host_ip) test_util.test_dsc('Inspect chassis, Because vbmc have bugs, \ reset vm unable to enable boot options, power off/on then reset is worked') baremetal_operations.inspect_chassis(chassis_uuid) baremetal_operations.power_off_baremetal(chassis_uuid) time.sleep(3) status = baremetal_operations.get_power_status(chassis_uuid).status if status != "Chassis Power is off": test_util.test_fail('Fail to power off chassis %s, current status is %s' %(chassis_uuid, status)) baremetal_operations.power_on_baremetal(chassis_uuid) time.sleep(3) status = baremetal_operations.get_power_status(chassis_uuid).status if status != "Chassis Power is on": test_util.test_fail('Fail to power on chassis %s, current status is %s' %(chassis_uuid, status)) test_util.test_dsc('Disable/Enable chassis and check') cond = res_ops.gen_query_conditions('uuid','=', chassis_uuid) baremetal_operations.change_baremetal_chassis_state(chassis_uuid, 'disable') state = res_ops.query_resource(res_ops.CHASSIS, cond)[0].state if state != 'Disabled': test_util.test_fail('Disable chassis %s failed, current state is %s' %(chassis_uuid, state)) baremetal_operations.change_baremetal_chassis_state(chassis_uuid, 'enable') state = res_ops.query_resource(res_ops.CHASSIS, cond)[0].state if state != 'Enabled': test_util.test_fail('Enable chassis %s failed, current state is %s' %(chassis_uuid, state)) test_util.test_dsc('Inspect chassis and check hardware info') baremetal_operations.inspect_chassis(chassis_uuid) hwinfo = test_stub.check_hwinfo(chassis_uuid) if not hwinfo: test_util.test_fail('Fail to get hardware info during the first inspection') baremetal_operations.power_reset_baremetal(chassis_uuid) time.sleep(30) test_util.test_dsc('Clear env') test_stub.delete_vbmc(vm, host_ip) baremetal_operations.delete_chassis(chassis_uuid) vm.destroy() baremetal_operations.delete_pxe(pxe_uuid) cluster_ops.delete_cluster(baremetal_cluster_uuid) test_util.test_pass('Create chassis Test Success')
def test(): global vm, baremetal_cluster_uuid, pxe_uuid, host_ip test_util.test_dsc('Create baremetal cluster and attach network') zone_uuid = res_ops.query_resource(res_ops.ZONE)[0].uuid cond = res_ops.gen_query_conditions('type', '=', 'baremetal') origin_bm_clusters = res_ops.query_resource(res_ops.CLUSTER, cond) if origin_bm_clusters != []: for i in range(len(origin_bm_clusters)): cluster_ops.delete_cluster(origin_bm_clusters[i].uuid) baremetal_cluster_uuid = test_stub.create_cluster(zone_uuid).uuid cond = res_ops.gen_query_conditions('name', '=', os.environ.get('l3NoVlanNetworkName1')) l3_network = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0] cidr = l3_network.ipRanges[0].networkCidr cond = res_ops.gen_query_conditions('l3Network.uuid', '=', l3_network.uuid) l2_uuid = res_ops.query_resource(res_ops.L2_NETWORK, cond)[0].uuid sys_tags = "l2NetworkUuid::%s::clusterUuid::%s::cidr::{%s}" %(l2_uuid, baremetal_cluster_uuid, cidr) net_ops.attach_l2(l2_uuid, baremetal_cluster_uuid, [sys_tags]) test_util.test_dsc('Create pxe server') pxe_servers = res_ops.query_resource(res_ops.PXE_SERVER) [pxe_ip, interface] = test_stub.get_pxe_info() if not pxe_servers: pxe_uuid = test_stub.create_pxe(dhcp_interface = interface, hostname = pxe_ip, zoneUuid = zone_uuid).uuid baremetal_operations.attach_pxe_to_cluster(pxe_uuid, baremetal_cluster_uuid) else: pxe_uuid = pxe_servers[0].uuid test_util.test_dsc('Create a vm to simulate baremetal host') #mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName #cond = res_ops.gen_query_conditions('managementIp', '=', mn_ip) host = res_ops.query_resource(res_ops.HOST)[0] host_uuid = host.uuid host_ip = host.managementIp cond = res_ops.gen_query_conditions('hypervisorType', '=', 'KVM') cluster_uuid = res_ops.query_resource(res_ops.CLUSTER, cond)[0].uuid vm = test_stub.create_vm(host_uuid = host_uuid, cluster_uuid = cluster_uuid) test_util.test_dsc('Create chassis') test_stub.create_vbmc(vm, host_ip, 623) chassis = test_stub.create_chassis(baremetal_cluster_uuid, address = host_ip) chassis_uuid = chassis.uuid #Hack inspect ks file to support vbmc, include ipmi device logic and ipmi addr to 127.0.0.1 test_stub.hack_inspect_ks(pxe_ip, host_ip) test_util.test_dsc('Inspect chassis, Because vbmc have bugs, \ reset vm unable to enable boot options, power off/on then reset is worked') baremetal_operations.inspect_chassis(chassis_uuid) baremetal_operations.power_off_baremetal(chassis_uuid) time.sleep(10) baremetal_operations.power_on_baremetal(chassis_uuid) time.sleep(30) baremetal_operations.inspect_chassis(chassis_uuid) hwinfo = test_stub.check_hwinfo(chassis_uuid) if not hwinfo: test_util.test_fail('Fail to get hardware info during the first inspection') test_util.test_dsc('Create baremetal instance') #Hack iso ks file to support unattended installation test_stub.hack_generic_ks(pxe_ip) #test_stub.ca_pem_workaround(host_ip) cond = res_ops.gen_query_conditions('name', '=', os.environ.get('imageName_iso')) image_uuid = res_ops.query_resource(res_ops.IMAGE, cond)[0].uuid time.sleep(30) baremetal_ins = test_stub.create_baremetal_ins(image_uuid, chassis_uuid) baremetal_ins_uuid = baremetal_ins.uuid ins_status = test_stub.check_baremetal_ins(baremetal_ins_uuid, 'password', \ baremetal_ins.managementIp, host_ip, chassis_uuid, os.environ.get('ipmiaddress')) if not ins_status: test_util.test_fail('Baremetal instance installation failed') test_util.test_dsc('Check baremetal instance operations') cond = res_ops.gen_query_conditions('uuid', '=', baremetal_ins_uuid) new_name = 'New Baremetal Instance' baremetal_operations.update_baremetal_instance(baremetal_ins_uuid, name = new_name) udated_name = res_ops.query_resource(res_ops.BAREMETAL_INS, cond)[0].name if udated_name != new_name: test_util.test_fail('Update baremetal instance name failed, expected: %s, real: %s'%(new_name, udated_name)) baremetal_operations.stop_baremetal_instance(baremetal_ins_uuid) state = res_ops.query_resource(res_ops.BAREMETAL_INS, cond)[0].state if state != 'Stopped': test_util.test_fail('Fail to stop baremetal instance, current status: %s'%state) baremetal_operations.start_baremetal_instance(baremetal_ins_uuid) time.sleep(60) state = res_ops.query_resource(res_ops.BAREMETAL_INS, cond)[0].state if state != 'Running' and state != 'Starting': test_util.test_fail('Fail to start baremetal instance, current status: %s'%state) baremetal_operations.reboot_baremetal_instance(baremetal_ins_uuid) #test_util.test_dsc('Clear env') baremetal_operations.destory_baremetal_instance(baremetal_ins_uuid) baremetal_operations.expunge_baremetal_instance(baremetal_ins_uuid) test_stub.delete_vbmc(vm, host_ip) baremetal_operations.delete_chassis(chassis_uuid) vm.destroy() baremetal_operations.delete_pxe(pxe_uuid) cluster_ops.delete_cluster(baremetal_cluster_uuid) test_util.test_pass('Create chassis Test Success')