예제 #1
0
파일: prog.py 프로젝트: david-hock/ToMaTo
	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
0
파일: kvm.py 프로젝트: joanmarkt/ToMaTo
	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)