src_ceph_args = self._ceph_args(src_user, src_conf, pool=src_pool)
dest_ceph_args = self._ceph_args(dest_user, dest_conf, pool=dest_pool)
+ cmd = ['rbd', 'export-diff'] + src_ceph_args
+ if from_snap is not None:
+ cmd.extend(['--from-snap', from_snap])
+ if src_snap:
+ path = self._utf8("%s/%s@%s" % (src_pool, src_name, src_snap))
+ else:
+ path = self._utf8("%s/%s" % (src_pool, src_name))
+ cmd.extend([path, '-'])
try:
- cmd = ['rbd', 'export-diff'] + src_ceph_args
- if from_snap is not None:
- cmd.extend(['--from-snap', from_snap])
- if src_snap:
- path = self._utf8("%s/%s@%s" % (src_pool, src_name, src_snap))
- else:
- path = self._utf8("%s/%s" % (src_pool, src_name))
- cmd.extend([path, '-'])
out, err = self._execute(*cmd)
- except (exception.ProcessExecutionError, exception.Error) as exc:
+ except (exception.ProcessExecutionError,
+ exception.UnknownArgumentError) as exc:
LOG.info(_("rbd export-diff failed - %s") % (str(exc)))
raise exception.BackupRBDOperationFailed("rbd export-diff failed")
+ cmd = ['rbd', 'import-diff'] + dest_ceph_args
+ cmd.extend(['-', self._utf8("%s/%s" % (dest_pool, dest_name))])
try:
- cmd = ['rbd', 'import-diff'] + dest_ceph_args
- cmd.extend(['-', self._utf8("%s/%s" % (dest_pool, dest_name))])
out, err = self._execute(*cmd, process_input=out)
- except (exception.ProcessExecutionError, exception.Error) as exc:
+ except (exception.ProcessExecutionError,
+ exception.UnknownArgumentError) as exc:
LOG.info(_("rbd import-diff failed - %s") % (str(exc)))
raise exception.BackupRBDOperationFailed("rbd import-diff failed")
import webob.exc
from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
LOG = logging.getLogger(__name__)
super(ConvertedException, self).__init__()
-class ProcessExecutionError(IOError):
- def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
- description=None):
- self.exit_code = exit_code
- self.stderr = stderr
- self.stdout = stdout
- self.cmd = cmd
- self.description = description
-
- if description is None:
- description = _('Unexpected error while running command.')
- if exit_code is None:
- exit_code = '-'
- message = _('%(description)s\nCommand: %(cmd)s\n'
- 'Exit code: %(exit_code)s\nStdout: %(stdout)r\n'
- 'Stderr: %(stderr)r') % {
- 'description': description,
- 'cmd': cmd,
- 'exit_code': exit_code,
- 'stdout': stdout,
- 'stderr': stderr,
- }
- IOError.__init__(self, message)
+class ProcessExecutionError(processutils.ProcessExecutionError):
+ pass
+
+
+class UnknownArgumentError(processutils.UnknownArgumentError):
+ pass
class Error(Exception):