Francesco Romani has uploaded a new change for review.
Change subject: virt: drop domain_event_to_string function ......................................................................
virt: drop domain_event_to_string function
The domain_event_to_string function doesn't do validation, so drop it and just use direct dictionary access. In the (only) calling site, we use get() to be more robust and forward compatible.
Change-Id: I767f3e49e7b34d72aada23228d5e8689ea8991af Signed-off-by: Francesco Romani fromani@redhat.com --- M vdsm/virt/libvirt_helpers.py M vdsm/virt/vm.py 2 files changed, 13 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/40432/1
diff --git a/vdsm/virt/libvirt_helpers.py b/vdsm/virt/libvirt_helpers.py index d89a62f..89a84c7 100644 --- a/vdsm/virt/libvirt_helpers.py +++ b/vdsm/virt/libvirt_helpers.py @@ -31,20 +31,17 @@
# These strings are representing libvirt virDomainEventType values # http://libvirt.org/html/libvirt-libvirt.html#virDomainEventType -_DOMAIN_EVENT_STRINGS = ( - "Defined", - "Undefined", - "Started", - "Suspended", - "Resumed", - "Stopped", - "Shutdown", - "PM-Suspended" -) - - -def domain_event_to_string(event): - return _DOMAIN_EVENT_STRINGS[event] +DOMAIN_EVENT_TO_STRING = { + libvirt.VIR_DOMAIN_EVENT_DEFINED: "Defined", + libvirt.VIR_DOMAIN_EVENT_UNDEFINED: "Undefined", + libvirt.VIR_DOMAIN_EVENT_STARTED: "Started", + libvirt.VIR_DOMAIN_EVENT_SUSPENDED: "Suspended", + libvirt.VIR_DOMAIN_EVENT_RESUMED: "Resumed", + libvirt.VIR_DOMAIN_EVENT_STOPPED: "Stopped", + libvirt.VIR_DOMAIN_EVENT_SHUTDOWN: "Shutdown", + libvirt.VIR_DOMAIN_EVENT_PMSUSPENDED: "PM-Suspended", + libvirt.VIR_DOMAIN_EVENT_CRASHED: "Crashed", +}
class TimeoutError(libvirt.libvirtError): diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index b2b400d..7685ba8 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -4063,7 +4063,8 @@
def _onLibvirtLifecycleEvent(self, event, detail, opaque): self.log.debug('event %s detail %s opaque %s', - libvirt_helpers.domain_event_to_string(event), + libvirt_helpers.DOMAIN_EVENT_TO_STRING.get( + event, "Unknown"), detail, opaque) if event == libvirt.VIR_DOMAIN_EVENT_STOPPED: if (detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_MIGRATED and
automation@ovirt.org has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 1:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18427/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 1:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1658/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 1:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1658/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18427/ : SUCCESS
Martin Polednik has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 1: Code-Review-1
(1 comment)
-1 to avoid string constants in code
https://gerrit.ovirt.org/#/c/40432/1/vdsm/virt/vm.py File vdsm/virt/vm.py:
Line 4063: Line 4064: def _onLibvirtLifecycleEvent(self, event, detail, opaque): Line 4065: self.log.debug('event %s detail %s opaque %s', Line 4066: libvirt_helpers.DOMAIN_EVENT_TO_STRING.get( Line 4067: event, "Unknown"), Extra: add UNKNOWN_EVENT to libvirt_helpers and use that. Line 4068: detail, opaque) Line 4069: if event == libvirt.VIR_DOMAIN_EVENT_STOPPED: Line 4070: if (detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_MIGRATED and Line 4071: self.lastStatus == vmstatus.MIGRATION_SOURCE):
Francesco Romani has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 1:
(1 comment)
https://gerrit.ovirt.org/#/c/40432/1/vdsm/virt/vm.py File vdsm/virt/vm.py:
Line 4063: Line 4064: def _onLibvirtLifecycleEvent(self, event, detail, opaque): Line 4065: self.log.debug('event %s detail %s opaque %s', Line 4066: libvirt_helpers.DOMAIN_EVENT_TO_STRING.get( Line 4067: event, "Unknown"),
Extra: add UNKNOWN_EVENT to libvirt_helpers and use that.
Done Line 4068: detail, opaque) Line 4069: if event == libvirt.VIR_DOMAIN_EVENT_STOPPED: Line 4070: if (detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_MIGRATED and Line 4071: self.lastStatus == vmstatus.MIGRATION_SOURCE):
automation@ovirt.org has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 2:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18432/
Martin Polednik has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 2: Code-Review+1
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 2:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1663/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 2:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1663/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18432/ : SUCCESS
Francesco Romani has abandoned this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Abandoned
automation@ovirt.org has posted comments on this change.
Change subject: virt: drop domain_event_to_string function ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found
vdsm-patches@lists.fedorahosted.org