本文整理汇总了Python中vdsm.netinfo.nics函数的典型用法代码示例。如果您正苦于以下问题:Python nics函数的具体用法?Python nics怎么用?Python nics使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nics函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _validateNetworkSetup
def _validateNetworkSetup(networks, bondings):
for network, networkAttrs in networks.iteritems():
if networkAttrs.get('remove', False):
if set(networkAttrs) - set(['remove']):
raise ConfigNetworkError(ne.ERR_BAD_PARAMS, 'Cannot specify '
'any attribute when removing')
currentBondings = netinfo.bondings()
currentNicsSet = set(netinfo.nics())
for bonding, bondingAttrs in bondings.iteritems():
Bond.validateName(bonding)
if 'options' in bondingAttrs:
Bond.validateOptions(bonding, bondingAttrs['options'])
if bondingAttrs.get('remove', False):
if bonding not in currentBondings:
raise ConfigNetworkError(ne.ERR_BAD_BONDING, "Cannot remove "
"bonding %s: Doesn't exist" % bonding)
continue
nics = bondingAttrs.get('nics', None)
if not nics:
raise ConfigNetworkError(ne.ERR_BAD_PARAMS,
"Must specify nics for bonding")
if not set(nics).issubset(currentNicsSet):
raise ConfigNetworkError(ne.ERR_BAD_NIC,
"Unknown nics in: %r" % list(nics))
开发者ID:int64ago-public,项目名称:vdsm,代码行数:27,代码来源:configNetwork.py
示例2: _validateNetworkSetup
def _validateNetworkSetup(networks, bondings):
for network, networkAttrs in networks.iteritems():
if networkAttrs.get('remove', False):
net_attr_keys = set(networkAttrs)
if 'remove' in net_attr_keys and net_attr_keys - set(
['remove', 'custom']):
raise ConfigNetworkError(
ne.ERR_BAD_PARAMS,
"Cannot specify any attribute when removing (other "
"than custom properties). specified attributes: %s" % (
networkAttrs,))
currentNicsSet = set(netinfo.nics())
for bonding, bondingAttrs in bondings.iteritems():
Bond.validateName(bonding)
if 'options' in bondingAttrs:
Bond.validateOptions(bonding, bondingAttrs['options'])
if bondingAttrs.get('remove', False):
continue
nics = bondingAttrs.get('nics', None)
if not nics:
raise ConfigNetworkError(ne.ERR_BAD_PARAMS,
"Must specify nics for bonding")
if not set(nics).issubset(currentNicsSet):
raise ConfigNetworkError(ne.ERR_BAD_NIC,
"Unknown nics in: %r" % list(nics))
开发者ID:Caez83,项目名称:vdsm,代码行数:28,代码来源:api.py
示例3: testFakeNics
def testFakeNics(self):
with MonkeyPatchScope([(ipwrapper.Link, '_fakeNics', ['veth_*',
'dummy_*'])]):
with veth_pair() as (v1a, v1b):
with dummy_device() as d1:
fakes = set([d1, v1a, v1b])
nics = netinfo.nics()
self.assertTrue(fakes.issubset(nics), 'Fake devices %s are'
' not listed in nics %s' % (fakes, nics))
with veth_pair(prefix='mehv_') as (v2a, v2b):
with dummy_device(prefix='mehd_') as d2:
hiddens = set([d2, v2a, v2b])
nics = netinfo.nics()
self.assertFalse(hiddens.intersection(nics), 'Some of '
'hidden devices %s is shown in nics %s' %
(hiddens, nics))
开发者ID:germanovm,项目名称:vdsm,代码行数:17,代码来源:netinfoTests.py
示例4: testNics
def testNics(self):
temp_dir = tempfile.mkdtemp()
with MonkeyPatchScope([(netinfo, 'NET_FN_MATCH',
self._dev_dirs_setup(temp_dir)),
(netinfo, 'config', self._config_setup())]):
try:
self.assertEqual(set(netinfo.nics()),
set(['em', 'me', 'fake0', 'fake']))
finally:
rmtree(temp_dir)
开发者ID:hackxay,项目名称:vdsm,代码行数:10,代码来源:netinfoTests.py
示例5: testNics
def testNics(self):
temp_dir = tempfile.mkdtemp()
with MonkeyPatchScope([(netinfo, 'BONDING_SLAVES',
temp_dir + '/%s/bonding/slaves'),
(netinfo, 'NET_PATH',
self._dev_dirs_setup(temp_dir)),
(netinfo, 'config', self._config_setup())]):
try:
self.assertEqual(set(netinfo.nics()),
set(['em', 'me', 'fake', 'fake0']))
finally:
rmtree(temp_dir)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:12,代码来源:netinfoTests.py
示例6: removeNic
def removeNic(self, nic):
to_be_removed = self._ifaceDownAndCleanup(nic)
if to_be_removed:
self.configApplier.removeNic(nic.name)
if nic.name in netinfo.nics():
_exec_ifup(nic.name)
else:
logging.warning('host interface %s missing', nic.name)
else:
set_mtu = self._setNewMtu(nic, netinfo.vlanDevsForIface(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:germanovm,项目名称:vdsm,代码行数:14,代码来源:ifcfg.py
示例7: __init__
def __init__(self, log):
"""
Initialize the (single) clientIF instance
:param log: a log object to be used for this object's logging.
:type log: :class:`logging.Logger`
"""
self.vmContainerLock = threading.Lock()
self._networkSemaphore = threading.Semaphore()
self._shutdownSemaphore = threading.Semaphore()
self.log = log
self._recovery = True
self.channelListener = Listener(self.log)
self._generationID = str(uuid.uuid4())
self._initIRS()
self.mom = None
if _glusterEnabled:
self.gluster = gapi.GlusterApi(self, log)
else:
self.gluster = None
try:
self.vmContainer = {}
ifids = netinfo.nics() + netinfo.bondings()
ifrates = map(netinfo.speed, ifids)
self._hostStats = sampling.HostStatsThread(
cif=self, log=log, ifids=ifids,
ifrates=ifrates)
self._hostStats.start()
self.lastRemoteAccess = 0
self._memLock = threading.Lock()
self._enabled = True
self._netConfigDirty = False
self._prepareMOM()
threading.Thread(target=self._recoverExistingVms,
name='clientIFinit').start()
self.channelListener.settimeout(
config.getint('vars', 'guest_agent_timeout'))
self.channelListener.start()
self.threadLocal = threading.local()
self.threadLocal.client = ''
except:
self.log.error('failed to init clientIF, '
'shutting down storage dispatcher')
if self.irs:
self.irs.prepareForShutdown()
if self.mom:
self.mom.stop()
raise
self._prepareBindings()
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:49,代码来源:clientIF.py
示例8: __init__
def __init__ (self, log):
"""
Initialize the (single) clientIF instance
:param log: a log object to be used for this object's logging.
:type log: :class:`logging.Logger`
"""
self.vmContainerLock = threading.Lock()
self._networkSemaphore = threading.Semaphore()
self._shutdownSemaphore = threading.Semaphore()
self.log = log
self._recovery = True
self._libvirt = libvirtconnection.get()
self._syncLibvirtNetworks()
self.channelListener = Listener(self.log)
self._generationID = str(uuid.uuid4())
self._initIRS()
try:
self.vmContainer = {}
ifids = netinfo.nics() + netinfo.bondings()
ifrates = map(netinfo.speed, ifids)
self._hostStats = utils.HostStatsThread(cif=self, log=log, ifids=ifids,
ifrates=ifrates)
self._hostStats.start()
mog = min(config.getint('vars', 'max_outgoing_migrations'),
caps.CpuInfo().cores())
vm.MigrationSourceThread.setMaxOutgoingMigrations(mog)
self.lastRemoteAccess = 0
self._memLock = threading.Lock()
self._enabled = True
self.ksmMonitor = ksm.KsmMonitorThread(self)
self._netConfigDirty = False
threading.Thread(target=self._recoverExistingVms,
name='clientIFinit').start()
self.channelListener.settimeout(config.getint('vars', 'guest_agent_timeout'))
self.channelListener.start()
self.threadLocal = threading.local()
self.threadLocal.client = ''
except:
self.log.error('failed to init clientIF, shutting down storage dispatcher')
if self.irs:
self.irs.prepareForShutdown()
raise
self._prepareBindings()
开发者ID:ekohl,项目名称:vdsm,代码行数:45,代码来源:clientIF.py
示例9: testNics
def testNics(self):
"""
managed by vdsm: em, me, fake0, fake1
not managed due to hidden bond (jbond) enslavement: me0, me1
not managed due to being hidden nics: hid0, hideous
"""
with MonkeyPatchScope([(netinfo, 'getLinks',
self._testNics),
(ipwrapper, '_bondExists',
lambda x: x == 'jbond'),
(ipwrapper.Link, '_detectType',
partial(_fakeTypeDetection, ipwrapper.Link)),
(ipwrapper.Link, '_fakeNics', ['fake*']),
(ipwrapper.Link, '_hiddenBonds', ['jb*']),
(ipwrapper.Link, '_hiddenNics', ['hid*'])
]):
self.assertEqual(set(netinfo.nics()),
set(['em', 'me', 'fake', 'fake0']))
开发者ID:germanovm,项目名称:vdsm,代码行数:18,代码来源:netinfoTests.py
示例10: testFakeNics
def testFakeNics(self):
with MonkeyPatchScope([(ipwrapper.Link, '_fakeNics', ['veth_*',
'dummy_*'])]):
d1 = dummy.create()
d2 = dummy.create(prefix='mehd_')
v1a, v1b = veth.create()
v2a, v2b = veth.create(prefix='mehv_')
fakes = set([d1, v1a, v1b])
hiddens = set([d2, v2a, v2b])
nics = netinfo.nics()
dummy.remove(d1)
dummy.remove(d2)
veth.remove(v1a)
veth.remove(v2a)
self.assertTrue(fakes.issubset(nics), 'Fake devices %s are not '
'listed in nics %s' % (fakes, nics))
self.assertFalse(hiddens.intersection(nics), 'Some of hidden '
'devices %s is shown in nics %s' % (hiddens,
nics))
开发者ID:Caez83,项目名称:vdsm,代码行数:21,代码来源:netinfoTests.py
示例11: testSpeedInRange
def testSpeedInRange(self):
for d in netinfo.nics():
s = netinfo.nicSpeed(d)
self.assertFalse(s < 0)
self.assertTrue(s in ETHTOOL_SPEEDS or s == 0)
开发者ID:germanovm,项目名称:vdsm,代码行数:5,代码来源:netinfoTests.py
示例12: testSpeedInvalidNic
def testSpeedInvalidNic(self):
nicName = 'DUMMYNICDEVNAME'
self.assertTrue(nicName not in netinfo.nics())
s = netinfo.speed(nicName)
self.assertEqual(s, 0)
开发者ID:lukas-bednar,项目名称:vdsm,代码行数:5,代码来源:netinfoTests.py
注:本文中的vdsm.netinfo.nics函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论