Beispiel #1
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))