示例#1
0
 def run_command(self, bash_command, background=False):
     output = ""
     if not self.node_controller.is_active:
         raise Exception("%s is not active, can't run given command")
     with ssh.SshConnection(self.ips[0], private_ssh_key_path=self.private_ssh_key_path,
                            username=self.username) as run:
         if background:
             run.background_script(bash_command)
         else:
             output = run.script(bash_command, verbose=False)
     return output
示例#2
0
    def ssh_connection(self):
        if not self.ips:
            raise RuntimeError(f"No available IPs for node {self.name}")

        logging.info("Trying to access through IP addresses: %s", ", ".join(self.ips))
        for ip in self.ips:
            exception = None
            try:
                connection = ssh.SshConnection(
                    ip, private_ssh_key_path=self.private_ssh_key_path, username=self.username
                )
                connection.connect()
                return connection

            except (TimeoutError, SCPException) as e:
                logging.warning("Could not SSH through IP %s: %s", ip, str(e))
                exception = e

        if exception is not None:
            raise exception
示例#3
0
 def ssh_connection(self):
     return ssh.SshConnection(
         self.ips[0],
         private_ssh_key_path=self.private_ssh_key_path,
         username=self.username)