Skip to content

Commit

Permalink
[AutoPR compute/resource-manager] Added Reimage API support for ephem…
Browse files Browse the repository at this point in the history
…eral os disks in single VM (#3664)

* Generated from 80e525cac7ec97a83050ccbec25446d38e6112ee

 updated swagger changes for reimage operation in single vm

* Packaging update of azure-mgmt-compute

* Generated from adb0812156159adb1b31ba461753f52afbb50085

 fixed validation errors
  • Loading branch information
AutorestCI authored Oct 24, 2018
1 parent 8ef8352 commit 1f6a253
Show file tree
Hide file tree
Showing 20 changed files with 630 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .virtual_machine_image_py3 import VirtualMachineImage
from .usage_name_py3 import UsageName
from .usage_py3 import Usage
from .virtual_machine_reimage_parameters_py3 import VirtualMachineReimageParameters
from .virtual_machine_capture_parameters_py3 import VirtualMachineCaptureParameters
from .virtual_machine_capture_result_py3 import VirtualMachineCaptureResult
from .plan_py3 import Plan
Expand Down Expand Up @@ -103,6 +104,8 @@
from .virtual_machine_scale_set_vm_profile_py3 import VirtualMachineScaleSetVMProfile
from .virtual_machine_scale_set_update_vm_profile_py3 import VirtualMachineScaleSetUpdateVMProfile
from .virtual_machine_scale_set_py3 import VirtualMachineScaleSet
from .virtual_machine_scale_set_vm_reimage_parameters_py3 import VirtualMachineScaleSetVMReimageParameters
from .virtual_machine_scale_set_reimage_parameters_py3 import VirtualMachineScaleSetReimageParameters
from .virtual_machine_scale_set_update_py3 import VirtualMachineScaleSetUpdate
from .virtual_machine_scale_set_vm_instance_ids_py3 import VirtualMachineScaleSetVMInstanceIDs
from .virtual_machine_scale_set_vm_instance_required_ids_py3 import VirtualMachineScaleSetVMInstanceRequiredIDs
Expand Down Expand Up @@ -194,6 +197,7 @@
from .virtual_machine_image import VirtualMachineImage
from .usage_name import UsageName
from .usage import Usage
from .virtual_machine_reimage_parameters import VirtualMachineReimageParameters
from .virtual_machine_capture_parameters import VirtualMachineCaptureParameters
from .virtual_machine_capture_result import VirtualMachineCaptureResult
from .plan import Plan
Expand Down Expand Up @@ -268,6 +272,8 @@
from .virtual_machine_scale_set_vm_profile import VirtualMachineScaleSetVMProfile
from .virtual_machine_scale_set_update_vm_profile import VirtualMachineScaleSetUpdateVMProfile
from .virtual_machine_scale_set import VirtualMachineScaleSet
from .virtual_machine_scale_set_vm_reimage_parameters import VirtualMachineScaleSetVMReimageParameters
from .virtual_machine_scale_set_reimage_parameters import VirtualMachineScaleSetReimageParameters
from .virtual_machine_scale_set_update import VirtualMachineScaleSetUpdate
from .virtual_machine_scale_set_vm_instance_ids import VirtualMachineScaleSetVMInstanceIDs
from .virtual_machine_scale_set_vm_instance_required_ids import VirtualMachineScaleSetVMInstanceRequiredIDs
Expand Down Expand Up @@ -413,6 +419,7 @@
'VirtualMachineImage',
'UsageName',
'Usage',
'VirtualMachineReimageParameters',
'VirtualMachineCaptureParameters',
'VirtualMachineCaptureResult',
'Plan',
Expand Down Expand Up @@ -487,6 +494,8 @@
'VirtualMachineScaleSetVMProfile',
'VirtualMachineScaleSetUpdateVMProfile',
'VirtualMachineScaleSet',
'VirtualMachineScaleSetVMReimageParameters',
'VirtualMachineScaleSetReimageParameters',
'VirtualMachineScaleSetUpdate',
'VirtualMachineScaleSetVMInstanceIDs',
'VirtualMachineScaleSetVMInstanceRequiredIDs',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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 msrest.serialization import Model


class VirtualMachineReimageParameters(Model):
"""Paramaters for Reimaging Virtual Machine. Default value for OSDisk : true.
:param temp_disk: Specified whether to reimage temp disk. Default value:
false.
:type temp_disk: bool
"""

_attribute_map = {
'temp_disk': {'key': 'tempDisk', 'type': 'bool'},
}

def __init__(self, **kwargs):
super(VirtualMachineReimageParameters, self).__init__(**kwargs)
self.temp_disk = kwargs.get('temp_disk', None)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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 msrest.serialization import Model


class VirtualMachineReimageParameters(Model):
"""Paramaters for Reimaging Virtual Machine. Default value for OSDisk : true.
:param temp_disk: Specified whether to reimage temp disk. Default value:
false.
:type temp_disk: bool
"""

_attribute_map = {
'temp_disk': {'key': 'tempDisk', 'type': 'bool'},
}

def __init__(self, *, temp_disk: bool=None, **kwargs) -> None:
super(VirtualMachineReimageParameters, self).__init__(**kwargs)
self.temp_disk = temp_disk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 .virtual_machine_scale_set_vm_reimage_parameters import VirtualMachineScaleSetVMReimageParameters


class VirtualMachineScaleSetReimageParameters(VirtualMachineScaleSetVMReimageParameters):
"""Describes a Virtual Machine Scale Set VM Reimage Parameters.
:param temp_disk: Specified whether to reimage temp disk. Default value:
false.
:type temp_disk: bool
:param instance_ids: The virtual machine scale set instance ids. Omitting
the virtual machine scale set instance ids will result in the operation
being performed on all virtual machines in the virtual machine scale set.
:type instance_ids: list[str]
"""

_attribute_map = {
'temp_disk': {'key': 'tempDisk', 'type': 'bool'},
'instance_ids': {'key': 'instanceIds', 'type': '[str]'},
}

def __init__(self, **kwargs):
super(VirtualMachineScaleSetReimageParameters, self).__init__(**kwargs)
self.instance_ids = kwargs.get('instance_ids', None)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 .virtual_machine_scale_set_vm_reimage_parameters_py3 import VirtualMachineScaleSetVMReimageParameters


class VirtualMachineScaleSetReimageParameters(VirtualMachineScaleSetVMReimageParameters):
"""Describes a Virtual Machine Scale Set VM Reimage Parameters.
:param temp_disk: Specified whether to reimage temp disk. Default value:
false.
:type temp_disk: bool
:param instance_ids: The virtual machine scale set instance ids. Omitting
the virtual machine scale set instance ids will result in the operation
being performed on all virtual machines in the virtual machine scale set.
:type instance_ids: list[str]
"""

_attribute_map = {
'temp_disk': {'key': 'tempDisk', 'type': 'bool'},
'instance_ids': {'key': 'instanceIds', 'type': '[str]'},
}

def __init__(self, *, temp_disk: bool=None, instance_ids=None, **kwargs) -> None:
super(VirtualMachineScaleSetReimageParameters, self).__init__(temp_disk=temp_disk, **kwargs)
self.instance_ids = instance_ids
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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 .virtual_machine_reimage_parameters import VirtualMachineReimageParameters


class VirtualMachineScaleSetVMReimageParameters(VirtualMachineReimageParameters):
"""Describes a Virtual Machine Scale Set VM Reimage Parameters.
:param temp_disk: Specified whether to reimage temp disk. Default value:
false.
:type temp_disk: bool
"""

_attribute_map = {
'temp_disk': {'key': 'tempDisk', 'type': 'bool'},
}

def __init__(self, **kwargs):
super(VirtualMachineScaleSetVMReimageParameters, self).__init__(**kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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 .virtual_machine_reimage_parameters_py3 import VirtualMachineReimageParameters


class VirtualMachineScaleSetVMReimageParameters(VirtualMachineReimageParameters):
"""Describes a Virtual Machine Scale Set VM Reimage Parameters.
:param temp_disk: Specified whether to reimage temp disk. Default value:
false.
:type temp_disk: bool
"""

_attribute_map = {
'temp_disk': {'key': 'tempDisk', 'type': 'bool'},
}

def __init__(self, *, temp_disk: bool=None, **kwargs) -> None:
super(VirtualMachineScaleSetVMReimageParameters, self).__init__(temp_disk=temp_disk, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def __init__(self, client, config, serializer, deserializer):


def _reimage_initial(
self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, **operation_config):
self, resource_group_name, vm_scale_set_name, instance_id, temp_disk=None, custom_headers=None, raw=False, **operation_config):
vm_scale_set_vm_reimage_input = None
if temp_disk is not None:
vm_scale_set_vm_reimage_input = models.VirtualMachineScaleSetVMReimageParameters(temp_disk=temp_disk)

# Construct URL
url = self.reimage.metadata['url']
path_format_arguments = {
Expand All @@ -58,15 +62,22 @@ def _reimage_initial(

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct body
if vm_scale_set_vm_reimage_input is not None:
body_content = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters')
else:
body_content = None

# Construct and send request
request = self._client.post(url, query_parameters, header_parameters)
request = self._client.post(url, query_parameters, header_parameters, body_content)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200, 202]:
Expand All @@ -79,7 +90,7 @@ def _reimage_initial(
return client_raw_response

def reimage(
self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, polling=True, **operation_config):
self, resource_group_name, vm_scale_set_name, instance_id, temp_disk=None, custom_headers=None, raw=False, polling=True, **operation_config):
"""Reimages (upgrade the operating system) a specific virtual machine in a
VM scale set.
Expand All @@ -89,6 +100,9 @@ def reimage(
:type vm_scale_set_name: str
:param instance_id: The instance ID of the virtual machine.
:type instance_id: str
:param temp_disk: Specified whether to reimage temp disk. Default
value: false.
:type temp_disk: bool
:param dict custom_headers: headers that will be added to the request
:param bool raw: The poller return type is ClientRawResponse, the
direct response alongside the deserialized response
Expand All @@ -104,6 +118,7 @@ def reimage(
resource_group_name=resource_group_name,
vm_scale_set_name=vm_scale_set_name,
instance_id=instance_id,
temp_disk=temp_disk,
custom_headers=custom_headers,
raw=True,
**operation_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1490,10 +1490,10 @@ def get_long_running_output(response):


def _reimage_initial(
self, resource_group_name, vm_scale_set_name, instance_ids=None, custom_headers=None, raw=False, **operation_config):
vm_instance_ids = None
if instance_ids is not None:
vm_instance_ids = models.VirtualMachineScaleSetVMInstanceIDs(instance_ids=instance_ids)
self, resource_group_name, vm_scale_set_name, temp_disk=None, instance_ids=None, custom_headers=None, raw=False, **operation_config):
vm_scale_set_reimage_input = None
if temp_disk is not None or instance_ids is not None:
vm_scale_set_reimage_input = models.VirtualMachineScaleSetReimageParameters(temp_disk=temp_disk, instance_ids=instance_ids)

# Construct URL
url = self.reimage.metadata['url']
Expand All @@ -1519,8 +1519,8 @@ def _reimage_initial(
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct body
if vm_instance_ids is not None:
body_content = self._serialize.body(vm_instance_ids, 'VirtualMachineScaleSetVMInstanceIDs')
if vm_scale_set_reimage_input is not None:
body_content = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters')
else:
body_content = None

Expand All @@ -1538,14 +1538,17 @@ def _reimage_initial(
return client_raw_response

def reimage(
self, resource_group_name, vm_scale_set_name, instance_ids=None, custom_headers=None, raw=False, polling=True, **operation_config):
self, resource_group_name, vm_scale_set_name, temp_disk=None, instance_ids=None, custom_headers=None, raw=False, polling=True, **operation_config):
"""Reimages (upgrade the operating system) one or more virtual machines in
a VM scale set.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param vm_scale_set_name: The name of the VM scale set.
:type vm_scale_set_name: str
:param temp_disk: Specified whether to reimage temp disk. Default
value: false.
:type temp_disk: bool
:param instance_ids: The virtual machine scale set instance ids.
Omitting the virtual machine scale set instance ids will result in the
operation being performed on all virtual machines in the virtual
Expand All @@ -1565,6 +1568,7 @@ def reimage(
raw_result = self._reimage_initial(
resource_group_name=resource_group_name,
vm_scale_set_name=vm_scale_set_name,
temp_disk=temp_disk,
instance_ids=instance_ids,
custom_headers=custom_headers,
raw=True,
Expand Down
Loading

0 comments on commit 1f6a253

Please sign in to comment.