コード例 #1
0
ファイル: prog.py プロジェクト: david-hock/ToMaTo
	def _prepareDev(self):
		#assign host
		self._assignHost()
		host = self.host
		
		self._assignTemplate()
		
		self._assignBridges()
		
		vmid = self.id
		
		state = repy.getState(host, vmid)
		if state == State.STARTED:
			repy.stop(host, vmid)
			state = repy.getState(host, vmid)
		if state == State.PREPARED:
			repy.destroy(host, vmid)
			state = repy.getState(host, vmid)
		assert state == State.CREATED
		
		#nothing happened until here
		
		repy.create(host, vmid, self.getTemplate())
		try:
			self.state = State.PREPARED
			self.save()
		except:
			try:
				repy.destroy(host, vmid)
			except:
				pass
			raise
コード例 #2
0
ファイル: prog.py プロジェクト: david-hock/ToMaTo
	def _startDev(self):
		host = self.host
		vmid = self.id
		state = repy.getState(host, vmid)
		if not self.getVncPort():
			self.host.takeId("port", self.setVncPort)
		if state == State.CREATED:
			self._prepareDev()
			state = repy.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:
				ifaces = [iface.name for iface in self.interfaceSetAll()]
				repy.start(host, vmid, ifaces, self.getArgs())
			for iface in self.interfaceSetAll():
				repy.waitForInterface(self.host, self.id, iface.name)
				ifaceutil.ifup(self.host, self.interfaceDevice(iface))
				self.connectToBridge(iface, self.getBridge(iface))
			self._startVnc()
			self.state = State.STARTED
			self.save()
		except:
			try:
				repy.stop(host, vmid)
			except:
				pass
			raise
コード例 #3
0
ファイル: prog.py プロジェクト: david-hock/ToMaTo
	def _stopDev(self):
		host = self.host
		vmid = self.id
		state = repy.getState(host, vmid)
		if state == State.STARTED:
			repy.stop(host, vmid)
			state = repy.getState(host, vmid)
		self.state = State.PREPARED
		self.save()
		if self.getVncPort():
			repy.stopVnc(host, vmid, self.getVncPort())
			self._unassignVncPort()
コード例 #4
0
ファイル: prog.py プロジェクト: david-hock/ToMaTo
	def _destroyDev(self):
		host = self.host
		vmid = self.id
		if not host:
			return
		if vmid:
			state = repy.getState(host, vmid)
			if state == State.STARTED:
				repy.stop(host, vmid)
				state = repy.getState(host, vmid)
			if state == State.PREPARED:
				repy.destroy(host, vmid)
				state = repy.getState(host, vmid)
			assert state == State.CREATED
			self.state = State.CREATED
			self.save()
		self._unassignBridges()
		self._unassignHost()