当前位置: 首页>>代码示例>>Python>>正文


Python fault.check函数代码示例

本文整理汇总了Python中tomato.fault.check函数的典型用法代码示例。如果您正苦于以下问题:Python check函数的具体用法?Python check怎么用?Python check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了check函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _runAction

	def _runAction(self, action, attrs, direct):
		if action == "execute":
			fault.check("cmd" in attrs, "Command not given")
			try:
				return self.execute(attrs["cmd"])
			except exceptions.CommandError, exc:
				raise fault.new(str(exc), fault.USER_ERROR)
开发者ID:m3z,项目名称:ToMaTo,代码行数:7,代码来源:openvz.py

示例2: interfacesRename

	def interfacesRename(self, name, properties): #@UnusedVariable, pylint: disable-msg=W0613
		fault.check(self.state != State.STARTED, "Changes of running KVMs are not supported")
		iface = self.interfaceSetGet(name)
		newName = properties["name"]
		fault.check(re.match("eth(\d+)", newName), "Invalid interface name: %s" % name)
		try:
			if self.interfaceSetGet(newName):
				raise fault.new("Duplicate interface name: %s" % newName, fault.USER_ERROR)
		except Interface.DoesNotExist: #pylint: disable-msg=W0702
			pass
		if self.state == State.PREPARED:
			connector = None
			connectionAttributes = None
			if iface.isConnected():
				connector = iface.connection.connector
				connectionAttributes = iface.connection.upcast().toDict(None)["attrs"]
				connector.upcast().connectionsDelete(unicode(iface))
			qm.deleteInterface(self.host, self.getVmid(), iface.name)
		iface.name = newName
		iface.save()
		if self.state == State.PREPARED:
			qm.addInterface(self.host, self.getVmid(), iface.name)
			if connector:
				connector.upcast().connectionsAdd(unicode(iface), connectionAttributes)
		self.save()
开发者ID:david-hock,项目名称:ToMaTo,代码行数:25,代码来源:kvm.py

示例3: stop

	def stop(self, direct, noProcess=False):
		fault.check(self.state != State.CREATED, "Connector must be started or prepared to be stopped but is %s: %s", (self.state, self.name))
		proc = tasks.Process("stop")
		proc.add(tasks.Task("renew", self.topology.renew))
		proc.add(self.upcast().getStopTasks())
		if noProcess:
			return proc.start(direct)
		return self.topology.startProcess(proc, direct)
开发者ID:david-hock,项目名称:ToMaTo,代码行数:8,代码来源:__init__.py

示例4: configure

	def configure(self, properties):
		if self.state != State.CREATED:
			fault.check(not "network_type" in properties, "Cannot change type of external network with prepared connections: %s", self.name)
			fault.check(not "network_group" in properties, "Cannot change group of external network with prepared connections: %s", self.name)
		Connector.configure(self, properties)
		if self.getNetworkGroup() == "auto":
			self.setNetworkGroup(None)
		self.save()		
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:8,代码来源:external.py

示例5: checkImage

def checkImage(host, path):
	assert host
	assert fileutil.existsFile(host, path)
	try:
		res = host.execute("tar -tzvf %s ./sbin/init" % util.escape(path))
		fault.check("0/0" in res, "Image contents not owned by root")
	except exceptions.CommandError, err:
		return err.errorMessage
开发者ID:m3z,项目名称:ToMaTo,代码行数:8,代码来源:vzctl.py

示例6: destroy

	def destroy(self, direct, noProcess=False):
		fault.check(self.state != State.STARTED, "Connector must not be started to be destroyed but is %s: %s", (self.state, self.name))
		proc = tasks.Process("destroy")
		proc.add(tasks.Task("renew", self.topology.renew))
		proc.add(self.upcast().getDestroyTasks())
		if noProcess:
			return proc.start(direct)
		return self.topology.startProcess(proc, direct)
开发者ID:david-hock,项目名称:ToMaTo,代码行数:8,代码来源:__init__.py

示例7: interfacesDelete

	def interfacesDelete(self, name): #@UnusedVariable, pylint: disable-msg=W0613
		fault.check(self.state != State.STARTED, "Changes of running KVMs are not supported")
		iface = self.interfaceSetGet(name)
		if iface.isConnected():
			iface.connection.connector.upcast().connectionsDelete(unicode(iface))
		if self.state == State.PREPARED:
			qm.deleteInterface(self.host, self.getVmid(), iface.name)
		iface.delete()
开发者ID:david-hock,项目名称:ToMaTo,代码行数:8,代码来源:kvm.py

示例8: connectionsAdd

	def connectionsAdd(self, iface_name, properties): #@UnusedVariable, pylint: disable-msg=W0613
		iface = self.topology.interfacesGet(iface_name)
		fault.check(iface.device.state != State.STARTED, "Cannot add connections to running device: %s -> %s", (iface_name, self.name) )
		con = Connection ()
		con.connector = self
		con.interface = iface
		con.init()
		con.save()
开发者ID:david-hock,项目名称:ToMaTo,代码行数:8,代码来源:external.py

示例9: configure

	def configure(self, properties):
		if "template" in properties:
			fault.check(self.state == State.CREATED, "Cannot change template of prepared device: %s" % self.name)
		Device.configure(self, properties)
		if "template" in properties:
			self.setTemplate(properties["template"])
			self._assignTemplate()
		self.save()
开发者ID:david-hock,项目名称:ToMaTo,代码行数:8,代码来源:kvm.py

示例10: interfacesRename

	def interfacesRename(self, name, properties):
		iface = self.interfaceSetGet(name).upcast()
		try:
			fault.check(not self.interfaceSetGet(properties["name"]), "Duplicate interface name: %s" % properties["name"])
		except Interface.DoesNotExist: #pylint: disable-msg=W0702
			pass
		iface.name = properties["name"]
		iface.save()
开发者ID:david-hock,项目名称:ToMaTo,代码行数:8,代码来源:prog.py

示例11: _runAction

	def _runAction(self, action, attrs, direct):
		if action == "download_capture":
			interface = self.topology.interfacesGet(attrs["iface"])
			fault.check(interface, "No such interface: %s", attrs["iface"])
			con = interface.connection.upcast()
			assert con.connector.id == self.id
			return con.downloadCaptureUri()
		else:
			return Connector._runAction(self, action, attrs, direct)			
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:9,代码来源:vpn.py

示例12: configure

	def configure(self, properties):
		if "template" in properties:
			fault.check(self.state != State.STARTED, "Cannot change template of running device: %s" % self.name)
		Device.configure(self, properties)
		if "template" in properties:
			self.setTemplate(properties["template"])
			if self.state == State.PREPARED:
				qm.useTemplate(self.host, self.getVmid(), self.getTemplate())
		self.save()
开发者ID:m3z,项目名称:ToMaTo,代码行数:9,代码来源:kvm.py

示例13: _runAction

	def _runAction(self, action, attrs, direct):
		if action == "download_capture":
			interface = self.topology.interfacesGet(attrs["iface"])
			fault.check(interface, "No such interface: %s", attrs["iface"])
			con = interface.connection.upcast()
			assert con.connector.id == self.id
			return tasks.runTask(tasks.Task("%s-download-capture-uri" % self, con.downloadCaptureUri, kwargs={"onlyLatest": "onlyLatest" in attrs and attrs["onlyLatest"]}))		
		else:
			return Connector._runAction(self, action, attrs, direct)			
开发者ID:m3z,项目名称:ToMaTo,代码行数:9,代码来源:vpn.py

示例14: _assignVtunData

	def _assignVtunData(self):
		host = None
		for con in self.connectionSetAll():
			if con.interface.device.host:
				host = con.interface.device.host
				break
		fault.check(host, "Failed to assign a host for external access")		
		if not self.getExternalAccessPort():
			self.external_access_port = resources.take(host, "port", self, self.EXTERNAL_ACCESS_PORT_SLOT)
			self.save()
开发者ID:m3z,项目名称:ToMaTo,代码行数:10,代码来源:vpn.py

示例15: prepare

	def prepare(self, direct, noProcess=False):
		fault.check(self.state == State.CREATED, "Connector must be created to be prepared but is %s: %s", (self.state, self.name))
		for con in self.connectionSetAll():
			dev = con.interface.device
			fault.check(dev.state != State.CREATED, "Device %s must be prepared before connector %s", (dev.name, self.name))
		proc = tasks.Process("prepare")
		proc.add(tasks.Task("renew", self.topology.renew))
		proc.add(self.upcast().getPrepareTasks())
		if noProcess:
			return proc.start(direct)
		return self.topology.startProcess(proc, direct)
开发者ID:david-hock,项目名称:ToMaTo,代码行数:11,代码来源:__init__.py


注:本文中的tomato.fault.check函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。