Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions src/diskpool/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.2.0
++++++
* Add `az disk-pool list-zones` command
* Add `az disk-pool redeploy` command

0.1.2
++++++
* Refine table output
Expand Down
64 changes: 47 additions & 17 deletions src/diskpool/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Azure CLI Extension #
# Azure CLI diskpool Extension #
This is the extension for diskpool

### How to use ###
Install this extension using the below CLI command
```
az extension add -s https://zuhdefault.blob.core.windows.net/cliext/diskpool-0.2.0-py3-none-any.whl
az extension add --name diskpool
```

### Included Features ###
#### disk-pool ####
##### Create #####
```
az disk-pool create --name "myDiskPool" --location "westus" --availability-zones "1" \
--disks id="/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_0" \
--disks id="/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1" \
az disk-pool create --location "westus" --availability-zones "1" \
--disks "/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_0" \
--disks "/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1" \
--subnet-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/mysubnet" \
--sku name="Standard_ABC" --tags key="value" --resource-group "myResourceGroup"
--sku name="Basic_V1" tier="Basic" --tags key="value" --name "myDiskPool" --resource-group "myResourceGroup"

az disk-pool wait --created --name "myDiskPool" --resource-group "myResourceGroup"
az disk-pool wait --created --name "{myDiskPool}" --resource-group "{rg}"
```
##### Show #####
```
Expand All @@ -29,25 +29,49 @@ az disk-pool list --resource-group "myResourceGroup"
```
##### Update #####
```
az disk-pool update --name "myDiskPool" --location "westus" --availability-zones "1" \
--disks id="/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_0" \
--disks id="/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1" \
--subnet-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/mysubnet" \
--tags key="value" --resource-group "myResourceGroup"
az disk-pool update --name "myDiskPool" \
--disks "/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_0" \
--disks "/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1" \
--sku name="Basic_B1" tier="Basic" --tags key="value" --resource-group "myResourceGroup"
```
##### List-outbound-network-dependency-endpoint #####
```
az disk-pool list-outbound-network-dependency-endpoint --name "SampleAse" --resource-group "Sample-WestUSResourceGroup"
```
##### Start #####
```
az disk-pool start --name "myDiskPool" --resource-group "myResourceGroup"
```
##### Stop #####
```
az disk-pool stop --name "myDiskPool" --resource-group "myResourceGroup"
```
##### Upgrade #####
```
az disk-pool upgrade --name "myDiskPool" --resource-group "myResourceGroup"
```
##### Delete #####
```
az disk-pool delete --name "myDiskPool" --resource-group "myResourceGroup"
```
#### disk-pool ####
##### List-skus #####
```
az disk-pool list-skus --location "eastus"
```
##### List-zones #####
```
az disk-pool list-zones --location "eastus"
```
#### disk-pool iscsi-target ####
##### Create #####
```
az disk-pool iscsi-target create --disk-pool-name "myDiskPool" --name "myIscsiTarget" \
--target-iqn "iqn.2005-03.org.iscsi:server1" \
--tpgs "[{\\"acls\\":[{\\"credentials\\":{\\"password\\":\\"some_pa$$word\\",\\"username\\":\\"some_username\\"},\\"initiatorIqn\\":\\"iqn.2005-03.org.iscsi:client\\",\\"mappedLuns\\":[\\"lun0\\"]}],\\"attributes\\":{\\"authentication\\":true,\\"prodModeWriteProtect\\":false},\\"luns\\":[{\\"name\\":\\"lun0\\",\\"managedDiskAzureResourceId\\":\\"/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1\\"}]}]" \
--resource-group "myResourceGroup"
az disk-pool iscsi-target create --disk-pool-name "myDiskPool" --acl-mode "Dynamic" \
--luns name="lun0" managed-disk-azure-resource-id="/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1" \
--target-iqn "iqn.2005-03.org.iscsi:server1" --name "myIscsiTarget" --resource-group "myResourceGroup"

az disk-pool iscsi-target wait --created --name "myIscsiTarget" --resource-group "myResourceGroup"
az disk-pool iscsi-target wait --created --disk-pool-name "{myDiskPool}" --name "{myIscsiTarget}" \
--resource-group "{rg}"
```
##### Show #####
```
Expand All @@ -57,6 +81,12 @@ az disk-pool iscsi-target show --disk-pool-name "myDiskPool" --name "myIscsiTarg
```
az disk-pool iscsi-target list --disk-pool-name "myDiskPool" --resource-group "myResourceGroup"
```
##### Update #####
```
az disk-pool iscsi-target update --disk-pool-name "myDiskPool" --name "myIscsiTarget" \
--luns name="lun0" managed-disk-azure-resource-id="/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1" \
--static-acls initiator-iqn="iqn.2005-03.org.iscsi:client" mapped-luns="lun0" --resource-group "myResourceGroup"
```
##### Delete #####
```
az disk-pool iscsi-target delete --disk-pool-name "myDiskPool" --name "myIscsiTarget" \
Expand Down
21 changes: 12 additions & 9 deletions src/diskpool/azext_diskpool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=unused-import

import azext_diskpool._help
from azure.cli.core import AzCommandsLoader
from azext_diskpool.generated._help import helps # pylint: disable=unused-import
try:
from azext_diskpool.manual._help import helps # pylint: disable=reimported
except ImportError:
pass


class StoragePoolManagementCommandsLoader(AzCommandsLoader):
Expand All @@ -33,8 +30,11 @@ def load_command_table(self, args):
try:
from azext_diskpool.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual.commands'):
pass
else:
raise e
return self.command_table

def load_arguments(self, command):
Expand All @@ -43,8 +43,11 @@ def load_arguments(self, command):
try:
from azext_diskpool.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual._params'):
pass
else:
raise e


COMMAND_LOADER_CLS = StoragePoolManagementCommandsLoader
7 changes: 5 additions & 2 deletions src/diskpool/azext_diskpool/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual.action'):
pass
else:
raise e
7 changes: 5 additions & 2 deletions src/diskpool/azext_diskpool/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError:
pass
except ImportError as e:
if e.name.endswith('manual.custom'):
pass
else:
raise e
8 changes: 8 additions & 0 deletions src/diskpool/azext_diskpool/generated/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,13 @@ def cf_disk_pool(cli_ctx, *_):
return cf_diskpool_cl(cli_ctx).disk_pools


def cf_disk_pool_zone(cli_ctx, *_):
return cf_diskpool_cl(cli_ctx).disk_pool_zones


def cf_resource_sku(cli_ctx, *_):
return cf_diskpool_cl(cli_ctx).resource_skus


def cf_iscsi_target(cli_ctx, *_):
return cf_diskpool_cl(cli_ctx).iscsi_targets
60 changes: 50 additions & 10 deletions src/diskpool/azext_diskpool/generated/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
from knack.help_files import helps


helps['disk-pool'] = '''
type: group
short-summary: Manage Storage Pool Management
'''

helps['disk-pool'] = """
type: group
short-summary: Manage disk pool with diskpool
Expand Down Expand Up @@ -40,7 +45,8 @@

helps['disk-pool create'] = """
type: command
short-summary: "Create Disk pool."
short-summary: "Create Disk pool. This Create operation can take 15 minutes to complete. This is expected service \
behavior."
parameters:
- name: --sku
short-summary: "Determines the SKU of the Disk Pool"
Expand All @@ -64,14 +70,21 @@
111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_0" --disks \
"/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/v\
m-name_DataDisk_1" --subnet-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/prov\
iders/Microsoft.Network/virtualNetworks/myvnet/subnets/mysubnet" --sku name="Basic_V0" tier="Basic" --tags key="value" \
iders/Microsoft.Network/virtualNetworks/myvnet/subnets/mysubnet" --sku name="Basic_V1" tier="Basic" --tags key="value" \
--name "myDiskPool" --resource-group "myResourceGroup"
"""

helps['disk-pool update'] = """
type: command
short-summary: "Update a Disk pool."
parameters:
- name: --sku
short-summary: "Determines the SKU of the Disk Pool"
long-summary: |
Usage: --sku name=XX tier=XX
name: Required. Sku name
tier: Sku tier
- name: --disks
short-summary: "List of Azure Managed Disks to attach to a Disk Pool."
long-summary: |
Expand All @@ -86,12 +99,13 @@
az disk-pool update --name "myDiskPool" --disks "/subscriptions/11111111-1111-1111-1111-111111111111/res\
ourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_0" --disks \
"/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/v\
m-name_DataDisk_1" --tags key="value" --resource-group "myResourceGroup"
m-name_DataDisk_1" --sku name="Basic_B1" tier="Basic" --tags key="value" --resource-group "myResourceGroup"
"""

helps['disk-pool delete'] = """
type: command
short-summary: "Delete a Disk pool."
short-summary: "Delete a Disk pool; attached disks are not affected. This delete operation can take 10 minutes to \
complete. This is expected service behavior."
examples:
- name: Delete Disk pool
text: |-
Expand All @@ -108,18 +122,20 @@
"Sample-WestUSResourceGroup"
"""

helps['disk-pool list-skus'] = """
helps['disk-pool redeploy'] = """
type: command
short-summary: "Lists available Disk Pool Skus in an Azure location."
short-summary: "Redeploy replaces the underlying virtual machine hosts one at a time. This operation can take 10-15 \
minutes to complete. This is expected service behavior."
examples:
- name: List Disk Pool Skus
- name: Redeploy Disk Pool
text: |-
az disk-pool list-skus --location "eastus"
az disk-pool redeploy --name "myDiskPool" --resource-group "myResourceGroup"
"""

helps['disk-pool start'] = """
type: command
short-summary: "The operation to start a Disk Pool."
short-summary: "The operation to start a Disk Pool. This start operation can take 10 minutes to complete. This is \
expected service behavior."
examples:
- name: Start Disk Pool
text: |-
Expand All @@ -129,7 +145,8 @@
helps['disk-pool stop'] = """
type: command
short-summary: "Shuts down the Disk Pool and releases the compute resources. You are not billed for the compute \
resources that this Disk Pool uses."
resources that this Disk Pool uses. This operation can take 10 minutes to complete. This is expected service \
behavior."
examples:
- name: Deallocate Disk Pool
text: |-
Expand All @@ -151,6 +168,29 @@
az disk-pool wait --name "myDiskPool" --resource-group "myResourceGroup" --deleted
"""

helps['disk-pool'] = """
type: group
short-summary: Manage disk pool zone with diskpool
"""
Comment on lines +171 to +174
Copy link
Member

Choose a reason for hiding this comment

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

Seems duplicated with Line15. I know it's generated, maybe should create an issue for code gen...

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kairu-ms for awareness


helps['disk-pool list-skus'] = """
type: command
short-summary: "Lists available StoragePool resources and skus in an Azure location."
examples:
- name: List Disk Pool Skus
text: |-
az disk-pool list-skus --location "eastus"
"""

helps['disk-pool list-zones'] = """
type: command
short-summary: "Lists available Disk Pool Skus in an Azure location."
examples:
- name: List Disk Pool Zones
text: |-
az disk-pool list-zones --location "eastus"
"""

helps['disk-pool iscsi-target'] = """
type: group
short-summary: Manage iscsi target with diskpool
Expand Down
25 changes: 23 additions & 2 deletions src/diskpool/azext_diskpool/generated/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def load_arguments(self, _):
c.argument('tags', tags_type)
c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
validator=get_default_location_from_resource_group)
c.argument('managed_by', type=str, help='Azure resource id. Indicates if this resource is managed by another '
'Azure resource.')
c.argument('managed_by_extended', nargs='+', help='List of Azure resource ids that manage this resource.')
c.argument('availability_zones', nargs='+', help='Logical zone for Disk Pool resource; example: ["1"].')
c.argument('disks', action=AddDiskPoolCreateDisks, nargs='+', help='List of Azure Managed Disks to attach to a '
'Disk Pool.')
Expand All @@ -57,6 +60,10 @@ def load_arguments(self, _):
c.argument('resource_group_name', resource_group_name_type)
c.argument('disk_pool_name', options_list=['--name', '-n', '--disk-pool-name'], type=str, help='The name of '
'the Disk Pool.', id_part='name')
c.argument('managed_by', type=str, help='Azure resource id. Indicates if this resource is managed by another '
'Azure resource.')
c.argument('managed_by_extended', nargs='+', help='List of Azure resource ids that manage this resource.')
c.argument('sku', action=AddSku, nargs='+', help='Determines the SKU of the Disk Pool')
c.argument('tags', tags_type)
c.argument('disks', action=AddDiskPoolUpdateDisks, nargs='+', help='List of Azure Managed Disks to attach to a '
'Disk Pool.')
Expand All @@ -71,8 +78,10 @@ def load_arguments(self, _):
c.argument('disk_pool_name', options_list=['--name', '-n', '--disk-pool-name'], type=str, help='The name of '
'the Disk Pool.')

with self.argument_context('disk-pool list-skus') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx))
with self.argument_context('disk-pool redeploy') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('disk_pool_name', options_list=['--name', '-n', '--disk-pool-name'], type=str, help='The name of '
'the Disk Pool.', id_part='name')

with self.argument_context('disk-pool start') as c:
c.argument('resource_group_name', resource_group_name_type)
Expand All @@ -89,6 +98,12 @@ def load_arguments(self, _):
c.argument('disk_pool_name', options_list=['--name', '-n', '--disk-pool-name'], type=str, help='The name of '
'the Disk Pool.', id_part='name')

with self.argument_context('disk-pool list-skus') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx))

with self.argument_context('disk-pool list-zones') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx))

with self.argument_context('disk-pool iscsi-target list') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('disk_pool_name', type=str, help='The name of the Disk Pool.')
Expand All @@ -104,6 +119,9 @@ def load_arguments(self, _):
c.argument('disk_pool_name', type=str, help='The name of the Disk Pool.')
c.argument('iscsi_target_name', options_list=['--name', '-n', '--iscsi-target-name'], type=str, help='The name '
'of the iSCSI Target.')
c.argument('managed_by', type=str, help='Azure resource id. Indicates if this resource is managed by another '
'Azure resource.')
c.argument('managed_by_extended', nargs='+', help='List of Azure resource ids that manage this resource.')
c.argument('acl_mode', arg_type=get_enum_type(['Dynamic', 'Static']), help='Mode for Target connectivity.')
c.argument('target_iqn', type=str, help='iSCSI Target IQN (iSCSI Qualified Name); example: '
'"iqn.2005-03.org.iscsi:server".')
Expand All @@ -117,6 +135,9 @@ def load_arguments(self, _):
c.argument('disk_pool_name', type=str, help='The name of the Disk Pool.', id_part='name')
c.argument('iscsi_target_name', options_list=['--name', '-n', '--iscsi-target-name'], type=str, help='The name '
'of the iSCSI Target.', id_part='child_name_1')
c.argument('managed_by', type=str, help='Azure resource id. Indicates if this resource is managed by another '
'Azure resource.')
c.argument('managed_by_extended', nargs='+', help='List of Azure resource ids that manage this resource.')
c.argument('static_acls', action=AddDiskPoolIscsiTargetUpdateStaticAcls, nargs='+', help='Access Control List '
'(ACL) for an iSCSI Target; defines LUN masking policy')
c.argument('luns', action=AddDiskPoolIscsiTargetUpdateLuns, nargs='+', help='List of LUNs to be exposed '
Expand Down
Loading