Esempio n. 1
0
 def create_remote_file_content(self, destination, content):
     G_SSHInstance.write_bare('cat > %s <<END_OF_DATA\n' %destination)
     if isinstance(content, list):
         for i in content:
             G_SSHInstance.write_bare('%s\n' %i)
     elif isinstance(content, dict):
         for key,value in content.items():
             G_SSHInstance.write_bare('%s=%s\n' %(key,value))
     else:
         G_SSHInstance.write_bare('%s\n' %content)
     G_SSHInstance.write_bare('END_OF_DATA\n')
 def execute_command(self,
                     command,
                     return_stdout=True,
                     return_stderr=False,
                     return_rc=False):
     return G_SSHInstance.execute_command(command, return_stdout,
                                          return_stderr, return_rc)
Esempio n. 3
0
 def tail_remote_file(self, path, lines=0):
     """
     Tail a remote file.\n
     
     path is the full path of the file.\n
     lines is the number of lines from the bottom of the file to start the output.\n
     
     This is generally used in conjunction with remote_tail_should_contain or remote_tail_should_contain_regexp
     
     Return null.
     
     Examples:
     | tail remote file | /tmp/1.txt  |
     | tail remote file | /tmp/1.txt  | 20 |
     """
     cmd = 'tail --lines=%d --follow=name --retry %s' %(lines,path)
     G_SSHInstance.write(cmd)
def wait_for_persist_load_to_start(timeout=60):
    """Wait for the MTE/FTE to begin loading from the PERSIST file.
    Argument:
    timeout : the maximum time to wait, in seconds
    
    1. This is not a generic function to search for a message from the log file.
    2. Using read_until() or read_until_regexp() is problematic if there is a lot of output
    3. To restrict the amount of output the routine grep's for only lines containing 'Persistence'
    """
    dt = LinuxCoreUtilities().get_date_and_time()
    currentFile = '%s/smf-log-files.%s%s%s.txt' % (SMFLOGDIR, dt[0], dt[1],
                                                   dt[2])
    orig_timeout = G_SSHInstance.get_connection().timeout
    G_SSHInstance.set_client_configuration(timeout='%s seconds' % timeout)
    G_SSHInstance.write('tail --lines=0 -f %s | grep Persistence' %
                        currentFile)
    G_SSHInstance.read_until_regexp('Persistence: Loading.*complete')
    G_SSHInstance.set_client_configuration(timeout=orig_timeout)
    LinuxCoreUtilities().kill_processes('tail')
 def open_connection(self,
                     host,
                     alias=None,
                     port=22,
                     timeout=None,
                     newline=None,
                     prompt=None,
                     term_type=None,
                     width=None,
                     height=None,
                     path_separator=None,
                     encoding=None):
     return G_SSHInstance.open_connection(host, alias, port, timeout,
                                          newline, prompt, term_type, width,
                                          height, path_separator, encoding)
Esempio n. 6
0
 def remote_tail_should_contain(self, text, maxwait='60 seconds'):
     """
     Read the results from a previous call to tail_remote_file and verify that it contains the specified string.
     
     text is a plain text string.
     maxwait is the maximum time to wait/process the search (default is 60 seconds)
     
     See also remote_tail_should_contain_regexp to search for a regular expression
     
     Returns null.  Fails if string not found within maxwait time
     
     Example:
     | remote file should contain | some text  |
     | remote file should contain | some text  | maxwait=2 minutes |
     """
     defaultTimeout = G_SSHInstance.get_connection(timeout=True)
     G_SSHInstance.set_client_configuration(timeout=maxwait)
     G_SSHInstance.read_until(text)
     G_SSHInstance.set_client_configuration(timeout=defaultTimeout)
Esempio n. 7
0
 def remote_tail_should_contain_regexp(self, pattern, maxwait='60 seconds'):
     """
     Read the results from a previous call to tail_remote_file and verify that it contains the specified pattern.
     
     Pattern is in Python regular expression syntax, http://docs.python.org/2/library/re.html|re module
     Pattern matching is case-sensitive regardless the local or remote operating system
     
     maxwait is the maximum time to wait/process the search (default is 60 seconds)
     
     See also remote_tail_should_contain to search for a simple string
     
     Returns null.  Fails if pattern not found within maxwait time
     
     Example:
     | remote file should contain regexp | Processing.*start.*${MTE} |
     | remote file should contain regexp | Processing.*start.*${MTE} | maxwait=2 minutes |
     """
     defaultTimeout = G_SSHInstance.get_connection(timeout=True)
     G_SSHInstance.set_client_configuration(timeout=maxwait)
     G_SSHInstance.read_until_regexp(pattern)
     G_SSHInstance.set_client_configuration(timeout=defaultTimeout)
 def read_command_output(self,
                         return_stdout=True,
                         return_stderr=False,
                         return_rc=False):
     return G_SSHInstance.read_command_output(return_stdout, return_stderr,
                                              return_rc)
 def start_command(self, command):
     G_SSHInstance.start_command(command)
 def close_all_connections(self):
     G_SSHInstance.close_all_connections()
 def switch_connection(self, index_or_alias):
     return G_SSHInstance.switch_connection(index_or_alias)
 def login(self, username, password, delay='0.5 seconds'):
     return G_SSHInstance.login(username, password, delay)
 def close_connection(self):
     G_SSHInstance.close_connection()
 def get_current_connection_index(self):
     return G_SSHInstance.get_connection(index=True)
Esempio n. 15
0
 def get_remote_file(self, source, destination='.'):
     return G_SSHInstance.get_file(source, destination)
Esempio n. 16
0
 def remote_file_should_not_exist(self, path):
     G_SSHInstance.file_should_not_exist(path)
Esempio n. 17
0
 def put_remote_file(self, source, destination='.', mode='0744', newline=''):
     return G_SSHInstance.put_file(source, destination, mode, newline)