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
7 changes: 7 additions & 0 deletions src/hpc-cache/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
Release History
===============

0.1.2
++++++
* Fix #13003: The command `az hpc-cache update` is modified to update only tags.
* Fix #1997: Fix the bug when executing command `az hpc-cache nfs-storage-target update` without passing the parameter `--junction`.
* Fix #14060: Improve the help description of parameter `--junction`.
* The parameter `storage_account` supports passing in the name of storage account.

0.1.1
++++++
* Remove line breaks from examples.
Expand Down
5 changes: 0 additions & 5 deletions src/hpc-cache/README.rst

This file was deleted.

4 changes: 2 additions & 2 deletions src/hpc-cache/azext_hpc_cache/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@

helps['hpc-cache update'] = """
type: command
short-summary: Create or update a Cache.
short-summary: Update a Cache.
examples:
- name: Caches_Update
text: az hpc-cache update --resource-group "scgroup" --name "sc1" --location "eastus" --cache-size-gb "3072" --subnet "/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.Network/virtualNetworks/{virtual_network_name}/subnets/{subnet_name}" --sku-name "Standard_2G"
text: az hpc-cache update --resource-group "scgroup" --name "sc1" --tags "key=val"
"""

helps['hpc-cache delete'] = """
Expand Down
120 changes: 46 additions & 74 deletions src/hpc-cache/azext_hpc_cache/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,123 +11,95 @@
resource_group_name_type,
get_location_type
)
from ._validators import process_container_resource, transfer_cache_name
from ._validators import process_container_resource, JunctionAddAction, validate_storage_account_name_or_id
from knack.arguments import CLIArgumentType

junction_type = CLIArgumentType(options_list=['--junction'],
help='List of Cache namespace junctions to target for namespace associations.'
'The sub parameters contains: '
'(1) --namespace-path: Namespace path on a Cache for a Storage Target '
'(2) --nfs-export: NFS export where targetPath exists '
'(3) --target-path(Optional): Path in Storage Target to '
'which namespacePath points',
action=JunctionAddAction, nargs='+')

def load_arguments(self, _):
storage_account_type = CLIArgumentType(options_list=['--storage-account'],
help='Resource ID or Name of target storage account.',
validator=validate_storage_account_name_or_id)

cache_name_type = CLIArgumentType(help='Name of Cache.')

storage_target_type = CLIArgumentType(help='Name of the Storage Target.')

with self.argument_context('hpc-cache skus list') as c:
pass

with self.argument_context('hpc-cache usage-model list') as c:
pass
def load_arguments(self, _):

with self.argument_context('hpc-cache create') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', help='Name of Cache.', required=True)
c.argument('name', cache_name_type, required=True)
c.argument('tags', tags_type)
c.argument('location', arg_type=get_location_type(self.cli_ctx), required=True)
c.argument('cache_size_gb', help='The size of this Cache, in GB.', required=True)
c.argument('subnet', help='Subnet used for the Cache.', required=True)
c.argument('sku_name', help='SKU name for this Cache.', required=True)

with self.argument_context('hpc-cache update') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', help='Name of Cache.')
c.argument('name', cache_name_type)
c.argument('tags', tags_type)
c.argument('location', arg_type=get_location_type(self.cli_ctx))
c.argument('cache_size_gb', help='The size of this Cache, in GB.')
c.argument('subnet', help='Subnet used for the Cache.')
c.argument('sku_name', help='SKU name for this Cache.')

with self.argument_context('hpc-cache delete') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', help='Name of Cache.')
c.argument('location', arg_type=get_location_type(self.cli_ctx), deprecate_info=c.deprecate(hide=True))
c.argument('cache_size_gb', help='The size of this Cache, in GB.', deprecate_info=c.deprecate(hide=True))
c.argument('subnet', help='Subnet used for the Cache.', deprecate_info=c.deprecate(hide=True))
c.argument('sku_name', help='SKU name for this Cache.', deprecate_info=c.deprecate(hide=True))

with self.argument_context('hpc-cache show') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', help='Name of Cache.')
for item in ['delete', 'show', 'flush', 'start', 'stop', 'upgrade-firmware']:
with self.argument_context('hpc-cache {}'.format(item)) as c:
c.argument('name', cache_name_type)

with self.argument_context('hpc-cache wait') as c:
c.argument('resource_group_name', resource_group_name_type)
c.extra('name', help='Name of Cache.', validator=transfer_cache_name, required=True)
c.ignore('cache_name')

with self.argument_context('hpc-cache list') as c:
c.argument('resource_group_name', resource_group_name_type, required=False)

with self.argument_context('hpc-cache flush') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', help='Name of Cache.')

with self.argument_context('hpc-cache start') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', help='Name of Cache.')

with self.argument_context('hpc-cache stop') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', help='Name of Cache.')

with self.argument_context('hpc-cache upgrade-firmware') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('name', help='Name of Cache.')
c.argument('cache_name', cache_name_type, options_list=['--name', '-n'], required=True)

with self.argument_context('hpc-cache blob-storage-target add') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('cache_name', help='Name of Cache.')
c.argument('name', help='Name of the Storage Target.')
c.argument('cache_name', cache_name_type)
c.argument('name', storage_target_type)
c.argument('virtual_namespace_path', options_list=['--virtual-namespace-path', '-v'], required=True,
help='Path to create for this storage target in the client-facing virtual filesystem.')
c.extra('storage_account', options_list=['--storage-account'], help='Resource ID of target storage account.',
required=True)
c.extra('storage_account', storage_account_type, required=True)
c.extra('container_name', options_list=['--container-name'], validator=process_container_resource,
required=True, help='Name of target storage container.')
c.ignore('clfs_target')

with self.argument_context('hpc-cache blob-storage-target update') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('cache_name', help='Name of Cache.')
c.argument('name', help='Name of the Storage Target.')
c.argument('cache_name', cache_name_type)
c.argument('name', storage_target_type)
c.argument('virtual_namespace_path', options_list=['--virtual-namespace-path', '-v'],
help='Path to create for this storage target in the client-facing virtual filesystem.')
c.extra('storage_account', options_list=['--storage-account'],
help='Resource ID of target storage account.')
c.extra('storage_account', storage_account_type)
c.extra('container_name', options_list=['--container-name'], validator=process_container_resource,
help='Name of target storage container.')
c.ignore('clfs_target')

with self.argument_context('hpc-cache storage-target remove') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('cache_name', help='Name of Cache.')
c.argument('name', help='Name of the Storage Target.')
c.argument('cache_name', cache_name_type)
c.argument('name', storage_target_type)

with self.argument_context('hpc-cache storage-target show') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('cache_name', help='Name of Cache.')
c.argument('name', help='Name of the Storage Target.')
c.argument('cache_name', cache_name_type)
c.argument('name', storage_target_type)

with self.argument_context('hpc-cache storage-target list') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('cache_name', help='Name of Cache.')
c.argument('cache_name', cache_name_type)

with self.argument_context('hpc-cache nfs-storage-target add') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('cache_name', help='Name of Cache.')
c.argument('name', help='Name of the Storage Target.')
from ._validators import JunctionAddAction
c.extra('junction', help='List of Cache namespace junctions to target for namespace associations.',
action=JunctionAddAction, nargs='+', required=True)
c.argument('cache_name', cache_name_type)
c.argument('name', storage_target_type)

c.argument('junctions', junction_type, required=True)
c.argument('nfs3_target', help='IP address or host name of an NFSv3 host (e.g., 10.0.44.44).', required=True)
c.argument('nfs3_usage_model', help='Identifies the primary usage model to be used for this Storage Target.',
required=True)
c.ignore('junctions')

with self.argument_context('hpc-cache nfs-storage-target update') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('cache_name', help='Name of Cache.')
c.argument('name', help='Name of the Storage Target.')
from ._validators import JunctionAddAction
c.extra('junction', help='List of Cache namespace junctions to target for namespace associations.', action=JunctionAddAction, nargs='+')
c.argument('cache_name', cache_name_type)
c.argument('name', storage_target_type)
c.argument('junctions', junction_type)
c.argument('nfs3_target', help='IP address or host name of an NFSv3 host (e.g., 10.0.44.44).')
c.argument('nfs3_usage_model', help='Identifies the primary usage model to be used for this Storage Target.')
c.ignore('junctions')
24 changes: 15 additions & 9 deletions src/hpc-cache/azext_hpc_cache/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@
import argparse
from knack.util import CLIError

# pylint: disable=unused-argument


def transfer_cache_name(cmd, namespace):
namespace.cache_name = namespace.name
del namespace.name


def process_container_resource(cmd, namespace):
"""Processes the resource group parameter from the storage account and container name"""
if not namespace.storage_account or not namespace.container_name:
raise ValueError('usage error: Please specify --storage-account and --container-name for blob-storage-target')
from msrestazure.tools import is_valid_resource_id
from azure.mgmt.core.tools import is_valid_resource_id
if not is_valid_resource_id(namespace.storage_account):
raise ValueError('usage error: {} is not a valid resource id'.format(namespace.storage_account))
namespace.clfs_target = '{}/blobServices/default/containers/{}'.format(
Expand All @@ -31,7 +24,6 @@ def process_container_resource(cmd, namespace):
class JunctionAddAction(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
if not namespace.junctions:
del namespace.junction
namespace.junctions = []
kwargs = {}
for item in values:
Expand All @@ -48,3 +40,17 @@ def __call__(self, parser, namespace, values, option_string=None):
if 'target-path' in kwargs:
junction['targetPath'] = kwargs['target-path']
namespace.junctions.append(junction)


def validate_storage_account_name_or_id(cmd, namespace):
if namespace.storage_account:
from azure.mgmt.core.tools import resource_id, is_valid_resource_id
from azure.cli.core.commands.client_factory import get_subscription_id
if not is_valid_resource_id(namespace.storage_account):
namespace.storage_account = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=namespace.resource_group_name,
namespace='Microsoft.Storage',
type='storageAccounts',
name=namespace.storage_account
)
Loading