From d14ac4bf38f23e429572f210f7b0560493968b15 Mon Sep 17 00:00:00 2001 From: Nirmal Ranganathan Date: Tue, 1 May 2012 14:02:16 -0500 Subject: Adding 'host' info to volume-compute connection information. Added a new key 'host' for the initialize/terminate volume connection information. Updated the HpSanISCSIDriver to use teh initialize and terminate methods. Added missing unit tests for the HpSanISCSIDriver. Fixes bug 992729. Change-Id: I09fad6b5328cbfb860ab2c7ae5d206010f3dd45d --- nova/virt/driver.py | 5 +++-- nova/virt/fake.py | 2 +- nova/virt/libvirt/connection.py | 1 + nova/virt/vmwareapi_conn.py | 5 +++-- nova/virt/xenapi/connection.py | 11 +++++++---- 5 files changed, 15 insertions(+), 9 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/driver.py b/nova/virt/driver.py index db004de80..68cbea340 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -676,12 +676,13 @@ class ComputeDriver(object): """Get connector information for the instance for attaching to volumes. Connector information is a dictionary representing the ip of the - machine that will be making the connection and and the name of the - iscsi initiator as follows:: + machine that will be making the connection, the name of the iscsi + initiator and the hostname of the machine as follows:: { 'ip': ip, 'initiator': initiator, + 'host': hostname } """ raise NotImplementedError() diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 3b0dbfd4c..b08c7661d 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -335,4 +335,4 @@ class FakeConnection(driver.ComputeDriver): pass def get_volume_connector(self, instance): - return {'ip': '127.0.0.1', 'initiator': 'fake'} + return {'ip': '127.0.0.1', 'initiator': 'fake', 'host': 'fakehost'} diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 42b6cbdbd..44e0bd09b 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -488,6 +488,7 @@ class LibvirtConnection(driver.ComputeDriver): return { 'ip': FLAGS.my_ip, 'initiator': self._initiator, + 'host': FLAGS.host } def _cleanup_resize(self, instance): diff --git a/nova/virt/vmwareapi_conn.py b/nova/virt/vmwareapi_conn.py index 444fc785a..a5f771eee 100644 --- a/nova/virt/vmwareapi_conn.py +++ b/nova/virt/vmwareapi_conn.py @@ -177,10 +177,11 @@ class VMWareESXConnection(driver.ComputeDriver): def get_volume_connector(self, _instance): """Return volume connector information""" # TODO(vish): When volume attaching is supported, return the - # proper initiator iqn. + # proper initiator iqn and host. return { 'ip': FLAGS.vmwareapi_host_ip, - 'initiator': None + 'initiator': None, + 'host': None } def attach_volume(self, connection_info, instance_name, mountpoint): diff --git a/nova/virt/xenapi/connection.py b/nova/virt/xenapi/connection.py index 2fa5516d3..c02f3581d 100644 --- a/nova/virt/xenapi/connection.py +++ b/nova/virt/xenapi/connection.py @@ -156,6 +156,7 @@ class XenAPIConnection(driver.ComputeDriver): self._host = host.Host(self._session) self._vmops = vmops.VMOps(self._session) self._initiator = None + self._hypervisor_hostname = None self._pool = pool.ResourcePool(self._session) @property @@ -336,17 +337,19 @@ class XenAPIConnection(driver.ComputeDriver): def get_volume_connector(self, instance): """Return volume connector information""" - if not self._initiator: + if not self._initiator or not self._hypervisor_hostname: stats = self.get_host_stats(refresh=True) try: self._initiator = stats['host_other-config']['iscsi_iqn'] - except (TypeError, KeyError): - LOG.warn(_('Could not determine iscsi initiator name'), + self._hypervisor_hostname = stats['host_hostname'] + except (TypeError, KeyError) as err: + LOG.warn(_('Could not determine key: %s') % err, instance=instance) self._initiator = None return { 'ip': self.get_host_ip_addr(), - 'initiator': self._initiator + 'initiator': self._initiator, + 'host': self._hypervisor_hostname } @staticmethod -- cgit