当前位置: 首页>>代码示例>>Python>>正文


Python ipwrapper.linkSet函数代码示例

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


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

示例1: _down

 def _down(self):
     with monitor.Monitor(groups=('link',), timeout=2) as mon:
         linkSet(self.devName, ['down'])
         for event in mon:
             if (event.get('name') == self.devName and
                     event.get('state') == 'down'):
                 return
开发者ID:andrewlukoshko,项目名称:vdsm,代码行数:7,代码来源:nettestlib.py

示例2: removeBond

    def removeBond(self, bonding):
        if not self.owned_device(bonding.name):
            IfcfgAcquire.acquire_device(bonding.name)
        to_be_removed = self._ifaceDownAndCleanup(bonding)
        if to_be_removed:
            self.configApplier.removeBonding(bonding.name)
            if bonding.on_removal_just_detach_from_network:
                # Recreate the bond with ip and master info cleared
                bonding.ipv4 = address.IPv4()
                bonding.ipv6 = address.IPv6()
                bonding.master = None
                bonding.configure()
            else:
                for slave in bonding.slaves:
                    slave.remove()
                self.runningConfig.removeBonding(bonding.name)
        else:
            vlans = link_vlan.get_vlans_on_base_device(bonding.name)
            set_mtu = self._setNewMtu(bonding, vlans)
            # Since we are not taking the device up again, ifcfg will not be
            # read at this point and we need to set the live mtu value.
            # Note that ip link set dev bondX mtu Y sets Y on all its links
            if set_mtu is not None:
                ipwrapper.linkSet(bonding.name, ['mtu', str(set_mtu)])

            # If the bond was bridged, we must remove BRIDGE parameter from its
            # ifcfg configuration file.
            if bonding.bridge:
                self.configApplier.dropBridgeParameter(bonding.name)

            bond_used_by_net = self.net_info.getNetworkForIface(bonding.name)
            bond_info = self.net_info.bondings[bonding.name]
            if (not bond_used_by_net and
                    (bond_info['ipv4addrs'] or bond_info['ipv6addrs'])):
                ipwrapper.addrFlush(bonding.name)
开发者ID:oVirt,项目名称:vdsm,代码行数:35,代码来源:ifcfg.py

示例3: removeNic

    def removeNic(self, nic, remove_even_if_used=False):
        if not self.owned_device(nic.name):
            IfcfgAcquire.acquire_device(nic.name)

        # If the nic is top device we should ifdown it even if it is
        # used by a VLAN. Otherwise we would keep its IP address.
        remove_even_if_used |= nic.master is None

        to_be_removed = self._ifaceDownAndCleanup(nic, remove_even_if_used)
        if to_be_removed:
            self.configApplier.removeNic(nic.name)
            if nic.name in nics.nics():
                _exec_ifup(nic)
            else:
                logging.warning('host interface %s missing', nic.name)
        else:
            vlans = link_vlan.get_vlans_on_base_device(nic.name)
            set_mtu = self._setNewMtu(nic, vlans)
            # Since we are not taking the device up again, ifcfg will not be
            # read at this point and we need to set the live mtu value
            if set_mtu is not None:
                ipwrapper.linkSet(nic.name, ['mtu', str(set_mtu)])

            # If the nic was bridged, we must remove BRIDGE parameter from its
            # ifcfg configuration file.
            if nic.bridge:
                self.configApplier.dropBridgeParameter(nic.name)
开发者ID:oVirt,项目名称:vdsm,代码行数:27,代码来源:ifcfg.py

示例4: test_switch_change_bonded_network_with_dhclient

    def test_switch_change_bonded_network_with_dhclient(self):
        with veth_pair() as (server, nic1):
            with dummy_device() as nic2:
                NETSETUP_SOURCE = {NET1_NAME: {
                    'bonding': BOND_NAME,
                    'bootproto': 'dhcp',
                    'blockingdhcp': True,
                    'switch': self.switch_type_source}}
                NETSETUP_TARGET = _change_switch_type(
                    NETSETUP_SOURCE, self.switch_type_target)
                BONDSETUP_SOURCE = {BOND_NAME: {
                    'nics': [nic1, nic2], 'switch': self.switch_type_source}}
                BONDSETUP_TARGET = _change_switch_type(
                    BONDSETUP_SOURCE, self.switch_type_target)

                addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
                linkSet(server, ['up'])

                with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO):
                    with self.setupNetworks(
                            NETSETUP_SOURCE, BONDSETUP_SOURCE, NOCHK):
                        self.setupNetworks(
                            NETSETUP_TARGET, BONDSETUP_TARGET, NOCHK)
                        self.assertNetwork(
                            NET1_NAME, NETSETUP_TARGET[NET1_NAME])
                        self.assertBond(BOND_NAME, BONDSETUP_TARGET[BOND_NAME])
开发者ID:EdDev,项目名称:vdsm,代码行数:26,代码来源:func_switch_type_change_test.py

示例5: removeBond

    def removeBond(self, bonding):
        if not self.owned_device(bonding.name):
            IfcfgAcquire.acquire_device(bonding.name)
        to_be_removed = self._ifaceDownAndCleanup(bonding)
        if to_be_removed:
            self.configApplier.removeBonding(bonding.name)
            if bonding.on_removal_just_detach_from_network:
                # Recreate the bond with ip and master info cleared
                bonding.ipv4 = address.IPv4()
                bonding.ipv6 = address.IPv6()
                bonding.master = None
                bonding.configure()
            else:
                for slave in bonding.slaves:
                    slave.remove()
                if self.unifiedPersistence:
                    self.runningConfig.removeBonding(bonding.name)
        else:
            set_mtu = self._setNewMtu(bonding, vlans.vlan_devs_for_iface(bonding.name))
            # Since we are not taking the device up again, ifcfg will not be
            # read at this point and we need to set the live mtu value.
            # Note that ip link set dev bondX mtu Y sets Y on all its links
            if set_mtu is not None:
                ipwrapper.linkSet(bonding.name, ["mtu", str(set_mtu)])

            # If the bond was bridged, we must remove BRIDGE parameter from its
            # ifcfg configuration file.
            if bonding.bridge:
                self.configApplier.dropBridgeParameter(bonding.name)
开发者ID:nirs,项目名称:vdsm,代码行数:29,代码来源:ifcfg.py

示例6: test_ovirtmgmtm_to_ovs

    def test_ovirtmgmtm_to_ovs(self):
        """ Test transformation of initial management network to OVS.
        # TODO: test it with ovirtmgmt and test-network
        # NOTE: without default route
        # TODO: more asserts
        """
        with veth_pair() as (left, right):
            addrAdd(left, IP_ADDRESS, IP_CIDR)
            addrAdd(left, IPv6_ADDRESS, IPv6_CIDR, 6)
            linkSet(left, ['up'])
            with dnsmasq_run(left, DHCP_RANGE_FROM, DHCP_RANGE_TO,
                             DHCPv6_RANGE_FROM, DHCPv6_RANGE_TO, IP_GATEWAY):
                network = {
                    NETWORK_NAME: {'nic': right, 'bootproto': 'dhcp',
                                   'bridged': True, 'blockingdhcp': True}}
                options = NOCHK
                options['ovs'] = False

                try:
                    status, msg = self.setupNetworks(network, {}, options)
                    self.assertEqual(status, SUCCESS, msg)
                    self.assertNetworkExists(NETWORK_NAME)

                    options['ovs'] = True
                    status, msg = self.setupNetworks(network, {}, options)
                    self.assertEqual(status, SUCCESS, msg)
                    self.assertNetworkExists(NETWORK_NAME)
                finally:
                    dhcp.delete_dhclient_leases(NETWORK_NAME, True, False)
开发者ID:andrewlukoshko,项目名称:vdsm,代码行数:29,代码来源:networkTestsOVS.py

示例7: test_add_net_with_dhcp

    def test_add_net_with_dhcp(self, switch, families, bridged):

        with veth_pair() as (server, client):
            addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
            addrAdd(server, IPv6_ADDRESS, IPv6_CIDR, IpFamily.IPv6)
            linkSet(server, ['up'])
            with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO,
                             DHCPv6_RANGE_FROM, DHCPv6_RANGE_TO,
                             router=DHCPv4_GATEWAY):

                network_attrs = {'bridged': bridged,
                                 'nic': client,
                                 'blockingdhcp': True,
                                 'switch': switch}

                if IpFamily.IPv4 in families:
                    network_attrs['bootproto'] = 'dhcp'
                if IpFamily.IPv6 in families:
                    network_attrs['dhcpv6'] = True

                netcreate = {NETWORK_NAME: network_attrs}

                with adapter.setupNetworks(netcreate, {}, NOCHK):
                    adapter.assertNetworkIp(
                        NETWORK_NAME, netcreate[NETWORK_NAME])
开发者ID:nirs,项目名称:vdsm,代码行数:25,代码来源:dynamic_ip_test.py

示例8: up

 def up(self, admin_blocking=True, oper_blocking=False):
     if self._is_dpdk_type:
         dpdk.up(self._dev)
         return
     if admin_blocking:
         self._up_blocking(oper_blocking)
     else:
         ipwrapper.linkSet(self._dev, [STATE_UP])
开发者ID:nirs,项目名称:vdsm,代码行数:8,代码来源:iface.py

示例9: removeNic

 def removeNic(self, nic, remove_even_if_used=False):
     to_be_removed = self._ifaceDownAndCleanup(nic, remove_even_if_used)
     if to_be_removed:
         self.configApplier.removeNic(nic.name)
         if nic.name in nics.nics():
             _exec_ifup(nic)
         else:
             logging.warning('host interface %s missing', nic.name)
     else:
         set_mtu = self._setNewMtu(nic, vlans.vlan_devs_for_iface(nic.name))
         # Since we are not taking the device up again, ifcfg will not be
         # read at this point and we need to set the live mtu value
         if set_mtu is not None:
             ipwrapper.linkSet(nic.name, ['mtu', str(set_mtu)])
开发者ID:andrewlukoshko,项目名称:vdsm,代码行数:14,代码来源:ifcfg.py

示例10: test_attach_dhcp_nic_to_ipless_network

    def test_attach_dhcp_nic_to_ipless_network(self):
        with veth_pair() as (server, client):
            addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
            linkSet(server, ["up"])
            with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO):
                with dhclient_run(client):
                    self.assertDhclient(client, family=4)

                    NETCREATE = {NETWORK_NAME: {"nic": client, "switch": self.switch}}
                    with self.setupNetworks(NETCREATE, {}, NOCHK):
                        nic_netinfo = self.netinfo.nics[client]
                        self.assertDisabledIPv4(nic_netinfo)
                        net_netinfo = self.netinfo.networks[NETWORK_NAME]
                        self.assertDisabledIPv4(net_netinfo)
开发者ID:nirs,项目名称:vdsm,代码行数:14,代码来源:func_dhclient_test.py

示例11: _test_add_net_with_dhcpv4

    def _test_add_net_with_dhcpv4(self, bridged=False):

        with veth_pair() as (server, client):
            addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
            linkSet(server, ['up'])
            with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO):

                netcreate = {NETWORK_NAME: {
                    'bridged': bridged, 'nic': client, 'blockingdhcp': True,
                    'bootproto': 'dhcp', 'switch': self.switch}}

                with self.setupNetworks(netcreate, {}, NOCHK):
                    self.assertNetworkIp(
                        NETWORK_NAME, netcreate[NETWORK_NAME])
开发者ID:yingyun001,项目名称:vdsm,代码行数:14,代码来源:func_dhclient_test.py

示例12: change_numvfs

def change_numvfs(pci_path, numvfs, net_name):
    """Change number of virtual functions of a device.

    The persistence is stored in the same place as other network persistence is
    stored. A call to setSafeNetworkConfig() will persist it across reboots.
    """
    # TODO: net_name is here only because it is hard to call pf_to_net_name
    # TODO: from here. once all our code will be under lib/vdsm this should be
    # TODO: removed.
    logging.info("Changing number of vfs on device %s -> %s.", pci_path, numvfs)
    _update_numvfs(pci_path, numvfs)

    logging.info("Changing number of vfs on device %s -> %s. succeeded.", pci_path, numvfs)
    _persist_numvfs(pci_path, numvfs)

    ipwrapper.linkSet(net_name, ["up"])
开发者ID:nirs,项目名称:vdsm,代码行数:16,代码来源:api.py

示例13: test_attach_dhcp_nic_to_dhcpv6_bridged_network

    def test_attach_dhcp_nic_to_dhcpv6_bridged_network(self, switch):
        with veth_pair() as (server, client):
            addrAdd(server, IPv6_ADDRESS, IPv6_CIDR, IpFamily.IPv6)
            linkSet(server, ['up'])
            with dnsmasq_run(server, DHCPv6_RANGE_FROM, DHCPv6_RANGE_TO):
                with dhclient_run(client, family=IpFamily.IPv6):
                    adapter.assertDhclient(client, family=IpFamily.IPv6)

                    NETCREATE = {NETWORK_NAME: {
                        'nic': client, 'dhcpv6': True,
                        'blockingdhcp': True, 'switch': switch}}
                    with adapter.setupNetworks(NETCREATE, {}, NOCHK):
                        nic_netinfo = adapter.netinfo.nics[client]
                        adapter.assertDisabledIPv6(nic_netinfo)
                        adapter.assertNoDhclient(client, family=IpFamily.IPv6)
                        net_netinfo = adapter.netinfo.networks[NETWORK_NAME]
                        adapter.assertDHCPv6(net_netinfo)
                        adapter.assertDhclient(NETWORK_NAME,
                                               family=IpFamily.IPv6)
开发者ID:nirs,项目名称:vdsm,代码行数:19,代码来源:dynamic_ip_test.py

示例14: _test_add_net_with_dhcpv4

    def _test_add_net_with_dhcpv4(self, bridged=False):

        with veth_pair() as (server, client):
            addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
            linkSet(server, ["up"])
            with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO):

                netcreate = {
                    NETWORK_NAME: {
                        "bridged": bridged,
                        "nic": client,
                        "blockingdhcp": True,
                        "bootproto": "dhcp",
                        "switch": self.switch,
                    }
                }

                with self.setupNetworks(netcreate, {}, NOCHK):
                    self.assertNetworkIp(NETWORK_NAME, netcreate[NETWORK_NAME])
开发者ID:nirs,项目名称:vdsm,代码行数:19,代码来源:func_dhclient_test.py

示例15: removeNic

    def removeNic(self, nic, remove_even_if_used=False):
        if not self.owned_device(nic.name):
            IfcfgAcquire.acquire_device(nic.name)
        to_be_removed = self._ifaceDownAndCleanup(nic, remove_even_if_used)
        if to_be_removed:
            self.configApplier.removeNic(nic.name)
            if nic.name in nics.nics():
                _exec_ifup(nic)
            else:
                logging.warning("host interface %s missing", nic.name)
        else:
            set_mtu = self._setNewMtu(nic, vlans.vlan_devs_for_iface(nic.name))
            # Since we are not taking the device up again, ifcfg will not be
            # read at this point and we need to set the live mtu value
            if set_mtu is not None:
                ipwrapper.linkSet(nic.name, ["mtu", str(set_mtu)])

            # If the nic was bridged, we must remove BRIDGE parameter from its
            # ifcfg configuration file.
            if nic.bridge:
                self.configApplier.dropBridgeParameter(nic.name)
开发者ID:nirs,项目名称:vdsm,代码行数:21,代码来源:ifcfg.py


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