libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From quent...@apache.org
Subject [1/2] libcloud git commit: Added ability to define OS disk size for Azure ARM compute
Date Fri, 13 Apr 2018 04:55:55 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 9df384348 -> 694b02161


Added ability to define OS disk size for Azure ARM compute

Signed-off-by: Quentin Pradet <quentinp@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/67cd2d5e
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/67cd2d5e
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/67cd2d5e

Branch: refs/heads/trunk
Commit: 67cd2d5ecf657d7d691cdf002b454695c4a12b04
Parents: 9df3843
Author: Vojta BartosĖŒ <hi@vojtech.me>
Authored: Thu Apr 5 15:42:34 2018 +0200
Committer: Quentin Pradet <quentinp@apache.org>
Committed: Fri Apr 13 08:49:53 2018 +0400

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py   |  9 ++++++
 libcloud/test/compute/test_azure_arm.py | 42 ++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/67cd2d5e/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index 1d9da01..edac4bb 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -415,6 +415,7 @@ class AzureNodeDriver(NodeDriver):
                     ex_tags={},
                     ex_customdata="",
                     ex_use_managed_disks=False,
+                    ex_disk_size=None,
                     ex_storage_account_type="Standard_LRS"):
         """Create a new node instance. This instance will be started
         automatically.
@@ -513,6 +514,9 @@ class AzureNodeDriver(NodeDriver):
             in all regions (default False).
         :type ex_use_managed_disks: ``bool``
 
+        :param ex_disk_size: Custom OS disk size in GB
+        :type ex_disk_size: ``int``
+
         :param ex_storage_account_type: The Storage Account type,
             ``Standard_LRS``(HDD disks) or ``Premium_LRS``(SSD disks).
         :type ex_storage_account_type: str
@@ -626,6 +630,11 @@ class AzureNodeDriver(NodeDriver):
             }
         }
 
+        if ex_disk_size:
+            data['properties']['storageProfile']['osDisk'].update({
+                'diskSizeGB': ex_disk_size
+            })
+
         if ex_customdata:
             data["properties"]["osProfile"]["customData"] = \
                 base64.b64encode(ex_customdata)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/67cd2d5e/libcloud/test/compute/test_azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_azure_arm.py b/libcloud/test/compute/test_azure_arm.py
index 29ba98e..68dd1ce 100644
--- a/libcloud/test/compute/test_azure_arm.py
+++ b/libcloud/test/compute/test_azure_arm.py
@@ -124,6 +124,48 @@ class AzureNodeDriverTests(LibcloudTestCase):
         self.assertEqual(os_profile['adminUsername'], 'any_user')
         self.assertEqual(os_profile['adminPassword'], 'any_password')
         self.assertTrue('managedDisk' in storage_profile['osDisk'])
+        self.assertTrue('diskSizeGB' not in storage_profile['osDisk'])
+        self.assertTrue(storage_profile['imageReference'], {
+            'publisher': image.publisher,
+            'offer': image.offer,
+            'sku': image.sku,
+            'version': image.version
+        })
+
+    def test_create_node_ex_disk_size(self):
+        location = NodeLocation('any_location', '', '', self.driver)
+        size = NodeSize('any_size', '', 0, 0, 0, 0, driver=self.driver)
+        image = AzureImage('1', '1', 'ubuntu', 'pub', location.id, self.driver)
+        auth = NodeAuthPassword('any_password')
+
+        node = self.driver.create_node(
+            'test-node-1',
+            size,
+            image,
+            auth,
+            location=location,
+            ex_resource_group='000000',
+            ex_storage_account='000000',
+            ex_user_name='any_user',
+            ex_network='000000',
+            ex_subnet='000000',
+            ex_disk_size=100,
+            ex_use_managed_disks=True
+        )
+        hardware_profile = node.extra['properties']['hardwareProfile']
+        os_profile = node.extra['properties']['osProfile']
+        storage_profile = node.extra['properties']['storageProfile']
+
+        self.assertEqual(node.name, 'test-node-1')
+        self.assertEqual(node.state, NodeState.UPDATING)
+        self.assertEqual(node.private_ips, ['10.0.0.1'])
+        self.assertEqual(node.public_ips, [])
+        self.assertEqual(node.extra['location'], location.id)
+        self.assertEqual(hardware_profile['vmSize'], size.id)
+        self.assertEqual(os_profile['adminUsername'], 'any_user')
+        self.assertEqual(os_profile['adminPassword'], 'any_password')
+        self.assertTrue('managedDisk' in storage_profile['osDisk'])
+        self.assertEqual(storage_profile['osDisk']['diskSizeGB'], 100)
         self.assertTrue(storage_profile['imageReference'], {
             'publisher': image.publisher,
             'offer': image.offer,


Mime
View raw message