本文整理汇总了Python中vdsm.netconfpersistence.RunningConfig类的典型用法代码示例。如果您正苦于以下问题:Python RunningConfig类的具体用法?Python RunningConfig怎么用?Python RunningConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RunningConfig类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: PyrouteTwo
class PyrouteTwo(Iproute2):
def __init__(self, inRollback=False):
super(Iproute2, self).__init__(ConfigApplier(), inRollback)
self.runningConfig = RunningConfig()
def commit(self):
self.configApplier.releaseSocket()
self.configApplier = None
self.runningConfig.save()
self.runningConfig = None
开发者ID:Caez83,项目名称:vdsm,代码行数:10,代码来源:pyroute_two.py
示例2: Ifcfg
class Ifcfg(Configurator):
# TODO: Do all the configApplier interaction from here.
def __init__(self, inRollback=False):
self.unifiedPersistence = \
config.get('vars', 'net_persistence') == 'unified'
super(Ifcfg, self).__init__(ConfigWriter(self.unifiedPersistence),
inRollback)
if self.unifiedPersistence:
self.runningConfig = RunningConfig()
def begin(self):
if self.configApplier is None:
self.configApplier = ConfigWriter(self.unifiedPersistence)
if self.unifiedPersistence and self.runningConfig is None:
self.runningConfig = RunningConfig()
def rollback(self):
self.configApplier.restoreBackups()
self.configApplier = None
if self.unifiedPersistence:
self.runningConfig = None
def commit(self):
self.configApplier = None
if self.unifiedPersistence:
self.runningConfig.save()
self.runningConfig = None
def configureBridge(self, bridge, **opts):
self.configApplier.addBridge(bridge, **opts)
ifdown(bridge.name)
if bridge.port:
bridge.port.configure(**opts)
self._addSourceRoute(bridge)
ifup(bridge.name, bridge.ipConfig.async)
def configureVlan(self, vlan, **opts):
self.configApplier.addVlan(vlan, **opts)
vlan.device.configure(**opts)
self._addSourceRoute(vlan)
ifup(vlan.name, vlan.ipConfig.async)
def configureBond(self, bond, **opts):
self.configApplier.addBonding(bond, **opts)
if not netinfo.isVlanned(bond.name):
for slave in bond.slaves:
ifdown(slave.name)
for slave in bond.slaves:
slave.configure(**opts)
self._addSourceRoute(bond)
ifup(bond.name, bond.ipConfig.async)
开发者ID:mpolednik,项目名称:vdsm,代码行数:51,代码来源:ifcfg.py
示例3: __init__
def __init__(self, inRollback=False):
self.unifiedPersistence = \
config.get('vars', 'net_persistence') == 'unified'
super(Ifcfg, self).__init__(ConfigWriter(self.unifiedPersistence),
inRollback)
if self.unifiedPersistence:
self.runningConfig = RunningConfig()
开发者ID:mykaul,项目名称:vdsm,代码行数:7,代码来源:ifcfg.py
示例4: begin
def begin(self):
if self.configApplier is None:
self.configApplier = ConfigWriter(self.unifiedPersistence)
if self.unifiedPersistence and self.runningConfig is None:
self.runningConfig = RunningConfig()
开发者ID:mykaul,项目名称:vdsm,代码行数:5,代码来源:ifcfg.py
示例5: Ifcfg
class Ifcfg(Configurator):
# TODO: Do all the configApplier interaction from here.
def __init__(self, inRollback=False):
self.unifiedPersistence = \
config.get('vars', 'net_persistence') == 'unified'
super(Ifcfg, self).__init__(ConfigWriter(self.unifiedPersistence),
inRollback)
if self.unifiedPersistence:
self.runningConfig = RunningConfig()
def begin(self):
if self.configApplier is None:
self.configApplier = ConfigWriter(self.unifiedPersistence)
if self.unifiedPersistence and self.runningConfig is None:
self.runningConfig = RunningConfig()
def rollback(self):
"""This reimplementation always returns None since Ifcfg can rollback
on its own via restoreBackups(). This makes the general mechanism of
API.Global._rollback redundant in this case."""
self.configApplier.restoreBackups()
self.configApplier = None
if self.unifiedPersistence:
self.runningConfig = None
def commit(self):
self.configApplier = None
if self.unifiedPersistence:
self.runningConfig.save()
self.runningConfig = None
def configureBridge(self, bridge, **opts):
self.configApplier.addBridge(bridge, **opts)
ifdown(bridge.name)
if bridge.port:
bridge.port.configure(**opts)
self._addSourceRoute(bridge)
_ifup(bridge)
if not bridge.ipv6.address and not bridge.ipv6.ipv6autoconf and (
not bridge.ipv6.dhcpv6 and misc.ipv6_supported()):
wait_for_device(bridge.name)
sysctl.disable_ipv6(bridge.name)
def configureVlan(self, vlan, **opts):
self.configApplier.addVlan(vlan, **opts)
vlan.device.configure(**opts)
self._addSourceRoute(vlan)
_ifup(vlan)
def configureBond(self, bond, **opts):
self.configApplier.addBonding(bond, **opts)
if not vlans.is_vlanned(bond.name):
for slave in bond.slaves:
ifdown(slave.name)
for slave in bond.slaves:
slave.configure(**opts)
self._addSourceRoute(bond)
_ifup(bond)
if self.unifiedPersistence:
self.runningConfig.setBonding(
bond.name, {'options': bond.options,
'nics': [slave.name for slave in bond.slaves]})
def editBonding(self, bond, _netinfo):
"""
Modifies the bond so that the bond in the system ends up with the
same slave and options configuration that are requested. Makes a
best effort not to interrupt connectivity.
"""
nicsToSet = frozenset(nic.name for nic in bond.slaves)
currentNics = frozenset(_netinfo.getNicsForBonding(bond.name))
nicsToAdd = nicsToSet - currentNics
# Create bond configuration in case it was a non ifcfg controlled bond.
# Needed to be before slave configuration for initscripts to add slave
# to bond.
bondIfcfgWritten = False
isIfcfgControlled = os.path.isfile(NET_CONF_PREF + bond.name)
areOptionsApplied = bond.areOptionsApplied()
if not isIfcfgControlled or not areOptionsApplied:
bridgeName = _netinfo.getBridgedNetworkForIface(bond.name)
if isIfcfgControlled and bridgeName:
bond.master = Bridge(bridgeName, self, port=bond)
self.configApplier.addBonding(bond)
bondIfcfgWritten = True
for nic in currentNics - nicsToSet:
ifdown(nic) # So that no users will be detected for it.
Nic(nic, self, _netinfo=_netinfo).remove()
for slave in bond.slaves:
if slave.name in nicsToAdd:
ifdown(slave.name) # nics must be down to join a bond
self.configApplier.addNic(slave)
_exec_ifup(slave.name)
if bondIfcfgWritten:
ifdown(bond.name)
_restore_default_bond_options(bond.name, bond.options)
_exec_ifup(bond.name)
#.........这里部分代码省略.........
开发者ID:mykaul,项目名称:vdsm,代码行数:101,代码来源:ifcfg.py
示例6: begin
def begin(self):
if self.configApplier is None:
self.configApplier = ConfigApplier()
if self.runningConfig is None:
self.runningConfig = RunningConfig()
开发者ID:Caez83,项目名称:vdsm,代码行数:5,代码来源:iproute2.py
示例7: __init__
def __init__(self, inRollback=False):
super(Iproute2, self).__init__(ConfigApplier(), inRollback)
self.runningConfig = RunningConfig()
开发者ID:Caez83,项目名称:vdsm,代码行数:3,代码来源:iproute2.py
示例8: Iproute2
class Iproute2(Configurator):
def __init__(self, inRollback=False):
super(Iproute2, self).__init__(ConfigApplier(), inRollback)
self.runningConfig = RunningConfig()
def begin(self):
if self.configApplier is None:
self.configApplier = ConfigApplier()
if self.runningConfig is None:
self.runningConfig = RunningConfig()
def commit(self):
self.configApplier = None
self.runningConfig.save()
self.runningConfig = None
def configureBridge(self, bridge, **opts):
self.configApplier.addBridge(bridge)
if bridge.port:
bridge.port.configure(**opts)
self.configApplier.addBridgePort(bridge)
DynamicSourceRoute.addInterfaceTracking(bridge)
self.configApplier.setIfaceConfigAndUp(bridge)
self._addSourceRoute(bridge)
if 'custom' in opts and 'bridge_opts' in opts['custom']:
self.configApplier._setBridgeOpts(bridge,
opts['custom']['bridge_opts'])
def configureVlan(self, vlan, **opts):
vlan.device.configure(**opts)
self.configApplier.addVlan(vlan)
DynamicSourceRoute.addInterfaceTracking(vlan)
self.configApplier.setIfaceConfigAndUp(vlan)
self._addSourceRoute(vlan)
def configureBond(self, bond, **opts):
self.configApplier.addBond(bond)
if not bond.areOptionsApplied():
self.configApplier.ifdown(bond)
self.configApplier.addBondOptions(bond)
for slave in bond.slaves:
if slave.name not in netinfo.slaves(bond.name):
self.configApplier.addBondSlave(bond, slave)
slave.configure(**opts)
DynamicSourceRoute.addInterfaceTracking(bond)
self.configApplier.setIfaceConfigAndUp(bond)
self._addSourceRoute(bond)
self.runningConfig.setBonding(
bond.name, {'options': bond.options,
'nics': [slave.name for slave in bond.slaves]})
def editBonding(self, bond, _netinfo):
"""
Modifies the bond so that the bond in the system ends up with the
same slave and options configuration that are requested. Makes a
best effort not to interrupt connectivity.
"""
nicsToSet = frozenset(nic.name for nic in bond.slaves)
currentNics = frozenset(_netinfo.getNicsForBonding(bond.name))
nicsToAdd = nicsToSet
nicsToRemove = currentNics
if bond.areOptionsApplied():
nicsToAdd -= currentNics
nicsToRemove -= nicsToSet
for nic in nicsToRemove:
slave = Nic(nic, self, _netinfo=_netinfo)
self.configApplier.removeBondSlave(bond, slave)
slave.remove()
if not bond.areOptionsApplied():
self.configApplier.ifdown(bond)
self.configApplier.addBondOptions(bond)
for slave in bond.slaves:
if slave.name in nicsToAdd:
self.configApplier.addBondSlave(bond, slave)
self.configApplier.ifup(bond)
self.runningConfig.setBonding(
bond.name, {'options': bond.options,
'nics': [slave.name for slave in bond.slaves]})
def configureNic(self, nic, **opts):
DynamicSourceRoute.addInterfaceTracking(nic)
self.configApplier.setIfaceConfigAndUp(nic)
self._addSourceRoute(nic)
ethtool_opts = getEthtoolOpts(nic.name)
if ethtool_opts:
# We ignore ethtool's return code to maintain initscripts'
# behaviour.
execCmd(
[_ETHTOOL_BINARY.cmd, '-K', nic.name] + ethtool_opts.split())
def removeBridge(self, bridge):
DynamicSourceRoute.addInterfaceTracking(bridge)
self.configApplier.ifdown(bridge)
self._removeSourceRoute(bridge, DynamicSourceRoute)
#.........这里部分代码省略.........
开发者ID:Caez83,项目名称:vdsm,代码行数:101,代码来源:iproute2.py
示例9: __init__
def __init__(self, inRollback=False):
self.unifiedPersistence = True
super(Iproute2, self).__init__(ConfigApplier(), inRollback)
self.runningConfig = RunningConfig()
开发者ID:nickxiao,项目名称:vdsm,代码行数:4,代码来源:iproute2.py
示例10: Iproute2
class Iproute2(Configurator):
def __init__(self, inRollback=False):
self.unifiedPersistence = True
super(Iproute2, self).__init__(ConfigApplier(), inRollback)
self.runningConfig = RunningConfig()
def begin(self):
if self.configApplier is None:
self.configApplier = ConfigApplier()
if self.runningConfig is None:
self.runningConfig = RunningConfig()
def commit(self):
self.configApplier = None
self.runningConfig.save()
self.runningConfig = None
def configureBridge(self, bridge, **opts):
self.configApplier.addBridge(bridge)
if bridge.port:
bridge.port.configure(**opts)
self.configApplier.addBridgePort(bridge)
DynamicSourceRoute.addInterfaceTracking(bridge)
self.configApplier.setIfaceConfigAndUp(bridge)
if not bridge.ipv6.address and not bridge.ipv6.ipv6autoconf and (not bridge.ipv6.dhcpv6):
wait_for_device(bridge.name)
sysctl.disable_ipv6(bridge.name)
self._addSourceRoute(bridge)
if "custom" in opts and "bridge_opts" in opts["custom"]:
self.configApplier._setBridgeOpts(bridge, opts["custom"]["bridge_opts"])
def configureVlan(self, vlan, **opts):
vlan.device.configure(**opts)
self.configApplier.addVlan(vlan)
DynamicSourceRoute.addInterfaceTracking(vlan)
self.configApplier.setIfaceConfigAndUp(vlan)
self._addSourceRoute(vlan)
def configureBond(self, bond, **opts):
self.configApplier.addBond(bond)
if not bond.areOptionsApplied():
self.configApplier.ifdown(bond)
self.configApplier.addBondOptions(bond)
for slave in bond.slaves:
if slave.name not in netinfo.slaves(bond.name):
self.configApplier.addBondSlave(bond, slave)
slave.configure(**opts)
DynamicSourceRoute.addInterfaceTracking(bond)
self.configApplier.setIfaceConfigAndUp(bond)
self._addSourceRoute(bond)
self.runningConfig.setBonding(
bond.name, {"options": bond.options, "nics": [slave.name for slave in bond.slaves]}
)
def editBonding(self, bond, _netinfo):
"""
Modifies the bond so that the bond in the system ends up with the
same slave and options configuration that are requested. Makes a
best effort not to interrupt connectivity.
"""
nicsToSet = frozenset(nic.name for nic in bond.slaves)
currentNics = frozenset(_netinfo.getNicsForBonding(bond.name))
nicsToAdd = nicsToSet
nicsToRemove = currentNics
if bond.areOptionsApplied():
nicsToAdd -= currentNics
nicsToRemove -= nicsToSet
for nic in nicsToRemove:
slave = Nic(nic, self, _netinfo=_netinfo)
self.configApplier.removeBondSlave(bond, slave)
slave.remove()
if not bond.areOptionsApplied():
self.configApplier.ifdown(bond)
self.configApplier.addBondOptions(bond)
for slave in bond.slaves:
if slave.name in nicsToAdd:
self.configApplier.addBondSlave(bond, slave)
self.configApplier.ifup(bond)
self.runningConfig.setBonding(
bond.name, {"options": bond.options, "nics": [slave.name for slave in bond.slaves]}
)
def configureNic(self, nic, **opts):
DynamicSourceRoute.addInterfaceTracking(nic)
self.configApplier.setIfaceConfigAndUp(nic)
self._addSourceRoute(nic)
ethtool_opts = getEthtoolOpts(nic.name)
if ethtool_opts:
# We ignore ethtool's return code to maintain initscripts'
# behaviour.
execCmd([_ETHTOOL_BINARY.cmd, "-K", nic.name] + ethtool_opts.split())
def removeBridge(self, bridge):
DynamicSourceRoute.addInterfaceTracking(bridge)
#.........这里部分代码省略.........
开发者ID:nickxiao,项目名称:vdsm,代码行数:101,代码来源:iproute2.py
示例11: __init__
def __init__(self, inRollback=False):
self.unifiedPersistence = config.get("vars", "net_persistence") == "unified"
super(Ifcfg, self).__init__(ConfigWriter(self.unifiedPersistence), inRollback)
if self.unifiedPersistence:
self.runningConfig = RunningConfig()
开发者ID:fancyKai,项目名称:vdsm,代码行数:5,代码来源:ifcfg.py
注:本文中的vdsm.netconfpersistence.RunningConfig类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论