• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python fault.check函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: interfacesRename

	def interfacesRename(self, name, properties):
		iface = self.interfaceSetGet(name).upcast()
		import re
		newName = properties["name"]
		fault.check(re.match("eth(\d+)", newName), "Invalid interface name: %s" % name)
		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:m3z,项目名称:ToMaTo,代码行数:11,代码来源:prog.py


示例17: configure

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


示例18: _assignVtunData

	def _assignVtunData(self):
		host = None
		if self.getExternalAccessCon():
			host = self.getExternalAccessHost()
		if not host:
			for con in self.connectionSetAll():
				if con.interface.device.host:
					self.setExternalAccessCon(con)
					host = con.interface.device.host
					self.setExternalAccessPort(None)
					break
		fault.check(host, "Failed to assign a host for external access")		
		if not self.getExternalAccessPort():
			host.takeId("port", self.setExternalAccessPort)
开发者ID:david-hock,项目名称:ToMaTo,代码行数:14,代码来源:vpn.py


示例19: interfacesRename

	def interfacesRename(self, name, properties):
		iface = self.interfaceSetGet(name).upcast()
		if self.state == State.PREPARED or self.state == State.STARTED:
			vzctl.deleteInterface(self.host, self.getVmid(), iface.name)
		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"]
		if self.state == State.PREPARED or self.state == State.STARTED:
			iface.prepare_run()
		if self.state == State.STARTED:
			iface.start_run()	
		iface.save()
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:14,代码来源:openvz.py


示例20: interfacesRename

	def interfacesRename(self, name, properties):
		iface = self.interfaceSetGet(name).upcast()
		if self.state == State.PREPARED or self.state == State.STARTED:
			vzctl.deleteInterface(self.host, self.getVmid(), iface.name)
		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"]
		if self.state == State.PREPARED or self.state == State.STARTED:
			vzctl.addInterface(self.host, self.getVmid(), iface.name)
		if self.state == State.STARTED:
			self.connectToBridge(iface, self.getBridge(iface))
			iface._configureNetwork()
		iface.save()
开发者ID:m3z,项目名称:ToMaTo,代码行数:15,代码来源:openvz.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python toml.dumps函数代码示例发布时间:2022-05-27
下一篇:
Python devices.Device类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap