Change in vdsm[master]: virt: move TimeoutError into utils

fromani at redhat.com fromani at redhat.com
Mon Mar 30 08:14:01 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: virt: move TimeoutError into utils
......................................................................

virt: move TimeoutError into utils

the TimeoutError exception is used across the virt package.
Let's move into a new errors module, to clean up things
and avoid nasty hidden imports (as we did in sampling.py).

This patch only moves code around.

Change-Id: I35ceeb12bc96bea12281ce9c9a1481342dd3afa9
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M debian/vdsm.install
M vdsm.spec.in
M vdsm/virt/Makefile.am
A vdsm/virt/errors.py
M vdsm/virt/sampling.py
M vdsm/virt/vm.py
6 files changed, 35 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/39332/1

diff --git a/debian/vdsm.install b/debian/vdsm.install
index 919398b..2127627 100644
--- a/debian/vdsm.install
+++ b/debian/vdsm.install
@@ -149,6 +149,7 @@
 ./usr/share/vdsm/vdsmapi-schema.json
 ./usr/share/vdsm/virt/__init__.py
 ./usr/share/vdsm/virt/domain_descriptor.py
+./usr/share/vdsm/virt/errors.py
 ./usr/share/vdsm/virt/guestagent.py
 ./usr/share/vdsm/virt/migration.py
 ./usr/share/vdsm/virt/periodic.py
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 4d6a276..c66ec8b 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1070,6 +1070,7 @@
 %{_datadir}/%{vdsm_name}/vdsm-store-net-config
 %{_datadir}/%{vdsm_name}/virt/__init__.py*
 %{_datadir}/%{vdsm_name}/virt/domain_descriptor.py*
+%{_datadir}/%{vdsm_name}/virt/errors.py*
 %{_datadir}/%{vdsm_name}/virt/guestagent.py*
 %{_datadir}/%{vdsm_name}/virt/migration.py*
 %{_datadir}/%{vdsm_name}/virt/periodic.py*
diff --git a/vdsm/virt/Makefile.am b/vdsm/virt/Makefile.am
index 376f973..8f4dbdd 100644
--- a/vdsm/virt/Makefile.am
+++ b/vdsm/virt/Makefile.am
@@ -26,6 +26,7 @@
 dist_vdsm_virt_PYTHON = \
 	__init__.py \
 	domain_descriptor.py \
+	errors.py \
 	guestagent.py \
 	migration.py \
 	periodic.py \
diff --git a/vdsm/virt/errors.py b/vdsm/virt/errors.py
new file mode 100644
index 0000000..f1cb604
--- /dev/null
+++ b/vdsm/virt/errors.py
@@ -0,0 +1,29 @@
+#
+# Copyright 2015 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+"""
+error and exceptions for the virt package
+"""
+
+import libvirt
+
+
+class TimeoutError(libvirt.libvirtError):
+    pass
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 94f4387..c8a42ef 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -36,6 +36,7 @@
 from vdsm import utils
 from vdsm.config import config
 
+from .errors import TimeoutError
 from .utils import ExpiringCache
 
 import caps
@@ -518,7 +519,6 @@
         return hs
 
     def run(self):
-        import vm
         try:
             # wait a bit before starting to sample
             time.sleep(self._sampleInterval)
@@ -535,7 +535,7 @@
 
                     if len(self._samples) > self.AVERAGING_WINDOW:
                         self._samples.pop(0)
-                except vm.TimeoutError:
+                except TimeoutError:
                     self._log.exception("Timeout while sampling stats")
                 self._stopEvent.wait(self._sampleInterval)
         except:
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index ef6652c..460d45a 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -71,6 +71,7 @@
 from .vmtune import io_tune_values_to_dom, io_tune_dom_to_values
 from . import vmxml
 
+from .errors import TimeoutError
 from .utils import isVdsmImage
 from vmpowerdown import VmShutdown, VmReboot
 
@@ -170,10 +171,6 @@
 
 VolumeChainEntry = namedtuple('VolumeChainEntry',
                               ['uuid', 'path', 'allocation'])
-
-
-class TimeoutError(libvirt.libvirtError):
-    pass
 
 
 class NotifyingVirDomain:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35ceeb12bc96bea12281ce9c9a1481342dd3afa9
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