def execute(self, cmd, nodes=None, use_private_ip=None, debug=False):
        """
            Executes an arbitrary command, prefixed with sh -c, on each node
        """
        nodes = nodes or self.nodes
        use_private_ip = use_private_ip or self.use_private_ip
        results = dict()
        cmd_full = self.PREFIX + [cmd]
        for node in nodes:
            hostip = node.extIp
            if use_private_ip:
                hostip = node.ip
            if self.override_host:
                hostip = self.override_host
            if self.ssh_password is not None:
                shell = spur.SshShell(
                    hostname=hostip,
                    username=self.user,
                    missing_host_key=self.missing_host_key,
                    password=self.ssh_password,
                )
            else:
                shell = spur.SshShell(
                    hostname=hostip,
                    username=self.user,
                    missing_host_key=self.missing_host_key,
                    private_key_file=self.ssh_path_to_private_key,
                )

            self.logger.debug("Executing '%s' on %s" % (cmd_full, node.name))
            try:
                with shell:
                    output = shell.run(cmd_full)
                    results[hostip] = {
                        "ret_code": output.return_code,
                        "stdout": output.output.decode('utf-8'),
                        "stderr": output.stderr_output.decode('utf-8'),
                    }
            except Exception as e:
                results[hostip] = {
                    "ret_code": 1,
                    "error": str(e),
                }
                self.logger.error("Executing '%s' on %s failed with error: %s" % (cmd_full, node.name, str(e)))
        return results

            Executes an arbitrary command, prefixed with sh -c, on each node
        
powerfulseal/execute/ssh_executor.py