Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resize node function for azure driver #1965

Merged
merged 3 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions libcloud/compute/drivers/azure_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
9 changes: 9 additions & 0 deletions libcloud/test/compute/test_azure_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading