Change in vdsm[master]: exception: add remaining for vdsm.define errors

fromani at redhat.com fromani at redhat.com
Fri Mar 11 17:18:10 UTC 2016


Francesco Romani has uploaded a new change for review.

Change subject: exception: add remaining for vdsm.define errors
......................................................................

exception: add remaining for vdsm.define errors

Complete the translation of vdsm.define errors
into proper exception, subclassing VdsmException.
Also add backward compatibility code in define.py

TODO: should probably squashed in
https://gerrit.ovirt.org/#/c/48871

Change-Id: I0343ebdd59fe467de662a8900b7094f6514d485e
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M lib/vdsm/define.py
M lib/vdsm/exception.py
2 files changed, 324 insertions(+), 158 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/63/54663/1

diff --git a/lib/vdsm/define.py b/lib/vdsm/define.py
index d163231..3f659f8 100644
--- a/lib/vdsm/define.py
+++ b/lib/vdsm/define.py
@@ -31,169 +31,65 @@
     'copyerr': exception.CopyFailed().response(),
     'sparse': exception.CannotCreateSparse().response(),
     'createErr': exception.CannotCreateVM().response(),
-    'noConPeer': {'status': {
-        'code': 10,
-        'message': 'Could not connect to peer VDS'}},
-    'MissParam': {'status': {
-        'code': 11,
-        'message': 'Missing required parameter'}},
-    'migrateErr': {'status': {
-        'code': 12,
-        'message': 'Fatal error during migration'}},
-    'imageErr': {'status': {
-        'code': 13,
-        'message': 'Drive image file could not be found'}},
-    'outOfMem': {'status': {
-        'code': 14,
-        'message': 'Not enough free memory to create VM'}},
-    'unexpected': {'status': {
-        'code': 16,
-        'message': 'Unexpected exception'}},
-    'unsupFormat': {'status': {
-        'code': 17,
-        'message': 'Unsupported image format'}},
-    'ticketErr': {'status': {
-        'code': 18, 'message': 'Error while setting spice ticket'}},
-    'nonresp': {'status': {
-        'code': 19,
-        'message': 'Guest agent non-responsive'}},
+    'noConPeer': exception.NoConnectionToPeer().response(),
+    'MissParam': exception.MissingParameter().response(),
+    'migrateErr': exception.MigrationError().response(),
+    'imageErr': exception.ImageFileNotFound().response(),
+    'outOfMem': exception.OutOfMemory().response(),
+    'unexpected': exception.UnexpectedError().response(),
+    'unsupFormat': exception.UnsupportedImageFormat().response(),
+    'ticketErr': exception.SpiceTicketError().response(),
+    'nonresp': exception.NonResponsiveGuestAgent().response(),
     # codes 20-35 are reserved for add/delNetwork
     # code 39 was used for:
     # wrongHost - migration destination has an invalid hostname
-    'unavail': {'status': {
-        'code': 40,
-        'message': 'Resource unavailable'}},
-    'changeDisk': {'status': {
-        'code': 41,
-        'message': 'Failed to change disk image'}},
-    'destroyErr': {'status': {
-        'code': 42,
-        'message': 'Virtual machine destroy error'}},
-    'fenceAgent': {'status': {
-        'code': 43,
-        'message': 'Unsupported fencing agent'}},
-    'noimpl': {'status': {
-        'code': 44,
-        'message': 'Not implemented'}},
-    'hotplugDisk': {'status': {
-        'code': 45,
-        'message': 'Failed to hotplug disk'}},
-    'hotunplugDisk': {'status': {
-        'code': 46,
-        'message': 'Failed to hotunplug disk'}},
-    'migCancelErr': {'status': {
-        'code': 47,
-        'message': 'Migration not in progress'}},
-    'snapshotErr': {'status': {
-        'code': 48,
-        'message': 'Snapshot failed'}},
-    'hotplugNic': {'status': {
-        'code': 49,
-        'message': 'Failed to hotplug NIC'}},
-    'hotunplugNic': {'status': {
-        'code': 50,
-        'message': 'Failed to hotunplug NIC'}},
-    'migInProgress': {'status': {
-        'code': 51,
-        'message': 'Command not supported during migration'}},
-    'mergeErr': {'status': {
-        'code': 52,
-        'message': 'Merge failed'}},
-    'balloonErr': {'status': {
-        'code': 53,
-        'message': 'Balloon operation is not available'}},
-    'momErr': {'status': {
-        'code': 54,
-        'message': 'Failed to set mom policy'}},
-    'replicaErr': {'status': {
-        'code': 55,
-        'message': 'Drive replication error'}},
-    'updateDevice': {'status': {
-        'code': 56,
-        'message': 'Failed to update device'}},
-    'hwInfoErr': {'status': {
-        'code': 57,
-        'message': 'Failed to read hardware information'}},
-    'resizeErr': {'status': {
-        'code': 58,
-        'message': 'Wrong resize disk parameter'}},
-    'transientErr': {'status': {
-        'code': 59,
-        'message': 'Action not permitted on a VM with transient disks'}},
-    'setNumberOfCpusErr': {'status': {
-        'code': 60,
-        'message': 'Failed to set the number of cpus'}},
-    'haErr': {'status': {
-        'code': 61,
-        'message': 'Failed to set Hosted Engine HA policy'}},
-    'cpuTuneErr': {'status': {
-        'code': 62,
-        'message': 'CpuTune operation is not available'}},
-    'updateVmPolicyErr': {'status': {
-        'code': 63,
-        'message': 'Failed to update VM SLA policy'}},
-    'updateIoTuneErr': {'status': {
-        'code': 64,
-        'message': 'Failed to update ioTune values'}},
-    'V2VConnection': {'status': {
-        'code': 65,
-        'message': 'error connecting to hypervisor'}},
-    'NoSuchJob': {'status': {
-        'code': 66,
-        'message': 'Job Id does not exists'}},
-    'V2VNoSuchOvf': {'status': {
-        'code': 67,
-        'message': 'OVF file does not exists'}},
-    'JobNotDone': {'status': {
-        'code': 68,
-        'message': 'Job status is not done'}},
-    'JobExists': {'status': {
-        'code': 69,
-        'message': 'Job id already exists'}},
-    'hotplugMem': {'status': {
-        'code': 70,
-        'message': 'Failed to hotplug memory'}},
-    'ksmErr': {'status': {
-        'code': 71,
-        'message': 'Failed to update KSM values'}},
-    'secretBadRequestErr': {'status': {
-        'code': 72,
-        'message': 'Bad secret request'}},
-    'secretRegisterErr': {'status': {
-        'code': 73,
-        'message': 'Error registering Libvirt secret'}},
-    'secretUnregisterErr': {'status': {
-        'code': 74,
-        'message': 'Error unregistering Libvirt secret'}},
-    'unsupportedOperationErr': {'status': {
-        'code': 75,
-        'message': 'Operation not supported'}},
-    'freezeErr': {'status': {
-        'code': 76,
-        'message': 'Unable to freeze guest filesystems'}},
-    'thawErr': {'status': {
-        'code': 77,
-        'message': 'Unable to thaw guest filesystems'}},
-    'hookError': {'status': {
-        'code': 78,
-        'message': 'Hook error'}},
-    'destVolumeTooSmall': {'status': {
-        'code': 79,
-        'message': 'Destination volume is too small'}},
-    'AbortNotSupported': {'status': {
-        'code': 80,
-        'message': 'Job does not support aborting'}},
-    'migNotInProgress': {'status': {
-        'code': 81,
-        'message': 'Migration not in progress'}},
-    'migrateLimit': {'status': {
-        'code': 82,
-        'message': 'Incoming migration limit exceeded'}},
-    'recovery': {'status': {
-        'code': 99,
-        'message': 'Recovering from crash or Initializing'}},
+    'unavail': exception.ResourceUnavailable().response(),
+    'changeDisk': exception.ChangeDiskFailed().response(),
+    'destroyErr': exception.VMDestroyFailed().response(),
+    'fenceAgent': exception.UnsupportedFenceAgent().response(),
+    'noimpl': exception.MethodNotImplemented().response(),
+    'hotplugDisk': exception.HotplugDiskFailed().response(),
+    'hotunplugDisk': exception.HotunplugDiskFailed().response(),
+    'migCancelErr': exception.MigrationCancelationFailed().response(),
+    'snapshotErr': exception.SnapshotFailed().response(),
+    'hotplugNic': exception.HotplugNicFailed().response(),
+    'hotunplugNic': exception.HotunplugNicFailed().response(),
+    'migInProgress': exception.MigrationInProgress().response(),
+    'mergeErr': exception.MergeFailed().response(),
+    'balloonErr': exception.BalloonError().response(),
+    'momErr': exception.MOMPolicyUpdateFailed().response(),
+    'replicaErr': exception.ReplicaError().response(),
+    'updateDevice': exception.UpdateDeviceFailed().response(),
+    'hwInfoErr': exception.CannotRetrieveHWInfo().response(),
+    'resizeErr': exception.BadDiskResizeParameter().response(),
+    'transientErr': exception.TransientError().response(),
+    'setNumberOfCpusErr': exception.SetNumberOfCpusFailed().response(),
+    'haErr': exception.SetHAPolicyFailed().response(),
+    'cpuTuneErr': exception.CpuTuneError().response(),
+    'updateVmPolicyErr': exception.UpdateVMPolicyFailed().response(),
+    'updateIoTuneErr': exception.UpdateIOTuneError().response(),
+    'V2VConnection': exception.V2VConnectionError().response(),
+    'NoSuchJob': exception.NoSuchJob().response(),
+    'V2VNoSuchOvf': exception.V2VNoSuchOVF().response(),
+    'JobNotDone': exception.JobNotDone().response(),
+    'JobExists': exception.JobExists().response(),
+    'hotplugMem': exception.HotplugMemFailed().response(),
+    'ksmErr': exception.KSMUpdateFailed().response(),
+    'secretBadRequestErr': exception.BadSecretRequest().response(),
+    'secretRegisterErr': exception.SecretRegistrationFailed().response(),
+    'secretUnregisterErr': exception.SecretUnregistrationFailed().response(),
+    'unsupportedOperationErr': exception.UnsupportedOperation().response(),
+    'freezeErr': exception.FreezeGuestFSFailed().response(),
+    'thawErr': exception.ThawGuestFSFailed().response(),
+    'hookError': exception.HookFailed().response(),
+    'destVolumeTooSmall': exception.DestinationVolumeTooSmall().response(),
+    'AbortNotSupported': exception.AbortNotSupported().response(),
+    'migNotInProgress': exception.MigrationNotInProgress().response(),
+    'migrateLimit': exception.MigrationLimitExceeded().response(),
+    'recovery': exception.RecoveryInProgress().response(),
 }
 
+
 doneCode = {'code': 0, 'message': 'Done'}
 
 Kbytes = 1024
diff --git a/lib/vdsm/exception.py b/lib/vdsm/exception.py
index ecca171..3a59878 100644
--- a/lib/vdsm/exception.py
+++ b/lib/vdsm/exception.py
@@ -77,6 +77,276 @@
     message = 'Error creating the requested VM'
 
 
+class NoConnectionToPeer(VdsmException):
+    code = 10
+    message = 'Could not connect to peer VDS'
+
+
+class MissingParameter(VdsmException):
+    code = 11
+    message = 'Missing required parameter'
+
+
+class MigrationError(VdsmException):
+    code = 12
+    message = 'Fatal error during migration'
+
+
+class ImageFileNotFound(VdsmException):
+    code = 13
+    message = 'Drive image file could not be found'
+
+
+class OutOfMemory(VdsmException):
+    code = 14
+    message = 'Not enough free memory to create VM'
+
+
+class UnexpectedError(VdsmException):
+    code = 16
+    message = 'Unexpected exception'
+
+
+class UnsupportedImageFormat(VdsmException):
+    code = 17
+    message = 'Unsupported image format'
+
+
+class SpiceTicketError(VdsmException):
+    code = 18
+    message = 'Error while setting spice ticket'
+
+
+class NonResponsiveGuestAgent(VdsmException):
+    code = 19
+    message = 'Guest agent non-responsive'
+
+
+# codes 20-35 are reserved for add/delNetwork
+# code 39 was used for:
+# wrongHost - migration destination has an invalid hostname
+
+
+class ResourceUnavailable(VdsmException):
+    code = 40
+    message = 'Resource unavailable'
+
+
+class ChangeDiskFailed(VdsmException):
+    code = 41
+    message = 'Failed to change disk image'
+
+
+class VMDestroyFailed(VdsmException):
+    code = 42
+    message = 'Virtual machine destroy error'
+
+
+class UnsupportedFenceAgent(VdsmException):
+    code = 43
+    message = 'Unsupported fencing agent'
+
+
+class MethodNotImplemented(VdsmException):
+    code = 44
+    message = 'Not implemented'
+
+
+class HotplugDiskFailed(VdsmException):
+    code = 45
+    message = 'Failed to hotplug disk'
+
+
+class HotunplugDiskFailed(VdsmException):
+    code = 46
+    message = 'Failed to hotunplug disk'
+
+
+class MigrationCancelationFailed(VdsmException):
+    code = 47
+    message = 'Migration not in progress'
+
+
+class SnapshotFailed(VdsmException):
+    code = 48
+    message = 'Snapshot failed'
+
+
+class HotplugNicFailed(VdsmException):
+    code = 49
+    message = 'Failed to hotplug NIC'
+
+
+class HotunplugNicFailed(VdsmException):
+    code = 50
+    message = 'Failed to hotunplug NIC'
+
+
+class MigrationInProgress(VdsmException):
+    code = 51
+    message = 'Command not supported during migration'
+
+
+class MergeFailed(VdsmException):
+    code = 52
+    message = 'Merge failed'
+
+
+class BalloonError(VdsmException):
+    code = 53
+    message = 'Balloon operation is not available'
+
+
+class MOMPolicyUpdateFailed(VdsmException):
+    code = 54
+    message = 'Failed to set mom policy'
+
+
+class ReplicaError(VdsmException):
+    code = 55
+    message = 'Drive replication error'
+
+
+class UpdateDeviceFailed(VdsmException):
+    code = 56
+    message = 'Failed to update device'
+
+
+class CannotRetrieveHWInfo(VdsmException):
+    code = 57
+    message = 'Failed to read hardware information'
+
+
+class BadDiskResizeParameter(VdsmException):
+    code = 58
+    message = 'Wrong resize disk parameter'
+
+
+class TransientError(VdsmException):
+    code = 59
+    message = 'Action not permitted on a VM with transient disks'
+
+
+class SetNumberOfCpusFailed(VdsmException):
+    code = 60
+    message = 'Failed to set the number of cpus'
+
+
+class SetHAPolicyFailed(VdsmException):
+    code = 61
+    message = 'Failed to set Hosted Engine HA policy'
+
+
+class CpuTuneError(VdsmException):
+    code = 62
+    message = 'CpuTune operation is not available'
+
+
+class UpdateVMPolicyFailed(VdsmException):
+    code = 63
+    message = 'Failed to update VM SLA policy'
+
+
+class UpdateIOTuneError(VdsmException):
+    code = 64
+    message = 'Failed to update ioTune values'
+
+
+class V2VConnectionError(VdsmException):
+    code = 65
+    message = 'error connecting to hypervisor'
+
+
+class NoSuchJob(VdsmException):
+    code = 66
+    message = 'Job Id does not exists'
+
+
+class V2VNoSuchOVF(VdsmException):
+    code = 67
+    message = 'OVF file does not exists'
+
+
+class JobNotDone(VdsmException):
+    code = 68
+    message = 'Job status is not done'
+
+
+class JobExists(VdsmException):
+    code = 69
+    message = 'Job id already exists'
+
+
+class HotplugMemFailed(VdsmException):
+    code = 70
+    message = 'Failed to hotplug memory'
+
+
+class KSMUpdateFailed(VdsmException):
+    code = 71
+    message = 'Failed to update KSM values'
+
+
+class BadSecretRequest(VdsmException):
+    code = 72
+    message = 'Bad secret request'
+
+
+class SecretRegistrationFailed(VdsmException):
+    code = 73,
+    message = 'Error registering Libvirt secret'
+
+
+class SecretUnregistrationFailed(VdsmException):
+    code = 74
+    message = 'Error unregistering Libvirt secret'
+
+
+class UnsupportedOperation(VdsmException):
+    code = 75
+    message = 'Operation not supported'
+
+
+class FreezeGuestFSFailed(VdsmException):
+    code = 76
+    message = 'Unable to freeze guest filesystems'
+
+
+class ThawGuestFSFailed(VdsmException):
+    code = 77
+    message = 'Unable to thaw guest filesystems'
+
+
+class HookFailed(VdsmException):
+    code = 78
+    message = 'Hook error'
+
+
+class DestinationVolumeTooSmall(VdsmException):
+    code = 79
+    message = 'Destination volume is too small'
+
+
+class AbortNotSupported(VdsmException):
+    code = 80
+    message = 'Job does not support aborting'
+
+
+class MigrationNotInProgress(VdsmException):
+    code = 81
+    message = 'Migration not in progress'
+
+
+class MigrationLimitExceeded(VdsmException):
+    code = 82
+    message = 'Incoming migration limit exceeded'
+
+
+class RecoveryInProgress(VdsmException):
+    code = 99
+    message = 'Recovering from crash or Initializing'
+
+
 class GeneralException(VdsmException):
     code = 100
     message = "General Exception"


-- 
To view, visit https://gerrit.ovirt.org/54663
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0343ebdd59fe467de662a8900b7094f6514d485e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list