summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-08-24 15:58:36 +0000
committerGerrit Code Review <review@openstack.org>2012-08-24 15:58:36 +0000
commit96ded530c2fe814f779af5db575fa2f196bf38f3 (patch)
treef2c4fe4f1f19d6fe01a5d937ac155979e773c689 /nova/virt
parentaf687ffb04021e2aa6daf9a876d18c32d6ad3d3f (diff)
parentff17c6fd898403da58c30672fe0276be75f410e3 (diff)
Merge "XCP-XAPI version fix"
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/xenapi/driver.py19
-rw-r--r--nova/virt/xenapi/vmops.py29
2 files changed, 34 insertions, 14 deletions
diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py
index 6eb39e2b7..644f598ca 100644
--- a/nova/virt/xenapi/driver.py
+++ b/nova/virt/xenapi/driver.py
@@ -652,14 +652,23 @@ class XenAPISession(object):
def _get_product_version_and_brand(self):
"""Return a tuple of (major, minor, rev) for the host version and
a string of the product brand"""
- host = self.get_xenapi_host()
- software_version = self.call_xenapi('host.get_software_version',
- host)
+ software_version = self._get_software_version()
+
+ product_version_str = software_version.get('product_version')
+ product_brand = software_version.get('product_brand')
+
+ if None in (product_version_str, product_brand):
+ return (None, None)
+
product_version = tuple(int(part) for part in
- software_version['product_version'].split('.'))
- product_brand = software_version['product_brand']
+ product_version_str.split('.'))
+
return product_version, product_brand
+ def _get_software_version(self):
+ host = self.get_xenapi_host()
+ return self.call_xenapi('host.get_software_version', host)
+
def get_session_id(self):
"""Return a string session_id. Used for vnc consoles."""
with self._get_session() as session:
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index d233244b2..090a16d46 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -789,17 +789,28 @@ class VMOps(object):
def check_resize_func_name(self):
"""Check the function name used to resize an instance based
on product_brand and product_version."""
- if (self._session.product_brand == 'XCP' and
- ((self._session.product_version[0] == 1 and
- self._session.product_version[1] > 1) or
- self._session.product_version[0] > 1)):
- return 'VDI.resize'
- if (self._session.product_brand == 'XenServer' and
- self._session.product_version[0] > 5):
- return 'VDI.resize'
+ brand = self._session.product_brand
+ version = self._session.product_version
- return 'VDI.resize_online'
+ # To maintain backwards compatibility. All recent versions
+ # should use VDI.resize
+ if bool(version) and bool(brand):
+ xcp = brand == 'XCP'
+ r1_2_or_above = (
+ (
+ version[0] == 1
+ and version[1] > 1
+ )
+ or version[0] > 1)
+
+ xenserver = brand == 'XenServer'
+ r6_or_above = version[0] > 5
+
+ if (xcp and not r1_2_or_above) or (xenserver and not r6_or_above):
+ return 'VDI.resize_online'
+
+ return 'VDI.resize'
def reboot(self, instance, reboot_type):
"""Reboot VM instance."""