Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cf336ef
Merge pull request #3 from Azure/dev
BigCat20196 Mar 24, 2021
783635e
Merge pull request #4 from Azure/dev
BigCat20196 Apr 2, 2021
1e0ede2
Merge pull request #5 from Azure/dev
BigCat20196 Apr 8, 2021
2137f75
Update test link
BigCat20196 Apr 8, 2021
ebd32e1
Merge pull request #6 from Azure/dev
BigCat20196 Apr 9, 2021
169ceb5
Merge branch 'jf_fix13385_408' into dev
BigCat20196 Apr 9, 2021
01d4476
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
BigCat20196 Apr 9, 2021
28dc2cf
Merge branch 'dev' of https://github.com/Azure/azure-cli into dev
BigCat20196 Apr 12, 2021
580a718
Merge pull request #7 from Azure/dev
BigCat20196 Apr 14, 2021
343c993
Merge pull request #8 from Azure/dev
BigCat20196 Apr 19, 2021
66e59c6
Merge pull request #9 from Azure/dev
BigCat20196 Apr 25, 2021
001e6c9
Merge pull request #11 from Azure/dev
BigCat20196 Apr 27, 2021
54c00cc
Merge pull request #12 from Azure/dev
BigCat20196 May 7, 2021
d8996cb
Merge pull request #13 from Azure/dev
BigCat20196 May 13, 2021
901d9c8
Update requirements
BigCat20196 May 13, 2021
81ae19c
Fix batch_data_plane
BigCat20196 May 18, 2021
875f0a0
Fix 2 tests
BigCat20196 May 25, 2021
f56208e
Fix their style and linter
BigCat20196 May 25, 2021
b71acc8
Merge branch 'dev' into batchtrack2
BigCat20196 May 25, 2021
c1f2b78
Fix _help
BigCat20196 May 26, 2021
419b67b
Merge branch 'batchtrack2' of https://github.com/BigCat20196/azure-cl…
BigCat20196 May 26, 2021
91f7de2
Fix batch style and linter
BigCat20196 May 26, 2021
3a9807c
Upload test yaml
BigCat20196 May 26, 2021
56854c9
Fix batch test in network
BigCat20196 May 27, 2021
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 @@ -59,9 +59,9 @@ def compute_node_client_factory(cli_ctx, kwargs):


def batch_client_factory(cli_ctx, **_):
from azure.mgmt.batch import BatchManagementClient
from azure.mgmt.batch import BatchManagement
from azure.cli.core.commands.client_factory import get_mgmt_service_client
return get_mgmt_service_client(cli_ctx, BatchManagementClient)
return get_mgmt_service_client(cli_ctx, BatchManagement)


def batch_data_service_factory(cli_ctx, kwargs):
Expand Down
8 changes: 8 additions & 0 deletions src/azure-cli/azure/cli/command_modules/batch/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
crafted: true
"""

helps['batch account keys renew'] = """
type: command
short-summary: Renew keys for a Batch account.
examples:
- name: Renew keys for a Batch account.
text: az batch account keys renew --name MyBatchAccount --resource-group MyResourceGroup --key-name primary
"""

helps['batch account show'] = """
type: command
short-summary: Get a specified Batch account or the currently set account.
Expand Down
18 changes: 13 additions & 5 deletions src/azure-cli/azure/cli/command_modules/batch/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ def load_arguments(self, _):
c.argument('identity_type', help="The type of identity used for the Batch account. Possible values include: 'SystemAssigned', 'None'.", arg_type=get_enum_type(ResourceIdentityType))

with self.argument_context('batch account keys renew') as c:
c.argument('key_name', arg_type=get_enum_type(AccountKeyType))
c.argument('resource_group_name', resource_group_name_type,
help='Name of the resource group. If not specified will display currently set account.',
required=False)
c.argument('account_name', batch_name_type, options_list=('--name', '-n'),
help='Name of the batch account to show. If not specified will display currently set account.',
required=False)
c.argument('key_name', arg_type=get_enum_type(AccountKeyType), help='Name of the batch account key.')

with self.argument_context('batch account login') as c:
c.argument('shared_key_auth', action='store_true', help='Using Shared Key authentication, if not specified, it will use Azure Active Directory authentication.')
Expand All @@ -95,10 +101,12 @@ def load_arguments(self, _):
with self.argument_context('batch application create') as c:
c.argument('allow_updates', options_list=('--allow-updates',), action="store_true", help="Specify to indicate whether packages within the application may be overwritten using the same version string. True if flag present.")

with self.argument_context('batch application package create') as c:
c.argument('package_file', type=file_type, help='The path of the application package in zip format', completer=FilesCompleter())
c.argument('application_name', options_list=('--application-name',), help="The name of the application.")
c.argument('version_name', options_list=('--version-name',), help="The version name of the application.")
for command in ['create', 'activate']:
with self.argument_context('batch application package {}'.format(command)) as c:
c.argument('package_file', type=file_type, help='The path of the application package in zip format', completer=FilesCompleter())
c.argument('application_name', options_list=('--application-name',), help="The name of the application.")
c.argument('version_name', options_list=('--version-name',), help="The version name of the application.")
c.argument('f_ormat', options_list=('--format',), help="The format of the application package binary file.")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
c.argument('f_ormat', options_list=('--format',), help="The format of the application package binary file.")
c.argument('format', options_list=('--format',), help="The format of the application package binary file.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Format is a keyword. If we use format as the parameter name, linter will report an error.

Copy link
Member

Choose a reason for hiding this comment

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

You are right. Options_list is the display name. No problem.


with self.argument_context('batch location quotas show') as c:
c.argument('location_name', get_location_type(self.cli_ctx), help='The region from which to display the Batch service quotas.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ def keyvault_id(cmd, namespace):

def application_enabled(cmd, namespace):
"""Validates account has auto-storage enabled"""
from azure.mgmt.batch import BatchManagementClient
from azure.mgmt.batch import BatchManagement
from azure.cli.core.commands.client_factory import get_mgmt_service_client

client = get_mgmt_service_client(cmd.cli_ctx, BatchManagementClient)
client = get_mgmt_service_client(cmd.cli_ctx, BatchManagement)
acc = client.batch_account.get(namespace.resource_group_name, namespace.account_name)
if not acc:
raise ValueError("Batch account '{}' not found.".format(namespace.account_name))
Expand Down Expand Up @@ -294,7 +294,7 @@ def validate_cert_settings(namespace):

def validate_client_parameters(cmd, namespace):
"""Retrieves Batch connection parameters from environment variables"""
from azure.mgmt.batch import BatchManagementClient
from azure.mgmt.batch import BatchManagement
from azure.cli.core.commands.client_factory import get_mgmt_service_client

# simply try to retrieve the remaining variables from environment variables
Expand All @@ -315,7 +315,7 @@ def validate_client_parameters(cmd, namespace):
if cmd.cli_ctx.config.get('batch', 'auth_mode', 'shared_key') == 'shared_key':
endpoint = urlsplit(namespace.account_endpoint)
host = endpoint.netloc
client = get_mgmt_service_client(cmd.cli_ctx, BatchManagementClient)
client = get_mgmt_service_client(cmd.cli_ctx, BatchManagement)
acc = next((x for x in client.batch_account.list()
if x.name == namespace.account_name and x.account_endpoint == host), None)
if acc:
Expand Down
8 changes: 5 additions & 3 deletions src/azure-cli/azure/cli/command_modules/batch/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ def get_data_factory(name):
g.custom_show_command('show', 'get_account')
g.custom_command('create', 'create_account', supports_no_wait=True)
g.custom_command('set', 'update_account')
g.command('delete', 'delete', supports_no_wait=True, confirmation=True)
g.command('delete', 'begin_delete', supports_no_wait=True, confirmation=True)
g.custom_command('login', 'login_account')
g.command('autostorage-keys sync', 'synchronize_auto_storage_keys')
g.command('keys list', 'get_keys', table_transformer=account_keys_list_table_format)
g.command('keys renew', 'regenerate_key', table_transformer=account_keys_renew_table_format)
# g.command('keys renew', 'regenerate_key', table_transformer=account_keys_renew_table_format)
g.custom_command('keys renew', 'renew_accounts_keys', table_transformer=account_keys_renew_table_format)

with self.command_group('batch application', get_mgmt_type('application'), client_factory=get_mgmt_factory('application')) as g:
g.command('list', 'list', table_transformer=application_list_table_format)
Expand All @@ -71,7 +72,8 @@ def get_data_factory(name):
g.custom_command('create', 'create_application_package')
g.command('delete', 'delete', confirmation=True)
g.show_command('show', 'get')
g.command('activate', 'activate')
# g.command('activate', 'activate')
g.custom_command('activate', 'activate_application_package')
g.command('list', 'list')

with self.command_group('batch location quotas', get_mgmt_type('location')) as g:
Expand Down
28 changes: 22 additions & 6 deletions src/azure-cli/azure/cli/command_modules/batch/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

from msrest.exceptions import DeserializationError

from azure.mgmt.batch import BatchManagementClient
from azure.mgmt.batch import BatchManagement
from azure.mgmt.batch.models import (BatchAccountCreateParameters, BatchAccountUpdateParameters,
AutoStorageBaseProperties,
AutoStorageBaseProperties, ActivateApplicationPackageParameters,
Application, EncryptionProperties,
KeyVaultProperties, BatchAccountIdentity)
KeyVaultProperties, BatchAccountIdentity,
BatchAccountRegenerateKeyParameters)
from azure.mgmt.batch.operations import (ApplicationPackageOperations)

from azure.batch.models import (CertificateAddParameter, PoolStopResizeOptions, PoolResizeParameter,
Expand Down Expand Up @@ -99,7 +100,7 @@ def create_account(client,
parameters.key_vault_reference = {'id': keyvault, 'url': keyvault_url}
parameters.pool_allocation_mode = 'UserSubscription'

return sdk_no_wait(no_wait, client.create, resource_group_name=resource_group_name,
return sdk_no_wait(no_wait, client.begin_create, resource_group_name=resource_group_name,
account_name=account_name, parameters=parameters)


Expand Down Expand Up @@ -171,6 +172,13 @@ def login_account(cmd, client, resource_group_name, account_name, shared_key_aut
}


def renew_accounts_keys(client, resource_group_name, account_name, key_name=None):
parameters = BatchAccountRegenerateKeyParameters(key_name=key_name)

return client.regenerate_key(resource_group_name=resource_group_name,
account_name=account_name, parameters=parameters)


@transfer_doc(Application)
def update_application(client,
resource_group_name, account_name, application_name, allow_updates=None,
Expand Down Expand Up @@ -215,7 +223,7 @@ def create_application_package(cmd, client,
resource_group_name, account_name, application_name, version_name,
package_file):
# create application if not exist
mgmt_client = get_mgmt_service_client(cmd.cli_ctx, BatchManagementClient)
mgmt_client = get_mgmt_service_client(cmd.cli_ctx, BatchManagement)
try:
mgmt_client.application.get(resource_group_name, account_name, application_name)
except Exception: # pylint:disable=broad-except
Expand All @@ -228,10 +236,18 @@ def create_application_package(cmd, client,
_upload_package_blob(cmd.cli_ctx, package_file, result.storage_url)

# activate the application package
client.activate(resource_group_name, account_name, application_name, version_name, "zip")
parameters = ActivateApplicationPackageParameters(format="zip")
client.activate(resource_group_name, account_name, application_name, version_name, parameters)
return client.get(resource_group_name, account_name, application_name, version_name)


@transfer_doc(ApplicationPackageOperations.activate)
def activate_application_package(client, resource_group_name, account_name, application_name, version_name, f_ormat):
# activate the application package
parameters = ActivateApplicationPackageParameters(format=f_ormat)
return client.activate(resource_group_name, account_name, application_name, version_name, parameters)


# Data plane custom commands


Expand Down
Loading