Exemple #1
0
def startVnc(host, vmid, port, password):
	assert getState(host, vmid) == generic.State.STARTED, "VM must be running to start vnc"
	if not process.portFree(host, port):
		process.killPortUser(host, port)
	try:
		execute(host, vmid, "which screen")
		host.execute("( while true; do vncterm -rfbport %d -passwd %s -c vzctl enter %d --exec 'screen -xRR' ; done ) >/dev/null 2>&1 & echo $! > %s" % ( port, util.escape(password), vmid, _vncPidfile(vmid) ))		
	except:
		host.execute("( while true; do vncterm -rfbport %d -passwd %s -c vzctl enter %d ; done ) >/dev/null 2>&1 & echo $! > %s" % ( port, util.escape(password), vmid, _vncPidfile(vmid) ))
	assert not process.portFree(host, port)
Exemple #2
0
def _startEndpoint(endpoint):
	state = getState(endpoint)
	assert state != generic.State.CREATED
	if state == generic.State.STARTED:
		_stopEndpoint(endpoint)
	host = endpoint.getHost()
	assert host
	if not process.portFree(host, endpoint.getPort()):
		process.killPortUser(host, endpoint.getPort())
	iface = _tincName(endpoint)
	host.execute("tincd --net=%s" % iface )
	util.waitFor(lambda :ifaceutil.interfaceExists(host, iface))
	assert ifaceutil.interfaceExists(host, iface), "Tinc deamon did not start"
	ifaceutil.ifup(host, iface)
Exemple #3
0
def stopVnc(host, vmid, port):
	process.killPidfile(host, _vncPidFile(vmid))
	process.killPortUser(host, port)
	assert process.portFree(host, port)
Exemple #4
0
def stopCaptureViaNet(host, name, port):
	rdir = _remoteDir(name)
	process.killPidfile(host, "%s.net.pid" % rdir)
	process.killPortUser(host, port)
	assert process.portFree(host, port)
Exemple #5
0
def startVnc(host, vmid, port, password):
	assert getState(host, vmid) == generic.State.STARTED, "VM must be running to start vnc"
	if not process.portFree(host, port):
		process.killPortUser(host, port)
	host.execute("vncterm -timeout 0 -rfbport %d -passwd %s -c vzctl enter %d >/dev/null 2>&1 & echo $! > %s" % ( port, util.escape(password), vmid, _vncPidfile(vmid) ))		
	assert util.waitFor(lambda :not process.portFree(host, port))
Exemple #6
0
def _stopEndpoint(endpoint):
	state = getState(endpoint)
	if state != generic.State.STARTED:
		return
	host = endpoint.getHost()
	assert host
	try:
		host.execute("tincd --net=%s -k" % _tincName(endpoint))
	except exceptions.CommandError, exc:
		if exc.errorCode != 1: #tincd was not running
			raise
	util.waitFor(lambda :getState(endpoint) != generic.State.STARTED, 2.0)
	if getState(endpoint) == generic.State.STARTED:
		process.killPidfile(host, _pidFile(endpoint), force=True)
	process.killPortUser(host, endpoint.getPort())
	assert getState(endpoint) != generic.State.STARTED

def _setupRouting(endpoint):
	host = endpoint.getHost()
	assert host
	bridge = endpoint.getBridge()
	assert bridge
	id = endpoint.getId()
	assert id
	assert ifaceutil.bridgeExists(host, bridge)
	tincname = _tincName(endpoint)
	assert ifaceutil.interfaceExists(host, tincname)
	assert not ifaceutil.interfaceBridge(host, tincname)
	#enable ip forwarding
	host.execute ("sysctl -q -w net.ipv6.conf.all.forwarding=1");