Example #1
0
File: openvz.py Project: m3z/ToMaTo
	def _startDev(self):
		host = self.host
		vmid = self.getVmid()
		state = vzctl.getState(host, vmid)
		if state == State.CREATED:
			self._prepareDev()
			state = vzctl.getState(host, vmid)
		for iface in self.interfaceSetAll():
			bridge = self.getBridge(iface)
			assert bridge, "Interface has no bridge %s" % iface
			ifaceutil.bridgeCreate(self.host, bridge)
			ifaceutil.ifup(self.host, bridge)
		try: 
			if state == State.PREPARED:
				vzctl.start(host, vmid)
			for iface in self.interfaceSetAll():
				assert util.waitFor(lambda: ifaceutil.interfaceExists(host, self.interfaceDevice(iface)))
				self.connectToBridge(iface, self.getBridge(iface))
				iface.upcast()._configureNetwork()
			self._startVnc()
			self.state = State.STARTED
			self.save()
		except:
			try:
				vzctl.stop(host, vmid)
			except:
				pass
			raise
Example #2
0
	def _startVm(self):
		for iface in self.interfaceSetAll():
			iface_id = int(re.match("eth(\d+)", iface.name).group(1))
			# qm automatically connects ethN to vmbrN
			# if this bridge does not exist, kvm start fails
			if not ifaceutil.interfaceExists(self.host, "vmbr%d" % iface_id):
				ifaceutil.bridgeCreate(self.host, "vmbr%d" % iface_id)
		qm.start(self.host, self.getVmid())
		for iface in self.interfaceSetAll():
			qm.waitForInterface(self.host, self.getVmid(), iface.name)
Example #3
0
 def _unconfigLink(self):
     host = self.getHost()
     iface = self.internalInterface()
     if ifaceutil.interfaceExists(host, iface):
         try:
             tc.clearIncomingRedirect(host, iface)
             tc.clearLinkEmulation(host, iface)
         except:
             # might still fail if interface is deleted in between
             pass
     if self.hasIfbId():
         ifb = "ifb%d" % self.getIfbId()
         tc.clearLinkEmulation(host, ifb)
     self._unassignIfb()
Example #4
0
	def _checkInterfacesExist(self):
		for i in self.interfaceSetAll():
			assert ifaceutil.interfaceExists(self.host, self.interfaceDevice(i))