def test():
    global default_l3_mtu
    test_util.test_dsc(
        'Create test vm and check. VR has DNS SNAT EIP PF and DHCP services')
    l3_name = os.environ.get('l3VlanNetworkName1')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    default_l3_mtu = net_ops.get_l3_mtu(l3_net_uuid)

    vm = test_stub.create_vlan_vm(l3_name)
    test_obj_dict.add_vm(vm)
    vrs = test_lib.lib_find_vr_by_vm(vm.vm)
    for vr in vrs:
        if vr.applianceVmType != "vrouter":
            test_util.test_skip("Skip l3 mtu test for non vrouter")

    vm.check()
    if not test_lib.lib_execute_command_in_vm(
            vm.get_vm(), 'tracepath -n yyk.net | tail -1 | grep "pmtu %s"' %
        (default_l3_mtu)):
        test_util.test_fail("fail to check mtu in [vm:] %s" %
                            (vm.get_vm().uuid))

    net_ops.set_l3_mtu(l3_net_uuid, 1200)
    vm.reboot()
    vm.check()
    if not test_lib.lib_execute_command_in_vm(
            vm.get_vm(), 'tracepath -n yyk.net | tail -1 | grep "pmtu 1200"'):
        test_util.test_fail("fail to check mtu in [vm:] %s" %
                            (vm.get_vm().uuid))

    vm.destroy()
    test_util.test_pass(
        'Create VirtualRouter VM DNS DHCP SANT EIP PF Test Success')
def test():
    global default_l3_mtu
    test_util.test_dsc('Create test vm and check. VR has DNS SNAT EIP PF and DHCP services')
    l3_name = os.environ.get('l3PublicNetworkName')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    default_l3_mtu = net_ops.get_l3_mtu(l3_net_uuid)
    vm = test_stub.create_vlan_vm(l3_name)
    test_obj_dict.add_vm(vm)
    vm.check()
    script_file = tempfile.NamedTemporaryFile(delete=False)
    script_file.write('tracepath -n yyk.net | tail -1 | grep "pmtu %s"' % (default_l3_mtu))
    script_file.close()
    if not test_lib.lib_execute_shell_script_in_vm(vm.get_vm(), script_file.name):
        test_util.test_fail("fail to check mtu in [vm:] %s" % (vm.get_vm().uuid))
    os.unlink(script_file.name)

    net_ops.set_l3_mtu(l3_net_uuid, 1200)
    vm.reboot()
    vm.check()
    
    script_file = tempfile.NamedTemporaryFile(delete=False)
    script_file.write('tracepath -n yyk.net | tail -1 | grep "pmtu 1200"')
    script_file.close()
    if not test_lib.lib_execute_shell_script_in_vm(vm.get_vm(), script_file.name):
        test_util.test_fail("fail to check mtu in [vm:] %s" % (vm.get_vm().uuid))
    os.unlink(script_file.name)

    vm.destroy()
    test_util.test_pass('Create VirtualRouter VM DNS DHCP SANT EIP PF Test Success')
def test():
    global default_l3_mtu
    test_util.test_dsc('Create test vm and check. VR has DNS SNAT EIP PF and DHCP services')
    l3_name = os.environ.get('l3VlanNetworkName1')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    default_l3_mtu = net_ops.get_l3_mtu(l3_net_uuid)

    vm = test_stub.create_vlan_vm(l3_name)
    test_obj_dict.add_vm(vm)
    vrs = test_lib.lib_find_vr_by_vm(vm.vm)
    for vr in vrs:
        if vr.applianceVmType != "vrouter":
            test_util.test_skip("Skip l3 mtu test for non vrouter")

    vm.check()
    if not test_lib.lib_execute_command_in_vm(vm.get_vm(), 'tracepath -n yyk.net | tail -1 | grep "pmtu %s"' % (default_l3_mtu)):
        test_util.test_fail("fail to check mtu in [vm:] %s" % (vm.get_vm().uuid))

    net_ops.set_l3_mtu(l3_net_uuid, 1200)
    vm.reboot()
    vm.check()
    if not test_lib.lib_execute_command_in_vm(vm.get_vm(), 'tracepath -n yyk.net | tail -1 | grep "pmtu 1200"'):
        test_util.test_fail("fail to check mtu in [vm:] %s" % (vm.get_vm().uuid))

    vm.destroy()
    test_util.test_pass('Create VirtualRouter VM DNS DHCP SANT EIP PF Test Success')
def test():
    global default_l3_mtu
    test_util.test_dsc(
        'Create test vm and check. VR has DNS SNAT EIP PF and DHCP services')
    l3_name = os.environ.get('l3PublicNetworkName')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    default_l3_mtu = net_ops.get_l3_mtu(l3_net_uuid)
    net_ops.set_l3_mtu(l3_net_uuid, 1200)

    vm = test_stub.create_vlan_vm(l3_name)
    test_obj_dict.add_vm(vm)
    vm.check()
    script_file = tempfile.NamedTemporaryFile(delete=False)
    script_file.write('tracepath -n yyk.net | tail -1 | grep "pmtu 1200"')
    script_file.close()
    if not test_lib.lib_execute_shell_script_in_vm(vm.get_vm(),
                                                   script_file.name):
        test_util.test_fail("fail to check mtu in [vm:] %s" %
                            (vm.get_vm().uuid))
    os.unlink(script_file.name)

    vm.destroy()
    test_util.test_pass(
        'Create VirtualRouter VM DNS DHCP SANT EIP PF Test Success')
def env_recover():
    global default_l3_mtu
    if default_l3_mtu:
        l3_name = os.environ.get('l3VlanNetworkName1')
        l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
        net_ops.set_l3_mtu(l3_net_uuid, default_l3_mtu)
def env_recover():
    global default_l3_mtu
    if default_l3_mtu:
        l3_name = os.environ.get('l3PublicNetworkName')
        l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
        net_ops.set_l3_mtu(l3_net_uuid, default_l3_mtu)