Ejemplo n.º 1
0
	def configure(self, properties):
		Interface.configure(self, properties)
		changed=False
		if "use_dhcp" in properties:
			self.setAttribute("use_dhcp", properties["use_dhcp"])
			changed = True
		if "ip4address" in properties:
			self.setAttribute("ip4address", properties["ip4address"])
			changed = True
		if "ip6address" in properties:
			self.setAttribute("ip6address", properties["ip6address"])
			changed = True
		if changed:
			if self.device.state == State.STARTED:
				self._configureNetwork()
			self.save()
Ejemplo n.º 2
0
	def getCapabilities(self, user):
		capabilities = Interface.getCapabilities(self, user)
		capabilities["configure"].update({
			"use_dhcp": True,
			"ip4address": True,
			"ip6address": True,
		})
		return capabilities
Ejemplo n.º 3
0
Archivo: kvm.py Proyecto: m3z/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, fault.USER_ERROR)
		except Interface.DoesNotExist: #pylint: disable-msg=W0702
			pass
		iface.beginChanges()
		try:
			iface.name = name
			iface.device = self
			iface.init()
			if self.state == State.PREPARED:
				qm.addInterface(self.host, self.getVmid(), iface.name)
		finally:
			iface.endChanges()
		self.interfaceSetAdd(iface)
		self.save()
Ejemplo n.º 4
0
	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)
Ejemplo n.º 5
0
	def toDict(self, auth):
		res = Interface.toDict(self, auth)
		res["attrs"].update(ip4address=self.getAttribute("ip4address"), ip6address=self.getAttribute("ip6address"),
			use_dhcp=self.getAttribute("use_dhcp"))	
		return res				
Ejemplo n.º 6
0
	def getPrepareTasks(self):
		return Interface.getPrepareTasks(self)
Ejemplo n.º 7
0
	def getStartTasks(self):
		taskset = Interface.getStartTasks(self)
		connect_to_bridge = tasks.Task("connect-to-bridge", self.connectToBridge)
		taskset.add(connect_to_bridge)
		taskset.add(tasks.Task("configure-network", self._configureNetwork, after=connect_to_bridge))
		return taskset