Skip to content

Commit 49dcd2f

Browse files
authored
update extension to newest version (#139)
* update extension to newest version
1 parent 7320514 commit 49dcd2f

File tree

37 files changed

+6317
-8390
lines changed

37 files changed

+6317
-8390
lines changed

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
SDK Release History
44
===================
55

6+
9.0.0 (2022-08-30)
7+
------------------
8+
9+
* Update to match latest Python SDK taking associated breaking changes.
10+
611
8.0.0 (2020-06-15)
712
------------------
813

azext/batch/batch_extensions_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class BatchExtensionsClient(BatchServiceClient):
5252

5353
def __init__(self, credentials=None, batch_url=None, subscription_id=None,
5454
resource_group=None, batch_account=None, storage_client=None,
55-
storage_endpoint=None, mgmt_credentials=None, mgmt_base_url=None):
55+
storage_endpoint=None, mgmt_credentials=None, mgmt_base_url="https://management.azure.com"):
5656
credentials, mgmt_credentials, subscription_id = self._configure_credentials(
5757
credentials, mgmt_credentials, subscription_id)
5858
super(BatchExtensionsClient, self).__init__(credentials, batch_url=batch_url)

azext/batch/models/_models.py

Lines changed: 321 additions & 323 deletions
Large diffs are not rendered by default.

azext/batch/models/_models_py3.py

Lines changed: 514 additions & 522 deletions
Large diffs are not rendered by default.

azext/batch/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55

6-
VERSION = "8.0.0"
6+
VERSION = "9.0.0"

batch-cli-extensions/azext_batch/_params.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from azure.cli.command_modules.batch._validators import (
1111
metadata_item_format, certificate_reference_format, validate_json_file,
1212
environment_setting_format, resource_file_format)
13-
from azext_batch._validators import validate_pool_settings, validate_client_parameters
13+
from azext_batch._validators import validate_client_parameters
1414

1515

1616
# pylint: disable=line-too-long, too-many-statements
@@ -20,9 +20,8 @@ def load_arguments(self, _):
2020
c.argument('json_file', type=file_type, help='The file containing the pool to create in JSON format, if this parameter is specified, all other parameters are ignored.', validator=validate_json_file, completer=FilesCompleter())
2121
c.argument('template', type=file_type, arg_group='Batch Extensions', help='A Batch pool JSON template file. If this parameter is specified, all other parameters are ignored.', completer=FilesCompleter())
2222
c.argument('parameters', type=file_type, arg_group='Batch Extensions', help='Parameter values for a Batch pool JSON template file. Can only be used with --template.', completer=FilesCompleter())
23-
c.argument('application_package_references', nargs='+', validator=validate_pool_settings)
23+
c.argument('os_version', arg_group='Pool: Cloud Service Configuration', help='The default value is * which specifies the latest operating system version for the specified OS family.')
2424
c.argument('certificate_references', nargs='+', type=certificate_reference_format)
25-
c.argument('application_licenses', nargs='+')
2625
c.argument('metadata', nargs='+', type=metadata_item_format)
2726
c.argument('start_task_command_line', arg_group='Pool: Start Task', help='The command line of the start task. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux.')
2827
c.argument('start_task_resource_files', arg_group='Pool: Start Task', nargs='+', type=resource_file_format, help='A list of files that the Batch service will download to the compute node before running the command line. Space separated resource references in filename=httpurl format.')
@@ -32,23 +31,38 @@ def load_arguments(self, _):
3231
c.extra('disk_encryption_targets',
3332
arg_group="Pool: Virtual Machine Configuration",
3433
help='A space seperated list of DiskEncryptionTargets. current possible values include OsDisk and TemporaryDisk.')
34+
c.extra('disk_encryption_configuration_targets', options_list=('--targets',),
35+
arg_group="Pool: Virtual Machine Configuration: Disk Encryption Configuration Arguments",
36+
help='If omitted, no disks on the compute nodes in the pool will be encrypted. On Linux pool, only "TemporaryDisk" is supported; on Windows pool, "OsDisk" and "TemporaryDisk" must be specified. Space seperated target disks to be encrypted. Values can either be OsDisk or TemporaryDisk.')
37+
c.extra('node_placement_policy', options_list=('--policy',),
38+
arg_group="Pool: Virtual Machine Configuration: Node Placement Configuration Arguments",
39+
help='Node placement Policy type on Batch Pools. Allocation policy used by Batch Service to provision the nodes. If not specified, Batch will use the regional policy. Allowed values: regional, zonal.')
3540
c.argument('node_agent_sku_id', arg_group="Pool: Virtual Machine Configuration", help='The SKU of the Batch node agent to be provisioned on compute nodes in the pool. The Batch node agent is a program that runs on each node in the pool, and provides the command-and-control interface between the node and the Batch service. There are different implementations of the node agent, known as SKUs, for different operating systems. You must specify a node agent SKU which matches the selected image reference. To get the list of supported node agent SKUs along with their list of verified image references, see the \'List supported node agent SKUs\' operation.')
3641
c.argument('image', completer=load_supported_images, arg_group="Pool: Virtual Machine Configuration",
3742
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 node-agent-skus list'. For example: 'MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:latest'")
3843

3944
with self.argument_context('batch job create') as c:
40-
c.argument('json_file', type=file_type, help='The file containing the job to create in JSON format, if this parameter is specified, all other parameters are ignored.', validator=validate_json_file, completer=FilesCompleter())
45+
c.argument('json_file', type=file_type, help='A file containing the job specification in JSON (formatted to match the respective REST API body). If this parameter is specified, all \'Job Arguments\' are ignored.', validator=validate_json_file, completer=FilesCompleter())
4146
c.argument('template', type=file_type, arg_group='Batch Extensions', help='A Batch job JSON template file. If this parameter is specified, all other parameters are ignored.', completer=FilesCompleter())
4247
c.argument('parameters', type=file_type, arg_group='Batch Extensions', help='Parameter values for a Batch job JSON template file. Can only be used with --template.', completer=FilesCompleter())
43-
c.argument('metadata', nargs='+', type=metadata_item_format, help='A list of name-value pairs associated with the job as metadata. The Batch service does not assign any meaning to metadata; it is solely for the use of user code. Space separated values in \'key=value\' format.')
44-
c.argument('uses_task_dependencies', action='store_true', help='The flag that determines if this job will use tasks with dependencies. True if flag present.')
48+
c.argument('metadata', arg_group='Job', nargs='+', type=metadata_item_format)
49+
c.argument('uses_task_dependencies', arg_group='Job', action='store_true', help='The flag that determines if this job will use tasks with dependencies. True if flag present.')
4550
c.argument('pool_id', arg_group='Job: Pool Info', help='The id of an existing pool. All the tasks of the job will run on the specified pool.')
4651
c.argument('job_max_task_retry_count', arg_group='Job: Constraints', help='The maximum number of times each task may be retried. The Batch service retries a task if its exit code is nonzero. Note that this value specifically controls the number of retries. The Batch service will try each task once, and may then retry up to this limit. For example, if the maximum retry count is 3, Batch tries a task up to 4 times (one initial try and 3 retries). If the maximum retry count is 0, the Batch service does not retry tasks. If the maximum retry count is -1, the Batch service retries tasks without limit. The default value is 0 (no retries).')
4752
c.argument('job_max_wall_clock_time', arg_group='Job: Constraints', help='The maximum elapsed time that the job may run, measured from the time the job is created. If the job does not complete within the time limit, the Batch service terminates it and any tasks that are still running. In this case, the termination reason will be MaxWallClockTimeExpiry. If this property is not specified, there is no time limit on how long the job may run. Expected format is an ISO-8601 duration.')
4853
c.argument('job_manager_task_command_line', arg_group='Job: Job Manager Task', help='The command line of the Job Manager task. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux.')
4954
c.argument('job_manager_task_environment_settings', arg_group='Job: Job Manager Task', type=environment_setting_format, help='A list of environment variable settings for the Job Manager task. Space separated values in \'key=value\' format.')
5055
c.argument('job_manager_task_resource_files', arg_group='Job: Job Manager Task', type=resource_file_format, help='A list of files that the Batch service will download to the compute node before running the command line. Files listed under this element are located in the task\'s working directory. Space separated resource references in filename=httpurl format.')
5156
c.argument('job_manager_task_id', arg_group='Job: Job Manager Task', help='A string that uniquely identifies the Job Manager task within the job. The id can contain any combination of alphanumeric characters including hyphens and underscores and cannot contain more than 64 characters.')
57+
c.argument('required_slots', arg_group='Job: Job Manager Task', help='The number of scheduling slots that the Task requires to run. The default is 1. A Task can only be scheduled to run on a compute node if the node has enough free scheduling slots available. For multi-instance Tasks, this property is not supported and must not be specified.')
58+
c.argument('allow_task_preemption', arg_group='Job')
59+
c.argument('max_parallel_tasks', arg_group='Job')
60+
c.argument('id', arg_group='Job')
61+
c.argument('priority', arg_group='Job')
62+
63+
64+
65+
5266

5367
with self.argument_context('batch file upload') as c:
5468
c.argument('local_path', type=file_type, help='Path to a local file or directory to be uploaded - can include wildcard patterns.')

batch-cli-extensions/azext_batch/commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414

1515
logger = get_logger(__name__)
16-
MINIMUM_UNSUPPORTED_BATCH_VERSION = "7.1"
17-
MINIMUM_UNSUPPORTED_BMGMT_VERSION = "6.1"
18-
MINIMUM_UNSUPPORTED_BATCH_EXT_VERSION = "6.1"
16+
MINIMUM_UNSUPPORTED_BATCH_VERSION = "12.2"
17+
MINIMUM_UNSUPPORTED_BMGMT_VERSION = "16.3"
18+
MINIMUM_UNSUPPORTED_BATCH_EXT_VERSION = "9.1"
1919

2020

2121
def confirm_version(current, supported, package):

batch-cli-extensions/azext_batch/custom.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55
import multiprocessing
6+
import os
67
from azure.cli.core.util import get_file_json
78
from knack.log import get_logger
89
from knack.prompting import prompt
@@ -28,19 +29,29 @@ def disk_encryption_target_format(value):
2829
message = 'Argument {} is not a valid disk_encryption_target'
2930
raise ValueError(message.format(value))
3031

32+
def node_placement_policy_format(value):
33+
"""If not specified, Batch will use the regional policy. Possible values include: regional,zonal"""
34+
from azext.batch.models import NodePlacementPolicyType
35+
if value == 'regional':
36+
return NodePlacementPolicyType.regional
37+
if value == 'zonal':
38+
return NodePlacementPolicyType.zonal
39+
message = 'Argument {} is not a valid node_placement_policy'
40+
raise ValueError(message.format(value))
3141

3242
def create_pool(client, template=None, parameters=None, json_file=None, id=None, vm_size=None, # pylint:disable=too-many-arguments, too-many-locals
3343
target_dedicated_nodes=None, target_low_priority_nodes=None, auto_scale_formula=None, # pylint: disable=redefined-builtin
3444
enable_inter_node_communication=False, os_family=None, image=None, disk_encryption_targets=None,
3545
node_agent_sku_id=None, resize_timeout=None, start_task_command_line=None,
3646
start_task_resource_files=None, start_task_wait_for_success=False, application_licenses=None,
37-
certificate_references=None, application_package_references=None, metadata=None):
47+
certificate_references=None, application_package_references=None, metadata=None, disk_encryption_configuration_targets=None,
48+
node_placement_policy=None, os_version=None, task_slots_per_node=None):
3849
# pylint: disable=too-many-branches, too-many-statements
3950
from azext.batch.errors import MissingParameterValue
4051
from azext.batch.models import (
4152
PoolAddOptions, StartTask, ImageReference,
4253
CloudServiceConfiguration, VirtualMachineConfiguration,
43-
DiskEncryptionConfiguration)
54+
DiskEncryptionConfiguration, NodePlacementConfiguration)
4455
if template or json_file:
4556
if template:
4657
json_obj = None
@@ -78,9 +89,9 @@ def create_pool(client, template=None, parameters=None, json_file=None, id=None,
7889
pool.enable_auto_scale = False
7990

8091
pool.enable_inter_node_communication = enable_inter_node_communication
81-
92+
pool.task_slots_per_node = task_slots_per_node
8293
if os_family:
83-
pool.cloud_service_configuration = CloudServiceConfiguration(os_family=os_family)
94+
pool.cloud_service_configuration = CloudServiceConfiguration(os_family=os_family,os_version=os_version)
8495
else:
8596
if image:
8697
version = 'latest'
@@ -94,12 +105,21 @@ def create_pool(client, template=None, parameters=None, json_file=None, id=None,
94105
image_reference=ImageReference(publisher=publisher, offer=offer, sku=sku, version=version),
95106
node_agent_sku_id=node_agent_sku_id)
96107
if disk_encryption_targets:
97-
targets = disk_encryption_targets.split(' ')
108+
targets_list = disk_encryption_targets.split(' ')
109+
parsed_targets = []
110+
for target in targets_list:
111+
parsed_targets.append(
112+
disk_encryption_target_format(target))
113+
pool.virtual_machine_configuration.disk_configuration = DiskEncryptionConfiguration(targets=parsed_targets)
114+
if disk_encryption_configuration_targets:
115+
targets_list = disk_encryption_configuration_targets.split(' ')
98116
parsed_targets = []
99-
for target in targets:
117+
for target in targets_list:
100118
parsed_targets.append(
101119
disk_encryption_target_format(target))
102120
pool.virtual_machine_configuration.disk_configuration = DiskEncryptionConfiguration(targets=parsed_targets)
121+
if node_placement_policy:
122+
pool.virtual_machine_configuration.node_placement_configuration = NodePlacementConfiguration(node_placement_policy_format(node_placement_policy))
103123
except ValueError:
104124
if '/' not in image:
105125
message = ("Incorrect format for VM image. Should be in the format: \n"
@@ -136,7 +156,8 @@ def create_job(client, template=None, parameters=None, json_file=None, id=None,
136156
pool_id=None, priority=None, uses_task_dependencies=False, metadata=None,
137157
job_max_wall_clock_time=None, job_max_task_retry_count=None,
138158
job_manager_task_command_line=None, job_manager_task_environment_settings=None,
139-
job_manager_task_id=None, job_manager_task_resource_files=None):
159+
job_manager_task_id=None, job_manager_task_resource_files=None, allow_task_preemption=None,
160+
max_parallel_tasks=None, required_slots=None):
140161
# pylint: disable=too-many-branches, too-many-statements
141162
from azext.batch.errors import MissingParameterValue
142163
from azext.batch.models import JobManagerTask, JobAddOptions, PoolInformation
@@ -179,14 +200,18 @@ def create_job(client, template=None, parameters=None, json_file=None, id=None,
179200
max_task_retry_count=job_max_task_retry_count)
180201
job.constraints = constraints
181202

182-
if metadata:
183-
job.metadata = metadata
184-
203+
job.metadata = metadata
204+
job.allow_task_preemption = allow_task_preemption
205+
job.max_parallel_tasks = max_parallel_tasks
206+
185207
if job_manager_task_command_line and job_manager_task_id:
186208
job_manager_task = JobManagerTask(id=job_manager_task_id,
187209
command_line=job_manager_task_command_line,
188210
resource_files=job_manager_task_resource_files,
189211
environment_settings=job_manager_task_environment_settings) # pylint: disable=line-too-long
212+
if required_slots:
213+
job_manager_task.required_slots = required_slots
214+
190215
job.job_manager_task = job_manager_task
191216

192217
add_option = JobAddOptions()

batch-cli-extensions/azext_batch/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55

6-
VERSION = "6.0.0"
6+
VERSION = "7.0.0"

batch-cli-extensions/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
]
2828

2929
DEPENDENCIES = [
30-
'azure-batch-extensions>=8.0.0,<8.1',
30+
'azure-batch-extensions>=8.0.0,<9.1',
3131
'pycparser==2.18'
3232
]
3333

0 commit comments

Comments
 (0)