Commit 2c8bb383 authored by Antoine Millet's avatar Antoine Millet
Browse files

Renamed rshell as shell and rshell_resize as resize

parent 85ec0b8b
Loading
Loading
Loading
Loading
+13 −15
Original line number Diff line number Diff line
@@ -69,9 +69,8 @@ class CliHandler(RegisteredCCHandler):
       CliHandler.migrate
       CliHandler.clone
       CliHandler.console
       CliHandler.rshell
       CliHandler.rshell_resize
       CliHandler.rshell_wait
       CliHandler.shell
       CliHandler.resize
       CliHandler.forward
       CliHandler.dbstats
    """
@@ -951,41 +950,40 @@ class CliHandler(RegisteredCCHandler):
    #

    @listed
    def rshell(self, tql):
    def shell(self, tql):
        """ Start a remote shell on object matching the provided tql.

        :param tql: tql matching only one object on which start the rshell
        :param tql: tql matching only one object on which start the shell
        :return: the label of the created tunnel
        """
        objects = self.client.list(tql, show=('r', 'p'), method='rshell')
        objects = self.client.list(tql, show=('r', 'p'), method='shell')
        if len(objects) != 1:
            raise NotImplementedError('Rshell only support one tunnel at time for now')
            raise NotImplementedError('Shell only support one tunnel at time for now')
        errs = Reporter()
        for obj in objects:
            if obj['r'] in ('host', 'hv'):
                client = self.server.get_client(obj['id'])
                srv_to_host_tun = client.rshell()
                cli_tun = self.client.register_tunnel('rshell', client, srv_to_host_tun)
                srv_to_host_tun = client.shell()
                cli_tun = self.client.register_tunnel('shell', client, srv_to_host_tun)
                errs.success(obj['id'], 'tunnel started.', output=cli_tun.label)
            else:
                errs.error(obj['id'], 'bad role')
        return errs.get_dict()

    @listed
    def rshell_resize(self, label, row, col, xpixel, ypixel):
    def resize(self, label, row, col, xpixel, ypixel):
        """ Send a resize event to the remote shell's tty.

        :param label: label of the rshell tunnel to resize
        :param label: label of the tty tunnel to resize
        :param row: number of rows
        :param col: number of columns
        :param xpixel: unused
        :param ypixel: unused
        """
        ttype, client, ctun, stun = self.client.get_tunnel(label)
        if ttype != 'rshell':
            raise ValueError('Label does not refers on a rshell')
        client.rshell_resize(stun.label, row, col, xpixel, ypixel)

        if ttype != 'shell':
            raise ValueError('Label does not refers on a shell')
        client.resize(stun.label, row, col, xpixel, ypixel)

    #
    # Port forwarding:
+4 −9
Original line number Diff line number Diff line
@@ -47,20 +47,15 @@ class HostClient(Client):
        tun = self.conn.create_tunnel(label=label)
        return tun

    def rshell(self):
    def shell(self):
        """ Start a remote shell on the host.
        """
        label = self.proxy.rshell()
        label = self.proxy.shell()
        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 resize(self, label, *args, **kwargs):
        return self.proxy.resize(label, *args, **kwargs)

    def forward(self, port, destination='127.0.0.1'):
        """ Create a forwarding tunnel on this client and return it.