本文整理汇总了Python中zstackwoodpecker.test_lib.lib_find_vr_by_l3_uuid函数的典型用法代码示例。如果您正苦于以下问题:Python lib_find_vr_by_l3_uuid函数的具体用法?Python lib_find_vr_by_l3_uuid怎么用?Python lib_find_vr_by_l3_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lib_find_vr_by_l3_uuid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
def test():
global session_uuid
session_uuid = acc_ops.login_as_admin()
l3_1_name = os.environ.get('l3VlanNetworkName1')
l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
#create VRs.
vrs = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)
if not vrs:
vm = test_stub.create_vlan_vm(l3_name=l3_1_name)
vm.destroy()
vr1 = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0]
else:
vr1 = vrs[0]
vm_ops.stop_vm(vr1.uuid)
if test_lib.lib_get_ha_enable() != 'true' or vr1.applianceVmType != "vrouter":
vm_ops.start_vm(vr1.uuid)
vr1_mgmt_ip = test_lib.lib_find_vr_mgmt_ip(vr1)
if not test_lib.lib_wait_target_up(vr1_mgmt_ip, '7272', 120):
test_util.test_fail('vr: %s is not startup in 120 seconds. Fail to reboot it. ' % vr1.uuid)
timeout = time.time() + 60
while time.time() < timeout:
cond = res_ops.gen_query_conditions('uuid', '=', vr1.uuid)
vms = res_ops.query_resource(res_ops.VM_INSTANCE, cond)
if vms[0].status == 'Connected':
test_util.test_pass('Test Reconnect VR VM start VRs success')
time.sleep(1)
test_util.test_fail('VR VM: %s is not connected within 60 seconds' % vr1.uuid)
示例2: test
def test():
test_util.test_dsc('Create test vm with EIP and check.')
vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
test_obj_dict.add_vm(vm)
l3_name = os.environ.get('l3VlanNetworkName1')
vr1_l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
vrs = test_lib.lib_find_vr_by_l3_uuid(vr1_l3_uuid)
temp_vm1 = None
if not vrs:
#create temp_vm1 for getting vlan1's vr for test pf_vm portforwarding
temp_vm1 = test_stub.create_vlan_vm()
test_obj_dict.add_vm(temp_vm1)
vr1 = test_lib.lib_find_vr_by_vm(temp_vm1.vm)[0]
else:
vr1 = vrs[0]
l3_name = os.environ.get('l3NoVlanNetworkName1')
vr2_l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
vrs = test_lib.lib_find_vr_by_l3_uuid(vr2_l3_uuid)
temp_vm2 = None
if not vrs:
#create temp_vm2 for getting novlan's vr for test pf_vm portforwarding
temp_vm2 = test_stub.create_user_vlan_vm()
test_obj_dict.add_vm(temp_vm2)
vr2 = test_lib.lib_find_vr_by_vm(temp_vm2.vm)[0]
else:
vr2 = vrs[0]
#we do not need temp_vm1 and temp_vm2, since we just use their VRs.
if temp_vm1:
temp_vm1.destroy()
test_obj_dict.rm_vm(temp_vm1)
if temp_vm2:
temp_vm2.destroy()
test_obj_dict.rm_vm(temp_vm2)
vm_nic = vm.vm.vmNics[0]
vm_nic_uuid = vm_nic.uuid
pri_l3_uuid = vm_nic.l3NetworkUuid
vr = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid)[0]
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr)
l3_uuid = vr_pub_nic.l3NetworkUuid
vip = test_stub.create_vip('create_eip_test', l3_uuid)
test_obj_dict.add_vip(vip)
eip = test_stub.create_eip('create eip test', vip_uuid=vip.get_vip().uuid, vnic_uuid=vm_nic_uuid, vm_obj=vm)
vip.attach_eip(eip)
vm.check()
vip.check()
vm.destroy()
test_obj_dict.rm_vm(vm)
vip.check()
eip.delete()
vip.delete()
test_obj_dict.rm_vip(vip)
test_util.test_pass('Create EIP for VM Success')
示例3: test
def test():
global mevoco1_ip
global mevoco2_ip
global ipsec1
global ipsec2
mevoco1_ip = os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP']
mevoco2_ip = os.environ['secondZStackMnIp']
test_util.test_dsc('Create test vm in mevoco1')
vm1 = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
test_obj_dict1.add_vm(vm1)
vm1.check()
pri_l3_uuid1 = vm1.vm.vmNics[0].l3NetworkUuid
vr1 = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid1)[0]
l3_uuid1 = test_lib.lib_find_vr_pub_nic(vr1).l3NetworkUuid
vip1 = test_stub.create_vip('ipsec1_vip', l3_uuid1)
os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco2_ip
test_util.test_dsc('Create test vm in mevoco2')
vm2 = test_stub.create_vlan_vm(os.environ.get('l3VlanDNATNetworkName'))
test_obj_dict2.add_vm(vm2)
vm2.check()
pri_l3_uuid2 = vm2.vm.vmNics[0].l3NetworkUuid
vr2 = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid2)[0]
l3_uuid2 = test_lib.lib_find_vr_pub_nic(vr2).l3NetworkUuid
vip2 = test_stub.create_vip('ipsec2_vip', l3_uuid2)
os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco1_ip
test_util.test_dsc('Create ipsec in mevoco1')
ipsec1 = ipsec_ops.create_ipsec_connection('ipsec1', pri_l3_uuid1, vip2.get_vip().ip, '123456', vip1.get_vip().uuid, [os.environ['secondZStackCidrs']])
os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco2_ip
test_util.test_dsc('Create ipsec in mevoco2')
ipsec2 = ipsec_ops.create_ipsec_connection('ipsec2', pri_l3_uuid2, vip1.get_vip().ip, '123456', vip2.get_vip().uuid, [os.environ['firstZStackCidrs']])
os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco1_ip
if not test_lib.lib_check_ping(vm1.vm, vm2.vm.vmNics[0].ip):
test_util.test_fail('vm in mevoco1[MN:%s] could not connect to vm in mevoco2[MN:%s]' % (mevoco1_ip, mevoco2_ip))
os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco2_ip
if not test_lib.lib_check_ping(vm2.vm, vm1.vm.vmNics[0].ip):
test_util.test_fail('vm in mevoco1[MN:%s] could not connect to vm in mevoco2[MN:%s]' % (mevoco2_ip, mevoco1_ip))
os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco1_ip
vip1.delete()
if test_lib.lib_check_ping(vm1.vm, vm2.vm.vmNics[0].ip, no_exception=True):
test_util.test_fail('vm in mevoco1[MN:%s] could still connect to vm in mevoco2[MN:%s] after Ipsec is deleted' % (mevoco1_ip, mevoco2_ip))
os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco2_ip
if test_lib.lib_check_ping(vm2.vm, vm1.vm.vmNics[0].ip, no_exception=True):
test_util.test_fail('vm in mevoco2[MN:%s] could still connect to vm in mevoco1[MN:%s] after Ipsec is deleted' % (mevoco2_ip, mevoco1_ip))
os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco1_ip
test_lib.lib_error_cleanup(test_obj_dict1)
os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco2_ip
ipsec_ops.delete_ipsec_connection(ipsec2.uuid)
test_lib.lib_error_cleanup(test_obj_dict2)
os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = mevoco1_ip
test_util.test_pass('Create Ipsec Success')
示例4: test
def test():
test_util.test_dsc('Create test vm with EIP and check.')
vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
test_obj_dict.add_vm(vm)
vm2 = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
test_obj_dict.add_vm(vm2)
l3_name = os.environ.get('l3VlanNetworkName1')
vr1_l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
vrs = test_lib.lib_find_vr_by_l3_uuid(vr1_l3_uuid)
temp_vm1 = None
if not vrs:
#create temp_vm1 for getting vlan1's vr for test pf_vm portforwarding
temp_vm1 = test_stub.create_vlan_vm()
test_obj_dict.add_vm(temp_vm1)
vr1 = test_lib.lib_find_vr_by_vm(temp_vm1.vm)[0]
else:
vr1 = vrs[0]
#we do not need temp_vm1 and temp_vm2, since we just use their VRs.
if temp_vm1:
temp_vm1.destroy()
test_obj_dict.rm_vm(temp_vm1)
vm_nic = vm.vm.vmNics[0]
vm2_nic = vm2.vm.vmNics[0]
vm_nic_uuid = vm_nic.uuid
pri_l3_uuid = vm_nic.l3NetworkUuid
vr = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid)[0]
if vr.applianceVmType == "VirtualRouter":
test_util.test_skip("This test only for vrouter network")
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr)
l3_uuid = vr_pub_nic.l3NetworkUuid
vip = test_stub.create_vip('create_eip_test', l3_uuid)
test_obj_dict.add_vip(vip)
eip = test_stub.create_eip('create eip test', vip_uuid=vip.get_vip().uuid, vnic_uuid=vm_nic_uuid, vm_obj=vm)
vip.attach_eip(eip)
vm.check()
vm2.check()
test_stub.make_ssh_no_password(vm2.get_vm())
vm_ip = vm_nic.ip
vm2_ip = vm2_nic.ip
ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null'
cmd = 'ping -c 8 %s' % (eip.get_eip().vipIp)
shell.call("%s %s %s" % (ssh_cmd, vm2_ip, cmd))
cmd = '''"echo quit | timeout 4 telnet %s 22|grep 'Escape character'"''' % (eip.get_eip().vipIp)
shell.call("%s %s %s" % (ssh_cmd, vm2_ip, cmd))
vm.destroy()
test_obj_dict.rm_vm(vm)
vip.check()
eip.delete()
vip.delete()
test_obj_dict.rm_vip(vip)
test_util.test_pass('Create EIP for VM Success')
示例5: test
def test():
global l2_net_uuid
global cluster_uuid
global vm
cluster1 = res_ops.get_resource(res_ops.CLUSTER)[0]
cluster2 = res_ops.get_resource(res_ops.CLUSTER)[1]
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('l3VlanNetworkName1')
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
l2_net_uuid = test_lib.lib_get_l3_by_name(l3_name).l2NetworkUuid
l2_net_type = res_ops.get_resource(res_ops.L2_NETWORK, uuid=l2_net_uuid)[0].type
test_util.test_logger("[email protected]@:%s" %(l2_net_type))
if l2_net_type == "VxlanNetwork":
test_util.test_skip("Vxlan network not support detach l2 network, therefore, skip the test")
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_cluster_uuid(cluster1.uuid)
vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
vm_creation_option.set_name('multicluster_basic_vm')
vm = test_vm_header.ZstackTestVm()
vm.set_creation_option(vm_creation_option)
vm.create()
vm2 = test_vm_header.ZstackTestVm()
vm_creation_option.set_cluster_uuid(cluster2.uuid)
vm2.set_creation_option(vm_creation_option)
vm2.create()
vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid)
if len(vrs) == 0:
test_util.test_skip("skip the test for non vr")
vr = vrs[0]
cluster_uuid = vr.clusterUuid
net_ops.detach_l2(l2_net_uuid, cluster_uuid)
vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid)
if len(vrs) == 0:
test_util.test_skip("skip the test for non vr")
vr = vrs[0]
if vr.clusterUuid == cluster_uuid:
test_util.test_logger('vr is expected to migrate to another cluster')
vm.destroy()
vm2.destroy()
net_ops.attach_l2(l2_net_uuid, cluster_uuid)
test_util.test_pass('Create detach l2 from clsuter vr migrate Test Success')
示例6: test
def test():
pf_vm = test_stub.create_dnat_vm()
test_obj_dict.add_vm(pf_vm)
vm_nic = pf_vm.vm.vmNics[0]
vm_nic_uuid = vm_nic.uuid
pri_l3_uuid = vm_nic.l3NetworkUuid
vr = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid)[0]
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr)
vr_pub_ip = vr_pub_nic.ip
l3_uuid = vr_pub_nic.l3NetworkUuid
vip = test_stub.create_vip('delete_vip_before_attach_PF_to_VM', l3_uuid)
test_obj_dict.add_vip(vip)
vip_uuid = vip.get_vip().uuid
#pf_creation_opt = PfRule.generate_pf_rule_option(vr1_pub_ip, protocol=inventory.TCP, vip_target_rule=Port.rule1_ports, private_target_rule=Port.rule1_ports)
pf_creation_opt = PfRule.generate_pf_rule_option(vr_pub_ip, protocol=inventory.TCP, vip_target_rule=Port.rule1_ports, private_target_rule=Port.rule1_ports, vip_uuid=vip_uuid)
test_pf = zstack_pf_header.ZstackTestPortForwarding()
test_pf.set_creation_option(pf_creation_opt)
test_pf.create(pf_vm)
vip.attach_pf(test_pf)
vip.check()
vip.delete()
test_obj_dict.rm_vip(vip)
pf_vm.destroy()
test_obj_dict.rm_vm(pf_vm)
test_util.test_pass("Test Delete VIP before attach Port Forwarding to any VM Successfully")
示例7: test
def test():
global test_obj_dict
global ps_uuid
global host_uuid
global vr_uuid
allow_ps_list = [inventory.CEPH_PRIMARY_STORAGE_TYPE, "SharedBlock"]
test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)
test_util.test_dsc('Create test vm and check')
bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, \
None)
if not bss:
test_util.test_skip("not find available backup storage. Skip test")
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.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')
test_stub.disable_all_pss()
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.delete()
volume.check()
volume.expunge()
volume.check()
#ps_ops.change_primary_storage_state(ps_uuid, 'enable')
test_stub.enable_all_pss()
host_ops.reconnect_host(host_uuid)
vm_ops.reconnect_vr(vr_uuid)
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 disable mode Test Success')
示例8: test
def test():
pf_vm1 = test_stub.create_dnat_vm()
test_obj_dict.add_vm(pf_vm1)
l3_name = os.environ.get('l3VlanNetworkName1')
vr1 = test_stub.create_vr_vm(test_obj_dict, l3_name)
vr1_pub_ip = test_lib.lib_find_vr_pub_ip(vr1)
pf_vm1.check()
vm_nic1 = pf_vm1.vm.vmNics[0]
vm_nic_uuid1 = vm_nic1.uuid
pri_l3_uuid = vm_nic1.l3NetworkUuid
vr = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid)[0]
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr)
l3_uuid = vr_pub_nic.l3NetworkUuid
vip = test_stub.create_vip('pf_attach_test', l3_uuid)
test_obj_dict.add_vip(vip)
vip_uuid = vip.get_vip().uuid
test_util.test_dsc("attach, detach and delete pf for many times")
for i in range(1, 451):
test_util.test_logger('round %s' % (i))
starttime = datetime.datetime.now()
pf_creation_opt1 = PfRule.generate_pf_rule_option(vr1_pub_ip, protocol=inventory.TCP, vip_target_rule=Port.rule5_ports, private_target_rule=Port.rule5_ports, vip_uuid=vip_uuid)
pf_creation_opt1.set_vip_ports(i, i)
pf_creation_opt1.set_private_ports(i, i)
test_pf1 = zstack_pf_header.ZstackTestPortForwarding()
test_pf1.set_creation_option(pf_creation_opt1)
test_pf1.create()
vip.attach_pf(test_pf1)
if i < 151:
test_pf1.attach(vm_nic_uuid1, pf_vm1)
pf_dict[i] = test_pf1.get_port_forwarding().uuid
elif i < 301:
test_pf1.attach(vm_nic_uuid1, pf_vm1)
test_pf1.detach()
pf_dict[i] = test_pf1.get_port_forwarding().uuid
else :
test_pf1.attach(vm_nic_uuid1, pf_vm1)
test_pf1.detach()
test_pf1.delete()
endtime = datetime.datetime.now()
optime = (endtime - starttime).seconds
test_util.test_dsc("round %s, pf operation time: %s" % (i, optime))
test_util.test_logger("the pf operation time is %s seconds" % optime)
if optime > 240:
test_util.test_fail("the pf operation time is %s seconds, more than 240 seconds" % optime)
vip.delete()
test_obj_dict.rm_vip(vip)
pf_vm1.destroy()
test_obj_dict.rm_vm(pf_vm1)
for j in pf_dict:
net_ops.delete_port_forwarding(pf_dict[j])
test_util.test_pass("Test Port Forwarding Attach/Detach Successfully")
示例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')
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()
#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')
test_stub.disable_all_pss()
if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, '22', 90):
test_util.test_fail('VM is expected to runnning when PS change to disable state')
vm.set_state(vm_header.RUNNING)
vm.check()
vm.suspend()
vm.check()
#ps_ops.change_primary_storage_state(ps_uuid, 'enable')
test_stub.enable_all_pss()
host_ops.reconnect_host(host_uuid)
vm_ops.reconnect_vr(vr_uuid)
test_util.test_pass('PS disable mode Test Success')
示例10: check_eip_denied_tcp
def check_eip_denied_tcp(self):
if not self.denied_vr_ip:
test_util.test_logger('No denied vm for eip testing. Skip EIP deined TCP checking')
return True
vip = self.test_obj.get_vip()
vip_ip = vip.ip
eip_obj = self.test_obj.get_eip()
eip = eip_obj.get_eip()
if not eip_obj.get_target_vm():
#eip is not attached yet. use vip's VR vm
l3_uuid = self.test_obj.get_vip().l3NetworkUuid
target_vm = test_lib.lib_find_vr_by_l3_uuid(l3_uuid)[0]
else:
target_vm = eip_obj.get_target_vm().vm
all_ports = port_header.all_ports
try:
test_lib.lib_check_ports_in_a_command(self.denied_vr, self.denied_vr_ip, vip_ip, [], all_ports, target_vm)
except:
traceback.print_exc(file=sys.stdout)
test_util.test_logger("Unexpected Result: Catch failure when checking [vip:] %s EIP: %s for denied ip: %s from [vm:] %s. All ports should be denied." % \
(vip.uuid, eip.uuid, self.denied_vr_ip, self.denied_vr.uuid))
return False
test_util.test_logger("Expected Result: Network checking pass for [vip:] %s EIP: %s by denied ip: %s from [vm:] %s . " % \
(vip.uuid, eip.uuid, self.denied_vr_ip, self.denied_vr.uuid))
return True
示例11: check_denied_pf
def check_denied_pf(self, pf):
pf_rule = pf.get_port_forwarding()
test_result = True
all_ports = port_header.all_ports
#all pf with same vip should have same l3.
allowed_ports = []
denied_ports = all_ports
if not pf.get_target_vm():
#Pf is not attached, use vip's VR VM. This wont' impact testing result.
l3_uuid = self.test_obj.get_vip().l3NetworkUuid
target_vm = test_lib.lib_find_vr_by_l3_uuid(l3_uuid)[0]
vm_nic_uuid = None
else:
target_vm = pf.get_target_vm().vm
vm_nic_uuid = pf_rule.vmNicUuid
allowedCidr = pf_rule.allowedCidr
allowed_vr_ip = allowedCidr.split('/')[0]
allowed_vr_vm, denied_vr_vm = \
self.get_allowed_denied_vr_vm(allowed_vr_ip, vm_nic_uuid)
vipIp = self.test_obj.get_vip().ip
try:
test_lib.lib_check_ports_in_a_command(allowed_vr_vm, \
allowed_vr_ip, vipIp, allowed_ports, \
denied_ports, target_vm)
except:
traceback.print_exc(file=sys.stdout)
test_util.test_logger("Catch failure when checking [vip:] %s Port Forwarding TCP [rules] for allowed Cidr: %s from [vm:] %s . " % \
(self.test_obj.get_vip().uuid, allowed_vr_ip, \
allowed_vr_vm.uuid))
test_result = False
return test_result
示例12: test
def test():
test_util.test_dsc('''
Will doing random test Security Group operations, including SG create/delete, rule add/remove, vm nics attach/detach. If reach max 4 coexisting running vm, testing will success and quit. Volume actions and Image actions are removed in this robot test.
VM resources: Since SG testing will create target test vm, there might be max 12 running VMs: 4 VR VMs, 4 SG target test VMs and 4 test VMs.
''')
target_running_vm = 4
target_l3s = test_lib.lib_get_limited_l3_network(2, 5)
vr_num = 0
for target_l3 in target_l3s:
vr_l3_uuid = target_l3.uuid
vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
temp_vm = None
if not vrs:
#create temp_vm for getting its vr for test pf_vm portforwarding
vm_create_option = test_util.VmOption()
vm_create_option.set_l3_uuids([vr_l3_uuid])
temp_vm = test_lib.lib_create_vm(vm_create_option)
test_dict.add_vm(temp_vm)
#we only need temp_vm's VR
temp_vm.destroy()
test_dict.rm_vm(temp_vm)
vr_num += 1
#VIP testing need 3 VRs
if vr_num > 2:
break
vm_create_option = test_util.VmOption()
#image has to use network test image, as it needs to do port checking
vm_create_option.set_image_uuid(test_lib.lib_get_image_by_name(img_name=os.environ.get('imageName_net')).uuid)
priority_actions = [test_state.TestAction.sg_rule_operations]*2
priority_action_obj = action_select.ActionPriority()
priority_action_obj.add_priority_action_list(priority_actions)
test_util.test_dsc('Random Test Begin. Test target: 4 coexisting running VM (not include VR and SG target test VMs.).')
robot_test_obj = test_util.Robot_Test_Object()
robot_test_obj.set_test_dict(test_dict)
robot_test_obj.set_vm_creation_option(vm_create_option)
robot_test_obj.set_priority_actions(priority_action_obj)
robot_test_obj.set_exclusive_actions_list(\
test_state.TestAction.volume_actions \
+ test_state.TestAction.image_actions \
+ test_state.TestAction.vip_actions \
+ test_state.TestAction.snapshot_actions)
rounds = 1
while len(test_dict.get_vm_list(vm_header.RUNNING)) < target_running_vm:
test_util.test_dsc('New round %s starts: random operation pickup.' % rounds)
test_lib.lib_vm_random_operation(robot_test_obj)
test_util.test_dsc('===============Round %s finished. Begin status checking.================' % rounds)
rounds += 1
test_lib.lib_robot_status_check(test_dict)
test_util.test_dsc('Reach test pass exit criterial.')
test_lib.lib_robot_cleanup(test_dict)
test_util.test_pass('Create random VM Test Success')
示例13: test
def test():
test_util.test_dsc('Create test vm with lb.')
vm1 = test_stub.create_lb_vm()
test_obj_dict.add_vm(vm1)
vm2 = test_stub.create_lb_vm()
test_obj_dict.add_vm(vm2)
vm3 = test_stub.create_lb_vm()
test_obj_dict.add_vm(vm3)
vm_nic1 = vm1.get_vm().vmNics[0]
vm_nic1_uuid = vm_nic1.uuid
vm_nic2 = vm2.get_vm().vmNics[0]
vm_nic2_uuid = vm_nic2.uuid
vm_nic3 = vm3.get_vm().vmNics[0]
vm_nic3_uuid = vm_nic3.uuid
pri_l3_uuid = vm_nic1.l3NetworkUuid
vr = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid)[0]
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr)
l3_uuid = vr_pub_nic.l3NetworkUuid
vip = test_stub.create_vip('vip_for_lb_test', l3_uuid)
test_obj_dict.add_vip(vip)
lb = zstack_lb_header.ZstackTestLoadBalancer()
lb.create('create lb test', vip.get_vip().uuid)
test_obj_dict.add_load_balancer(lb)
lbl_creation_option = test_lib.lib_create_lb_listener_option()
lbl_creation_option.set_load_balancer_uuid(lb.get_load_balancer().uuid)
lbl = zstack_lb_header.ZstackTestLoadBalancerListener()
lbl.set_creation_option(lbl_creation_option)
lbl.set_algorithm(lb_header.LB_ALGORITHM_LC)
lbl.create()
lb.add_load_balancer_listener(lbl)
lbl.add_nics([vm_nic1_uuid, vm_nic2_uuid, vm_nic3_uuid])
vm1.check()
vm2.check()
vm3.check()
lb.check()
vm3.stop()
import time
time.sleep(5)
lb.check()
vm3.start()
time.sleep(60)
lb.check()
lb.delete()
test_obj_dict.rm_load_balancer(lb)
lb.check()
test_lib.lib_robot_cleanup(test_obj_dict)
test_util.test_pass('Create Load Balancer Test Success')
示例14: test
def test():
'''
PF test needs at least 3 VR existence. Besides of PF_VM's VR, there
are needed another 2 VR VMs. 1st VR public IP address will be set as
allowedCidr. The 1st VR VM should be able to access PF_VM. The 2nd VR
VM should not be able to access PF_VM.
'''
pf_vm = test_stub.create_dnat_vm()
test_obj_dict.add_vm(pf_vm)
l3_name = os.environ.get('l3VlanNetworkName1')
vr1 = test_stub.create_vr_vm(test_obj_dict, l3_name)
l3_name = os.environ.get('l3NoVlanNetworkName1')
vr2 = test_stub.create_vr_vm(test_obj_dict, l3_name)
vr1_pub_ip = test_lib.lib_find_vr_pub_ip(vr1)
vr2_pub_ip = test_lib.lib_find_vr_pub_ip(vr2)
pf_vm.check()
vm_nic = pf_vm.vm.vmNics[0]
vm_nic_uuid = vm_nic.uuid
pri_l3_uuid = vm_nic.l3NetworkUuid
vr = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid)[0]
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr)
l3_uuid = vr_pub_nic.l3NetworkUuid
vip = test_stub.create_vip('pf_vm_ops', l3_uuid)
test_obj_dict.add_vip(vip)
vip_uuid = vip.get_vip().uuid
pf_creation_opt = PfRule.generate_pf_rule_option(vr1_pub_ip, protocol=inventory.TCP, vip_target_rule=Port.rule1_ports, private_target_rule=Port.rule1_ports, vip_uuid=vip_uuid, vm_nic_uuid=vm_nic_uuid)
test_pf = zstack_pf_header.ZstackTestPortForwarding()
test_pf.set_creation_option(pf_creation_opt)
test_pf.create(pf_vm)
vip.attach_pf(test_pf)
pf_vm.check()
vip.check()
#stop vm
pf_vm.stop()
test_pf.check()
pf_vm.start()
pf_vm.check()
vip.check()
pf_vm.reboot()
pf_vm.check()
vip.check()
test_pf.delete()
pf_vm.destroy()
test_obj_dict.rm_vm(pf_vm)
vip.delete()
test_obj_dict.rm_vip(vip)
test_util.test_pass("Test Port Forwarding with VM Operations Successfully")
示例15: test
def test():
vip_bandwidth = 1*1024
vm1 = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
test_obj_dict.add_vm(vm1)
vm1.check()
vm1_nic = vm1.vm.vmNics[0]
vm1_nic_uuid = vm1_nic.uuid
pri_l3_uuid1 = vm1.vm.vmNics[0].l3NetworkUuid
vr1 = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid1)[0]
l3_uuid1 = test_lib.lib_find_vr_pub_nic(vr1).l3NetworkUuid
vip1 = test_stub.create_vip('qos_vip', l3_uuid1)
test_obj_dict.add_vip(vip1)
eip1 = test_stub.create_eip('create qos test', vip_uuid=vip1.get_vip().uuid, vnic_uuid=vm1_nic_uuid, vm_obj=vm1)
vip1.attach_eip(eip1)
vip1_ip = vip1.get_vip().ip
vip1_qos = net_ops.set_vip_qos(vip_uuid=vip1.get_vip().uuid, inboundBandwidth=vip_bandwidth*8*1024, outboundBandwidth=vip_bandwidth*8*1024)
vm2 = test_stub.create_vlan_vm(os.environ.get('l3VlanDNATNetworkName'))
test_obj_dict.add_vm(vm2)
vm2.check()
vm2_nic = vm2.vm.vmNics[0]
vm2_nic_uuid = vm2_nic.uuid
pri_l3_uuid2 = vm2.vm.vmNics[0].l3NetworkUuid
vr2 = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid2)[0]
l3_uuid2 = test_lib.lib_find_vr_pub_nic(vr2).l3NetworkUuid
vip2 = test_stub.create_vip('qos_vip', l3_uuid2)
test_obj_dict.add_vip(vip2)
eip2 = test_stub.create_eip('create qos test', vip_uuid=vip2.get_vip().uuid, vnic_uuid=vm2_nic_uuid, vm_obj=vm2)
vip2.attach_eip(eip2)
vip2_ip = vip2.get_vip().ip
vm1_inv = vm1.get_vm()
vm2_inv = vm2.get_vm()
test_stub.make_ssh_no_password(vm1_inv)
test_stub.make_ssh_no_password(vm2_inv)
test_stub.install_iperf(vm1_inv)
test_stub.install_iperf(vm2_inv)
iptables_cmd = "iptables -F"
exec_cmd_in_vm(vm1, iptables_cmd, "Failed to clean iptables.")
exec_cmd_in_vm(vm2, iptables_cmd, "Failed to clean iptables.")
test_stub.test_iperf_bandwidth(vm1_inv,vm2_inv,vip1_ip,5001,5001,vip_bandwidth)
test_stub.test_iperf_bandwidth(vm2_inv,vm1_inv,vip2_ip,5001,5001,vip_bandwidth)
test_lib.lib_error_cleanup(test_obj_dict)
test_util.test_pass('Create VIP Qos for EIP Success')