本文整理汇总了Python中zstackwoodpecker.operations.resource_operations.gen_query_conditions函数的典型用法代码示例。如果您正苦于以下问题:Python gen_query_conditions函数的具体用法?Python gen_query_conditions怎么用?Python gen_query_conditions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gen_query_conditions函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test
def test():
global ipsec
global vip1_uuid
global vpc_vr
cond = res_ops.gen_query_conditions('name', '=', 'public network')
public_network = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0]
vip1 = test_stub.create_vip('vip_ipsec', public_network.uuid)
vip1_uuid = vip1.get_vip().uuid
test_util.test_dsc('Create vpc vr and attach networks')
vpc_vr = test_stub.create_vpc_vrouter()
cond = res_ops.gen_query_conditions('name', '=', 'l3VlanNetwork11')
l3_vlan_network11 = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0]
vpc_vr.add_nic(l3_vlan_network11.uuid)
peer_address = '10.94.10.10'
try:
ipsec = ipsec_ops.create_ipsec_connection('ipsec', None, peer_address, '123456', vip1_uuid, None)
except:
test_util.test_fail('Failed to create vpc ipsec')
test_stub.delete_vip(vip1_uuid)
vpc_vr.destroy()
ipsec_ops.delete_ipsec_connection(ipsec.uuid)
test_util.test_pass('Create VPC Ipsec Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:26,代码来源:test_create_ipsec.py
示例2: add_storage_for_backup
def add_storage_for_backup(deployConfig):
print "try to add backup storage"
if xmlobject.has_element(deployConfig, 'backupStorages.imageStoreBackupStorage'):
print "find image store backup storage"
for bs in xmlobject.safe_list(deployConfig.backupStorages.imageStoreBackupStorage):
if hasattr(bs, 'local_backup_storage_'):
print "find local_backup_storage"
cond = res_ops.gen_query_conditions('tag', '=', "allowbackup")
tags = res_ops.query_resource(res_ops.SYSTEM_TAG, cond)
if len(tags) > 0:
print "local backup storage already exists"
break
cond = res_ops.gen_query_conditions('name', '=', bs.name_)
bss = res_ops.query_resource(res_ops.BACKUP_STORAGE, cond)
print bss
add_local_bs_tag = tag_ops.create_system_tag('ImageStoreBackupStorageVO', bss[0].uuid,'allowbackup')
if xmlobject.has_element(deployConfig, 'backupStorages.imageStoreBackupStorage'):
for bs in xmlobject.safe_list(deployConfig.backupStorages.imageStoreBackupStorage):
if hasattr(bs, 'remote_backup_storage_'):
print "find remote_backup_storage"
cond = res_ops.gen_query_conditions('tag', '=', "remotebackup")
tags = res_ops.query_resource(res_ops.SYSTEM_TAG, cond)
if len(tags) > 0:
print "remote backup storage already exists"
break
cond = res_ops.gen_query_conditions('name', '=', bs.name_)
bss = res_ops.query_resource(res_ops.BACKUP_STORAGE, cond)
print bss
add_local_bs_tag = tag_ops.create_system_tag('ImageStoreBackupStorageVO', bss[0].uuid,'remotebackup')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:29,代码来源:run_path.py
示例3: get_host_by_mn_vm_process
def get_host_by_mn_vm_process(scenarioConfig, scenarioFile):
zstack_management_ip = scenarioConfig.basicConfig.zstackManagementIp.text_
mha_s_vm_list = get_mha_s_vm_list_from_scenario_file(scenarioConfig, scenarioFile)
if len(mha_s_vm_list) < 1:
return []
host_vm_inv = dict()
host_inv = dict()
for host in mha_s_vm_list:
cond = res_ops.gen_query_conditions('vmNics.ip', '=', host.ip_)
host_vm_inv[host] = sce_ops.query_resource(zstack_management_ip, res_ops.VM_INSTANCE, cond).inventories[0]
cond = res_ops.gen_query_conditions('uuid', '=', host_vm_inv[host].hostUuid)
host_inv[host] = sce_ops.query_resource(zstack_management_ip, res_ops.HOST, cond).inventories[0]
host_list = []
for host in mha_s_vm_list:
cmd = "ps axjf |grep kvm | grep mnvm.img | grep -v grep"
try:
query_kvm_process = sce_ops.execute_in_vm_console(zstack_management_ip, host_inv[host].managementIp, host_vm_inv[host].uuid, host, cmd)
test_util.test_logger("check mn vm kvm process on host %s: %s" % (host.ip_, query_kvm_process))
if query_kvm_process.find('zstack/mnvm.img') >= 0:
host_list.append(host)
except:
continue
return host_list
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:25,代码来源:test_stub.py
示例4: shutdown_host_network
def shutdown_host_network(host_vm, scenarioConfig, downMagt=True):
'''
Here we change l2network_nic to be global is due to the maybe failed once all mn nodes disconnected
In that case, lib_get_l2_magt_nic_by_vr_offering will be failed because of mn is disconnected.
Of course, to be global means the management network can be only selected once in ZStack DB.
'''
global l2network_nic
zstack_management_ip = scenarioConfig.basicConfig.zstackManagementIp.text_
cond = res_ops.gen_query_conditions('vmNics.ip', '=', host_vm.ip_)
host_vm_inv = sce_ops.query_resource(zstack_management_ip, res_ops.VM_INSTANCE, cond).inventories[0]
cond = res_ops.gen_query_conditions('uuid', '=', host_vm_inv.hostUuid)
host_inv = sce_ops.query_resource(zstack_management_ip, res_ops.HOST, cond).inventories[0]
host_vm_config = sce_ops.get_scenario_config_vm(host_vm_inv.name_, scenarioConfig)
if not l2network_nic:
if downMagt:
l2network_nic = test_lib.lib_get_l2_magt_nic_by_vr_offering()
else:
l2network_nic = test_lib.lib_get_l2_pub_nic_by_vr_offering()
if not l2network_nic:
test_util.test_fail("fail to get management l2 by vr offering")
#l2network_nic = os.environ.get('l2ManagementNetworkInterface').replace("eth", "zsn")
cmd = "ifdown %s" % (l2network_nic)
sce_ops.execute_in_vm_console(zstack_management_ip, host_inv.managementIp, host_vm_inv.uuid, host_vm_config, cmd)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:26,代码来源:test_stub.py
示例5: test
def test():
global agent_url
global vm
imagestore = test_lib.lib_get_image_store_backup_storage()
if imagestore == None:
test_util.test_skip('Required imagestore to test')
image_uuid = test_stub.get_image_by_bs(imagestore.uuid)
cond = res_ops.gen_query_conditions('type', '=', 'SharedMountPoint')
pss = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)
if len(pss) == 0:
test_util.test_skip('Required %s ps to test' % (ps_type))
ps_uuid = pss[0].uuid
vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid)
vm.stop()
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid,'NeverStop')
cond = res_ops.gen_query_conditions('uuid', '=', vm.get_vm().uuid)
for i in range(5):
time.sleep(1)
try:
if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state == vm_header.RUNNING:
break
except:
test_util.test_logger('Retry until VM change to running')
if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state == vm_header.RUNNING:
test_util.test_pass('set HA after stopped VM test pass')
test_util.test_fail('set HA after stopped VM test fail')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_set_ha_for_stopped_vm.py
示例6: test
def test():
global vm, host3_uuid
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
conf_ops.change_global_config('ha', 'allow.slibing.cross.clusters', 'true')
vm_creation_option = test_util.VmOption()
image_name = os.environ.get('imageName_s')
image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
#l3_name = os.environ.get('l3NoVlanNetworkName1')
#l3_name = os.environ.get('l3VlanNetworkName1')
l3_name = os.environ.get('l3PublicNetworkName')
host3_name = os.environ.get('hostName3')
host4_name = os.environ.get('hostName4')
conditions1 = res_ops.gen_query_conditions('name', '=', host3_name)
host3_uuid = res_ops.query_resource(res_ops.HOST, conditions1)[0].uuid
host3_ip = res_ops.query_resource(res_ops.HOST, conditions1)[0].managementIp
conditions2 = res_ops.gen_query_conditions('name', '=', host4_name)
host4_uuid = res_ops.query_resource(res_ops.HOST, conditions2)[0].uuid
host4_ip = res_ops.query_resource(res_ops.HOST, conditions2)[0].managementIp
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
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('multihost_basic_vm')
vm_creation_option.set_host_uuid(host3_uuid)
vm = test_vm_header.ZstackTestVm()
vm.set_creation_option(vm_creation_option)
vm.create()
time.sleep(30)
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
time.sleep(5)
vm.check()
ssh_cmd1 = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % host3_ip
cmd = '%s "poweroff" ' % ssh_cmd1
process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
time.sleep(360)
host3_status = res_ops.query_resource(res_ops.HOST, conditions1)[0].status
if host3_status == "Disconnected":
conditions3 = res_ops.gen_query_conditions('uuid', '=', vm.vm.uuid)
vm_status = res_ops.query_resource(res_ops.VM_INSTANCE, conditions3)[0].state
vm_host_uuid = res_ops.query_resource(res_ops.VM_INSTANCE, conditions3)[0].hostUuid
if vm_status != "Running" or vm_host_uuid != host4_uuid:
test_util.test_fail('Test fail vm status: %s, vm_host_uuid: %s,' %(vm_status, vm_host_uuid))
vm.destroy()
conf_ops.change_global_config('ha', 'allow.slibing.cross.clusters', 'false')
conditions4 = res_ops.gen_query_conditions('vmNics.ip', '=', host3_ip)
vm3_uuid = sce_ops.query_resource(zstack_management_ip, res_ops.VM_INSTANCE, conditions4).inventories[0].uuid
sce_ops.start_vm(zstack_management_ip, vm3_uuid)
test_util.test_pass('VM auto ha across cluster Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_ha_vm_auto_across_cluster_migration.py
示例7: test
def test():
global test_obj_dict
volume_creation_option = test_util.VolumeOption()
ps_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE, [])[0].uuid
test_util.test_dsc('Create volume and check')
disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
volume_creation_option.set_primary_storage_uuid(ps_uuid)
if res_ops.query_resource(res_ops.PRIMARY_STORAGE, [])[0].type == "LocalStorage":
host = test_lib.lib_find_random_host()
volume_creation_option.set_system_tags(["localStorage::hostUuid::%s" % host.uuid])
volume = test_stub.create_volume(volume_creation_option)
test_obj_dict.add_volume(volume)
volume.check()
volume_uuid = volume.volume.uuid
vol_size = volume.volume.size
set_size = 1024*1024*1024*5
vol_ops.resize_data_volume(volume_uuid, set_size)
cond = res_ops.gen_query_conditions('type', '=', "Data")
cond = res_ops.gen_query_conditions('status', '=', "Ready", cond)
vol_size_after = res_ops.query_resource(res_ops.VOLUME, cond)[0].size
if set_size != vol_size_after:
test_util.test_fail('Resize Data Volume failed, size = %s' % vol_size_after)
test_lib.lib_error_cleanup(test_obj_dict)
test_util.test_pass('Resize Data Volume Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:26,代码来源:test_resize_unattached_data_volume.py
示例8: test
def test():
if os.environ.get('CASE_FLAVOR'):
flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
num = flavor['vm_num']
else:
num = 10000
cond = res_ops.gen_query_conditions('system', '=', 'false')
imageUuid = res_ops.query_resource_fields(res_ops.IMAGE, cond)[0].uuid
hostUuid = ''
hostName = ''
cond = res_ops.gen_query_conditions('type', '=', 'UserVm')
instanceOfferingUuid = res_ops.query_resource_fields(res_ops.INSTANCE_OFFERING, cond)[0].uuid
cond = res_ops.gen_query_conditions('system', '=', 'false')
l3NetworkUuids = res_ops.query_resource_fields(res_ops.L3_NETWORK, cond)[0].uuid
hosts = res_ops.query_resource_fields(res_ops.HOST)
counter = 0
for i in range(0, 500):
hostUuid = hosts[i].uuid
hostName = hosts[i].name
for j in range(0, 20):
counter += 1
if counter > num:
test_util.test_pass("Create %s vms finished" %num)
vm_name = 'vm-'+str(j)+'-on-host-'+hostName
thread = threading.Thread(target=create_vm, args=(vm_name, imageUuid, hostUuid, instanceOfferingUuid, l3NetworkUuids))
while threading.active_count() > 10:
time.sleep(5)
thread.start()
test_util.test_fail("Fail to create vms")
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:29,代码来源:test_create_vms.py
示例9: test
def test():
global test_obj_dict
cond = res_ops.gen_query_conditions('state', '=', 'Enabled')
cond = res_ops.gen_query_conditions('type', '=', 'LocalStorage')
cond = res_ops.gen_query_conditions('status', '=', 'Connected', cond)
ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)
if len(ps) < 2:
test_util.test_skip("Requres at least two local ps")
ps1_res = vol_ops.get_local_storage_capacity(None, ps[0].uuid)[0]
ps2_res = vol_ops.get_local_storage_capacity(None, ps[1].uuid)[0]
if ps1_res.availableCapacity > ps2_res.availableCapacity:
data_volume_size = ps2_res.availableCapacity + (ps1_res.availableCapacity - ps2_res.availableCapacity) / 2
else:
data_volume_size = ps1_res.availableCapacity + (ps2_res.availableCapacity - ps1_res.availableCapacity) / 2
disk_offering_option = test_util.DiskOfferingOption()
disk_offering_option.set_name('2-local-ps-test')
disk_offering_option.set_diskSize(data_volume_size)
data_volume_offering = vol_ops.create_volume_offering(disk_offering_option)
test_obj_dict.add_disk_offering(data_volume_offering)
vm = test_stub.create_vlan_vm(disk_offering_uuids=[data_volume_offering.uuid])
test_obj_dict.add_vm(vm)
test_lib.lib_robot_cleanup(test_obj_dict)
test_util.test_pass('2 Local PS Test Pass')
return False
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:27,代码来源:test_create_large_vm_2_local_ps.py
示例10: compare
def compare(ps, vm, dvol, backup):
test_util.test_logger("-----------------compare----------------")
# find vm_host
host = test_lib.lib_find_host_by_vm(vm.vm)
cond = res_ops.gen_query_conditions("type", '=', "ImageStoreBackupStorage")
bs = res_ops.query_resource(res_ops.BACKUP_STORAGE, cond)[0]
cond = res_ops.gen_query_conditions("uuid", '=', dvol.volume.uuid)
current_volume = res_ops.query_resource(res_ops.VOLUME, cond)[0]
vol_path = current_volume.installPath
if ps.type == "SharedBlock":
vol_path = "/dev/" + current_volume.installPath.split("/")[2] + "/" + current_volume.installPath.split("/")[3]
test_util.test_logger(vol_path)
name = backup.backupStorageRefs[0].installPath.split("/")[2]
id = backup.backupStorageRefs[0].installPath.split("/")[3]
# compare vm_root_volume & image
cmd = "mkdir /root/%s;" \
"/usr/local/zstack/imagestore/bin/zstcli " \
"-rootca=/var/lib/zstack/imagestorebackupstorage/package/certs/ca.pem " \
"-url=%s:8000 " \
"pull -installpath /root/%s/old.qcow2 %s:%s;" \
"qemu-img compare %s /root/%s/old.qcow2;" % (id, bs.hostname, id, name, id, vol_path, id)
# clean image
result = test_lib.lib_execute_ssh_cmd(host.managementIp, "root", "password", cmd, timeout=300)
if result != "Images are identical.\n":
test_util.test_fail("compare vm_root_volume & image created by backup")
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:28,代码来源:test_backup_volume_ops.py
示例11: test
def test():
global volume_offering_uuid
test_util.test_dsc('Test VM data volume bandwidth QoS by 20MB')
#unit is KB
volume_bandwidth = 5*1024*1024
new_volume_offering = test_lib.lib_create_disk_offering(volume_bandwidth = volume_bandwidth)
volume_offering_uuid = new_volume_offering.uuid
vm = test_stub.create_vm(vm_name = 'vm_volume_qos', disk_offering_uuids = [volume_offering_uuid])
vm.check()
test_obj_dict.add_vm(vm)
vm_inv = vm.get_vm()
cond = res_ops.gen_query_conditions("vmInstanceUuid", '=', vm_inv.uuid)
cond = res_ops.gen_query_conditions("type", '=', 'Data', cond)
volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond)[0].uuid
test_lib.lib_mkfs_for_volume(volume_uuid, vm_inv)
path = '/mnt'
user_name = 'root'
user_password = 'password'
os.system("sshpass -p '%s' ssh %[email protected]%s 'mount /dev/vdb1 %s'"%(user_password, user_name, vm_inv.vmNics[0].ip, path))
vm.check()
test_stub.make_ssh_no_password(vm_inv)
test_stub.install_fio(vm_inv)
test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth, path)
vol_ops.delete_disk_offering(volume_offering_uuid)
test_lib.lib_robot_cleanup(test_obj_dict)
test_util.test_pass('VM data volume QoS Test Pass')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:28,代码来源:test_data_vol_qos.py
示例12: create_vm
def create_vm(vm_creation_option=None, volume_uuids=None, root_disk_uuid=None, \
image_uuid=None, session_uuid=None):
if not vm_creation_option:
instance_offering_uuid = test_lib.lib_get_instance_offering_by_name(os.environ.get('instanceOfferingName_s')).uuid
cond = res_ops.gen_query_conditions('mediaType', '!=', 'ISO')
cond = res_ops.gen_query_conditions('platform', '=', 'Linux', cond)
image_uuid = res_ops.query_resource(res_ops.IMAGE, cond, session_uuid)[0].uuid
l3net_uuid = res_ops.get_resource(res_ops.L3_NETWORK, session_uuid)[0].uuid
vm_creation_option = test_util.VmOption()
vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
vm_creation_option.set_image_uuid(image_uuid)
vm_creation_option.set_l3_uuids([l3net_uuid])
if volume_uuids:
if isinstance(volume_uuids, list):
vm_creation_option.set_data_disk_uuids(volume_uuids)
else:
test_util.test_fail('volume_uuids type: %s is not "list".' % type(volume_uuids))
if root_disk_uuid:
vm_creation_option.set_root_disk_uuid(root_disk_uuid)
if image_uuid:
vm_creation_option.set_image_uuid(image_uuid)
if session_uuid:
vm_creation_option.set_session_uuid(session_uuid)
vm = test_vm.ZstackTestVm()
vm.set_creation_option(vm_creation_option)
vm.create()
return vm
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:32,代码来源:test_stub.py
示例13: test
def test():
global new_image
bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, \
None, fields=['uuid'])
if not bss:
test_util.test_skip("not find available backup storage. Skip test")
if bss[0].type != inventory.CEPH_BACKUP_STORAGE_TYPE:
if hasattr(inventory, 'IMAGE_STORE_BACKUP_STORAGE_TYPE') and bss[0].type != inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE:
test_util.test_skip("not find available imagestore or ceph backup storage. Skip test")
thread = threading.Thread(target=add_image, args=(bss[0].uuid, ))
thread.start()
time.sleep(5)
image_cond = res_ops.gen_query_conditions("status", '=', "Downloading")
image = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \
None, fields=['uuid'])
progress = res_ops.get_task_progress(image[0].uuid)
if int(progress.progress) < 0 or int(progress.progress) > 100:
test_util.test_fail("Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress))
thread.join()
new_image.delete()
if test_lib.lib_get_image_delete_policy() != 'Direct':
new_image.expunge()
test_util.test_pass('Add image Progress Test Success')
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:29,代码来源:test_add_image_progress.py
示例14: 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')
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_maintain_ps_attach_iso.py
示例15: check
def check(self):
import json
import zstacklib.utils.jsonobject as jsonobject
super(zstack_vid_policy_db_checker, self).check()
try:
conditions = res_ops.gen_query_conditions('uuid', '=', self.test_obj.get_vid().uuid)
vid = res_ops.query_resource(res_ops.IAM2_VIRTUAL_ID, conditions)[0]
except Exception as e:
traceback.print_exc(file=sys.stdout)
test_util.test_logger('Check result: [vid Inventory uuid:] %s does not exist in database.' % self.test_obj.get_vid().uuid)
return self.judge(False)
conditions = res_ops.gen_query_conditions('virtualIDs.uuid', '=', self.test_obj.get_vid().uuid)
role_statements = res_ops.query_resource(res_ops.ROLE, conditions)[0].statements
for state_lst in self.test_obj.get_vid_statements()[0]['actions']:
test_result = False
for statement in role_statements:
atatement_dict = json.loads(jsonobject.dumps(statement))['statement']
for lst in atatement_dict['actions']:
if lst == state_lst:
test_result = True
if test_result == False:
test_util.test_logger('Check result: [vid Inventory statement:] does not exist in database.')
return self.judge(False)
return self.judge(True)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:25,代码来源:zstack_db_checker.py
示例16: path
def path():
cond = res_ops.gen_query_conditions('state', '=', "Enabled")
cond = res_ops.gen_query_conditions('status', '=', "Connected", cond)
ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)
cond_imagestore = res_ops.gen_query_conditions('type', '=', "ImageStoreBackupStorage", cond)
cond_ceph = res_ops.gen_query_conditions('type', '=', "Ceph", cond)
imagestore = res_ops.query_resource(res_ops.BACKUP_STORAGE, cond_imagestore)
ceph_bs = res_ops.query_resource(res_ops.BACKUP_STORAGE, cond_ceph)
san_ps = [ps.uuid for ps in ps_inv if ps.type == 'SharedBlock']
ceph_ps = [ps.uuid for ps in ps_inv if ps.type == 'Ceph']
san_vms = ['utility_vm_for_robot_test' + '-' + ps.name for ps in ps_inv if ps.type == 'SharedBlock']
ceph_vms = ['utility_vm_for_robot_test' + '-' + ps.name for ps in ps_inv if ps.type == 'Ceph']
if san_ps and ceph_ps:
return dict(initial_formation="template3",
path_list=[[TestAction.create_volume, "volume1", "=ps_uuid::%s" % san_ps[0]],
[TestAction.attach_volume, san_vms[-1], "volume1"],
[TestAction.resize_volume, san_vms[-1], 5*1024*1024],
[TestAction.clone_vm, san_vms[-1], "vm2", "=full"],
[TestAction.detach_volume, "volume1"],
[TestAction.attach_volume, ceph_vms[0], "volume1"],
[TestAction.stop_vm, san_vms[-1]],
[TestAction.reinit_vm, san_vms[-1]],
[TestAction.start_vm, san_vms[-1]],
[TestAction.clone_vm, ceph_vms[0], "vm3"],
[TestAction.resize_volume, ceph_vms[0], 5*1024*1024],
[TestAction.detach_volume, "volume1"],
[TestAction.create_image_from_volume, ceph_vms[0], 'image_created_from_%s' % ceph_vms[0], "=bs_uuid::%s" % imagestore[0].uuid],
[TestAction.create_vm_by_image, 'image_created_from_%s' % ceph_vms[0], 'qcow2', 'vm4', '=ps_uuid::%s' % random.choice(san_ps)],
[TestAction.stop_vm, 'vm4'],
[TestAction.ps_migrage_vm, 'vm4'],
[TestAction.attach_volume, 'vm4', "volume1"]])
else:
return dict(initial_formation="template3", path_list=[])
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:34,代码来源:ceph_san_path1.py
示例17: test
def test():
test_util.test_dsc('Test storage capacity when using expunge vm')
if conf_ops.get_global_config_value('vm', 'deletionPolicy') != 'Delay' :
test_util.test_skip('vm delete_policy is not Delay, skip test.')
return
zone_uuid = res_ops.query_resource(res_ops.ZONE)[0].uuid
cond = res_ops.gen_query_conditions('state', '=', 'Enabled')
cond = res_ops.gen_query_conditions('status', '=', 'Connected', cond)
host = res_ops.query_resource_with_num(res_ops.HOST, cond, limit = 1)
if not host:
test_util.test_skip('No Enabled/Connected host was found, skip test.' )
return True
ps = res_ops.query_resource_with_num(res_ops.PRIMARY_STORAGE, cond, limit = 1)
if not ps:
test_util.test_skip('No Enabled/Connected primary storage was found, skip test.' )
return True
host = host[0]
ps = ps[0]
host_res = vol_ops.get_local_storage_capacity(host.uuid, ps.uuid)[0]
avail_cap = host_res.availableCapacity
vm = test_stub.create_vm(vm_name = 'basic-test-vm', host_uuid = host.uuid)
test_obj_dict.add_vm(vm)
time.sleep(1)
vm.destroy()
vm.expunge()
host_res2 = vol_ops.get_local_storage_capacity(host.uuid, ps.uuid)[0]
avail_cap2 = host_res.availableCapacity
if avail_cap != avail_cap2:
test_util.test_fail('PS capacity is not same after create/expunge vm on host: %s. Capacity before create vm: %s, after expunge vm: %s ' % (host.uuid, avail_cap, avail_cap2))
test_util.test_pass('Expunge VM Test Success')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:35,代码来源:test_expunge_vm_ps_capacity2.py
示例18: get_bs
def get_bs(self):
if self.ceph_bs_name:
conditions = res_ops.gen_query_conditions('name', '=', self.ceph_bs_name)
self.ceph_bs = res_ops.query_resource(res_ops.BACKUP_STORAGE, conditions)[0]
if self.ceph_bs_name_2:
conditions = res_ops.gen_query_conditions('name', '=', self.ceph_bs_name_2)
self.ceph_bs_2 = res_ops.query_resource(res_ops.BACKUP_STORAGE, conditions)[0]
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:7,代码来源:test_stub.py
示例19: test
def test():
global price
#1.create root volume price with systemtags
bill_rootvolume = test_lib.RootVolumeBilling()
time_unit = random.choice(time_unit_dict)
price = str(random.randint(0,9999))
resource_unit = random.choice(resource_unit_dict.keys())
bill_rootvolume.set_timeUnit(time_unit)
bill_rootvolume.set_price(price)
bill_rootvolume.set_resourceUnit(resource_unit)
bill_rootvolume.set_price_system_tags(price_system_tags)
test_util.test_logger("create root volume price with systemtags")
price = bill_rootvolume.create_resource_type()
if not price:
test_util.test_fail("fail: create rootvolume price")
else:
test_util.test_logger("success: create rootvolume price %s" % price.uuid)
#2.query root volume price
cond = res_ops.gen_query_conditions('uuid', '=', price.uuid)
price_query = bill_ops.query_resource_price(cond)[0]
if price_query.uuid == price.uuid:
test_util.test_logger("success: query rootvolume price %s" % price_query.uuid)
else:
test_util.test_fail("fail: query rootvolume price %s" % price.uuid)
#3.delete root volume price
delete_result = bill_ops.delete_resource_price(price.uuid)
cond = res_ops.gen_query_conditions('uuid', '=', price.uuid)
#delete check,because delete API always return success
delete_check = bill_ops.query_resource_price(cond)
if delete_check:
test_util.test_fail("fail: delete rootvolume price %s" % price.uuid)
else:
test_util.test_logger("success: delete rootvolume price %s" % price_query.uuid)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:35,代码来源:test_root_volume_price_with_systemtags_life_cycle.py
示例20: check
def check(self):
super(zstack_kvm_sg_db_exist_checker, self).check()
sg_list = self.test_obj.get_sg_list_by_nic(self.nic_uuid)
if not sg_list:
conditions = res_ops.gen_query_conditions('vmNicUuid', '=', self.nic_uuid)
nic_sg = res_ops.query_resource(res_ops.VM_SECURITY_GROUP, conditions)
if not nic_sg:
test_util.test_logger('Check result: No [Security Group] is found in database for [nic:] %s.' % self.nic_uuid)
return self.judge(False)
else:
test_util.test_warn('Check result: [Security Group] is found in database for [nic:] %s. It is not consistent with test_sg record.' % self.nic_uuid)
return self.judge(True)
for test_sg in sg_list:
try:
conditions = res_ops.gen_query_conditions('uuid', '=', test_sg.security_group.uuid)
sg = res_ops.query_resource(res_ops.SECURITY_GROUP, conditions)[0]
except Exception as e:
traceback.print_exc(file=sys.stdout)
test_util.test_logger('Check result: [Security Group Inventory uuid:] %s does not exist in database.' % test_sg.security_group.uuid)
return self.judge(False)
test_util.test_logger('Check result: [SecurityGroup Inventory uuid:] %s exist in database.' % sg.uuid)
return self.judge(True)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:25,代码来源:zstack_kvm_security_group_checker.py
注:本文中的zstackwoodpecker.operations.resource_operations.gen_query_conditions函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论