示例#1
0
文件: qm.py 项目: david-hock/ToMaTo
def interfaceDevice(host, vmid, iface, failSilent=False):
	"""
	Returns the name of the host device for the given interface
	
	Note: Proxmox changes the names of the interface devices with every 
	release of qemu-server. Here the current list of naming schemes:
	qemu-server 1.1-22 vmtab1000i0 
	qemu-server 1.1-25 vmtab1000i0d0
	qemu-server 1.1-28 tap1000i0d0 or tap1000i0
	Due to this naming chaos the name must determined on the host with a
	command, so	this can only be determined for started devices.
		
	@param iface: interface object
	@type iface: generic.Interface
	@return: name of host device
	@rtype: string
	"""
	iface_id = int(re.match("eth(\d+)", iface).group(1))
	assert getState(host, vmid) == generic.State.STARTED, "Cannot determine KVM host device names when not running"
	for name in ["vmtab%(vmid)di%(iface_id)d", "vmtab%(vmid)di%(iface_id)dd0", "tap%(vmid)di%(iface_id)d", "tap%(vmid)di%(iface_id)dd0"]:
		name = name % { "vmid": vmid, "iface_id": iface_id }
		if fileutil.existsDir(host, "/sys/class/net/%s" % name):
			return name
	assert failSilent, "Failed to determine kvm interface name for %s.%s" % (vmid, iface)
	return None
示例#2
0
文件: tinc.py 项目: joanmarkt/ToMaTo
def getState(endpoint):
	assert _isEndpoint(endpoint)
	host = endpoint.getHost()
	assert host
	if not fileutil.existsDir(host, _configDir(endpoint)):
		return generic.State.CREATED
	if not fileutil.existsFile(host, _pidFile(endpoint)):
		return generic.State.PREPARED
	if not process.processRunning(host, _pidFile(endpoint), "tincd"):
		return generic.State.PREPARED
	return generic.State.STARTED
示例#3
0
文件: ifaceutil.py 项目: m3z/ToMaTo
def interfaceExists(host, iface):
	import fileutil
	return fileutil.existsDir(host, "/sys/class/net/%s" % util.identifier(iface))
示例#4
0
文件: ifaceutil.py 项目: m3z/ToMaTo
def bridgeExists(host, bridge):
	import fileutil
	return fileutil.existsDir(host, "/sys/class/net/%s/brif" % util.identifier(bridge))