diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py index 9c540fec73..9a5c96430b 100644 --- a/libcloud/compute/drivers/azure_arm.py +++ b/libcloud/compute/drivers/azure_arm.py @@ -2184,6 +2184,24 @@ def ex_stop_node(self, node, deallocate=True): # Libcloud v2.7.0 return self.stop_node(node=node, ex_deallocate=deallocate) + def ex_resize_node(self, node, size): + """ + Resize the node to a different machine size. + + :param node: Node to resize + :type node: :class:`Node` + + :param size: New size for this machine + :type node: :class:`NodeSize` + """ + target = "%s/resize" % node.id + data = {"size": size.id} + r = self.connection.request( + target, params={"api-version": VM_API_VERSION}, data=data, + method="POST" + ) + return r.object + def ex_get_storage_account_keys(self, resource_group, storage_account): """ Get account keys required to access to a storage account diff --git a/libcloud/test/compute/fixtures/azure_arm/_subscriptions_99999999_resourceGroups_000000_providers_Microsoft_Compute_virtualMachines_test_node_1_resize.json b/libcloud/test/compute/fixtures/azure_arm/_subscriptions_99999999_resourceGroups_000000_providers_Microsoft_Compute_virtualMachines_test_node_1_resize.json new file mode 100644 index 0000000000..9cbc7c1d6c --- /dev/null +++ b/libcloud/test/compute/fixtures/azure_arm/_subscriptions_99999999_resourceGroups_000000_providers_Microsoft_Compute_virtualMachines_test_node_1_resize.json @@ -0,0 +1,51 @@ +{ + "properties": { + "vmId": "99999999-9999-9999-9999-999999999999", + "hardwareProfile": { + "vmSize": "Standard_A1" + }, + "storageProfile": { + "osDisk": { + "osType": "Linux", + "name": "OSD-9999", + "createOption": "Attach", + "caching": "ReadWrite", + "managedDisk": { + "storageAccountType": "Standard_LRS", + "id": "/subscriptions/99999999-9999-9999-9999-999999999999/resourceGroups/000000/providers/Microsoft.Compute/disks/OSD-9999" + } + }, + "dataDisks": [ + { + "lun": 0, + "name": "DD0-9999", + "createOption": "Attach", + "caching": "None", + "managedDisk": { + "storageAccountType": "Standard_LRS", + "id": "/subscriptions/99999999-9999-9999-9999-999999999999/resourceGroups/000000/providers/Microsoft.Compute/disks/DD0-9999" + }, + "diskSizeGB": 8 + } + ] + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "/subscriptions/99999999-9999-9999-9999-999999999999/resourceGroups/0000/providers/Microsoft.Network/networkInterfaces/test-nic", + "properties": { + "primary": true + } + } + ] + }, + "provisioningState": "Succeeded" + }, + "type": "Microsoft.Compute/virtualMachines", + "location": "eastus", + "tags": { + "tag_key1": "tag_val1" + }, + "id": "/subscriptions/99999999-9999-9999-9999-999999999999/resourceGroups/0000/providers/Microsoft.Compute/virtualMachines/test_vm", + "name": "test_vm" +} diff --git a/libcloud/test/compute/test_azure_arm.py b/libcloud/test/compute/test_azure_arm.py index 038850c466..90d532900e 100644 --- a/libcloud/test/compute/test_azure_arm.py +++ b/libcloud/test/compute/test_azure_arm.py @@ -673,6 +673,15 @@ def test_resize_volume(self): self.assertEqual(new_size, original_size + 8) + def test_resize_node(self): + location = self.driver.list_locations()[0] + size = self.driver.list_sizes(location=location)[0] + node = self.driver.list_nodes()[0] + + value = self.driver.ex_resize_node(node, size) + + self.assertEqual(value["size"], size.id) + def test_detach_volume(self): volumes = self.driver.list_volumes() node = self.driver.list_nodes()[0]