From e0fc121064d773215ad70f4ede0611ce096dfc5a Mon Sep 17 00:00:00 2001 From: Kurt Martin Date: Wed, 29 Jul 2015 15:53:25 -0700 Subject: [PATCH] Over subscription for HP LeftHand iSCSI driver Add support for over subscription in the HP LeftHand iSCSI driver. DocImpact Change-Id: Ibaef68264edd8019a4afd72fea4d8f002254adbb Implements: blueprint over-subscription-lefthand --- cinder/tests/unit/test_hplefthand.py | 64 +++++++++++-------- .../drivers/san/hp/hp_lefthand_rest_proxy.py | 15 ++++- 2 files changed, 50 insertions(+), 29 deletions(-) diff --git a/cinder/tests/unit/test_hplefthand.py b/cinder/tests/unit/test_hplefthand.py index 66492019c..c0e8450e4 100644 --- a/cinder/tests/unit/test_hplefthand.py +++ b/cinder/tests/unit/test_hplefthand.py @@ -668,7 +668,7 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): mock.call.getCluster(1), mock.call.getVolumes( cluster='CloudCluster1', - fields=['members[id]', 'members[clusterName]']), + fields=['members[id]', 'members[clusterName]', 'members[size]']), ] def default_mock_conf(self): @@ -1719,10 +1719,11 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): mock_client.getVolumes.return_value = { "type": "volume", "total": 1, - "members": { + "members": [{ "id": self.volume_id, - "clusterName": self.cluster_name - } + "clusterName": self.cluster_name, + "size": 1 + }] } existing_ref = {'source-name': self.volume_name} @@ -1769,10 +1770,11 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): mock_client.getVolumes.return_value = { "type": "volume", "total": 1, - "members": { + "members": [{ "id": self.volume_id, - "clusterName": self.cluster_name - } + "clusterName": self.cluster_name, + "size": 1 + }] } existing_ref = {'source-name': self.volume_name} @@ -1822,10 +1824,11 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): mock_client.getVolumes.return_value = { "type": "volume", "total": 1, - "members": { + "members": [{ "id": self.volume_id, - "clusterName": self.cluster_name - } + "clusterName": self.cluster_name, + "size": 1 + }] } existing_ref = {'source-name': self.volume_name} @@ -1865,10 +1868,11 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): mock_client.getVolumes.return_value = { "type": "volume", "total": 1, - "members": { + "members": [{ "id": self.volume_id, - "clusterName": self.cluster_name - } + "clusterName": self.cluster_name, + "size": 1 + }] } existing_ref = {'source-name': self.volume_name} @@ -1895,10 +1899,11 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): mock_client.getVolumes.return_value = { "type": "volume", "total": 1, - "members": { + "members": [{ "id": self.volume_id, - "clusterName": self.cluster_name - } + "clusterName": self.cluster_name, + "size": 1 + }] } volume = {} @@ -1957,10 +1962,11 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): mock_client.getVolumes.return_value = { "type": "volume", "total": 1, - "members": { + "members": [{ "id": self.volume_id, - "clusterName": self.cluster_name - } + "clusterName": self.cluster_name, + "size": 1 + }] } volume = {} @@ -1985,10 +1991,11 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): mock_client.getVolumes.return_value = { "type": "volume", "total": 1, - "members": { + "members": [{ "id": self.volume_id, - "clusterName": self.cluster_name - } + "clusterName": self.cluster_name, + "size": 1 + }] } self.driver.proxy.api_version = "1.1" @@ -2028,10 +2035,11 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): mock_client.getVolumes.return_value = { "type": "volume", "total": 1, - "members": { + "members": [{ "id": 12345, - "clusterName": self.cluster_name - } + "clusterName": self.cluster_name, + "size": 1 * units.Gi + }] } with mock.patch.object(hp_lefthand_rest_proxy.HPLeftHandRESTProxy, @@ -2045,6 +2053,9 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): self.assertEqual(GOODNESS_FUNCTION, stats['goodness_function']) self.assertEqual(FILTER_FUNCTION, stats['filter_function']) self.assertEqual(1, int(stats['total_volumes'])) + self.assertEqual(True, stats['thin_provisioning_support']) + self.assertEqual(True, stats['thick_provisioning_support']) + self.assertEqual(1, int(stats['provisioned_capacity_gb'])) cap_util = ( float(units.Gi * 500 - units.Gi * 250) / float(units.Gi * 500) @@ -2055,7 +2066,8 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): expected = self.driver_startup_call_stack + [ mock.call.getCluster(1), mock.call.getVolumes(fields=['members[id]', - 'members[clusterName]'], + 'members[clusterName]', + 'members[size]'], cluster=self.cluster_name), mock.call.logout()] diff --git a/cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py b/cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py index 65fcc4cf3..4c4dfef41 100644 --- a/cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py +++ b/cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py @@ -1,4 +1,4 @@ -# (c) Copyright 2014 Hewlett-Packard Development Company, L.P. +# (c) Copyright 2014-2015 Hewlett-Packard Development Company, L.P. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -105,9 +105,10 @@ class HPLeftHandRESTProxy(driver.ISCSIDriver): 1.0.8 - Fixed bug #1418201, A cloned volume fails to attach. 1.0.9 - Adding support for manage/unmanage. 1.0.10 - Add stats for goodness_function and filter_function + 1.0.11 - Add over subscription support """ - VERSION = "1.0.10" + VERSION = "1.0.11" device_stats = {} @@ -303,6 +304,10 @@ class HPLeftHandRESTProxy(driver.ISCSIDriver): data['location_info'] = (self.DRIVER_LOCATION % { 'cluster': self.configuration.hplefthand_clustername, 'vip': self.cluster_vip}) + data['thin_provisioning_support'] = True + data['thick_provisioning_support'] = True + data['max_over_subscription_ratio'] = ( + self.configuration.safe_get('max_over_subscription_ratio')) cluster_info = client.getCluster(self.cluster_id) @@ -321,11 +326,15 @@ class HPLeftHandRESTProxy(driver.ISCSIDriver): # so try to limit the size of data for now. Once new lefthand API is # available, replace this call. total_volumes = 0 + provisioned_size = 0 volumes = client.getVolumes( cluster=self.configuration.hplefthand_clustername, - fields=['members[id]', 'members[clusterName]']) + fields=['members[id]', 'members[clusterName]', 'members[size]']) if volumes: total_volumes = volumes['total'] + provisioned_size = sum( + members['size'] for members in volumes['members']) + data['provisioned_capacity_gb'] = int(provisioned_size) / units.Gi data['capacity_utilization'] = capacity_utilization data['total_volumes'] = total_volumes data['filter_function'] = self.get_filter_function() -- 2.45.2