Skip to content
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
6 changes: 6 additions & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Release History
* [BREAKING] When not specified, the default value for `--start-task-wait-for-success` on `az batch pool create` is now true (was false).
* [BREAKING] The default value for Scope on AutoUserSpecification is now always Pool (was Task on Windows nodes, Pool on Linux nodes). This argument is not exposed via the commandline, but can be set in the `--json-file` arguments.

**Compute**
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the output of the vmss show command?
Is it the json output of the response?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the output of the vmss show command?
Is it the json output of the response?

vmss show visit GET https://management.azure.com/subscriptions/{...}/resourceGroups/{...}/providers/Microsoft.Compute/virtualMachineScaleSets/{name}?api-version=2019-03-01.

Basically, Yes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, vmss get-instance-view visit GET https://management.azure.com/subscriptions/{...}/resourceGroups/{...}/providers/Microsoft.Compute/virtualMachineScaleSets/{name}/instanceView?api-version=2019-03-01

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between virtualMachineScaleSets/{name}?$expand=instanceView and virtualMachineScaleSets/{name}/instanceView?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

virtualMachineScaleSets/{name}?$expand=instanceView returns the vmScaleSet goal state with a property named instance view populated (instanceView is expensive runtime state)

virtualMachineScaleSets/{name}/instanceView just returns the expensive runtimestate without the vmScaleSet goal state infromation


* vmss create: Add --terminate-notification-time parameters to support terminate scheduled event configurability.
* vmss update: Add --enable-terminate-notification and --terminate-notification-time parameters to support terminate scheduled event configurability.
* Update azure-mgmt-compute version to 7.0.0.

**HDInsight**

* `az hdinsight resize`: Make parameter `--workernode-count/-c` required
Expand Down
7 changes: 7 additions & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,13 @@ def load_arguments(self, _):

c.argument('protect_from_scale_in', arg_type=protection_policy_type, help="Protect the VM instance from scale-in operations.")
c.argument('protect_from_scale_set_actions', arg_type=protection_policy_type, help="Protect the VM instance from scale set actions (including scale-in).")
c.argument('enable_terminate_notification', min_api='2019-03-01', arg_type=get_three_state_flag(),
help='Enable terminate notification')

for scope in ['vmss create', 'vmss update']:
with self.argument_context(scope) as c:
c.argument('terminate_notification_time', min_api='2019-03-01',
Comment thread
qwordy marked this conversation as resolved.
help='Length of time (in minutes, between 5 and 15) a notification to be sent to the VM on the instance metadata server till the VM gets deleted')

for scope, help_prefix in [('vmss update', 'Update the'), ('vmss wait', 'Wait on the')]:
with self.argument_context(scope) as c:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ def build_vmss_resource(cmd, name, naming_prefix, location, tags, overprovision,
backend_address_pool_id=None, inbound_nat_pool_id=None, health_probe=None,
single_placement_group=None, platform_fault_domain_count=None, custom_data=None,
secrets=None, license_type=None, zones=None, priority=None, eviction_policy=None,
application_security_groups=None, ultra_ssd_enabled=None, proximity_placement_group=None):
application_security_groups=None, ultra_ssd_enabled=None, proximity_placement_group=None,
terminate_notification_time=None):

# Build IP configuration
ip_configuration = {
Expand Down Expand Up @@ -795,6 +796,15 @@ def build_vmss_resource(cmd, name, naming_prefix, location, tags, overprovision,
if proximity_placement_group:
vmss_properties['proximityPlacementGroup'] = {'id': proximity_placement_group}

if terminate_notification_time is not None:
scheduled_events_profile = {
'terminateNotificationProfile': {
'notBeforeTimeout': terminate_notification_time,
Comment thread
qwordy marked this conversation as resolved.
'enable': 'true'
}
}
vmss_properties['virtualMachineProfile']['scheduledEventsProfile'] = scheduled_events_profile

vmss = {
'type': 'Microsoft.Compute/virtualMachineScaleSets',
'name': name,
Expand Down
23 changes: 23 additions & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,7 @@ def process_vmss_create_namespace(cmd, namespace):
_validate_vm_vmss_create_auth(namespace)
_validate_vm_vmss_msi(cmd, namespace)
_validate_proximity_placement_group(cmd, namespace)
_validate_vmss_terminate_notification(cmd, namespace)

if namespace.secrets:
_validate_secrets(namespace.secrets, namespace.os_type)
Expand All @@ -1306,6 +1307,7 @@ def validate_vmss_update_namespace(cmd, namespace): # pylint: disable=unused-ar
if namespace.protect_from_scale_in is not None or namespace.protect_from_scale_set_actions is not None:
raise CLIError("usage error: protection policies can only be applied to VM instances within a VMSS."
" Please use --instance-id to specify a VM instance")
_validate_vmss_update_terminate_notification_related(cmd, namespace)
# endregion


Expand Down Expand Up @@ -1489,3 +1491,24 @@ def process_vm_vmss_stop(cmd, namespace): # pylint: disable=unused-argument
else:
logger.warning("About to power off the specified VM...\nIt will continue to be billed. "
"To deallocate a VM, run: az vm deallocate.")


def _validate_vmss_update_terminate_notification_related(cmd, namespace): # pylint: disable=unused-argument
"""
Validate vmss update enable_terminate_notification and terminate_notification_time.
If terminate_notification_time is specified, enable_terminate_notification should not be false
If enable_terminate_notification is true, must specify terminate_notification_time
"""
if namespace.enable_terminate_notification is False and namespace.terminate_notification_time is not None:
raise CLIError("usage error: please enable --enable-terminate-notification")
if namespace.enable_terminate_notification is True and namespace.terminate_notification_time is None:
raise CLIError("usage error: please set --terminate-notification-time")
_validate_vmss_terminate_notification(cmd, namespace)


def _validate_vmss_terminate_notification(cmd, namespace): # pylint: disable=unused-argument
"""
Transform minutes to ISO 8601 formmat
"""
if namespace.terminate_notification_time is not None:
namespace.terminate_notification_time = 'PT' + namespace.terminate_notification_time + 'M'
12 changes: 10 additions & 2 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,7 @@ def create_vmss(cmd, vmss_name, resource_group_name, image,
assign_identity=None, identity_scope=None, identity_role='Contributor',
identity_role_id=None, zones=None, priority=None, eviction_policy=None,
application_security_groups=None, ultra_ssd_enabled=None, ephemeral_os_disk=None,
proximity_placement_group=None, aux_subscriptions=None):
proximity_placement_group=None, aux_subscriptions=None, terminate_notification_time=None):
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.core.util import random_string, hash_string
from azure.cli.core.commands.arm import ArmTemplateBuilder
Expand Down Expand Up @@ -2062,7 +2062,8 @@ def _get_public_ip_address_allocation(value, sku):
single_placement_group=single_placement_group, platform_fault_domain_count=platform_fault_domain_count,
custom_data=custom_data, secrets=secrets, license_type=license_type, zones=zones, priority=priority,
eviction_policy=eviction_policy, application_security_groups=application_security_groups,
ultra_ssd_enabled=ultra_ssd_enabled, proximity_placement_group=proximity_placement_group)
ultra_ssd_enabled=ultra_ssd_enabled, proximity_placement_group=proximity_placement_group,
terminate_notification_time=terminate_notification_time)
vmss_resource['dependsOn'] = vmss_dependencies

if plan_name:
Expand Down Expand Up @@ -2289,6 +2290,7 @@ def update_vmss_instances(cmd, resource_group_name, vm_scale_set_name, instance_

def update_vmss(cmd, resource_group_name, name, license_type=None, no_wait=False, instance_id=None,
protect_from_scale_in=None, protect_from_scale_set_actions=None,
enable_terminate_notification=None, terminate_notification_time=None,
**kwargs):
vmss = kwargs['parameters']
client = _compute_client_factory(cmd.cli_ctx)
Expand Down Expand Up @@ -2316,6 +2318,12 @@ def update_vmss(cmd, resource_group_name, name, license_type=None, no_wait=False
if license_type is not None:
vmss.virtual_machine_profile.license_type = license_type

if enable_terminate_notification is not None or terminate_notification_time is not None:
TerminateNotificationProfile = cmd.get_models('TerminateNotificationProfile')
vmss.virtual_machine_profile.scheduled_events_profile.terminate_notification_profile =\
TerminateNotificationProfile(not_before_timeout=terminate_notification_time,
enable=enable_terminate_notification)

return sdk_no_wait(no_wait, client.virtual_machine_scale_sets.create_or_update,
resource_group_name, name, **kwargs)

Expand Down
Loading