]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Over subscription for HP LeftHand iSCSI driver
authorKurt Martin <kurt.f.martin@hp.com>
Wed, 29 Jul 2015 22:53:25 +0000 (15:53 -0700)
committerKurt Martin <kurt.f.martin@hp.com>
Fri, 31 Jul 2015 15:47:03 +0000 (15:47 +0000)
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
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py

index 66492019c9bab59488887f5d26c77ebe64fe0f10..c0e8450e48673d5db989714257694cee58e6f799 100644 (file)
@@ -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()]
 
index 65fcc4cf3ad7474694da25d3212c2d97503b36a9..4c4dfef41a1b4255a75790fdfa65d4128a2de979 100644 (file)
@@ -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()