Skip to content

[AutoPR track2_azure-mgmt-compute] Add ResiliencyPolicy to VMSS API #5204

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

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions sdk/compute/azure-mgmt-compute/_meta.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"commit": "0ebd4949e8e1cd9537ca5a07384c7661162cc7a6",
"commit": "40d2a23557a5a1cf82851a197a417af9b5735831",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest": "3.9.7",
"use": [
"@autorest/[email protected]",
"@autorest/[email protected]"
],
"autorest_command": "autorest specification/compute/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.9.7 --version-tolerant=False",
"autorest_command": "autorest specification/compute/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.9.7 --version-tolerant=False",
"readme": "specification/compute/resource-manager/readme.md",
"package-2023-03-01-only": "2023-04-17 22:42:05 -0400 b06a6f45e472dd07c2e0dab06b1e52dfe2684c88 Microsoft.Compute/ComputeRP/stable/2023-03-01/virtualMachineScaleSet.json",
"package-2023-01-02-only": "2023-06-28 00:48:15 -0400 b1d41f8dc643415d4dc6ee82bdb2fef04ef45bc9 Microsoft.Compute/DiskRP/stable/2023-01-02/snapshot.json",
Expand Down Expand Up @@ -47,6 +47,6 @@
"package-compute-2016-04-preview": "2022-07-31 21:47:43 -0400 2dcad6d6e9a96882eb6d317e7500a94be007a9c6 Microsoft.Compute/DiskRP/preview/2016-04-30-preview/disk.json",
"package-compute-2016-03": "2022-07-31 21:47:43 -0400 2dcad6d6e9a96882eb6d317e7500a94be007a9c6 Microsoft.Compute/ComputeRP/stable/2016-03-30/compute.json",
"package-compute-2015-06": "2022-07-31 21:47:43 -0400 2dcad6d6e9a96882eb6d317e7500a94be007a9c6 Microsoft.Compute/ComputeRP/stable/2015-06-15/compute.json",
"package-2023-07-01-only": "2023-08-10 16:21:40 -0400 1a925d1afe288a5f20d078bbc89214a36a0e4287 Microsoft.Compute/ComputeRP/stable/2023-07-01/virtualMachineScaleSet.json",
"package-2023-07-01-only": "2023-11-01 08:25:03 -0700 7189ecf96b23dad6c80c1195d2862ea70ef93380 Microsoft.Compute/ComputeRP/stable/2023-07-01/virtualMachineScaleSet.json",
"package-2023-04-02-only": "2023-08-07 20:58:57 -0400 b9403296f0b0e112b0d8222ad05fd1d79ee10e03 Microsoft.Compute/DiskRP/stable/2023-04-02/snapshot.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "30.3.0"
VERSION = "1.0.0b1"
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
from ._models_py3 import PurchasePlan
from ._models_py3 import RecoveryWalkResponse
from ._models_py3 import RequestRateByIntervalInput
from ._models_py3 import ResiliencyPolicy
from ._models_py3 import ResilientVMCreationPolicy
from ._models_py3 import ResilientVMDeletionPolicy
from ._models_py3 import Resource
from ._models_py3 import ResourceWithOptionalLocation
from ._models_py3 import RestorePoint
Expand Down Expand Up @@ -454,6 +457,9 @@
"PurchasePlan",
"RecoveryWalkResponse",
"RequestRateByIntervalInput",
"ResiliencyPolicy",
"ResilientVMCreationPolicy",
"ResilientVMDeletionPolicy",
"Resource",
"ResourceWithOptionalLocation",
"RestorePoint",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5697,6 +5697,90 @@ def __init__(
self.interval_length = interval_length


class ResiliencyPolicy(_serialization.Model):
"""Describes an resiliency policy - resilientVMCreationPolicy and/or resilientVMDeletionPolicy.

:ivar resilient_vm_creation_policy: The configuration parameters used while performing
resilient VM creation.
:vartype resilient_vm_creation_policy:
~azure.mgmt.compute.v2023_07_01.models.ResilientVMCreationPolicy
:ivar resilient_vm_deletion_policy: The configuration parameters used while performing
resilient VM deletion.
:vartype resilient_vm_deletion_policy:
~azure.mgmt.compute.v2023_07_01.models.ResilientVMDeletionPolicy
"""

_attribute_map = {
"resilient_vm_creation_policy": {"key": "resilientVMCreationPolicy", "type": "ResilientVMCreationPolicy"},
"resilient_vm_deletion_policy": {"key": "resilientVMDeletionPolicy", "type": "ResilientVMDeletionPolicy"},
}

def __init__(
self,
*,
resilient_vm_creation_policy: Optional["_models.ResilientVMCreationPolicy"] = None,
resilient_vm_deletion_policy: Optional["_models.ResilientVMDeletionPolicy"] = None,
**kwargs: Any
) -> None:
"""
:keyword resilient_vm_creation_policy: The configuration parameters used while performing
resilient VM creation.
:paramtype resilient_vm_creation_policy:
~azure.mgmt.compute.v2023_07_01.models.ResilientVMCreationPolicy
:keyword resilient_vm_deletion_policy: The configuration parameters used while performing
resilient VM deletion.
:paramtype resilient_vm_deletion_policy:
~azure.mgmt.compute.v2023_07_01.models.ResilientVMDeletionPolicy
"""
super().__init__(**kwargs)
self.resilient_vm_creation_policy = resilient_vm_creation_policy
self.resilient_vm_deletion_policy = resilient_vm_deletion_policy


class ResilientVMCreationPolicy(_serialization.Model):
"""The configuration parameters used while performing resilient VM creation.

:ivar enabled: Specifies whether resilient VM creation should be enabled on the virtual machine
scale set. The default value is false.
:vartype enabled: bool
"""

_attribute_map = {
"enabled": {"key": "enabled", "type": "bool"},
}

def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None:
"""
:keyword enabled: Specifies whether resilient VM creation should be enabled on the virtual
machine scale set. The default value is false.
:paramtype enabled: bool
"""
super().__init__(**kwargs)
self.enabled = enabled


class ResilientVMDeletionPolicy(_serialization.Model):
"""The configuration parameters used while performing resilient VM deletion.

:ivar enabled: Specifies whether resilient VM deletion should be enabled on the virtual machine
scale set. The default value is false.
:vartype enabled: bool
"""

_attribute_map = {
"enabled": {"key": "enabled", "type": "bool"},
}

def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None:
"""
:keyword enabled: Specifies whether resilient VM deletion should be enabled on the virtual
machine scale set. The default value is false.
:paramtype enabled: bool
"""
super().__init__(**kwargs)
self.enabled = enabled


class ResourceWithOptionalLocation(_serialization.Model):
"""The Resource model definition with location property as optional.

Expand Down Expand Up @@ -11088,6 +11172,8 @@ class VirtualMachineScaleSet(Resource): # pylint: disable=too-many-instance-att
:ivar automatic_repairs_policy: Policy for automatic repairs.
:vartype automatic_repairs_policy:
~azure.mgmt.compute.v2023_07_01.models.AutomaticRepairsPolicy
:ivar resiliency_policy: Policy for Resiliency.
:vartype resiliency_policy: ~azure.mgmt.compute.v2023_07_01.models.ResiliencyPolicy
:ivar virtual_machine_profile: The virtual machine profile.
:vartype virtual_machine_profile:
~azure.mgmt.compute.v2023_07_01.models.VirtualMachineScaleSetVMProfile
Expand Down Expand Up @@ -11166,6 +11252,7 @@ class VirtualMachineScaleSet(Resource): # pylint: disable=too-many-instance-att
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"},
"automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"},
"resiliency_policy": {"key": "properties.resiliencyPolicy", "type": "ResiliencyPolicy"},
"virtual_machine_profile": {
"key": "properties.virtualMachineProfile",
"type": "VirtualMachineScaleSetVMProfile",
Expand Down Expand Up @@ -11203,6 +11290,7 @@ def __init__( # pylint: disable=too-many-locals
extended_location: Optional["_models.ExtendedLocation"] = None,
upgrade_policy: Optional["_models.UpgradePolicy"] = None,
automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None,
resiliency_policy: Optional["_models.ResiliencyPolicy"] = None,
virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None,
overprovision: Optional[bool] = None,
do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None,
Expand Down Expand Up @@ -11244,6 +11332,8 @@ def __init__( # pylint: disable=too-many-locals
:keyword automatic_repairs_policy: Policy for automatic repairs.
:paramtype automatic_repairs_policy:
~azure.mgmt.compute.v2023_07_01.models.AutomaticRepairsPolicy
:keyword resiliency_policy: Policy for Resiliency.
:paramtype resiliency_policy: ~azure.mgmt.compute.v2023_07_01.models.ResiliencyPolicy
:keyword virtual_machine_profile: The virtual machine profile.
:paramtype virtual_machine_profile:
~azure.mgmt.compute.v2023_07_01.models.VirtualMachineScaleSetVMProfile
Expand Down Expand Up @@ -11301,6 +11391,7 @@ def __init__( # pylint: disable=too-many-locals
self.extended_location = extended_location
self.upgrade_policy = upgrade_policy
self.automatic_repairs_policy = automatic_repairs_policy
self.resiliency_policy = resiliency_policy
self.virtual_machine_profile = virtual_machine_profile
self.provisioning_state = None
self.overprovision = overprovision
Expand Down Expand Up @@ -13218,6 +13309,8 @@ class VirtualMachineScaleSetUpdate(UpdateResource): # pylint: disable=too-many-
:ivar automatic_repairs_policy: Policy for automatic repairs.
:vartype automatic_repairs_policy:
~azure.mgmt.compute.v2023_07_01.models.AutomaticRepairsPolicy
:ivar resiliency_policy: Policy for Resiliency.
:vartype resiliency_policy: ~azure.mgmt.compute.v2023_07_01.models.ResiliencyPolicy
:ivar virtual_machine_profile: The virtual machine profile.
:vartype virtual_machine_profile:
~azure.mgmt.compute.v2023_07_01.models.VirtualMachineScaleSetUpdateVMProfile
Expand Down Expand Up @@ -13258,6 +13351,7 @@ class VirtualMachineScaleSetUpdate(UpdateResource): # pylint: disable=too-many-
"identity": {"key": "identity", "type": "VirtualMachineScaleSetIdentity"},
"upgrade_policy": {"key": "properties.upgradePolicy", "type": "UpgradePolicy"},
"automatic_repairs_policy": {"key": "properties.automaticRepairsPolicy", "type": "AutomaticRepairsPolicy"},
"resiliency_policy": {"key": "properties.resiliencyPolicy", "type": "ResiliencyPolicy"},
"virtual_machine_profile": {
"key": "properties.virtualMachineProfile",
"type": "VirtualMachineScaleSetUpdateVMProfile",
Expand All @@ -13284,6 +13378,7 @@ def __init__(
identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None,
upgrade_policy: Optional["_models.UpgradePolicy"] = None,
automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None,
resiliency_policy: Optional["_models.ResiliencyPolicy"] = None,
virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None,
overprovision: Optional[bool] = None,
do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None,
Expand All @@ -13310,6 +13405,8 @@ def __init__(
:keyword automatic_repairs_policy: Policy for automatic repairs.
:paramtype automatic_repairs_policy:
~azure.mgmt.compute.v2023_07_01.models.AutomaticRepairsPolicy
:keyword resiliency_policy: Policy for Resiliency.
:paramtype resiliency_policy: ~azure.mgmt.compute.v2023_07_01.models.ResiliencyPolicy
:keyword virtual_machine_profile: The virtual machine profile.
:paramtype virtual_machine_profile:
~azure.mgmt.compute.v2023_07_01.models.VirtualMachineScaleSetUpdateVMProfile
Expand Down Expand Up @@ -13350,6 +13447,7 @@ def __init__(
self.identity = identity
self.upgrade_policy = upgrade_policy
self.automatic_repairs_policy = automatic_repairs_policy
self.resiliency_policy = resiliency_policy
self.virtual_machine_profile = virtual_machine_profile
self.overprovision = overprovision
self.do_not_run_extensions_on_overprovisioned_v_ms = do_not_run_extensions_on_overprovisioned_v_ms
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient

"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python virtual_machine_scale_set_create_with_resilient_vm_creation_policy.py

Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""


def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)

response = client.virtual_machine_scale_sets.begin_create_or_update(
resource_group_name="myResourceGroup",
vm_scale_set_name="{vmss-name}",
parameters={
"location": "westus",
"properties": {
"overprovision": False,
"resiliencyPolicy": {"resilientVMCreationPolicy": {"enabled": True}},
"upgradePolicy": {"mode": "Manual"},
"virtualMachineProfile": {
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"enableIPForwarding": True,
"ipConfigurations": [
{
"name": "{vmss-name}",
"properties": {
"subnet": {
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"
}
},
}
],
"primary": True,
},
}
]
},
"osProfile": {
"adminPassword": "{your-password}",
"adminUsername": "{your-username}",
"computerNamePrefix": "{vmss-name}",
},
"storageProfile": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest",
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {"storageAccountType": "Standard_LRS"},
},
},
},
},
"sku": {"capacity": 3, "name": "Standard_D1_v2", "tier": "Standard"},
},
).result()
print(response)


# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2023-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Create_WithResilientVMCreationPolicy.json
if __name__ == "__main__":
main()
Loading