本文整理汇总了Python中zstackwoodpecker.test_lib.lib_find_vr_pub_nic函数的典型用法代码示例。如果您正苦于以下问题:Python lib_find_vr_pub_nic函数的具体用法?Python lib_find_vr_pub_nic怎么用?Python lib_find_vr_pub_nic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lib_find_vr_pub_nic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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')
示例2: 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")
示例3: 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()
示例4: 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")
示例5: 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")
示例6: 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')
示例7: 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')
示例8: 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')
示例9: 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')
示例10: test
def test():
vip_bandwidth = 1*1024
pf_vm1 = test_stub.create_dnat_vm()
test_obj_dict.add_vm(pf_vm1)
pf_vm2 = test_stub.create_vlan_sg_vm()
test_obj_dict.add_vm(pf_vm2)
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()
pf_vm2.check()
vm1_inv=pf_vm1.get_vm()
vm2_inv=pf_vm2.get_vm()
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
vip_ip = vip.get_vip().ip
#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_opt1 = PfRule.generate_pf_rule_option(vr1_pub_ip, protocol=inventory.TCP, vip_target_rule=Port.rule4_ports, private_target_rule=Port.rule4_ports, vip_uuid=vip_uuid)
test_pf1 = zstack_pf_header.ZstackTestPortForwarding()
test_pf1.set_creation_option(pf_creation_opt1)
test_pf1.create()
vip.attach_pf(test_pf1)
pf_vm1.check()
test_pf1.attach(vm_nic_uuid1, pf_vm1)
vip_qos = net_ops.set_vip_qos(vip_uuid=vip_uuid, inboundBandwidth=vip_bandwidth*8*1024, outboundBandwidth=vip_bandwidth*8*1024)
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(pf_vm1, iptables_cmd, "Failed to clean iptables.")
test_stub.test_iperf_bandwidth(vm1_inv,vm2_inv,vip_ip,20502,20502,vip_bandwidth)
vip.delete()
test_obj_dict.rm_vip(vip)
pf_vm1.destroy()
test_obj_dict.rm_vm(pf_vm1)
pf_vm2.destroy()
test_obj_dict.rm_vm(pf_vm2)
test_util.test_pass("Test Port Forwarding Vip Qos Successfully.")
示例11: test
def test():
flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
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(flavor['vm1l3'], flavor['vm2l3']))
vm1 = test_stub.create_vm_with_random_offering(vm_name='vpc_vm_{}'.format(flavor['vm1l3']), l3_name=flavor['vm1l3'])
test_obj_dict.add_vm(vm1)
vm1.check()
vm2 = test_stub.create_vm_with_random_offering(vm_name='vpc_vm_{}'.format(flavor['vm2l3']), l3_name=flavor['vm2l3'])
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()
if flavor['one_vpc']:
for vm in (vm1, vm2):
eip.attach(vm.get_vm().vmNics[0].uuid, vm)
vip.check()
eip.detach()
vip.check()
else:
eip.attach(vm1.get_vm().vmNics[0].uuid, vm1)
vip.check()
eip.detach()
vip.check()
eip.delete()
test_util.test_dsc("Create a new eip")
eip = test_stub.create_eip('eip2', vip_uuid=vip.get_vip().uuid)
vip.attach_eip(eip)
vip.check()
eip.attach(vm2.get_vm().vmNics[0].uuid, vm2)
vip.check()
eip.detach()
vip.check()
eip.delete()
test_lib.lib_error_cleanup(test_obj_dict)
test_stub.remove_all_vpc_vrouter()
示例12: test
def test():
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('2 pfs with same vip', 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_opt1 = PfRule.generate_pf_rule_option(vr1_pub_ip, protocol=inventory.TCP, vip_target_rule=Port.rule1_ports, private_target_rule=Port.rule2_ports, vip_uuid=vip_uuid, vm_nic_uuid=vm_nic_uuid)
test_pf1 = zstack_pf_header.ZstackTestPortForwarding()
test_pf1.set_creation_option(pf_creation_opt1)
test_pf1.create(pf_vm)
vip.attach_pf(test_pf1)
pf_creation_opt2 = PfRule.generate_pf_rule_option(vr1_pub_ip, protocol=inventory.TCP, vip_target_rule=Port.rule3_ports, private_target_rule=Port.rule4_ports, vip_uuid=vip_uuid, vm_nic_uuid=vm_nic_uuid)
test_pf2 = zstack_pf_header.ZstackTestPortForwarding()
test_pf2.set_creation_option(pf_creation_opt2)
test_pf2.create(pf_vm)
vip.attach_pf(test_pf2)
pf_vm.check()
vip.check()
test_pf1.delete()
test_pf2.delete()
import time
time.sleep(1)
vip.check()
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 TCP Rule Successfully")
示例13: test
def test():
flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
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))
time.sleep(120) #waiting for vrouter boot up
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(flavor['vm1l3'], flavor['vm2l3']))
vm1, vm2 = [test_stub.create_vm_with_random_offering(vm_name='vpc_vm_{}'.format(name), l3_name=name) for name in (flavor['vm1l3'], flavor['vm2l3'])]
[test_obj_dict.add_vm(vm) for vm in (vm1,vm2)]
[vm.check() for vm in (vm1,vm2)]
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr_list[0].inv)
vip_list = []
for vm in (vm1, vm2):
test_util.test_dsc("Create vip for vm {}".format(vm.get_vm().name))
vip = test_stub.create_vip('vip_{}'.format(vm.get_vm().name), vr_pub_nic.l3NetworkUuid)
test_obj_dict.add_vip(vip)
vip_list.append(vip)
test_util.test_dsc("Create eip for vm {}".format(vm.get_vm().name))
eip = test_stub.create_eip('eip_{}'.format(vm.get_vm().name), vip_uuid=vip.get_vip().uuid)
vip.attach_eip(eip)
eip.attach(vm.get_vm().vmNics[0].uuid, vm)
time.sleep(10) #waiting for eip attach to vm
vip.check()
vm.check()
for vm in (vm1, vm2):
vm.check()
vm1_inv, vm2_inv = [vm.get_vm() for vm in (vm1, vm2)]
vip1, vip2 = vip_list
test_util.test_dsc("test two vm EIP connectivity")
test_stub.run_command_in_vm(vm1_inv, 'iptables -F')
test_stub.run_command_in_vm(vm2_inv, 'iptables -F')
test_lib.lib_check_ping(vm1_inv, vip2.get_vip().ip)
test_lib.lib_check_ping(vm2_inv, vip1.get_vip().ip)
test_lib.lib_check_ports_in_a_command(vm1_inv, vip1.get_vip().ip,
vip2.get_vip().ip, ["22"], [], vm2_inv)
test_lib.lib_check_ports_in_a_command(vm2_inv, vip2.get_vip().ip,
vip1.get_vip().ip, ["22"], [], vm1_inv)
示例14: test
def test():
test_util.test_dsc('Create test vm with lb for LB different ports testing.')
vm1 = test_stub.create_lb_vm()
test_obj_dict.add_vm(vm1)
vm2 = test_stub.create_lb_vm()
test_obj_dict.add_vm(vm2)
#l3_name = os.environ.get('l3VlanNetworkName1')
#vr1 = test_stub.get_vr_by_private_l3_name(l3_name)
#l3_name = os.environ.get('l3NoVlanNetworkName1')
#vr2 = test_stub.get_vr_by_private_l3_name(l3_name)
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
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)
lb_creation_option = test_lib.lib_create_lb_listener_option(\
lbl_port = 2222, lbi_port = 22)
lbl = lb.create_listener(lb_creation_option)
lbl.add_nics([vm_nic1_uuid, vm_nic2_uuid])
vm1.check()
vm2.check()
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 with Different Ports Test Success')
示例15: 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)
l3_uuid = vr_pub_nic.l3NetworkUuid
vip = test_stub.create_vip('test_pf_after_destroy_vm', l3_uuid)
test_obj_dict.add_vip(vip)
vip_uuid = vip.get_vip().uuid
vr_pub_ip = test_lib.lib_find_vr_pub_ip(vr)
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)
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()
pf_vm.stop()
pf_vm.check()
vip.check()
pf_vm.destroy()
test_obj_dict.rm_vm(pf_vm)
vip.check()
test_pf.delete()
vip.delete()
test_obj_dict.rm_vip(vip)
test_util.test_pass("Port Forwarding Rule checking pass when stopping VM and destroying VM.")