You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2022/09/25 10:04:30 UTC

[libcloud] branch trunk updated (c2cd33259 -> c48b456af)

This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git


    from c2cd33259 Merge pull request #1766 from apache/dependabot/pip/pyupgrade-2.38.0
     new aba66415d Azure: Add the ability to use Ultra SSDs
     new 410a87698 Reformat code with black.
     new 4ec6a3a05 Add changelog entry for #1744.
     new c48b456af Fix docstring.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.rst                                        | 10 ++++
 libcloud/compute/drivers/azure_arm.py              | 57 ++++++++++++++++++++++
 ...roviders_Microsoft_Compute_virtualMachines.json |  6 ++-
 libcloud/test/compute/test_azure_arm.py            | 15 ++++++
 4 files changed, 87 insertions(+), 1 deletion(-)


[libcloud] 03/04: Add changelog entry for #1744.

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit 4ec6a3a05f641c38acb3d7de43504748d3ee1de5
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Sep 25 11:54:53 2022 +0200

    Add changelog entry for #1744.
---
 CHANGES.rst | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/CHANGES.rst b/CHANGES.rst
index c756cd4a4..221e0b1ad 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -64,6 +64,16 @@ Compute
   (GITHUB-1699)
   [Eis D. Zaster - @Eis-D-Z]
 
+- [Azure ARM] Add new ``ex_create_additional_capabilities()`` method which allows
+  user to set capabilities on a stopped node. This allows users to utilize ultra
+  SSDs and similar.
+
+  Also add support for new ``ex_iops`` and ``ex_throughput`` argument to the
+  ``create_volume()`` method.
+
+  (GITHUB-1744)
+  [John Wren Kennedy - @jwk404]
+
 Storage
 ~~~~~~~
 


[libcloud] 02/04: Reformat code with black.

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit 410a8769834ac664c6204e89965a261567780dd5
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Sep 25 11:52:34 2022 +0200

    Reformat code with black.
---
 libcloud/compute/drivers/azure_arm.py   | 9 +++++----
 libcloud/test/compute/test_azure_arm.py | 8 ++------
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index 984cebb0b..23ca64498 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -2037,7 +2037,10 @@ class AzureNodeDriver(NodeDriver):
         )
 
     def ex_create_additional_capabilities(
-        self, node, additional_capabilities, resource_group,
+        self,
+        node,
+        additional_capabilities,
+        resource_group,
     ):
         """
         Set the additional capabilities on a stopped node.
@@ -2064,9 +2067,7 @@ class AzureNodeDriver(NodeDriver):
 
         data = {
             "location": node.extra["location"],
-            "properties": {
-                "additionalCapabilities": additional_capabilities
-            }
+            "properties": {"additionalCapabilities": additional_capabilities},
         }
 
         r = self.connection.request(
diff --git a/libcloud/test/compute/test_azure_arm.py b/libcloud/test/compute/test_azure_arm.py
index 8763f4921..85b320d6b 100644
--- a/libcloud/test/compute/test_azure_arm.py
+++ b/libcloud/test/compute/test_azure_arm.py
@@ -789,12 +789,8 @@ class AzureNodeDriverTests(LibcloudTestCase):
 
         node = self.driver.list_nodes()[0]
         self.driver.ex_create_additional_capabilities(node, add_cap, "000000")
-        self.assertTrue(
-            node.extra["properties"]["additionalCapabilities"]["ultraSSDEnabled"]
-        )
-        self.assertTrue(
-            node.extra["properties"]["additionalCapabilities"]["hibernationEnabled"]
-        )
+        self.assertTrue(node.extra["properties"]["additionalCapabilities"]["ultraSSDEnabled"])
+        self.assertTrue(node.extra["properties"]["additionalCapabilities"]["hibernationEnabled"])
 
 
 class AzureMockHttp(MockHttp):


[libcloud] 04/04: Fix docstring.

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit c48b456af7dc243a6ccf00d53408f0494e961f79
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Sep 25 11:57:50 2022 +0200

    Fix docstring.
---
 libcloud/compute/drivers/azure_arm.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index 23ca64498..971c2152b 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -2046,7 +2046,7 @@ class AzureNodeDriver(NodeDriver):
         Set the additional capabilities on a stopped node.
 
         :param node: The node to be updated
-        :type node: ``str``
+        :type node: :class:`.Node`
 
         :param ex_additional_capabilities: Optional additional capabilities
             allowing Ultra SSD and hibernation on this node.


[libcloud] 01/04: Azure: Add the ability to use Ultra SSDs

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit aba66415df8dc3f1c002c921d94085d85d5ee817
Author: John Wren Kennedy <jo...@delphix.com>
AuthorDate: Mon Aug 8 13:55:49 2022 -0600

    Azure: Add the ability to use Ultra SSDs
    
    This change adds a function to update additional_capabilities so that
    Ultra SSDs can be added. Additional changes allow specific provisioned
    IOPS and throughput.
---
 libcloud/compute/drivers/azure_arm.py              | 56 ++++++++++++++++++++++
 ...roviders_Microsoft_Compute_virtualMachines.json |  6 ++-
 libcloud/test/compute/test_azure_arm.py            | 19 ++++++++
 3 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index 40243102a..984cebb0b 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -898,6 +898,8 @@ class AzureNodeDriver(NodeDriver):
         ex_sku_name=None,
         ex_tags=None,
         ex_zones=None,
+        ex_iops=None,
+        ex_throughput=None,
     ):
         """
         Create a new managed volume.
@@ -929,6 +931,12 @@ class AzureNodeDriver(NodeDriver):
             in. Options are any or all of ["1", "2", "3"]. (optional)
         :type ex_zones: ``list`` of ``str``
 
+        :param ex_iops: The max IOPS this volume is capable of.
+        :type ex_iops: ``int``
+
+        :param ex_throughput: The max throughput of this volume in MBps.
+        :type ex_throughput: ``int``
+
         :return: The newly created volume.
         :rtype: :class:`StorageVolume`
         """
@@ -964,6 +972,12 @@ class AzureNodeDriver(NodeDriver):
         if ex_zones is not None:
             data["zones"] = ex_zones
 
+        if ex_iops is not None:
+            data["properties"]["diskIopsReadWrite"] = ex_iops
+
+        if ex_throughput is not None:
+            data["properties"]["diskMBpsReadWrite"] = ex_throughput
+
         response = self.connection.request(
             action,
             method="PUT",
@@ -2022,6 +2036,48 @@ class AzureNodeDriver(NodeDriver):
             method="PATCH",
         )
 
+    def ex_create_additional_capabilities(
+        self, node, additional_capabilities, resource_group,
+    ):
+        """
+        Set the additional capabilities on a stopped node.
+
+        :param node: The node to be updated
+        :type node: ``str``
+
+        :param ex_additional_capabilities: Optional additional capabilities
+            allowing Ultra SSD and hibernation on this node.
+        :type ex_additional_capabilities: ``dict``
+
+        :param resource_group: The resource group of the node to be updated
+        :type resource_group: ``str``
+
+        :return: True if the update was successful, otherwise False
+        :rtype: ``bool``
+        """
+
+        target = (
+            "/subscriptions/%s/resourceGroups/%s/providers"
+            "/Microsoft.Compute/virtualMachines/%s"
+            % (self.subscription_id, resource_group, node.name)
+        )
+
+        data = {
+            "location": node.extra["location"],
+            "properties": {
+                "additionalCapabilities": additional_capabilities
+            }
+        }
+
+        r = self.connection.request(
+            target,
+            data=data,
+            params={"api-version": VM_API_VERSION},
+            method="PUT",
+        )
+
+        return r.status in [200, 202, 204]
+
     def start_node(self, node):
         """
         Start a stopped node.
diff --git a/libcloud/test/compute/fixtures/azure_arm/_subscriptions_99999999_providers_Microsoft_Compute_virtualMachines.json b/libcloud/test/compute/fixtures/azure_arm/_subscriptions_99999999_providers_Microsoft_Compute_virtualMachines.json
index 8973cf9c9..019c5c7b2 100644
--- a/libcloud/test/compute/fixtures/azure_arm/_subscriptions_99999999_providers_Microsoft_Compute_virtualMachines.json
+++ b/libcloud/test/compute/fixtures/azure_arm/_subscriptions_99999999_providers_Microsoft_Compute_virtualMachines.json
@@ -3,6 +3,10 @@
     {
       "properties": {
         "vmId": "CCEEBF63-E92B-4A50-9949-6E44BFC61D3F",
+        "additionalCapabilities": {
+          "ultraSSDEnabled": "False",
+          "hibernationEnabled": "False"
+        },
         "hardwareProfile": {
           "vmSize": "Standard_A1"
         },
@@ -49,4 +53,4 @@
       "name": "test-node-1"
     }
   ]
-}
\ No newline at end of file
+}
diff --git a/libcloud/test/compute/test_azure_arm.py b/libcloud/test/compute/test_azure_arm.py
index b157b0e34..8763f4921 100644
--- a/libcloud/test/compute/test_azure_arm.py
+++ b/libcloud/test/compute/test_azure_arm.py
@@ -479,6 +479,8 @@ class AzureNodeDriverTests(LibcloudTestCase):
             ex_resource_group="000000",
             ex_tags={"description": "MyVolume"},
             ex_zones=["1", "2", "3"],
+            ex_iops=12345,
+            ex_throughput=6789,
         )
 
         self.assertEqual(volume.size, 2)
@@ -492,6 +494,8 @@ class AzureNodeDriverTests(LibcloudTestCase):
         self.assertEqual(volume.extra["properties"]["diskState"], "Attached")
         self.assertEqual(volume.state, StorageVolumeState.INUSE)
         self.assertEqual(volume.extra["zones"], ["1", "2", "3"])
+        self.assertEqual(volume.extra["properties"]["diskIopsReadWrite"], 12345)
+        self.assertEqual(volume.extra["properties"]["diskMBpsReadWrite"], 6789)
 
     def test_create_volume__with_snapshot(self):
         location = self.driver.list_locations()[0]
@@ -777,6 +781,21 @@ class AzureNodeDriverTests(LibcloudTestCase):
                     name="test1", ex_resource_group="000000", ex_storage_account="sga1"
                 )
 
+    def test_ex_create_additional_capabilities(self):
+        add_cap = {
+            "ultraSSDEnabled": True,
+            "hibernationEnabled": True,
+        }
+
+        node = self.driver.list_nodes()[0]
+        self.driver.ex_create_additional_capabilities(node, add_cap, "000000")
+        self.assertTrue(
+            node.extra["properties"]["additionalCapabilities"]["ultraSSDEnabled"]
+        )
+        self.assertTrue(
+            node.extra["properties"]["additionalCapabilities"]["hibernationEnabled"]
+        )
+
 
 class AzureMockHttp(MockHttp):
     fixtures = ComputeFileFixtures("azure_arm")