Newer
Older
from cloudcontrol.server.clients import Client
class HostClient(Client):
""" A host client connected to the cc-server.
"""
ROLE = 'host'
def __init__(self, *args, **kwargs):
super(HostClient, self).__init__(*args, **kwargs)
def execute(self, command):
return self.conn.call('execute_command', command)
def console(self, name):
""" Start a remote console on the specified vm.
"""
label = self.proxy.vm_open_console(name)
tun = self.conn.create_tunnel(label=label)
return tun
def rshell(self):
""" Start a remote shell on the host.
"""
label = self.proxy.rshell()
tun = self.conn.create_tunnel(label=label)
return tun
def rshell_resize(self, label, *args, **kwargs):
return self.proxy.rshell_resize(label, *args, **kwargs)
def rshell_wait(self, label):
""" Wait for a remote shell termination.
"""
return self.proxy.rshell_wait(label, _timeout=None)
def forward(self, port, destination='127.0.0.1'):
""" Create a forwarding tunnel on this client and return it.
"""
tun = self.conn.create_tunnel()
self.proxy.forward(tun.label, port, destination)
return tun
Client.register_client_class(HostClient)