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


Python devices.Device类代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: interfacesAdd

	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)
开发者ID:david-hock,项目名称:ToMaTo,代码行数:14,代码来源:prog.py

示例5: getStopTasks

	def getStopTasks(self):
		taskset = Device.getStopTasks(self)
		stop_vnc = tasks.Task("stop-vnc", self._stopVnc, reverseFn=self._fallbackStop)
		stop_vm = tasks.Task("stop-vm", self._stopVm, reverseFn=self._fallbackStop)
		unassign_vnc_port = tasks.Task("unassign-vnc-port", self._unassignVncPort, reverseFn=self._fallbackStop, after=stop_vnc)
		taskset.add([stop_vnc, stop_vm, unassign_vnc_port])
		return self._adaptTaskset(taskset)
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:7,代码来源:openvz.py

示例6: getDestroyTasks

	def getDestroyTasks(self):
		taskset = Device.getDestroyTasks(self)
		destroy_vm = tasks.Task("destroy-vm", self._destroyVm, reverseFn=self._fallbackDestroy)
		unassign_vmid = tasks.Task("unassign-vmid", self._unassignVmid, after=destroy_vm, reverseFn=self._fallbackDestroy)
		unassign_host = tasks.Task("unassign-host", self._unassignHost, after=unassign_vmid, reverseFn=self._fallbackDestroy)
		taskset.add([destroy_vm, unassign_host, unassign_vmid])
		return self._adaptTaskset(taskset)
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:7,代码来源:openvz.py

示例7: toDict

	def toDict(self, auth):
		res = Device.toDict(self, auth)
		res["attrs"].update(vmid=self.getVmid(), vnc_port=self.getVncPort(), template=self.getTemplate(),
			gateway4=self.getAttribute("gateway4"), gateway6=self.getAttribute("gateway6"))
		if auth:
			res["attrs"].update(root_password=self.getRootPassword(), vnc_password = self.vncPassword())
		return res
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:7,代码来源:openvz.py

示例8: interfacesAdd

	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)
		except Interface.DoesNotExist: #pylint: disable-msg=W0702
			pass
		iface.name = name
		iface.device = self
		iface.init()
		if self.state == State.PREPARED:
			qm.addInterface(self.host, self.getVmid(), iface.name)
		iface.save()
		Device.interfaceSetAdd(self, iface)
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:16,代码来源:kvm.py

示例9: interfacesAdd

	def interfacesAdd(self, name, properties):
		fault.check(self.state != State.STARTED, "OpenVZ 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 = ConfiguredInterface()
		iface.name = name
		iface.device = self
		iface.init()
		if self.state == State.PREPARED or self.state == State.STARTED:
			vzctl.addInterface(self.host, self.getVmid(), iface.name)
		iface.configure(properties)
		iface.save()
		Device.interfaceSetAdd(self, iface)
开发者ID:david-hock,项目名称:ToMaTo,代码行数:17,代码来源:openvz.py

示例10: getStartTasks

	def getStartTasks(self):
		taskset = Device.getStartTasks(self)
		start_vm = tasks.Task("start-vm", self._startVm, reverseFn=self._fallbackStop)
		for iface in self.interfaceSetAll():
			taskset.add(tasks.Task("start-interface-%s" % iface, self._startIface, args=(iface,), reverseFn=self._fallbackStop, after=start_vm))
		assign_vnc_port = tasks.Task("assign-vnc-port", self._assignVncPort, reverseFn=self._fallbackStop)
		start_vnc = tasks.Task("start-vnc", self._startVnc, reverseFn=self._fallbackStop, after=[start_vm, assign_vnc_port])
		taskset.add([start_vm, assign_vnc_port, start_vnc])
		return self._adaptTaskset(taskset)
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:9,代码来源:kvm.py

示例11: getPrepareTasks

	def getPrepareTasks(self):
		taskset = Device.getPrepareTasks(self)
		assign_template = tasks.Task("assign-template", self._assignTemplate, reverseFn=self._fallbackDestroy)
		assign_host = tasks.Task("assign-host", self._assignHost, reverseFn=self._fallbackDestroy)
		assign_vmid = tasks.Task("assign-vmid", self._assignVmid, reverseFn=self._fallbackDestroy, after=assign_host)
		create_vm = tasks.Task("create-vm", self._createVm, reverseFn=self._fallbackDestroy, after=assign_vmid)
		configure_vm = tasks.Task("configure-vm", self._configureVm, reverseFn=self._fallbackDestroy, after=create_vm)
		create_interfaces = tasks.Task("create-interfaces", self._createInterfaces, reverseFn=self._fallbackDestroy, after=configure_vm)
		taskset.add([assign_template, assign_host, assign_vmid, create_vm, configure_vm, create_interfaces])
		return self._adaptTaskset(taskset)
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:10,代码来源:openvz.py

示例12: getCapabilities

	def getCapabilities(self, user):
		capabilities = Device.getCapabilities(self, user)
		isUser = self.topology.checkAccess(Permission.ROLE_USER, user)
		capabilities["configure"].update({
			"template": self.state == State.CREATED,
			"args": self.state != State.STARTED,
		})
		capabilities.update(other={
			"console": isUser and self.getVncPort() and self.state == State.STARTED
		})
		return capabilities
开发者ID:david-hock,项目名称:ToMaTo,代码行数:11,代码来源:prog.py

示例13: getIdUsage

	def getIdUsage(self, host):
		ids = Device.getIdUsage(self, host)
		if self.vnc_port and self.host == host:
			ids["port"] = ids.get("port", set()) | set((self.vnc_port,))
		if self.vmid and self.host == host:
			ids["vmid"] = ids.get("vmid", set()) | set((self.vmid,))
		if self.hasAttribute("migration"):
			migration = self.getAttribute("migration")
			if host.name in migration:
				ids["vmid"] |= set((migration[host.name],))
		return ids
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:11,代码来源:openvz.py

示例14: getPrepareTasks

	def getPrepareTasks(self):
		taskset = Device.getPrepareTasks(self)
		assign_template = tasks.Task("assign-template", self._assignTemplate)
		assign_host = tasks.Task("assign-host", self._assignHost)
		assign_vmid = tasks.Task("assign-vmid", self._assignVmid, after=assign_host)
		create_vm = tasks.Task("create-vm", self._createVm, reverseFn=self._fallbackDestroy, after=assign_vmid)
		use_template = tasks.Task("use-template", self._useTemplate, reverseFn=self._fallbackDestroy, after=create_vm)
		configure_vm = tasks.Task("configure-vm", self._configureVm, reverseFn=self._fallbackDestroy, after=create_vm)
		for iface in self.interfaceSetAll():
			taskset.add(tasks.Task("create-interface-%s" % iface.name, self._createIface, args=(iface,), reverseFn=self._fallbackDestroy, after=create_vm))
		taskset.add([assign_template, assign_host, assign_vmid, create_vm, use_template, configure_vm])
		return self._adaptTaskset(taskset)
开发者ID:joanmarkt,项目名称:ToMaTo,代码行数:12,代码来源:kvm.py

示例15: 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 "root_password" in properties:
			self.setRootPassword(properties["root_password"])
			if self.state == State.PREPARED or self.state == State.STARTED:
				vzctl.setUserPassword(self.host, self.getVmid(), self.getRootPassword(), username="root")
		if "gateway4" in properties:
			self.setAttribute("gateway4", properties["gateway4"])
			if self.state == State.STARTED:
				self._configureRoutes()
		if "gateway6" in properties:
			self.setAttribute("gateway6", properties["gateway6"])
			if self.state == State.STARTED:
				self._configureRoutes()
		if "template" in properties:
			self.setTemplate(properties["template"])
			self._assignTemplate()
			fault.check(self.getTemplate(), "Template not found: %s" % properties["template"])
		self.save()
开发者ID:david-hock,项目名称:ToMaTo,代码行数:21,代码来源:openvz.py


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