• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils_net.get_linux_ifname函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中virttest.utils_net.get_linux_ifname函数的典型用法代码示例。如果您正苦于以下问题:Python get_linux_ifname函数的具体用法?Python get_linux_ifname怎么用?Python get_linux_ifname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_linux_ifname函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_ip_by_mac

    def get_ip_by_mac(mac_addr, timeout=120):
        """
        Get interface IP address by given MAC address.
        """
        if vm.serial_console is not None:
            vm.cleanup_serial_console()
        vm.create_serial_console()
        session = vm.wait_for_serial_login(timeout=240)

        def get_ip():
            return utils_net.get_guest_ip_addr(session, mac_addr)

        try:
            ip_addr = ""
            iface_name = utils_net.get_linux_ifname(session, mac_addr)
            if iface_name is None:
                test.fail("no interface with MAC address %s found" % mac_addr)
            session.cmd("pkill -9 dhclient", ignore_all_errors=True)
            session.cmd("dhclient %s " % iface_name, ignore_all_errors=True)
            ip_addr = utils_misc.wait_for(get_ip, 20)
            logging.debug("The ip addr is %s", ip_addr)
        except Exception:
            logging.warning("Find %s with MAC address %s but no ip for it" % (iface_name, mac_addr))
        finally:
            session.close()
        return ip_addr
开发者ID:balamuruhans,项目名称:tp-libvirt,代码行数:26,代码来源:sriov.py


示例2: run_enable_mq

def run_enable_mq(test, params, env):
    """
    Enable MULTI_QUEUE feature in guest

    1) Boot up VM(s)
    2) Login guests one by one
    3) Enable MQ for all virtio nics by ethtool -L

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """

    login_timeout = int(params.get("login_timeout", 360))
    queues = int(params.get("queues", 1))
    vms = params.get("vms").split()
    if queues == 1:
        logging.info("No need to enable MQ feature for single queue")
        return

    for vm in vms:
        vm = env.get_vm(vm)
        vm.verify_alive()
        session = vm.wait_for_login(timeout=login_timeout)
        for i, nic in enumerate(vm.virtnet):
            if "virtio" in nic["nic_model"]:
                ifname = utils_net.get_linux_ifname(session, vm.get_mac_address(0))
                session.cmd_output("ethtool -L %s combined %d" % (ifname, queues))
                o = session.cmd_output("ethtool -l %s" % ifname)
                if len(re.findall("Combined:\s+%d\s" % queues, o)) != 2:
                    raise error.TestError("Fail to enable MQ feature of (%s)" % nic.nic_name)

                logging.info("MQ feature of (%s) is enabled" % nic.nic_name)

        session.close()
开发者ID:nloopa,项目名称:virt-test,代码行数:35,代码来源:enable_mq.py


示例3: get_ip_by_mac

    def get_ip_by_mac(mac_addr, try_dhclint=False):
        """
        Get interface IP address by given MAC addrss. If try_dhclint is
        True, then try to allocate IP addrss for the interface.
        """
        session = vm.wait_for_login()

        def f():
            return utils_net.get_guest_ip_addr(session, mac_addr)

        try:
            ip_addr = utils_misc.wait_for(f, 10)
            if ip_addr is None:
                iface_name = utils_net.get_linux_ifname(session, mac_addr)
                if try_dhclint:
                    session.cmd("dhclient %s" % iface_name)
                    ip_addr = utils_misc.wait_for(f, 10)
                else:
                    # No IP for the interface, just print the interface name
                    logging.warn("Find '%s' with MAC address '%s', "
                                 "but which has no IP address", iface_name,
                                 mac_addr)
        finally:
            session.close()
        return ip_addr
开发者ID:Hao-Liu,项目名称:tp-libvirt,代码行数:25,代码来源:virsh_net_dhcp_leases.py


示例4: chk_mq_enabled

    def chk_mq_enabled(vm, queues):
        """
        Check whether MQ value set in qemu cmd line fits the value in guest

        :param vm: guest vm
        :param queues: queues value in qemu cmd line
        """
        login_timeout = int(params.get("login_timeout", 360))
        session = vm.wait_for_login(timeout=login_timeout)

        mac = vm.get_mac_address(0)
        ifname = utils_net.get_linux_ifname(session, mac)
        queues_status_list = get_queues_status(session, ifname)

        session.close()
        if not queues_status_list[0] == queues or \
                not queues_status_list[1] == min(queues, int(vm.cpuinfo.smp)):
            txt = "Pre-set maximums Combined should equals to queues in qemu"
            txt += " cmd line.\n"
            txt += "Current hardware settings Combined should be the min of "
            txt += "queues and smp.\n"
            txt += "Pre-set maximum Combined is: %s, " % queues_status_list[0]
            txt += " queues in qemu cmd line is: %s.\n" % queues
            txt += "Current hardware settings Combined "
            txt += "is: %s, " % queues_status_list[1]
            txt += " smp in qemu cmd line is: %s." % int(vm.cpuinfo.smp)
            test.fail(txt)
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:27,代码来源:mq_enabled_chk.py


示例5: enable_multi_queues

 def enable_multi_queues(vm):
     sess = vm.wait_for_serial_login(timeout=login_timeout)
     error.context("Enable multi queues in guest.", logging.info)
     for nic_index, nic in enumerate(vm.virtnet):
         ifname = utils_net.get_linux_ifname(sess, nic.mac)
         queues = int(nic.queues)
         change_queues_number(sess, ifname, queues)
开发者ID:CongLi,项目名称:tp-qemu,代码行数:7,代码来源:mq_change_qnum.py


示例6: transfer_file

    def transfer_file(src):
        """
        Transfer file by scp, use tcpdump to capture packets, then check the
        return string.

        :param src: Source host of transfer file
        :return: Tuple (status, error msg/tcpdump result)
        """
        sess = vm.wait_for_login(timeout=login_timeout)
        session.cmd_output("rm -rf %s" % filename)
        dd_cmd = ("dd if=/dev/urandom of=%s bs=1M count=%s" %
                  (filename, params.get("filesize")))
        failure = (False, "Failed to create file using dd, cmd: %s" % dd_cmd)
        txt = "Creating file in source host, cmd: %s" % dd_cmd
        error.context(txt, logging.info)
        ethname = utils_net.get_linux_ifname(session,
                                             vm.get_mac_address(0))
        tcpdump_cmd = "tcpdump -lep -i %s -s 0 tcp -vv port ssh" % ethname
        if src == "guest":
            tcpdump_cmd += " and src %s" % guest_ip
            copy_files_func = vm.copy_files_from
            try:
                sess.cmd_output(dd_cmd, timeout=360)
            except aexpect.ShellCmdError, e:
                return failure
开发者ID:WenliQuan,项目名称:virt-test,代码行数:25,代码来源:ethtool.py


示例7: run_nic_promisc

def run_nic_promisc(test, params, env):
    """
    Test nic driver in promisc mode:

    1) Boot up a VM.
    2) Repeatedly enable/disable promiscuous mode in guest.
    3) Transfer file from host to guest, and from guest to host in the same time

    @param test: QEMU test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = int(params.get("login_timeout", 360))
    session_serial = vm.wait_for_serial_login(timeout=timeout)

    ethname = utils_net.get_linux_ifname(session_serial,
                                              vm.get_mac_address(0))

    try:
        transfer_thread = utils.InterruptedThread(
                                               utils_test.run_file_transfer,
                                               (test, params, env))
        transfer_thread.start()
        while transfer_thread.isAlive():
            session_serial.cmd("ip link set %s promisc on" % ethname)
            session_serial.cmd("ip link set %s promisc off" % ethname)
    except Exception:
        transfer_thread.join(suppress_exception=True)
        raise
    else:
        transfer_thread.join()
开发者ID:kmaehara,项目名称:virt-test,代码行数:33,代码来源:nic_promisc.py


示例8: check_output

    def check_output(ifaces_actual, vm, login_nic_index=0):
        """
        1. Get the interface details of the command output
        2. Get the interface details from xml file
        3. Check command output against xml and guest output
        """
        vm_name = vm.name

        try:
            session = vm.wait_for_login(nic_index=login_nic_index)
        except Exception as detail:
            test.fail("Unable to login to VM:%s" % detail)
        iface_xml = {}
        error_count = 0
        # Check for the interface values
        for item in ifaces_actual:
            # Check for mac and model
            model = item['model']
            iname = utils_net.get_linux_ifname(session, item['mac'])
            if iname is not None:
                cmd = 'ethtool -i %s | grep driver | awk \'{print $2}\'' % iname
                drive = session.cmd_output(cmd).strip()
                if driver_dict[model] != drive:
                    error_count += 1
                    logging.error("Mismatch in the model for the interface %s\n"
                                  "Expected Model:%s\nActual Model:%s",
                                  item['interface'], driver_dict[model],
                                  item['model'])
            else:
                error_count += 1
                logging.error("Mismatch in the mac for the interface %s\n",
                              item['interface'])
            iface_xml = vm_xml.VMXML.get_iface_by_mac(vm_name, item['mac'])
            if iface_xml is not None:
                if iface_xml['type'] != item['type']:
                    error_count += 1
                    logging.error("Mismatch in the network type for the "
                                  "interface %s \n Type in command output: %s\n"
                                  "Type in xml file: %s",
                                  item['interface'],
                                  item['type'],
                                  iface_xml['type'])
                if iface_xml['source'] != item['source']:
                    error_count += 1
                    logging.error("Mismatch in the network source for the"
                                  " interface %s \n Source in command output:"
                                  "%s\nSource in xml file: %s",
                                  item['interface'],
                                  item['source'],
                                  iface_xml['source'])

            else:
                error_count += 1
                logging.error("There is no interface in the xml file "
                              "with the below specified mac address\n"
                              "Mac:%s", item['mac'])
            iface_xml = {}
        if error_count > 0:
            test.fail("The test failed, consult previous error logs")
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:59,代码来源:virsh_domiflist.py


示例9: run_nicdriver_unload

def run_nicdriver_unload(test, params, env):
    """
    Test nic driver.

    1) Boot a VM.
    2) Get the NIC driver name.
    3) Repeatedly unload/load NIC driver.
    4) Multi-session TCP transfer on test interface.
    5) Check whether the test interface should still work.

    @param test: QEMU test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    timeout = int(params.get("login_timeout", 360))
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    session_serial = vm.wait_for_serial_login(timeout=timeout)

    ethname = utils_net.get_linux_ifname(session_serial,
                                               vm.get_mac_address(0))

    # get ethernet driver from '/sys' directory.
    # ethtool can do the same thing and doesn't care about os type.
    # if we make sure all guests have ethtool, we can make a change here.
    sys_path = params.get("sys_path") % (ethname)

    # readlink in RHEL4.8 doesn't have '-e' param, should use '-f' in RHEL4.8.
    readlink_cmd = params.get("readlink_command", "readlink -e")
    driver = os.path.basename(session_serial.cmd("%s %s" % (readlink_cmd,
                                                 sys_path)).strip())

    logging.info("driver is %s", driver)

    try:
        threads = []
        for _ in range(int(params.get("sessions_num", "10"))):
            thread = utils.InterruptedThread(utils_test.run_file_transfer,
                                             (test, params, env))
            thread.start()
            threads.append(thread)

        time.sleep(10)
        while threads[0].isAlive():
            session_serial.cmd("sleep 10")
            session_serial.cmd("ifconfig %s down" % ethname)
            session_serial.cmd("modprobe -r %s" % driver)
            session_serial.cmd("modprobe %s" % driver)
            session_serial.cmd("ifconfig %s up" % ethname)
    except Exception:
        for thread in threads:
            thread.join(suppress_exception=True)
            raise
    else:
        for thread in threads:
            thread.join()
开发者ID:kmaehara,项目名称:virt-test,代码行数:56,代码来源:nicdriver_unload.py


示例10: check_iface_exist

 def check_iface_exist():
     try:
         session = vm.wait_for_serial_login(username=username,
                                            password=password)
         if utils_net.get_linux_ifname(session, iface['mac']):
             return True
         else:
             logging.debug("can not find interface in vm")
     except Exception:
         return False
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:10,代码来源:iface_hotplug.py


示例11: run_nic_promisc

def run_nic_promisc(test, params, env):
    """
    Test nic driver in promisc mode:

    1) Boot up a VM.
    2) Repeatedly enable/disable promiscuous mode in guest.
    3) Transfer file between host and guest during nic promisc on/off

    @param test: QEMU test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    def set_nic_promisc_onoff(session):
        if os_type == "linux":
            session.cmd("ip link set %s promisc on" % ethname)
            session.cmd("ip link set %s promisc off" % ethname)
        else:
            cmd = "c:\\set_win_promisc.py"
            session.cmd(cmd)

    error.context("Boot vm and prepare test environment", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = int(params.get("login_timeout", 360))
    session_serial = vm.wait_for_serial_login(timeout=timeout)
    session = vm.wait_for_login(timeout=timeout)

    os_type = params.get("os_type")
    if os_type == "linux":
        ethname = utils_net.get_linux_ifname(session, vm.get_mac_address(0))
    else:
        script_path = os.path.join(test.virtdir, "scripts/set_win_promisc.py")
        vm.copy_files_to(script_path, "C:\\")

    try:
        transfer_thread = utils.InterruptedThread(utils_test.run_file_transfer,
                                                  (test, params, env))

        error.context("Run utils_test.file_transfer ...", logging.info)
        transfer_thread.start()

        error.context("Perform file transfer while turning nic promisc on/off",
                      logging.info)
        while transfer_thread.isAlive():
            set_nic_promisc_onoff(session_serial)
    except Exception:
        transfer_thread.join(suppress_exception=True)
        raise
    else:
        transfer_thread.join()
        if session_serial:
            session_serial.close()
        if session:
            session.close()
开发者ID:FengYang,项目名称:virt-test,代码行数:54,代码来源:nic_promisc.py


示例12: check_nics_num

    def check_nics_num(expect_c, session):
        txt = "Check whether guest NICs info match with params setting."
        error.context(txt, logging.info)
        nics_list = utils_net.get_linux_ifname(session)
        actual_c = len(nics_list)
        msg = "Expected NICs count is: %d\n" % expect_c
        msg += "Actual NICs count is: %d\n" % actual_c

        if not expect_c == actual_c:
            msg += "Nics count mismatch!\n"
            return (False, msg)
        return (True, msg + 'Nics count match')
开发者ID:CongLi,项目名称:tp-qemu,代码行数:12,代码来源:multi_nics_verify.py


示例13: enable_multi_queues

 def enable_multi_queues(vm):
     session = vm.wait_for_login(timeout=login_timeout)
     error_context.context("Enable multi queues in guest.", logging.info)
     for nic_index, nic in enumerate(vm.virtnet):
         ifname = utils_net.get_linux_ifname(session, nic.mac)
         queues = int(nic.queues)
         mq_set_cmd = "ethtool -L %s combined %d" % (ifname, queues)
         status, output = session.cmd_status_output(mq_set_cmd)
         if status:
             msg = "Fail to enable multi queue in guest."
             msg += "Command %s, fail with output %s" % (mq_set_cmd, output)
             test.error(msg)
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:12,代码来源:boot_with_different_vectors.py


示例14: ping_hotplug_nic

 def ping_hotplug_nic(ip, mac, session, is_linux_guest):
     status, output = utils_test.ping(ip, 10, timeout=30)
     if status != 0:
         if not is_linux_guest:
             return status, output
         ifname = utils_net.get_linux_ifname(session, mac)
         add_route_cmd = "route add %s dev %s" % (ip, ifname)
         del_route_cmd = "route del %s dev %s" % (ip, ifname)
         logging.warn("Failed to ping %s from host.")
         logging.info("Add route and try again")
         session.cmd_output_safe(add_route_cmd)
         status, output = utils_test.ping(hotnic_ip, 10, timeout=30)
         logging.info("Del the route.")
         status, output = session.cmd_output_safe(del_route_cmd)
     return status, output
开发者ID:EIChaoYang,项目名称:tp-qemu,代码行数:15,代码来源:nic_hotplug.py


示例15: renew_ip_address

 def renew_ip_address(session, mac, is_linux_guest=True):
     if not is_linux_guest:
         utils_net.restart_windows_guest_network_by_key(session, "macaddress", mac)
         return None
     ifname = utils_net.get_linux_ifname(session, mac)
     p_cfg = "/etc/sysconfig/network-scripts/ifcfg-%s" % ifname
     cfg_con = "DEVICE=%s\nBOOTPROTO=dhcp\nONBOOT=yes" % ifname
     make_conf = "test -f %s || echo '%s' > %s" % (p_cfg, cfg_con, p_cfg)
     arp_clean = "arp -n|awk '/^[1-9]/{print \"arp -d \" $1}'|sh"
     session.cmd_output_safe(make_conf)
     session.cmd_output_safe("ifconfig %s up" % ifname)
     session.cmd_output_safe("dhclient -r", timeout=240)
     session.cmd_output_safe("dhclient %s" % ifname, timeout=240)
     session.cmd_output_safe(arp_clean)
     return None
开发者ID:MiriamDeng,项目名称:tp-qemu,代码行数:15,代码来源:nic_hotplug.py


示例16: mtu_set

    def mtu_set(mtu):
        """
        Set server/client/host's mtu

        :param mtu: mtu value to be set
        """

        server_mtu_cmd = params.get("server_mtu_cmd")
        client_mtu_cmd = params.get("client_mtu_cmd")
        host_mtu_cmd = params.get("host_mtu_cmd")
        error_context.context("Changing the MTU of guest", logging.info)
        if params.get("os_type") == "linux":
            ethname = utils_net.get_linux_ifname(server_ctl, mac)
            ssh_cmd(server_ctl, server_mtu_cmd % (ethname, mtu))
        elif params.get("os_type") == "windows":
            connection_id = utils_net.get_windows_nic_attribute(
                server_ctl, "macaddress", mac, "netconnectionid")
            ssh_cmd(server_ctl, server_mtu_cmd % (connection_id, mtu))

        error_context.context("Changing the MTU of client", logging.info)
        ssh_cmd(client, client_mtu_cmd
                % (params.get("client_physical_nic"), mtu))

        netdst = params.get("netdst", "switch")
        host_bridges = utils_net.Bridge()
        br_in_use = host_bridges.list_br()
        if netdst in br_in_use:
            ifaces_in_use = host_bridges.list_iface()
            target_ifaces = list(ifaces_in_use + br_in_use)
        if params.get("netdst_nic1") in process.system_output(
                "ovs-vsctl list-br", ignore_status=True, shell=True).decode():
            ovs_list = "ovs-vsctl list-ports %s" % params["netdst_nic1"]
            ovs_port = process.system_output(ovs_list,
                                             shell=True).decode().splitlines()
            target_ifaces = target_ifaces + \
                params.objects("netdst_nic1") + ovs_port
        if vm.virtnet[0].nettype == "macvtap":
            target_ifaces.extend([vm.virtnet[0].netdst, vm.get_ifname(0)])
        error_context.context("Change all Bridge NICs MTU to %s"
                              % mtu, logging.info)
        for iface in target_ifaces:
            try:
                process.run(host_mtu_cmd % (iface, mtu), ignore_status=False,
                            shell=True)
            except process.CmdError as err:
                if "SIOCSIFMTU" in err.result.stderr.decode():
                    test.cancel("The ethenet device does not support jumbo,"
                                "cancel test")
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:48,代码来源:netperf.py


示例17: guest_config

    def guest_config(vm, ip_addr):
        """
        Add a new nic to guest and set a static ip address

        :param vm: Configured guest
        :param ip_addr: Set ip address
        """
        # Attach an interface device
        # Use attach-device, not attach-interface, because attach-interface
        # doesn't support 'direct'
        interface_class = vm_xml.VMXML.get_device_class('interface')
        interface = interface_class(type_name="direct")
        interface.source = dict(dev=str(eth_card_no), mode=str(iface_mode))
        interface.model = "virtio"
        interface.xmltreefile.write()
        if vm.is_alive():
            vm.destroy(gracefully=False)
        virsh.attach_device(vm.name, interface.xml, flagstr="--config")
        os.remove(interface.xml)
        vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm.name)
        new_nic = vmxml.get_devices(device_type="interface")[-1]

        # Modify new interface's IP
        vm.start()
        session = vm.wait_for_login()
        eth_name = utils_net.get_linux_ifname(session, new_nic.mac_address)
        eth_config_detail_list = ['DEVICE=%s' % eth_name,
                                  'HWADDR=%s' % new_nic.mac_address,
                                  'ONBOOT=yes',
                                  'BOOTPROTO=static',
                                  'IPADDR=%s' % ip_addr]
        remote_file = remote.RemoteFile(vm.get_address(), 'scp', 'root',
                                        params.get('password'), 22,
                                        eth_config_file)
        remote_file.truncate()
        remote_file.add(eth_config_detail_list, linesep='\n')
        try:
            # Attached interface maybe already active
            session.cmd("ifdown %s" % eth_name)
        except aexpect.ShellCmdError:
            raise error.TestFail("ifdown %s failed." % eth_name)

        try:
            session.cmd("ifup %s" % eth_name)
        except aexpect.ShellCmdError:
            raise error.TestFail("ifup %s failed." % eth_name)
        return session
开发者ID:noxdafox,项目名称:tp-libvirt,代码行数:47,代码来源:macvtap.py


示例18: check_nics_num

    def check_nics_num(expect_c, session):
        """
        Check whether guest NICs number match with params set in cfg file

        :param expect_c: expected nics no.
        :param session: in which session the guest runs in
        """
        txt = "Check whether guest NICs info match with params setting."
        error_context.context(txt, logging.info)
        nics_list = utils_net.get_linux_ifname(session)
        actual_c = len(nics_list)
        msg = "Expected NICs count is: %d\n" % expect_c
        msg += "Actual NICs count is: %d\n" % actual_c

        if not expect_c == actual_c:
            msg += "Nics count mismatch!\n"
            return (False, msg)
        return (True, msg + 'Nics count match')
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:18,代码来源:multi_nics_verify.py


示例19: guest_config

    def guest_config(vm, ip_addr):
        """
        Add a new nic to guest and set a static ip address

        :param vm: Configured guest
        :param ip_addr: Set ip address
        """
        # Attach an interface device
        # Use attach-device, not attach-interface, because attach-interface
        # doesn't support 'direct'
        interface_class = vm_xml.VMXML.get_device_class('interface')
        interface = interface_class(type_name="direct")
        interface.source = dict(dev=str(eth_card_no), mode=str(iface_mode))
        interface.model = "virtio"
        interface.xmltreefile.write()
        if vm.is_alive():
            vm.destroy(gracefully=False)
        virsh.attach_device(vm.name, interface.xml, flagstr="--config")
        os.remove(interface.xml)
        vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm.name)
        new_nic = vmxml.get_devices(device_type="interface")[-1]

        # Modify new interface's IP
        vm.start()
        session = vm.wait_for_login()
        eth_name = utils_net.get_linux_ifname(session, new_nic.mac_address)
        eth_config_detail = "DEVICE=%s\nHWADDR=%s\nONBOOT=yes\n"\
                            "BOOTPROTO=static\nIPADDR=%s"\
                            % (eth_name, new_nic.mac_address, ip_addr)
        add_cmd = "echo %s >> %s" % (eth_config_detail, eth_config_file)
        session.cmd(add_cmd)
        session.cmd("sync")
        try:
            session.cmd("ifup %s" % eth_name)
        except aexpect.ShellCmdError:
            pass
开发者ID:libvirt-qe,项目名称:tp-libvirt,代码行数:36,代码来源:macvtap.py


示例20: mtu_set

    def mtu_set(mtu):
        """
        Set server/client/host's mtu

        :param mtu: mtu value to be set
        """

        server_mtu_cmd = params.get("server_mtu_cmd")
        client_mtu_cmd = params.get("client_mtu_cmd")
        host_mtu_cmd = params.get("host_mtu_cmd")
        error_context.context("Changing the MTU of guest", logging.info)
        if params.get("os_type") == "linux":
            ethname = utils_net.get_linux_ifname(server_ctl, mac)
            ssh_cmd(server_ctl, server_mtu_cmd % (ethname, mtu))
        elif params.get("os_type") == "windows":
            connection_id = utils_net.get_windows_nic_attribute(
                server_ctl, "macaddress", mac, "netconnectionid")
            ssh_cmd(server_ctl, server_mtu_cmd % (connection_id, mtu))

        error_context.context("Changing the MTU of client", logging.info)
        ssh_cmd(client, client_mtu_cmd
                % (params.get("client_physical_nic"), mtu))

        netdst = params.get("netdst", "switch")
        host_bridges = utils_net.Bridge()
        br_in_use = host_bridges.list_br()
        if netdst in br_in_use:
            ifaces_in_use = host_bridges.list_iface()
            target_ifaces = list(ifaces_in_use + br_in_use)
        if vm.virtnet[0].nettype == "macvtap":
            target_ifaces.extend([vm.virtnet[0].netdst, vm.get_ifname(0)])
        error_context.context("Change all Bridge NICs MTU to %s"
                              % mtu, logging.info)
        for iface in target_ifaces:
            process.run(host_mtu_cmd % (iface, mtu), ignore_status=False,
                        shell=True)
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:36,代码来源:netperf.py



注:本文中的virttest.utils_net.get_linux_ifname函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils_selinux.get_status函数代码示例发布时间:2022-05-26
下一篇:
Python utils_net.get_ip_address_by_interface函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap