summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorMarco Sinhoreli <msinhore@gmail.com>2012-07-23 15:24:59 -0300
committerMarco Sinhoreli <msinhore@gmail.com>2012-07-23 17:16:12 -0300
commit9a2cc2544a4e6609c409b06c8ff91d596fe43a8c (patch)
tree118a284e8f04b8b8e39f70c9f7a0d6dced86218c /nova/virt
parent62b75bf7c4259993e493d66d2fdf256d59ed4aa9 (diff)
Adds xcp disk resize support.
Implements resize image during instance creation. Fixes bug 1016650. Change-Id: I25f9d1030d9d014b1c9a65430bd535388b8f8943
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/xenapi/driver.py14
-rw-r--r--nova/virt/xenapi/vmops.py19
2 files changed, 24 insertions, 9 deletions
diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py
index 2f4059bd3..37fdb05e1 100644
--- a/nova/virt/xenapi/driver.py
+++ b/nova/virt/xenapi/driver.py
@@ -589,7 +589,8 @@ class XenAPISession(object):
url = self._create_first_session(url, user, pw, exception)
self._populate_session_pool(url, user, pw, exception)
self.host_uuid = self._get_host_uuid()
- self.product_version = self._get_product_version()
+ self.product_version, self.product_brand = \
+ self._get_product_version_and_brand()
def _create_first_session(self, url, user, pw, exception):
try:
@@ -631,13 +632,16 @@ class XenAPISession(object):
host_ref = session.xenapi.session.get_this_host(session.handle)
return session.xenapi.host.get_uuid(host_ref)
- def _get_product_version(self):
- """Return a tuple of (major, minor, rev) for the host version"""
+ 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)
- product_version = software_version['product_version']
- return tuple(int(part) for part in product_version.split('.'))
+ product_version = tuple(int(part) for part in
+ software_version['product_version'].split('.'))
+ product_brand = software_version['product_brand']
+ return product_version, product_brand
def get_session_id(self):
"""Return a string session_id. Used for vnc consoles."""
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 8eef23dd5..0e3709d2c 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -790,14 +790,25 @@ class VMOps(object):
vdi_uuid = root_vdi['uuid']
LOG.debug(_("Resizing up VDI %(vdi_uuid)s from %(old_gb)dGB to "
"%(new_gb)dGB"), locals(), instance=instance)
- if self._session.product_version[0] > 5:
- resize_func_name = 'VDI.resize'
- else:
- resize_func_name = 'VDI.resize_online'
+ resize_func_name = self.check_resize_func_name()
self._session.call_xenapi(resize_func_name, root_vdi['ref'],
str(new_disk_size))
LOG.debug(_("Resize complete"), instance=instance)
+ 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_brand == 'XCP' and
+ self._session.product_version[0] > 1) or
+ (self._session.product_brand is 'XenServer' and
+ self._session.product_version[0] > 5)):
+ return 'VDI.resize'
+ else:
+ return 'VDI.resize_online'
+
def reboot(self, instance, reboot_type):
"""Reboot VM instance."""
# Note (salvatore-orlando): security group rules are not re-enforced