本文整理汇总了Python中tomato.devices.Device.interfaceSetAdd方法的典型用法代码示例。如果您正苦于以下问题:Python Device.interfaceSetAdd方法的具体用法?Python Device.interfaceSetAdd怎么用?Python Device.interfaceSetAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tomato.devices.Device
的用法示例。
在下文中一共展示了Device.interfaceSetAdd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: interfacesAdd
# 需要导入模块: from tomato.devices import Device [as 别名]
# 或者: from tomato.devices.Device import interfaceSetAdd [as 别名]
def interfacesAdd(self, name, properties):
fault.check(self.state != State.STARTED, "Repy does not support adding interfaces to running VMs: %s" % self.name)
import re
fault.check(re.match("eth(\d+)", name), "Invalid interface name: %s" % name)
try:
fault.check(not self.interfaceSetGet(name), "Duplicate interface name: %s" % name)
except Interface.DoesNotExist: #pylint: disable-msg=W0702
pass
iface = Interface()
iface.name = name
iface.device = self
iface.init()
iface.save()
Device.interfaceSetAdd(self, iface)
示例2: interfacesAdd
# 需要导入模块: from tomato.devices import Device [as 别名]
# 或者: from tomato.devices.Device import interfaceSetAdd [as 别名]
def interfacesAdd(self, name, properties): #@UnusedVariable, pylint: disable-msg=W0613
fault.check(self.state != State.STARTED, "Changes of running KVMs are not supported")
fault.check(re.match("eth(\d+)", name), "Invalid interface name: %s" % name)
iface = Interface()
try:
if self.interfaceSetGet(name):
raise fault.new("Duplicate interface name: %s" % name)
except Interface.DoesNotExist: #pylint: disable-msg=W0702
pass
iface.name = name
iface.device = self
iface.init()
if self.state == State.PREPARED:
qm.addInterface(self.host, self.getVmid(), iface.name)
iface.save()
Device.interfaceSetAdd(self, iface)
示例3: interfacesAdd
# 需要导入模块: from tomato.devices import Device [as 别名]
# 或者: from tomato.devices.Device import interfaceSetAdd [as 别名]
def interfacesAdd(self, name, properties):
fault.check(self.state != State.STARTED, "OpenVZ does not support adding interfaces to running VMs: %s" % self.name)
import re
fault.check(re.match("eth(\d+)", name), "Invalid interface name: %s" % name)
try:
fault.check(not self.interfaceSetGet(name), "Duplicate interface name: %s" % name)
except Interface.DoesNotExist: #pylint: disable-msg=W0702
pass
iface = ConfiguredInterface()
iface.name = name
iface.device = self
iface.init()
if self.state == State.PREPARED or self.state == State.STARTED:
vzctl.addInterface(self.host, self.getVmid(), iface.name)
iface.configure(properties)
iface.save()
Device.interfaceSetAdd(self, iface)