def test(): global vms, ts test_util.test_dsc('create VM with setting password') for root_password in root_password_list: test_util.test_dsc("root_password: \"%s\"" % (root_password)) for i in range(vm_num): vm_name = "VM%s" % (str(i)) t = threading.Thread(target=create_vm_wrapper, args=('c7-' + vm_name, "batch_test_image", root_password)) ts.append(t) t.start() for t in ts: t.join() for vm in vms: if not test_lib.lib_check_login_in_vm(vm.get_vm(), "root", root_password): test_util.test_fail("create vm with root password: %s failed", root_password) vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vm test_util.test_dsc('create VM with setting password') for root_password in root_password_list: test_util.test_dsc("root_password: \"%s\"" %(root_password)) vm = test_stub.create_vm(vm_name = 'u13-vm', image_name = "imageName_i_u13", root_password=root_password) backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') if not test_lib.lib_check_login_in_vm(vm.get_vm(), "root", root_password): test_util.test_fail("create vm with root password: %s failed", root_password) vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vm, test_account_uuid, test_account_session import uuid account_name = uuid.uuid1().get_hex() account_pass = uuid.uuid1().get_hex() account_pass = hashlib.sha512(account_name).hexdigest() test_account = acc_ops.create_normal_account(account_name, account_pass) test_account_uuid = test_account.uuid test_account_session = acc_ops.login_by_account(account_name, account_pass) test_stub.share_admin_resource([test_account_uuid]) vm = test_stub.create_vm(vm_name='c7-vm-no-sys-tag', image_name="imageName_i_c7_no_tag", session_uuid=test_account_session) vm.check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') for (usr, passwd) in zip(users, passwds): if usr not in exist_users: test_stub.create_user_in_vm(vm.get_vm(), usr, passwd) exist_users.append(usr) #When vm is running: #res_ops.enable_change_vm_password("true", vm.get_vm().uuid, 'VmInstanceVO', session_uuid = test_account_session) vm_ops.set_vm_qga_enable(vm.get_vm().uuid, session_uuid=test_account_session) vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm=None, session_uuid=test_account_session) if not test_lib.lib_check_login_in_vm(vm.get_vm(), usr, passwd): test_util.test_fail("create vm with user:%s password: %s failed", usr, passwd) vm_ops.change_vm_password(vm.get_vm().uuid, "root", test_stub.original_root_password, session_uuid=test_account_session) vm.check() vm.destroy(test_account_session) vm.check() vm.expunge(test_account_session) vm.check() acc_ops.delete_account(test_account_uuid) test_util.test_pass( 'enable and change vm password by normal user account Success')
def test(): global vms, ts test_util.test_dsc('create VM with setting password') for root_password in root_password_list: test_util.test_dsc("root_password: \"%s\"" %(root_password)) for i in range(vm_num): vm_name = "VM%s" %(str(i)) t = threading.Thread(target=create_vm_wrapper, args=('c7-'+vm_name, "batch_test_image", root_password)) ts.append(t) t.start() for t in ts: t.join() for vm in vms: if not test_lib.lib_check_login_in_vm(vm.get_vm(), "root", root_password): test_util.test_fail("create vm with root password: %s failed", root_password) vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vm test_util.test_dsc('create VM with setting password') for root_password in root_password_list: test_util.test_dsc("root_password: \"%s\"" % (root_password)) vm = test_stub.create_vm(vm_name='c7-vm-32', image_name="imageName_i_c7_32", root_password=root_password) backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') if not test_lib.lib_check_login_in_vm(vm.get_vm(), "root", root_password): test_util.test_fail("create vm with root password: %s failed", root_password) vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vm, exist_users test_util.test_dsc('Change unexisted user password test') vm = test_stub.create_vm(vm_name = 'cknewusrvmpswd-u13-64', image_name = "imageName_i_u13") vm.check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') for (usr,passwd) in zip(users, passwds): if usr not in exist_users: test_util.test_logger("un-existed user:%s change vm password" %(usr)) #if the user is not existed, it should report #try: # vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm = None, session_uuid = None) #except Exception,e: # test_util.test_logger("unexisted user change vm password exception is %s" %(str(e))) # normal_failed_string = "not exist" # if normal_failed_string in str(e): # test_util.test_logger("unexisted user return correct, create a the user for it.") #else: # test_util.test_fail("user not exist in this OS, it should not raise exception, but return a failure.") test_stub.create_user_in_vm(vm.get_vm(), usr, passwd) exist_users.append(usr) #When vm is running: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm = None, session_uuid = None) if not test_lib.lib_check_login_in_vm(vm.get_vm(), usr, passwd): test_util.test_fail("create vm with user:%s password: %s failed", usr, passwd) #When vm is stopped: #vm.stop() vm_ops.change_vm_password(vm.get_vm().uuid, "root", test_stub.original_root_password) #vm.start() vm.check() vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vm, exist_users, cur_usr, cur_passwd test_util.test_dsc('change VM with assigned password test') vm = test_stub.create_vm(vm_name='ckvmpswd-c6-32', image_name="imageName_i_c6_32") vm.check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') cur_usr = "******" cur_passwd = "password" for (usr, passwd) in zip(users, passwds): #When vm is running: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm=None, session_uuid=None) cur_usr = usr cur_passwd = passwd if not test_lib.lib_check_login_in_vm(vm.get_vm(), usr, passwd): test_util.test_fail("create vm with user:%s password: %s failed", usr, passwd) #When vm is stopped: #vm.stop() vm_ops.change_vm_password(vm.get_vm().uuid, "root", test_stub.original_root_password) cur_usr = "******" cur_passwd = "password" #vm.start() vm.check() vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vm, vm2, image_uuid test_util.test_dsc('create VM with setting password') for root_password in root_password_list: test_util.test_dsc("root_password: \"%s\"" %(root_password)) vm = test_stub.create_vm(vm_name = 'c7-vm-no-sys-tag', image_name = "imageName_i_c7_no_tag") backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') vm.check() #add tag to vm tag_ops.create_system_tag('VmInstanceVO', vm.get_vm().uuid, "qemuga") vm_ops.change_vm_password(vm.get_vm().uuid, "root", root_password) #create image by the vm with tag vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm()) root_volume_uuid = vm_root_volume_inv.uuid image_option1 = test_util.ImageOption() image_option1.set_root_volume_uuid(root_volume_uuid) image_option1.set_name('add_tag_vm_to_image') image_option1.set_format('qcow2') image_option1.set_backup_storage_uuid_list([bs.uuid]) vm.stop() image = img_ops.create_root_volume_template(image_option1) #create vm by new image vm2 = test_stub.create_vm(vm_name = 'c7-vm-add-tag-from-previous-vm', image_name = "add_tag_vm_to_image") if not test_lib.lib_check_login_in_vm(vm2.get_vm(), "root", root_password): test_util.test_fail("create vm with user:%s password: %s failed", "root", root_password) vm_ops.change_vm_password(vm2.get_vm().uuid, "root", root_password) image_uuid = image.uuid if not image_uuid: img_ops.delete_image(image_uuid) img_ops.expunge_image(image_uuid) test_util.test_pass('add system tag on a no system tag image test passed')
def test(): global vm, test_account_uuid, test_account_session, image_uuid import uuid account_name = uuid.uuid1().get_hex() account_pass = uuid.uuid1().get_hex() account_pass = hashlib.sha512(account_name).hexdigest() test_account = acc_ops.create_normal_account(account_name, account_pass) test_account_uuid = test_account.uuid test_account_session = acc_ops.login_by_account(account_name, account_pass) test_stub.share_admin_resource([test_account_uuid]) img_cond = res_ops.gen_query_conditions("name", '=', "centos7-installation-no-system-tag") img_inv = res_ops.query_resource_fields(res_ops.IMAGE, img_cond, None) image_uuid = img_inv[0].uuid #res_ops.enable_change_vm_password("true", image_uuid, 'ImageVO', session_uuid = test_account_session) img_ops.set_image_qga_enable(image_uuid, session_uuid = test_account_session) vm = test_stub.create_vm(vm_name = 'c7-vm-no-sys-tag', image_name = "imageName_i_c7_no_tag", session_uuid = test_account_session) vm.check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') for (usr,passwd) in zip(users, passwds): if usr not in exist_users: test_stub.create_user_in_vm(vm.get_vm(), usr, passwd) exist_users.append(usr) #When vm is running: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm = None, session_uuid = test_account_session) if not test_lib.lib_check_login_in_vm(vm.get_vm(), usr, passwd): test_util.test_fail("create vm with user:%s password: %s failed", usr, passwd) vm_ops.change_vm_password(vm.get_vm().uuid, "root", test_stub.original_root_password, session_uuid = test_account_session) vm.check() #res_ops.enable_change_vm_password("false", img_inv[0].uuid, 'ImageVO', session_uuid = test_account_session) img_ops.set_image_qga_disable(img_inv[0].uuid, session_uuid = test_account_session) vm.destroy(test_account_session) vm.check() vm.expunge(test_account_session) vm.check() acc_ops.delete_account(test_account_uuid) test_util.test_pass('enable and change vm password by normal user account Success')
def test(): global vms, ts, invs test_util.test_dsc('create VM with setting password') for (usr, passwd) in zip(users, passwds): test_util.test_dsc("user:%s; password:%s" % (usr, passwd)) vms = [] for i in range(vm_num): vms.append( test_stub.create_vm(vm_name='c7-vm' + str(i), image_name="batch_test_image")) time.sleep(30) for vm in vms: t = threading.Thread(target=change_vm_password_wrapper, args=(vm.get_vm().uuid, usr, passwd)) ts.append(t) t.start() for t in ts: t.join() for vm in vms: if not test_lib.lib_check_login_in_vm(vm.get_vm(), usr, passwd): test_util.test_fail( "create vm with user:%s password: %s failed", usr, passwd) ts = [] invs = [] #When vm is stopped: #for vm in vms: # vm.stop() for vm in vms: t = threading.Thread(target=change_vm_password_wrapper, args=(vm.get_vm().uuid, "root", "password")) ts.append(t) t.start() for t in ts: t.join() for vm in vms: #vm.start() vm.check() vm.destroy() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vm, exist_users, cur_usr, cur_passwd test_util.test_dsc('change VM with assigned password test') vm = test_stub.create_vm(vm_name = 'ckvmpswd-c7-64', image_name = "imageName_i_c7") vm.check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') cur_usr = "******" cur_passwd = "password" for (usr,passwd) in zip(users, passwds): #When vm is running: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm = None, session_uuid = None) cur_usr = usr cur_passwd = passwd if not test_lib.lib_check_login_in_vm(vm.get_vm(), usr, passwd): test_util.test_fail("create vm with user:%s password: %s failed", usr, passwd) #When vm is stopped: #vm.stop() vm_ops.change_vm_password(vm.get_vm().uuid, "root", test_stub.original_root_password) cur_usr = "******" cur_passwd = "password" #vm.start() vm.check() vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vms, ts, invs test_util.test_dsc('create VM with setting password') for (usr,passwd) in zip(users, passwds): test_util.test_dsc("user:%s; password:%s" %(usr, passwd)) vms = [] for i in range(vm_num): vms.append(test_stub.create_vm(vm_name = 'c7-vm'+str(i), image_name = "batch_test_image")) time.sleep(30) for vm in vms: t = threading.Thread(target=change_vm_password_wrapper, args=(vm.get_vm().uuid, usr, passwd)) ts.append(t) t.start() for t in ts: t.join() for vm in vms: if not test_lib.lib_check_login_in_vm(vm.get_vm(), usr, passwd): test_util.test_fail("create vm with user:%s password: %s failed", usr, passwd) ts = [] invs = [] #When vm is stopped: #for vm in vms: # vm.stop() for vm in vms: t = threading.Thread(target=change_vm_password_wrapper, args=(vm.get_vm().uuid, "root", "password")) ts.append(t) t.start() for t in ts: t.join() for vm in vms: #vm.start() vm.check() vm.destroy() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vm, test_account_uuid, test_account_session import uuid account_name = uuid.uuid1().get_hex() account_pass = uuid.uuid1().get_hex() account_pass = hashlib.sha512(account_name).hexdigest() test_account = acc_ops.create_normal_account(account_name, account_pass) test_account_uuid = test_account.uuid test_account_session = acc_ops.login_by_account(account_name, account_pass) test_stub.share_admin_resource([test_account_uuid]) vm = test_stub.create_vm(vm_name = 'c7-vm', image_name = "imageName_i_c7", session_uuid = test_account_session) vm.check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') for (usr,passwd) in zip(users, passwds): if usr not in exist_users: test_stub.create_user_in_vm(vm.get_vm(), usr, passwd) exist_users.append(usr) #When vm is running: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm = None, session_uuid = test_account_session) if not test_lib.lib_check_login_in_vm(vm.get_vm(), usr, passwd): test_util.test_fail("create vm with user:%s password: %s failed", usr, passwd) #When vm is stopped: #vm.stop(session_uuid = test_account_session) vm_ops.change_vm_password(vm.get_vm().uuid, "root", test_stub.original_root_password, session_uuid = test_account_session) #vm.start(session_uuid = test_account_session) vm.check() vm.destroy(test_account_session) vm.check() vm.expunge(test_account_session) vm.check() acc_ops.delete_account(test_account_uuid) test_util.test_pass('change vm password by normal user account Success')
def test(): global vm, exist_users test_util.test_dsc('cloned vm change password test') vm = test_stub.create_vm(vm_name = '1st-created-vm-u13', image_name = "imageName_i_u13") test_obj_dict.add_vm(vm) vm.check() force_vm_auto_boot(vm) test_util.test_logger("change vm password for initial created vm") vm_ops.change_vm_password(vm.get_vm().uuid, "root", "password", skip_stopped_vm = None, session_uuid = None) backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break #if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: # break #if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: # break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') for (usr,passwd) in zip(users, passwds): if usr not in exist_users: test_util.test_logger("find new account: <%s:%s>" %(usr, passwd)) test_stub.create_user_in_vm(vm.get_vm(), usr, passwd) exist_users.append(usr) #new vm->cloned new_vm1/new_vm2 test_util.test_logger("1st clone") new_vms = vm.clone(vm_names) if len(new_vms) != len(vm_names): test_util.test_fail('only %s VMs have been cloned, which is less than required: %s' % (len(new_vms), vm_names)) for new_vm in new_vms: new_vm.update() #new_vm.check() test_obj_dict.add_vm(new_vm) #When vm is running: test_util.test_logger("vm running && change 1st cloned vm password:<%s:%s:%s>" %(new_vm, usr, passwd)) vm_ops.change_vm_password(new_vm.get_vm().uuid, usr, passwd, skip_stopped_vm = None, session_uuid = None) if not test_lib.lib_check_login_in_vm(new_vm.get_vm(), usr, passwd): test_util.test_fail("check login cloned vm with user:%s password: %s failed", usr, passwd) #When vm is stopped: #new_vm.stop() test_util.test_logger("vm stopped && change 1st cloned vm password:<%s:%s:%s>" %(new_vm, usr, passwd)) vm_ops.change_vm_password(new_vm.get_vm().uuid, "root", test_stub.original_root_password) #new_vm.start() new_vm.check() #test use the cloned vm change password to clone new vm and then change password test_util.test_logger("2nd cloned") in_new_vms = new_vm.clone(in_vm_names) new_vm.destroy() new_vm.check() new_vm.expunge() new_vm.check() for in_new_vm in in_new_vms: in_new_vm.update() test_obj_dict.add_vm(in_new_vm) test_util.test_logger("vm running && change 2nd cloned vm password:<%s:%s:%s>" %(new_vm, usr, passwd)) vm_ops.change_vm_password(in_new_vm.get_vm().uuid, usr, passwd, skip_stopped_vm = None, session_uuid = None) if not test_lib.lib_check_login_in_vm(in_new_vm.get_vm(), usr, passwd): test_util.test_fail("check login cloned in_vm with user:%s password: %s failed", usr, passwd) #When vm is stopped: #in_new_vm.stop() test_util.test_logger("vm stopped && change 2nd cloned vm password:<%s:%s:%s>" %(new_vm, usr, passwd)) vm_ops.change_vm_password(in_new_vm.get_vm().uuid, "root", test_stub.original_root_password) #in_new_vm.start() in_new_vm.check() in_new_vm.destroy() in_new_vm.check() in_new_vm.expunge() in_new_vm.check() vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vm, exist_users test_util.test_dsc('change VM with assigned password test') for (usr, passwd) in zip(users, passwds): test_util.test_dsc("username:%s, password: \"%s\"" % (usr, passwd)) #Create VM API if usr == "root": try: vm = test_stub.create_vm(vm_name='c7-vm', image_name="imageName_i_c7", root_password=passwd) except: pass else: test_util.test_fail( "create vm && the invaild password: %s successfully be set" % (passwd)) #Check bs type vm = test_stub.create_vm(vm_name='c7-vm', image_name="imageName_i_c7") vm.check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: test_util.test_skip('Not find image store type backup storage.') #inject normal account username/password if usr not in exist_users: test_stub.create_user_in_vm(vm.get_vm(), usr, "password") exist_users.append(usr) #Change VM API && Running try: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm=None, session_uuid=None) except: pass else: test_util.test_fail( "vm running && the invaild password: %s successfully be set" % (passwd)) #Change VM API && Stopped #vm.stop() try: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm=None, session_uuid=None) except: pass else: test_util.test_fail( "vm stopped && the invaild password: %s successfully be set" % (passwd)) #vm.start() vm.check() if not test_lib.lib_check_login_in_vm(vm.get_vm(), "root", "password"): test_util.test_fail( "create vm with root password: \"password\" failed") vm.destroy() vm.expunge() vm.check() test_util.test_pass('Invalid password test is passed.')
def test(): global vm, exist_users test_util.test_dsc('cloned vm change password test') vm = test_stub.create_vm(vm_name='1st-created-vm-u12', image_name="imageName_i_u12") test_obj_dict.add_vm(vm) vm.check() force_vm_auto_boot(vm) test_util.test_logger("change vm password for initial created vm") vm_ops.change_vm_password(vm.get_vm().uuid, "root", "password", skip_stopped_vm=None, session_uuid=None) backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break #if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: # break #if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: # break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') for (usr, passwd) in zip(users, passwds): if usr not in exist_users: test_util.test_logger("find new account: <%s:%s>" % (usr, passwd)) test_stub.create_user_in_vm(vm.get_vm(), usr, passwd) exist_users.append(usr) #new vm->cloned new_vm1/new_vm2 test_util.test_logger("1st clone") new_vms = vm.clone(vm_names) if len(new_vms) != len(vm_names): test_util.test_fail( 'only %s VMs have been cloned, which is less than required: %s' % (len(new_vms), vm_names)) for new_vm in new_vms: new_vm.update() #new_vm.check() test_obj_dict.add_vm(new_vm) #When vm is running: test_util.test_logger( "vm running && change 1st cloned vm password:<%s:%s:%s>" % (new_vm, usr, passwd)) vm_ops.change_vm_password(new_vm.get_vm().uuid, usr, passwd, skip_stopped_vm=None, session_uuid=None) if not test_lib.lib_check_login_in_vm(new_vm.get_vm(), usr, passwd): test_util.test_fail( "check login cloned vm with user:%s password: %s failed", usr, passwd) #When vm is stopped: #new_vm.stop() test_util.test_logger( "vm stopped && change 1st cloned vm password:<%s:%s:%s>" % (new_vm, usr, passwd)) vm_ops.change_vm_password(new_vm.get_vm().uuid, "root", test_stub.original_root_password) #new_vm.start() new_vm.check() #test use the cloned vm change password to clone new vm and then change password test_util.test_logger("2nd cloned") in_new_vms = new_vm.clone(in_vm_names) new_vm.destroy() new_vm.check() new_vm.expunge() new_vm.check() for in_new_vm in in_new_vms: in_new_vm.update() test_obj_dict.add_vm(in_new_vm) test_util.test_logger( "vm running && change 2nd cloned vm password:<%s:%s:%s>" % (new_vm, usr, passwd)) vm_ops.change_vm_password(in_new_vm.get_vm().uuid, usr, passwd, skip_stopped_vm=None, session_uuid=None) if not test_lib.lib_check_login_in_vm(in_new_vm.get_vm(), usr, passwd): test_util.test_fail( "check login cloned in_vm with user:%s password: %s failed", usr, passwd) #When vm is stopped: #in_new_vm.stop() test_util.test_logger( "vm stopped && change 2nd cloned vm password:<%s:%s:%s>" % (new_vm, usr, passwd)) vm_ops.change_vm_password(in_new_vm.get_vm().uuid, "root", test_stub.original_root_password) #in_new_vm.start() in_new_vm.check() in_new_vm.destroy() in_new_vm.check() in_new_vm.expunge() in_new_vm.check() vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global vm, exist_users test_util.test_dsc('change VM with assigned password test') for (usr,passwd) in zip(users, passwds): test_util.test_dsc("username:%s, password: \"%s\"" %(usr, passwd)) #Create VM API if usr == "root": try: vm = test_stub.create_vm(vm_name = 'c7-vm', image_name = "imageName_i_c7", root_password=passwd) except: pass else: test_util.test_fail("create vm && the invaild password: %s successfully be set" % (passwd)) #Check bs type vm = test_stub.create_vm(vm_name = 'c7-vm', image_name = "imageName_i_c7") vm.check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: test_util.test_skip('Not find image store type backup storage.') #inject normal account username/password if usr not in exist_users: test_stub.create_user_in_vm(vm.get_vm(), usr, "password") exist_users.append(usr) #Change VM API && Running try: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm = None, session_uuid = None) except: pass else: test_util.test_fail("vm running && the invaild password: %s successfully be set" %(passwd)) #Change VM API && Stopped #vm.stop() try: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm = None, session_uuid = None) except: pass else: test_util.test_fail("vm stopped && the invaild password: %s successfully be set" %(passwd)) #vm.start() vm.check() if not test_lib.lib_check_login_in_vm(vm.get_vm(), "root", "password"): test_util.test_fail("create vm with root password: \"password\" failed") vm.destroy() vm.expunge() vm.check() test_util.test_pass('Invalid password test is passed.')