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

{Batch} Upgrade api-version to v2023-11-01 #28315

Merged
merged 7 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _is_bool(self, name):

def _is_list(self, name):
"""Whether argument value is a list"""
return self._arg_tree[name]['type'].startswith('[')
return self._arg_tree[name]['type'].startswith('[') or self._arg_tree[name]['type'] == '{str}'

def _is_datetime(self, name):
"""Whether argument value is a timestamp"""
Expand Down Expand Up @@ -612,7 +612,6 @@ def _get_attrs(self, model, path):
conditions.append(
model._validation.get(attr, {}).get('constant')) # pylint: disable=protected-access
conditions.append(any(i for i in pformat.IGNORE_PARAMETERS if i in full_path))
conditions.append(details['type'][0] in ['{'])
if not any(conditions):
yield attr, details

Expand Down Expand Up @@ -693,7 +692,7 @@ def _flatten_object(self, path, param_model, conflict_names=None):
if details['type'] in pformat.BASIC_TYPES:
self._resolve_conflict(param_attr, param_attr, path, options,
details['type'], required_attrs, conflict_names)
elif details['type'].startswith('['):
elif details['type'].startswith('[') or details['type'].startswith('{'):
# We only expose a list arg if there's a validator for it
# This will fail for 2D arrays - though Batch doesn't have any yet
inner_type = details['type'][1:-1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
'job_manager_task.allow_low_priority_node',
'job.job_manager_task.application_package_references',
'virtual_machine_configuration.windows_configuration',
'virtual_machine_configuration.os_disk',
'virtual_machine_configuration.container_configuration',
'virtual_machine_configuration.license_type',
'task_scheduling_policy',
Expand All @@ -95,7 +94,8 @@
'job_schedule.job_specification.job_manager_task.environment_settings',
'resource_file.storage_container_url',
'resource_file.blob_prefix',
'resource_file.auto_storage_container_name'
'resource_file.auto_storage_container_name',
'virtual_machine_configuration.service_artifact_reference'
]

# Options to be flattened into multiple arguments.
Expand Down
32 changes: 32 additions & 0 deletions src/azure-cli/azure/cli/command_modules/batch/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
keyvault_id,
metadata_item_format,
resource_file_format,
resource_tag_format,
storage_account_id,
validate_cert_file,
validate_cert_settings,
Expand Down Expand Up @@ -236,11 +237,42 @@ def load_arguments(self, _):
c.argument('json_file', help='The file containing pool create properties parameter specification in JSON(formatted to match REST API request body). If this parameter is specified, all \'Pool Create Properties Parameter Arguments\' are ignored. See https://docs.microsoft.com/en-us/rest/api/batchservice/pool/add?tabs=HTTP#request-body')
c.argument('os_family', arg_type=get_enum_type(['2', '3', '4', '5', '6']))
c.argument('auto_scale_formula', help='A formula for the desired number of compute nodes in the pool. The formula is checked for validity before the pool is created. If the formula is not valid, the Batch service rejects the request with detailed error information. For more information about specifying this formula, see https://azure.microsoft.com/documentation/articles/batch-automatic-scaling/.')
c.extra('resource_tags', arg_group='Pool', type=resource_tag_format, help="User is able to specify resource tags for the pool. Any resource created for the pool will then also be tagged by the same resource tags")
c.extra('encryption_at_host',
arg_group='Pool: Security Profile',
help='This property can be used by user in the request to enable or disable the Host Encryption for the virtual machine or virtual machine scale set. This will enable the encryption for all the disks including Resource/Temp disk at host itself. The default behavior is: The Encryption at host will be disabled unless this property is set to true for the resource.')
c.extra('security_type',
arg_group='Pool: Security Profile',
help='Specifies the SecurityType of the virtual machine. It has to be set to any specified value to enable UefiSettings. The default behavior is: UefiSettings will not be enabled unless this property is set.')
c.extra('secure_boot_enabled', arg_type=get_three_state_flag(),
options_list=('--enable-secure-boot'),
arg_group='Pool: Security Profile',
help='Enable secure boot')
c.extra('v_tpm_enabled', arg_type=get_three_state_flag(),
options_list=('--enable-vtpm'),
arg_group='Pool: Security Profile',
help='Enable vTPM')
c.extra('disk_encryption_targets',
arg_group="Pool: Virtual Machine Configuration",
help='A space separated list of DiskEncryptionTargets. current possible values include OsDisk and TemporaryDisk.', type=disk_encryption_configuration_format)
c.extra('image', completer=load_supported_images, arg_group="Pool: Virtual Machine Configuration",
help="OS image reference. This can be either 'publisher:offer:sku[:version]' format, or a fully qualified ARM image id of the form '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}'. If 'publisher:offer:sku[:version]' format, version is optional and if omitted latest will be used. Valid values can be retrieved via 'az batch pool supported-images list'. For example: 'MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:latest'")
c.extra('caching',
options_list=('--os-disk-caching'),
arg_group="Pool: OS Disk",
arg_type=get_enum_type(['None', 'ReadOnly', 'ReadWrite']),
help="Specifies the caching requirements. Possible values are: None, ReadOnly, ReadWrite. The default values are: None for Standard storage. ReadOnly for Premium storage.")
c.extra('storage_account_type',
arg_group="Pool: OS Disk",
help="The storage account type for managed disk")
c.extra('disk_size_gb',
options_list=('--os-disk-size'),
arg_group="Pool: OS Disk",
help="The initial disk size in GB when creating new OS disk.")
c.extra('write_accelerator_enabled', arg_type=get_three_state_flag(),
options_list=('--enable-write-accel'),
arg_group="Pool: OS Disk",
help="Specifies whether writeAccelerator should be enabled or disabled on the disk.")
c.argument('target_node_communication_mode', options_list=['--target-communication'],
help="The desired node communication mode for the pool. If this element is present, it replaces the existing targetNodeCommunicationMode configured on the Pool. If omitted, any existing metadata is left unchanged.",
arg_type=get_enum_type(NodeCommunicationMode))
Expand Down
17 changes: 17 additions & 0 deletions src/azure-cli/azure/cli/command_modules/batch/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ def metadata_item_format(value):
return {'name': data_name, 'value': data_value}


def resource_tag_format(values):
"""Space-separated values in 'key=value' format."""
if not values:
raise ValueError("No values in resource tags. "
"Argument values should be in the format a=b c=d")
result = {}
try:
for value in values.split(' '):
k, v = value.split('=')
result[k] = v
except ValueError:
message = ("Incorrectly formatted resource tags. "
"Argument values should be in the format a=b c=d")
raise ValueError(message)
return result


def environment_setting_format(value):
"""Space-separated values in 'key=value' format."""
try:
Expand Down
Loading