本文整理汇总了Python中zstackwoodpecker.operations.primarystorage_operations.change_primary_storage_state函数的典型用法代码示例。如果您正苦于以下问题:Python change_primary_storage_state函数的具体用法?Python change_primary_storage_state怎么用?Python change_primary_storage_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了change_primary_storage_state函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
def test():
global test_obj_dict
global ps_uuid
global host_uuid
global vr_uuid
test_util.test_dsc('Create test vm and check')
l3_1_name = os.environ.get('l3VlanNetworkName1')
vm = test_stub.create_vlan_vm(l3_name=l3_1_name)
l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
vr = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0]
vr_uuid = vr.uuid
host = test_lib.lib_get_vm_host(vm.get_vm())
host_uuid = host.uuid
test_obj_dict.add_vm(vm)
vm.check()
ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
ps_uuid = ps.uuid
ps_ops.change_primary_storage_state(ps_uuid, 'disable')
if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, '22', 90):
test_util.test_fail('VM is expected to running when PS change to disable state')
vm.set_state(vm_header.RUNNING)
vm.check()
vm.destroy()
vm.check()
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
host_ops.reconnect_host(host_uuid)
vm_ops.reconnect_vr(vr_uuid)
test_util.test_pass('PS disable mode Test Success')
示例2: test
def test():
ps_env = test_stub.PSEnvChecker()
nfs_ps = ps_env.get_random_nfs()
test_util.test_dsc("Create 1 vm with {} data volume".format(VOLUME_NUMBER))
vm = test_stub.create_multi_vms(name_prefix='test-', count=1, data_volume_number=VOLUME_NUMBER)[0]
test_obj_dict.add_vm(vm)
test_util.test_dsc("disable NFS PS")
ps_ops.change_primary_storage_state(nfs_ps.uuid, state='disable')
disabled_ps_list.append(nfs_ps)
test_util.test_dsc("make sure VM till OK and running")
vm.update()
vm.check()
assert vm.get_vm().state == inventory.RUNNING
with test_stub.expected_failure("Create datavol in nfs-local env when nfs disabled", Exception):
test_stub.create_multi_volumes(count=1, ps=nfs_ps)
test_util.test_dsc("Try to create vm")
new_vm = test_stub.create_multi_vms(name_prefix='test-vm', count=1)[0]
test_obj_dict.add_vm(new_vm)
test_util.test_pass('Multi PrimaryStorage Test Pass')
示例3: test
def test():
global test_obj_dict
global ps_uuid
global host_uuid
global vr_uuid
test_util.test_dsc('Create test vm and check')
l3_1_name = os.environ.get('l3VlanNetworkName1')
vm = test_stub.create_vlan_vm(l3_name=l3_1_name)
#l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
#vr = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0]
#vr_uuid = vr.uuid
host = test_lib.lib_get_vm_host(vm.get_vm())
host_uuid = host.uuid
test_obj_dict.add_vm(vm)
vm.check()
ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
ps_uuid = ps.uuid
ps_ops.change_primary_storage_state(ps_uuid, 'maintain')
if not test_lib.lib_wait_target_down(vm.get_vm().vmNics[0].ip, '22', 90):
test_util.test_fail('VM is expected to stop when PS change to maintain state')
vm.set_state(vm_header.STOPPED)
vm.check()
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
host_ops.reconnect_host(host_uuid)
#vm_ops.reconnect_vr(vr_uuid)
vrs = test_lib.lib_get_all_vrs()
for vr in vrs:
vm_ops.start_vm(vr.uuid)
vm.start()
vm.check()
vm.destroy()
test_util.test_pass('PS maintain mode Test Success')
示例4: test
def test():
global test_obj_dict
global ps_uuid
global host_uuid
global vr_uuid
test_util.test_dsc('Create test vm and check')
l3_1_name = os.environ.get('l3VlanNetworkName1')
vm = test_stub.create_vlan_vm(l3_name=l3_1_name)
#l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
#vr = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0]
#vr_uuid = vr.uuid
host = test_lib.lib_get_vm_host(vm.get_vm())
host_uuid = host.uuid
test_obj_dict.add_vm(vm)
vm.check()
test_util.test_dsc('Add ISO Image')
cond = res_ops.gen_query_conditions("status", '=', "Connected")
bs_uuid = res_ops.query_resource(res_ops.BACKUP_STORAGE, cond)[0].uuid
img_option = test_util.ImageOption()
img_option.set_name('iso')
img_option.set_backup_storage_uuid_list([bs_uuid])
os.system("echo fake iso for test only > %s/apache-tomcat/webapps/zstack/static/test.iso" % (os.environ.get('zstackInstallPath')))
img_option.set_url('http://%s:8080/zstack/static/test.iso' % (os.environ.get('node1Ip')))
image_inv = img_ops.add_iso_template(img_option)
image = test_image.ZstackTestImage()
image.set_image(image_inv)
image.set_creation_option(img_option)
test_obj_dict.add_image(image)
ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
ps_uuid = ps.uuid
ps_ops.change_primary_storage_state(ps_uuid, 'maintain')
if not test_lib.lib_wait_target_down(vm.get_vm().vmNics[0].ip, '22', 90):
test_util.test_fail('VM is expected to stop when PS change to maintain state')
vm.set_state(vm_header.STOPPED)
vm.check()
test_util.test_dsc('Attach ISO to VM')
cond = res_ops.gen_query_conditions('name', '=', 'iso')
iso_uuid = res_ops.query_resource(res_ops.IMAGE, cond)[0].uuid
img_ops.attach_iso(iso_uuid, vm.vm.uuid)
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
host_ops.reconnect_host(host_uuid)
#vm_ops.reconnect_vr(vr_uuid)
vrs = test_lib.lib_get_all_vrs()
for vr in vrs:
vm_ops.start_vm(vr.uuid)
vm.start()
vm.check()
vm.destroy()
vm.check()
#vm.expunge()
#vm.check()
test_util.test_pass('PS maintain mode Test Success')
示例5: env_recover
def env_recover():
global ps_uuid
if ps_uuid != None:
try:
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
except:
pass
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:7,代码来源:test_ls_vm_ha_ps_maintain_recover_vm_self_start.py
示例6: env_recover
def env_recover():
local_ps, shared_ps = test_stub.PSEnvChecker().get_two_ps()
if local_ps.state == 'Disabled':
ps_ops.change_primary_storage_state(local_ps.uuid, state='enable')
if shared_ps.state == 'Disabled':
ps_ops.change_primary_storage_state(shared_ps.uuid, state='enable')
test_lib.lib_error_cleanup(test_obj_dict)
示例7: env_recover
def env_recover():
test_lib.lib_error_cleanup(test_obj_dict)
for disabled_ps in disabled_ps_list:
ps_ops.change_primary_storage_state(disabled_ps.uuid, state='enable')
if new_ps_list:
for new_ps in new_ps_list:
ps_ops.detach_primary_storage(new_ps.uuid, new_ps.attachedClusterUuids[0])
ps_ops.delete_primary_storage(new_ps.uuid)
示例8: test
def test():
ps_env = test_stub.PSEnvChecker()
if ps_env.is_sb_ceph_env:
env = test_stub.SanAndCephPrimaryStorageEnv(test_object_dict=test_obj_dict,
first_ps_vm_number=VM_COUNT,
second_ps_vm_number=VM_COUNT,
first_ps_volume_number=VOLUME_NUMBER,
second_ps_volume_number=VOLUME_NUMBER)
else:
env = test_stub.TwoPrimaryStorageEnv(test_object_dict=test_obj_dict,
first_ps_vm_number=VM_COUNT,
second_ps_vm_number=VM_COUNT,
first_ps_volume_number=VOLUME_NUMBER,
second_ps_volume_number=VOLUME_NUMBER)
env.check_env()
env.deploy_env()
first_ps_vm_list = env.first_ps_vm_list
first_ps_volume_list = env.first_ps_volume_list
second_ps_vm_list = env.second_ps_vm_list
second_ps_volume_list = env.second_ps_volume_list
if env.new_ps:
new_ps_list.append(env.second_ps)
tbj_list = first_ps_vm_list + second_ps_vm_list + first_ps_volume_list + second_ps_volume_list
test_util.test_dsc('Disable All Primary Storage')
for ps in [env.first_ps, env.second_ps]:
ps_ops.change_primary_storage_state(ps.uuid, state='disable')
disabled_ps_list.append(ps)
test_util.test_dsc('make sure all VM and Volumes still OK and running')
for test_object in tbj_list:
test_object.check()
test_util.test_dsc("Try to Create one vm")
with test_stub.expected_failure("Create vm when no ps in enable status", Exception):
test_stub.create_multi_vms(name_prefix='test-vm', count=1)
test_util.test_dsc("Try to Create one volume")
with test_stub.expected_failure("Create volume when no ps in enable status", Exception):
test_stub.create_multi_volumes(count=1, ps=random.choice([env.first_ps, env.second_ps]))
test_util.test_dsc("enable All primaryStorage")
for ps in [env.first_ps, env.second_ps]:
ps_ops.change_primary_storage_state(ps.uuid, state='enable')
disabled_ps_list.remove(ps)
test_util.test_dsc("Try to create vm in both PrimaryStorage")
if ps_env.is_sb_ceph_env:
vm1 = test_stub.create_multi_vms(name_prefix='test-vm_first_ps', count=1, ps_uuid=env.first_ps.uuid, bs_type='ImageStoreBackupStorage')[0]
vm2 = test_stub.create_multi_vms(name_prefix='test-vm_second_ps', count=1, ps_uuid=env.second_ps.uuid, bs_type='Ceph')[0]
else:
vm1 = test_stub.create_multi_vms(name_prefix='test-vm_first_ps', count=1, ps_uuid=env.first_ps.uuid)[0]
vm2 = test_stub.create_multi_vms(name_prefix='test-vm_second_ps', count=1, ps_uuid=env.second_ps.uuid)[0]
test_obj_dict.add_vm(vm1)
test_obj_dict.add_vm(vm2)
test_util.test_pass('Multi PrimaryStorage Test Pass')
示例9: test
def test():
global test_obj_dict
global ps_uuid
global host_uuid
global vr_uuid
test_util.test_dsc('Create test vm and check')
test_lib.lib_set_delete_policy('vm', 'Delay')
test_lib.lib_set_delete_policy('volume', 'Delay')
l3_1_name = os.environ.get('l3VlanNetworkName1')
vm = test_stub.create_vlan_vm(l3_name=l3_1_name)
#l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
#vr = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0]
#vr_uuid = vr.uuid
host = test_lib.lib_get_vm_host(vm.get_vm())
host_uuid = host.uuid
test_obj_dict.add_vm(vm)
vm.check()
disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName'))
volume_creation_option = test_util.VolumeOption()
volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
volume_creation_option.set_system_tags(['ephemeral::shareable', 'capability::virtio-scsi'])
volume = test_stub.create_volume(volume_creation_option)
test_obj_dict.add_volume(volume)
volume.check()
volume.delete()
volume.check()
ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
ps_uuid = ps.uuid
ps_ops.change_primary_storage_state(ps_uuid, 'maintain')
if not test_lib.lib_wait_target_down(vm.get_vm().vmNics[0].ip, '22', 90):
test_util.test_fail('VM is expected to stop when PS change to maintain state')
vm.set_state(vm_header.STOPPED)
vm.check()
volume.recover()
volume.check()
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
host_ops.reconnect_host(host_uuid)
#vm_ops.reconnect_vr(vr_uuid)
vrs = test_lib.lib_get_all_vrs()
for vr in vrs:
vm_ops.start_vm(vr.uuid)
vm.start()
vm.check()
volume.delete()
#volume.expunge()
volume.check()
vm.destroy()
test_lib.lib_set_delete_policy('vm', 'Direct')
test_lib.lib_set_delete_policy('volume', 'Direct')
test_util.test_pass('Delete volume under PS maintain mode Test Success')
示例10: test
def test():
global vm
global test_host
global ps_uuid
global host_ip
global max_attempts
global storagechecker_timeout
allow_ps_list = [inventory.LOCAL_STORAGE_TYPE]
test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm_creation_option = test_util.VmOption()
image_name = os.environ.get('imageName_net')
image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
l3_name = os.environ.get('l3VlanNetworkName1')
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
test_lib.clean_up_all_vr()
conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
vm_creation_option.set_l3_uuids([l3_net_uuid])
vm_creation_option.set_image_uuid(image_uuid)
vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
vm_creation_option.set_name('ls_vm_ha_self_start')
vm = test_vm_header.ZstackTestVm()
vm.set_creation_option(vm_creation_option)
vm.create()
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
ps_uuid = ps.uuid
ps_ops.change_primary_storage_state(ps_uuid, 'maintain')
if not test_lib.lib_wait_target_down(vm.get_vm().vmNics[0].ip, '22', 90):
test_util.test_fail('VM is expected to stop when PS change to maintain state')
vm.set_state(vm_header.STOPPED)
vm.check()
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
for i in range(0, 300):
if res_ops.query_resource(res_ops.VM_INSTANCE, conditions)[0].state == "Running":
break
time.sleep(1)
else:
test_util.test_fail("vm has not been changed to running as expected within 300s.")
vm.destroy()
test_util.test_pass('Test checking VM ha and none status when force stop vm Success.')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:56,代码来源:test_ls_vm_ha_ps_maintain_recover_vm_self_start.py
示例11: env_recover
def env_recover():
local_ps, shared_ps = test_stub.PSEnvChecker().get_two_ps()
if local_ps.state in ('Disabled', "Maintenance"):
ps_ops.change_primary_storage_state(local_ps.uuid, state='enable')
if shared_ps.state in ('Disabled', "Maintenance"):
ps_ops.change_primary_storage_state(shared_ps.uuid, state='enable')
for vr in res_ops.get_resource(res_ops.APPLIANCE_VM):
if vr.state != inventory.RUNNING:
vm_ops.start_vm(vr.uuid)
test_lib.lib_error_cleanup(test_obj_dict)
示例12: error_cleanup
def error_cleanup():
global ps_uuid
if ps_uuid != None:
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
global host_uuid
if host_uuid != None:
host_ops.reconnect_host(host_uuid)
global vr_uuid
if vr_uuid != None:
vm_ops.reconnect_vr(vr_uuid)
global test_obj_dict
test_lib.lib_error_cleanup(test_obj_dict)
示例13: error_cleanup
def error_cleanup():
global ps_uuid
test_lib.lib_set_delete_policy('vm', 'Direct')
test_lib.lib_set_delete_policy('volume', 'Direct')
if ps_uuid != None:
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
global host_uuid
if host_uuid != None:
host_ops.reconnect_host(host_uuid)
global vr_uuid
if vr_uuid != None:
vm_ops.reconnect_vr(vr_uuid)
global test_obj_dict
test_lib.lib_error_cleanup(test_obj_dict)
示例14: error_cleanup
def error_cleanup():
global ps_uuid
if ps_uuid != None:
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
global host_uuid
if host_uuid != None:
host_ops.reconnect_host(host_uuid)
vrs = test_lib.lib_get_all_vrs()
for vr in vrs:
vm_ops.start_vm(vr.uuid)
#global vr_uuid
#if vr_uuid != None:
# vm_ops.reconnect_vr(vr_uuid)
global test_obj_dict
test_lib.lib_error_cleanup(test_obj_dict)
示例15: test
def test():
global test_obj_dict
global ps_uuid
global host_uuid
global vr_uuid
test_util.test_dsc('Create test vm and check')
l3_1_name = os.environ.get('l3VlanNetworkName1')
vm = test_stub.create_vlan_vm(l3_name=l3_1_name)
l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
vr = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0]
vr_uuid = vr.uuid
#l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
host = test_lib.lib_get_vm_host(vm.get_vm())
host_uuid = host.uuid
test_obj_dict.add_vm(vm)
vm.check()
disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName'))
volume_creation_option = test_util.VolumeOption()
volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
#volume_creation_option.set_system_tags(['ephemeral::shareable', 'capability::virtio-scsi'])
volume = test_stub.create_volume(volume_creation_option)
test_obj_dict.add_volume(volume)
volume.check()
volume.attach(vm)
ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
ps_uuid = ps.uuid
ps_ops.change_primary_storage_state(ps_uuid, 'disable')
if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, '22', 90):
test_util.test_fail('VM is expected to running when PS change to disable state')
vm.set_state(vm_header.RUNNING)
vm.check()
volume.detach(vm.get_vm().uuid)
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
host_ops.reconnect_host(host_uuid)
vm_ops.reconnect_vr(vr_uuid)
volume.delete()
#volume.expunge()
volume.check()
vm.destroy()
test_util.test_pass('Delete volume under PS disable mode Test Success')