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)
def startCaptureViaNet(host, name, port, iface, filter=""): assert name, "Name not given" assert port, "Port not given" assert ifaceutil.interfaceExists(host, iface), "Interface does not exist" assert process.portFree(host, port), "Port already in use" assert _checkSyntax(host, iface, filter), "Syntax error: tcpdump -i %s %s" % (iface, filter) rdir = _remoteDir(name) fileutil.mkdir(host, rdir) ifaceutil.ifup(host, iface) host.execute("tcpserver -qHRl 0 0 %(port)d tcpdump -i %(iface)s -nUw - '%(filter)s' >/dev/null 2>&1 </dev/null & echo $! > %(rdir)s.net.pid" % {"iface": util.escape(iface), "rdir": rdir, "filter": util.escape(filter), "port": port }) assert not process.portFree(host, port)
def start(host, port): assert host assert process.portFree(host, port) host.execute("vtund -s -f %s" % _configPath(port)) util.waitFor(lambda :fileutil.existsFile(host, "/var/run/vtund.server.pid"), 5.0) assert fileutil.existsFile(host, "/var/run/vtund.server.pid") fileutil.copy(host, "/var/run/vtund.server.pid", _pidFile(port))
def _startEndpoint(endpoint): assert getState(endpoint) == generic.State.PREPARED host = endpoint.getHost() assert host assert process.portFree(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)
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)
def stopVnc(host, vmid, port): process.killPidfile(host, _vncPidFile(vmid)) process.killPortUser(host, port) assert process.portFree(host, port)
def startVnc(host, vmid, port, password): assert getState(host, vmid) == generic.State.STARTED, "VM must be running to start vnc" assert process.portFree(host, port) host.execute("( while true; do vncterm -rfbport %d -passwd %s -c tail -f %s ; done ) >/dev/null 2>&1 & echo $! > %s" % ( port, util.escape(password), _logFile(vmid), _vncPidFile(vmid) )) assert not process.portFree(host, port)
def stopCaptureViaNet(host, name, port): rdir = _remoteDir(name) process.killPidfile(host, "%s.net.pid" % rdir) process.killPortUser(host, port) assert process.portFree(host, port)
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))
def startVnc(host, vmid, port, password): assert getState(host, vmid) == generic.State.STARTED, "VM must be running to start vnc" assert process.portFree(host, port) host.execute("tcpserver -qHRl 0 0 %s qm vncproxy %s %s & echo $! > %s" % ( port, vmid, password, _vncPidfile(vmid) )) assert not process.portFree(host, port)
def startVnc(host, vmid, port, password): assert getState(host, vmid) == generic.State.STARTED, "VM must be running to start vnc" assert process.portFree(host, port) host.execute("vncterm -timeout 0 -rfbport %d -passwd %s -c tail -n +1 -f %s >/dev/null 2>&1 & echo $! > %s" % ( port, util.escape(password), _logFile(vmid), _vncPidFile(vmid) )) assert util.waitFor(lambda :not process.portFree(host, port))
def startVnc(host, vmid, port, password): assert getState(host, vmid) == generic.State.STARTED, "VM must be running to start vnc" assert process.portFree(host, port) host.execute("( while true; do vncterm -rfbport %d -passwd %s -c vzctl enter %d ; done ) >/dev/null 2>&1 & echo $! > %s" % ( port, password, vmid, _vncPidfile(vmid) )) assert not process.portFree(host, port)