Example #1
0
    def ssh(self, ssh_command=None, name=None, tags=None, env=None, summary=False):
        hosts = self.cloud.query({'name': name, 'tags': tags, 'env': env})
        if not hosts:
            print('No hosts found!')
            return False
        else:
            print('Found these hosts:')
            for host in hosts:
                print('\t', host)

        group = SSHGroup(hosts, max_pool_size=10)
        ssh_commands = ssh_command.split(';')
        results = group.run_commands(ssh_commands)

        show_stdout = True
        show_stderr = not summary
        print(results.display(show_stderr=show_stderr, show_stdout=show_stdout))
Example #2
0
    def shell(self, name=None, tags=None, env=None, summary=False):
        hosts = self.cloud.query({'name': name, 'tags': tags, 'env': env})
        if not hosts:
            print('No hosts found!')
            return False
        else:
            print('Found these hosts:')
            for host in hosts:
                print('\t', host)

        group = SSHGroup(hosts, max_pool_size=10)
        show_stdout = True
        show_stderr = True
        while True:
            try:
                cmd = input("[cloud]$ ")
            except KeyboardInterrupt:
                break
            if not cmd:
                continue
            if cmd == 'exit':
                break
            results = group.run_command(cmd)
            print(results.display(show_summary=False, show_stdout=show_stdout, show_stderr=show_stderr))