diff options
| author | Daniel P. Berrange <berrange@redhat.com> | 2012-06-19 11:24:06 +0100 |
|---|---|---|
| committer | Daniel P. Berrange <berrange@redhat.com> | 2012-06-19 15:01:28 +0100 |
| commit | 225f6f21b1f4158e635f06b4d040b41fa21be09d (patch) | |
| tree | 19ae9bc877dcbfe8efc331ffd55ed5197a970a78 | |
| parent | 6e6ffc2e4eff90e07f03049452979773e67a6a1c (diff) | |
| download | nova-225f6f21b1f4158e635f06b4d040b41fa21be09d.tar.gz nova-225f6f21b1f4158e635f06b4d040b41fa21be09d.tar.xz nova-225f6f21b1f4158e635f06b4d040b41fa21be09d.zip | |
Move libvirt version comparison code into separate function helper
To help various areas of libvirt driver code to perform version
comparisons, move the libvirt version comparison code out of the
"init_host" method and into a seperate "has_min_version" helper
method
Change-Id: Idc54dceff7bda60e1459ebe7c9c60c869d15aedb
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
| -rw-r--r-- | nova/virt/libvirt/connection.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index ba4d90a4a..6f0f1f630 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -297,13 +297,19 @@ class LibvirtDriver(driver.ComputeDriver): self._host_state = HostState(self.read_only) return self._host_state - def init_host(self, host): + def has_min_version(self, ver): libvirt_version = self._conn.getLibVersion() def _munge_version(ver): return ver[0] * 1000000 + ver[1] * 1000 + ver[2] - if libvirt_version < _munge_version(MIN_LIBVIRT_VERSION): + if libvirt_version < _munge_version(ver): + return False + + return True + + def init_host(self, host): + if not self.has_min_version(MIN_LIBVIRT_VERSION): major = MIN_LIBVIRT_VERSION[0] minor = MIN_LIBVIRT_VERSION[1] micro = MIN_LIBVIRT_VERSION[2] |
