Esempio 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()
Esempio n. 2
0
	def getCapabilities(self, user):
		capabilities = Interface.getCapabilities(self, user)
		capabilities["configure"].update({
			"use_dhcp": True,
			"ip4address": True,
			"ip6address": True,
		})
		return capabilities
Esempio n. 3
0
File: kvm.py Progetto: 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()
Esempio 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)
Esempio 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				
Esempio n. 6
0
	def getPrepareTasks(self):
		return Interface.getPrepareTasks(self)
Esempio 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