예제 #1
0
 def check_stderr(self, command, verbose=False):
     ret = self.check_call(command, verbose)
     if ret['stderr']:
         raise DevopsCalledProcessError(command, ret['exit_code'],
                                        stdout=ret['stdout_str'],
                                        stderr=ret['stderr_str'])
     return ret
예제 #2
0
    def _execute_check_retcode(self, command):
        result = self.ssh_manager.execute(ip=self.admin_ip, cmd=command)
        if result['exit_code'] != 0:
            raise DevopsCalledProcessError(command=command,
                                           returncode=result['exit_code'],
                                           output=result['stderr'])

        return ''.join(result['stdout'])
예제 #3
0
 def check_call(self, command, verbose=False, excpected=0):
     ret = self.execute(command, verbose)
     if ret['exit_code'] != excpected:
         raise DevopsCalledProcessError(
             command, ret['exit_code'],
             expected=excpected,
             stdout=ret['stdout_str'],
             stderr=ret['stderr_str'])
     return ret
예제 #4
0
 def execute_together(cls, remotes, command):
     futures = {}
     errors = {}
     for remote in remotes:
         chan, _, _, _ = remote.execute_async(command)
         futures[remote] = chan
     for remote, chan in futures.items():
         ret = chan.recv_exit_status()
         chan.close()
         if ret != 0:
             errors[remote.host] = ret
     if errors:
         raise DevopsCalledProcessError(command, errors)
예제 #5
0
 def execute_together(cls, remotes, command):
     futures = {}
     errors = {}
     for remote in remotes:
         cmd = "%s\n" % command
         if remote.sudo_mode:
             cmd = 'sudo -S bash -c "%s"' % cmd.replace('"', '\\"')
         chan = remote._ssh.get_transport().open_session()
         chan.exec_command(cmd)
         futures[remote] = chan
     for remote, chan in futures.items():
         ret = chan.recv_exit_status()
         if ret != 0:
             errors[remote.host] = ret
     if errors:
         raise DevopsCalledProcessError(command, errors)
예제 #6
0
 def check_call(self, command, verbose=False):
     ret = self.execute(command, verbose)
     if ret['exit_code'] != 0:
         raise DevopsCalledProcessError(command, ret['exit_code'],
                                        ret['stdout'] + ret['stderr'])
     return ret
예제 #7
0
 def test2(self):
     raise DevopsCalledProcessError('asdf', 1)
예제 #8
0
 def test(self):
     raise DevopsCalledProcessError('asdf', 1, ['a', 'b'] + ['b', 'c'])