Exemple #1
0
 def execute(self, *args, **kwargs):
     stdout_value, stderr_value = _utils.execute(*args, **kwargs)
     if stdout_value.find('The operation completed successfully') == -1:
         raise exceptions.HyperVException(
           _('An error has occurred when calling the iscsi initiator: %s')
           % stdout_value)
     return stdout_value
Exemple #2
0
 def copy(self, src, dest):
     # With large files this is 2x-3x faster than shutil.copy(src, dest),
     # especially when copying to a UNC target.
     # shutil.copyfileobj(...) with a proper buffer is better than
     # shutil.copy(...) but still 20% slower than a shell copy.
     # It can be replaced with Win32 API calls to avoid the process
     # spawning overhead.
     LOG.debug('Copying file from %s to %s', src, dest)
     output, ret = _utils.execute('cmd.exe', '/C', 'copy', '/Y', src, dest)
     if ret:
         raise IOError(_('The file copy from %(src)s to %(dest)s failed')
                        % {'src': src, 'dest': dest})
Exemple #3
0
 def test_execute(self, mock_execute):
     _utils.execute(mock.sentinel.cmd, kwarg=mock.sentinel.kwarg)
     mock_execute.assert_called_once_with(mock.sentinel.cmd,
                                          kwarg=mock.sentinel.kwarg)