|
| 1 | +# -------------------------------------------------------------------------------------------- |
| 2 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | +# |
| 5 | +# Code generated by aaz-dev-tools |
| 6 | +# -------------------------------------------------------------------------------------------- |
| 7 | + |
| 8 | +# pylint: skip-file |
| 9 | +# flake8: noqa |
| 10 | + |
| 11 | +from azure.cli.core.aaz import * |
| 12 | + |
| 13 | + |
| 14 | +@register_command( |
| 15 | + "compute virtual-machine-scale-set extension-rolling-upgrade", |
| 16 | +) |
| 17 | +class ExtensionRollingUpgrade(AAZCommand): |
| 18 | + """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to the latest available extension version. Instances which are already running the latest extension versions are not affected. |
| 19 | + """ |
| 20 | + |
| 21 | + _aaz_info = { |
| 22 | + "version": "2024-11-01", |
| 23 | + "resources": [ |
| 24 | + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/virtualmachinescalesets/{}/extensionrollingupgrade", "2024-11-01"], |
| 25 | + ] |
| 26 | + } |
| 27 | + |
| 28 | + AZ_SUPPORT_NO_WAIT = True |
| 29 | + |
| 30 | + def _handler(self, command_args): |
| 31 | + super()._handler(command_args) |
| 32 | + return self.build_lro_poller(self._execute_operations, None) |
| 33 | + |
| 34 | + _args_schema = None |
| 35 | + |
| 36 | + @classmethod |
| 37 | + def _build_arguments_schema(cls, *args, **kwargs): |
| 38 | + if cls._args_schema is not None: |
| 39 | + return cls._args_schema |
| 40 | + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) |
| 41 | + |
| 42 | + # define Arg Group "" |
| 43 | + |
| 44 | + _args_schema = cls._args_schema |
| 45 | + _args_schema.resource_group = AAZResourceGroupNameArg( |
| 46 | + required=True, |
| 47 | + ) |
| 48 | + _args_schema.vm_scale_set_name = AAZStrArg( |
| 49 | + options=["--vm-scale-set-name"], |
| 50 | + help="The name of the VM scale set.", |
| 51 | + required=True, |
| 52 | + id_part="name", |
| 53 | + ) |
| 54 | + return cls._args_schema |
| 55 | + |
| 56 | + def _execute_operations(self): |
| 57 | + self.pre_operations() |
| 58 | + yield self.VirtualMachineScaleSetRollingUpgradesStartExtensionUpgrade(ctx=self.ctx)() |
| 59 | + self.post_operations() |
| 60 | + |
| 61 | + @register_callback |
| 62 | + def pre_operations(self): |
| 63 | + pass |
| 64 | + |
| 65 | + @register_callback |
| 66 | + def post_operations(self): |
| 67 | + pass |
| 68 | + |
| 69 | + class VirtualMachineScaleSetRollingUpgradesStartExtensionUpgrade(AAZHttpOperation): |
| 70 | + CLIENT_TYPE = "MgmtClient" |
| 71 | + |
| 72 | + def __call__(self, *args, **kwargs): |
| 73 | + request = self.make_request() |
| 74 | + session = self.client.send_request(request=request, stream=False, **kwargs) |
| 75 | + if session.http_response.status_code in [202]: |
| 76 | + return self.client.build_lro_polling( |
| 77 | + self.ctx.args.no_wait, |
| 78 | + session, |
| 79 | + self.on_200, |
| 80 | + self.on_error, |
| 81 | + lro_options={"final-state-via": "location"}, |
| 82 | + path_format_arguments=self.url_parameters, |
| 83 | + ) |
| 84 | + if session.http_response.status_code in [200]: |
| 85 | + return self.client.build_lro_polling( |
| 86 | + self.ctx.args.no_wait, |
| 87 | + session, |
| 88 | + self.on_200, |
| 89 | + self.on_error, |
| 90 | + lro_options={"final-state-via": "location"}, |
| 91 | + path_format_arguments=self.url_parameters, |
| 92 | + ) |
| 93 | + |
| 94 | + return self.on_error(session.http_response) |
| 95 | + |
| 96 | + @property |
| 97 | + def url(self): |
| 98 | + return self.client.format_url( |
| 99 | + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", |
| 100 | + **self.url_parameters |
| 101 | + ) |
| 102 | + |
| 103 | + @property |
| 104 | + def method(self): |
| 105 | + return "POST" |
| 106 | + |
| 107 | + @property |
| 108 | + def error_format(self): |
| 109 | + return "ODataV4Format" |
| 110 | + |
| 111 | + @property |
| 112 | + def url_parameters(self): |
| 113 | + parameters = { |
| 114 | + **self.serialize_url_param( |
| 115 | + "resourceGroupName", self.ctx.args.resource_group, |
| 116 | + required=True, |
| 117 | + ), |
| 118 | + **self.serialize_url_param( |
| 119 | + "subscriptionId", self.ctx.subscription_id, |
| 120 | + required=True, |
| 121 | + ), |
| 122 | + **self.serialize_url_param( |
| 123 | + "vmScaleSetName", self.ctx.args.vm_scale_set_name, |
| 124 | + required=True, |
| 125 | + ), |
| 126 | + } |
| 127 | + return parameters |
| 128 | + |
| 129 | + @property |
| 130 | + def query_parameters(self): |
| 131 | + parameters = { |
| 132 | + **self.serialize_query_param( |
| 133 | + "api-version", "2024-11-01", |
| 134 | + required=True, |
| 135 | + ), |
| 136 | + } |
| 137 | + return parameters |
| 138 | + |
| 139 | + def on_200(self, session): |
| 140 | + pass |
| 141 | + |
| 142 | + |
| 143 | +class _ExtensionRollingUpgradeHelper: |
| 144 | + """Helper class for ExtensionRollingUpgrade""" |
| 145 | + |
| 146 | + |
| 147 | +__all__ = ["ExtensionRollingUpgrade"] |
0 commit comments