本文整理汇总了Python中zstackwoodpecker.operations.config_operations.change_global_config函数的典型用法代码示例。如果您正苦于以下问题:Python change_global_config函数的具体用法?Python change_global_config怎么用?Python change_global_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了change_global_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: error_cleanup
def error_cleanup():
if session_to:
con_ops.change_global_config('identity', 'session.timeout', session_to, session_uuid)
if session_mc:
con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc, session_uuid)
if session_uuid:
acc_ops.logout(session_uuid)
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:7,代码来源:test_crt_vm_with_3_vr_nics_by_max_threads.py
示例2: test
def test():
global session_to
global session_mc
session_to = con_ops.change_global_config('identity', 'session.timeout', '720000')
session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000')
test_util.test_dsc('Create test vm as utility vm')
vm = test_stub.create_vlan_vm()
test_obj_dict.add_vm(vm)
#use root volume to skip add_checking_point
test_util.test_dsc('Use root volume for snapshot testing')
root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
root_volume = zstack_volume_header.ZstackTestVolume()
root_volume.set_volume(root_volume_inv)
root_volume.set_state(volume_header.ATTACHED)
root_volume.set_target_vm(vm)
test_obj_dict.add_volume(root_volume)
vm.check()
snapshots = test_obj_dict.get_volume_snapshot(root_volume.get_volume().uuid)
snapshots.set_utility_vm(vm)
ori_num = 100
index = 1
while index < 101:
thread = threading.Thread(target=create_snapshot, args=(snapshots, index,))
thread.start()
index += 1
while threading.activeCount() > 1:
time.sleep(0.1)
#snapshot.check() doesn't work for root volume
#snapshots.check()
#check if snapshot exists in install_path
ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
if ps.type == inventory.NFS_PRIMARY_STORAGE_TYPE or ps.type == inventory.LOCAL_STORAGE_TYPE:
host = test_lib.lib_get_vm_host(vm.get_vm())
for snapshot in snapshots.get_snapshot_list():
snapshot_inv = snapshot.get_snapshot()
sp_ps_install_path = snapshot_inv.primaryStorageInstallPath
if test_lib.lib_check_file_exist(host, sp_ps_install_path):
test_util.test_logger('Check result: snapshot %s is found in host %s in path %s' % (snapshot_inv.name, host.managementIp, sp_ps_install_path))
else:
test_lib.lib_robot_cleanup(test_obj_dict)
test_util.test_fail('Check result: snapshot %s is not found in host %s in path %s' % (snapshot_inv.name, host.managementIp, sp_ps_install_path))
else:
test_util.test_logger('Skip check file install path for %s primary storage' % (ps.type))
cond = res_ops.gen_query_conditions('volumeUuid', '=', root_volume.get_volume().uuid)
sps_num = res_ops.query_resource_count(res_ops.VOLUME_SNAPSHOT, cond)
if sps_num != ori_num:
test_util.test_fail('Create %d snapshots, but only %d snapshots were successfully created' % (ori_num, sps_num))
try:
test_lib.lib_robot_cleanup(test_obj_dict)
except:
test_lib.test_logger('Delete VM may timeout')
test_util.test_pass('Test create 100 snapshots simultaneously success')
示例3: error_cleanup
def error_cleanup():
global test_obj_dict
global test_file_des
global ct_original
con_ops.change_global_config('vm', 'cleanTraffic', ct_original)
os.system('rm -f %s' % test_file_des)
test_lib.lib_error_cleanup(test_obj_dict)
示例4: delete_all_volumes
def delete_all_volumes(thread_threshold = 1000):
session_uuid = acc_ops.login_as_admin()
session_to = con_ops.change_global_config('identity', 'session.timeout', '720000')
session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000')
delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct')
expunge_time = test_lib.lib_set_expunge_time('volume', 1)
cond = res_ops.gen_query_conditions('status', '!=', 'Deleted')
num = res_ops.query_resource_count(res_ops.VOLUME, cond)
if num <= thread_threshold:
volumes = res_ops.query_resource(res_ops.VOLUME, cond)
do_delete_volumes(volumes, thread_threshold)
else:
start = 0
limit = thread_threshold - 1
curr_num = start
volumes = []
while curr_num < num:
volumes_temp = res_ops.query_resource_fields(res_ops.VOLUME, \
cond, None, ['uuid'], start, limit)
volumes.extend(volumes_temp)
curr_num += limit
start += limit
do_delete_volumes(volumes, thread_threshold)
test_lib.lib_set_delete_policy('volume', delete_policy)
test_lib.lib_set_expunge_time('volume', expunge_time)
test_util.test_logger('Volumes destroy Success. Destroy %d Volumes.' % num)
示例5: __init__
def __init__(self, get_host_con = None, justify_con = None):
self.exc_info = []
self.hosts = []
self.i = 0
self.session_uuid = None
self.session_to = None
self.session_mc = None
self.host_num = os.environ.get('ZSTACK_TEST_NUM')
self.thread_threshold = os.environ.get('ZSTACK_THREAD_THRESHOLD')
self.get_host_con = get_host_con
self.justify_con = justify_con
if not self.host_num:
self.host_num = 0
else:
self.host_num = int(self.host_num)
if not self.thread_threshold:
self.thread_threshold = 1000
else:
self.thread_threshold = int(self.thread_threshold)
self.hosts = res_ops.query_resource(res_ops.HOST, self.get_host_con)
if self.host_num > len(self.hosts):
self.host_num = len(self.hosts)
test_util.test_warn('ZSTACK_TEST_NUM is forcibly set as %d\n' % len(self.hosts))
self.session_to = con_ops.change_global_config('identity', 'session.timeout',\
'720000', self.session_uuid)
self.session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent',\
'10000', self.session_uuid)
self.session_uuid = acc_ops.login_as_admin()
示例6: error_cleanup
def error_cleanup():
if session_to:
con_ops.change_global_config("identity", "session.timeout", session_to)
if session_mc:
con_ops.change_global_config("identity", "session.maxConcurrent", session_mc)
if session_uuid:
acc_ops.logout(session_uuid)
示例7: test
def test():
test_util.test_dsc("set global config anti-spoofing value to true ")
cfg_ops.change_global_config(category="vm", name="cleanTraffic", value="true")
test_util.test_dsc("create vpc vrouter and attach vpc l3 to vpc")
for vpc_name in vpc_name_list:
vr_list.append(test_stub.create_vpc_vrouter(vpc_name))
for vr, l3_list in izip(vr_list, vpc_l3_list):
test_stub.attach_l3_to_vpc_vr(vr, l3_list)
test_util.test_dsc("create two vm, vm1 in l3 {}, vm2 in l3 {}".format(VLAN1_NAME, VLAN2_NAME))
vm1 = test_stub.create_vm_with_random_offering(vm_name='vpc_vm_{}'.format(VLAN1_NAME), l3_name=VLAN1_NAME)
test_obj_dict.add_vm(vm1)
vm1.check()
vm2 = test_stub.create_vm_with_random_offering(vm_name='vpc_vm_{}'.format(VLAN2_NAME), l3_name=VLAN2_NAME)
test_obj_dict.add_vm(vm2)
vm2.check()
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr_list[0].inv)
test_util.test_dsc("Create vip")
vip = test_stub.create_vip('vip1', vr_pub_nic.l3NetworkUuid)
test_obj_dict.add_vip(vip)
test_util.test_dsc("Create eip")
eip = test_stub.create_eip('eip1', vip_uuid=vip.get_vip().uuid)
vip.attach_eip(eip)
vip.check()
test_util.test_dsc("set global config anti-spoofing value to default value false ")
cfg_ops.change_global_config(category="vm", name="cleanTraffic", value="false")
test_lib.lib_error_cleanup(test_obj_dict)
test_stub.remove_all_vpc_vrouter()
示例8: test
def test():
#Enable twofa and check login
password = 'b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86'
session_uuid = acc_ops.login_as_admin()
twofa_enabled = conf_ops.get_global_config_value('twofa', 'twofa.enable')
if twofa_enabled == 'false':
conf_ops.change_global_config('twofa', 'twofa.enable', 'true')
twofa = acc_ops.get_twofa_auth_secret('admin', password, session_uuid = session_uuid)
secret = twofa.secret
twofa_status = twofa.status
if twofa_status != 'NewCreated':
test_util.test_fail("The twofa auth secret statue should be 'NewCreated' but it's %s" %twofa_status)
security_code = test_stub.get_security_code(secret)
session1_uuid = acc_ops.login_by_account('admin', password, system_tags=['twofatoken::%s' %security_code])
if session1_uuid != None:
test_util.test_logger("Enable twofa and login with security code passed")
twofa_status = acc_ops.get_twofa_auth_secret('admin', password, session_uuid = session_uuid).status
if twofa_status != 'Logined':
test_util.test_fail("The twofa auth secret statue should be 'Logined' but it's %s" %twofa_status)
#Disable twofa and check login again
conf_ops.change_global_config('twofa', 'twofa.enable', 'false', session_uuid = session_uuid)
session2_uuid = acc_ops.login_as_admin()
if session2_uuid != None:
test_util.test_pass("Disable twofa and login without security code passed")
test_util.test_fail("Fail to login without security code after twofa disabled")
示例9: delete_all_volumes
def delete_all_volumes(thread_threshold=1000):
session_uuid = acc_ops.login_as_admin()
session_to = con_ops.change_global_config("identity", "session.timeout", "720000")
session_mc = con_ops.change_global_config("identity", "session.maxConcurrent", "10000")
delete_policy = test_lib.lib_set_delete_policy("volume", "Direct")
expunge_time = test_lib.lib_set_expunge_time("volume", 1)
cond = res_ops.gen_query_conditions("status", "!=", "Deleted")
num = res_ops.query_resource_count(res_ops.VOLUME, cond)
if num <= thread_threshold:
volumes = res_ops.query_resource(res_ops.VOLUME, cond)
do_delete_volumes(volumes, thread_threshold)
else:
start = 0
limit = thread_threshold - 1
curr_num = start
volumes = []
while curr_num < num:
volumes_temp = res_ops.query_resource_fields(res_ops.VOLUME, cond, None, ["uuid"], start, limit)
volumes.extend(volumes_temp)
curr_num += limit
start += limit
do_delete_volumes(volumes, thread_threshold)
test_lib.lib_set_delete_policy("volume", delete_policy)
test_lib.lib_set_expunge_time("volume", expunge_time)
test_util.test_logger("Volumes destroy Success. Destroy %d Volumes." % num)
示例10: 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')
示例11: env_recover
def env_recover():
config_ops.change_global_config('ha','enable', 'true')
global origin_value
config_ops.change_global_config('ha','neverStopVm.scan.interval', origin_value)
global vm
if vm != None:
vm.destroy()
vm.expunge()
示例12: error_cleanup
def error_cleanup():
global eip_snatInboundTraffic_default_value
global pf_snatInboundTraffic_default_value
conf_ops.change_global_config('eip', 'snatInboundTraffic', \
eip_snatInboundTraffic_default_value )
conf_ops.change_global_config('portForwarding', 'snatInboundTraffic', \
pf_snatInboundTraffic_default_value)
test_lib.lib_error_cleanup(test_obj_dict)
示例13: error_cleanup
def error_cleanup():
global test_obj_dict
global origin_interval
global bs_type
if bs_type == 'Ceph':
conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval', origin_interval)
test_lib.lib_error_cleanup(test_obj_dict)
示例14: env_recover
def env_recover():
global vm
if vm != None:
vm.destroy()
vm.expunge()
global live_migration
if ps_type == "Local":
config_ops.change_global_config('localStoragePrimaryStorage','liveMigrationWithStorage.allow', live_migration)
示例15: test
def test():
global origin_interval
global bs_type
test_util.test_dsc('Create test vm and check')
bs = res_ops.query_resource(res_ops.BACKUP_STORAGE)
for i in bs:
if i.type == 'AliyunEBS':
test_util.test_skip('Skip test on AliyunEBS')
vm1 = test_stub.create_vlan_vm()
#Without this checking, the image (created later) might be not able to get a DHCP IP, when using to create a new vm.
vm1.check()
test_obj_dict.add_vm(vm1)
vm1.stop()
image_creation_option = test_util.ImageOption()
backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm1.vm)
image_creation_option.set_backup_storage_uuid_list([backup_storage_list[0].uuid])
image_creation_option.set_root_volume_uuid(vm1.vm.rootVolumeUuid)
image_creation_option.set_name('test_create_image_template')
bs_type = backup_storage_list[0].type
if bs_type == 'Ceph':
origin_interval = conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval', '1')
image = test_image.ZstackTestImage()
image.set_creation_option(image_creation_option)
image.create()
test_obj_dict.add_image(image)
image.check()
test_util.test_dsc('Use new created Image to create a VM')
new_img_uuid = image.image.uuid
vm_creation_option = vm1.get_creation_option()
vm_creation_option.set_image_uuid(new_img_uuid)
vm2 = test_vm.ZstackTestVm()
vm2.set_creation_option(vm_creation_option)
vm2.create()
test_obj_dict.add_vm(vm2)
vm2.check()
vm1.start()
vm1.check()
vm2.destroy()
vm1.destroy()
image.delete()
if bs_type == 'Ceph':
time.sleep(60)
image.check()
if bs_type == 'Ceph':
conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval', origin_interval)
test_util.test_pass('Create Image Template Test Success')