a_frame/utils/action_providers/SSHRemoteExecution.py
def scp_template(self, template):
        """
        Uses scp to copy the template to the remote endpoint
        Hint, the file_path parameter can be overridden with the {{ syntax }}
        :param template:
        :return:
        """
        try:

            if self.file_path.endswith("/"):
                # bad news! no actual file name! let's use a random file name and continue
                new_path = self.file_path + str(uuid.uuid4())
                self.file_path = new_path

            # remove last thing after last "/"
            # results in only the path we care about
            script_path = "/".join(self.file_path.split('/')[:-1])
            transport = paramiko.Transport((self.endpoint_ip, 22))
            transport.connect(username=self.endpoint_username, password=self.endpoint_password)

            client = paramiko.SFTPClient.from_transport(transport)

        except SSHException as se:
            print "Caught SSHException"
            return str(se)

        try:
            print "Checking directory: " + script_path
            rstats = client.stat(script_path)
            print rstats
        except IOError:
            print "Creating non-existant path"
            client.mkdir(script_path)

        try:
            print "Writing file"
            f = client.file(self.file_path, 'w')
            f.write(template)
            f.close()
            print "setting execute permissions"
            client.chmod(self.file_path, 0744)
            client.close()

            log_message = "Wrote file %s with contents\n\n%s" % (self.file_path, template)
            return log_message

        except Exception as e:
            print "Caught error!"
            return str(e)

        Uses scp to copy the template to the remote endpoint
        Hint, the file_path parameter can be overridden with the {{ syntax }}
        :param template:
        :return:
        
Uses scp to copy the template to the remote endpoint
Hint, the file_path parameter can be overridden with the {{ syntax }}
Uses scp to copy the template to the remote endpoint Hint the file_path parameter can be overridden with the {{ syntax }}
def scp_template(self, template):
        try:
            if self.file_path.endswith("/"):
                new_path = self.file_path + str(uuid.uuid4())
                self.file_path = new_path
            script_path = "/".join(self.file_path.split('/')[:-1])
            transport = paramiko.Transport((self.endpoint_ip, 22))
            transport.connect(username=self.endpoint_username, password=self.endpoint_password)
            client = paramiko.SFTPClient.from_transport(transport)
        except SSHException as se:
            print "Caught SSHException"
            return str(se)
        try:
            print "Checking directory: " + script_path
            rstats = client.stat(script_path)
            print rstats
        except IOError:
            print "Creating non-existant path"
            client.mkdir(script_path)
        try:
            print "Writing file"
            f = client.file(self.file_path, 'w')
            f.write(template)
            f.close()
            print "setting execute permissions"
            client.chmod(self.file_path, 0744)
            client.close()
            log_message = "Wrote file %s with contents\n\n%s" % (self.file_path, template)
            return log_message
        except Exception as e:
            print "Caught error!"
            return str(e)
def scp_template ( self , template ) : try : if self . file_path . endswith ( "/" ) : new_path = self . file_path + str ( uuid . uuid4 ( ) ) self . file_path = new_path script_path = "/" . join ( self . file_path . split ( '/' ) [ : - 1 ] ) transport = paramiko . Transport ( ( self . endpoint_ip , 22 ) ) transport . connect ( username = self . endpoint_username , password = self . endpoint_password ) client = paramiko . SFTPClient . from_transport ( transport ) except SSHException as se : print "Caught SSHException" return str ( se ) try : print "Checking directory: " + script_path rstats = client . stat ( script_path ) print rstats except IOError : print "Creating non-existant path" client . mkdir ( script_path ) try : print "Writing file" f = client . file ( self . file_path , 'w' ) f . write ( template ) f . close ( ) print "setting execute permissions" client . chmod ( self . file_path , 0744 ) client . close ( ) log_message = "Wrote file %s with contents\n\n%s" % ( self . file_path , template ) return log_message except Exception as e : print "Caught error!" return str ( e )
Uses scp to copy the template to the remote endpoint
Hint, the file_path parameter can be overridden with the {{ syntax }}
Uses scp to copy the template to the remote endpoint Hint the file_path parameter can be overridden with the {{ syntax }}
"""
        Uses scp to copy the template to the remote endpoint
        Hint, the file_path parameter can be overridden with the {{ syntax }}
        :param template:
        :return:
        """ # bad news! no actual file name! let's use a random file name and continue # remove last thing after last "/" # results in only the path we care about
None
self
template
None