-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Breadth Coverage] Onboard Import Export #1515
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
Changes from 5 commits
d7fa25a
78e36be
c2fe423
2b5f894
c1435ff
3ff07a3
e1feead
bffaa84
17948fc
c552dcc
0a27a31
607daf9
abd7e7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,3 +97,5 @@ | |
| /src/databox/ @jsntcy | ||
|
|
||
| /src/hpc-cache/ @qianwens | ||
|
|
||
| /src/import-export/ @arrownj | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| .. :changelog: | ||
|
|
||
| Release History | ||
| =============== | ||
|
|
||
| 0.1.0 | ||
| ++++++ | ||
| * Initial release. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Azure CLI import-export Extension # | ||
| This package is for the 'import-export' extension, i.e. 'az import-export'. | ||
|
|
||
| ### How to use ### | ||
| Install this extension using the below CLI command | ||
| ``` | ||
| az extension add --name import-export | ||
| ``` | ||
|
|
||
| ### Included Features | ||
| #### Import Export Management: | ||
| Manage Import Export: [more info](https://docs.microsoft.com/en-us/azure/storage/common/storage-import-export-service)\ | ||
| *Examples:* | ||
|
|
||
| ##### Create an Import Job | ||
|
|
||
| ``` | ||
| az import-export create \ | ||
| --resource-group groupName \ | ||
| --name jobName \ | ||
| --location localtionName \ | ||
| --type Import \ | ||
| --log-level Verbose \ | ||
| --storage-account-id storageAccountID \ | ||
| --backup-drive-manifest true \ | ||
| --diagnostics-path waimportexport \ | ||
| --drive-list \ | ||
| drive-id=00000001 \ | ||
| bit-locker-key=000000-000000-000000-000000-000000-000000-000000-000000 \ | ||
| drive-header-hash="" \ | ||
| manifest-file=\\DriveManifest.xml \ | ||
| manifest-hash=109B21108597EF36D5785F08303F3638 \ | ||
| --return-address \ | ||
| city=Redmond \ | ||
| country-or-region=USA \ | ||
| [email protected] \ | ||
| phone=4250000000 \ | ||
| postal-code=98007 \ | ||
| recipient-name=Tests \ | ||
| state-or-province=wa \ | ||
| street-address1=Street1 \ | ||
| street-address2=street2 | ||
| ``` | ||
|
|
||
| ##### Update an Import Job | ||
|
|
||
| ``` | ||
| az import-export update \ | ||
| --resource-group groupName \ | ||
| --name jobName \ | ||
| --cancel-requested true | ||
| ``` | ||
|
|
||
| ##### List Import Export Jobs | ||
|
|
||
| ``` | ||
| az import-export list \ | ||
| --resource-group groupName | ||
| ``` | ||
|
|
||
| ##### Delete a Job | ||
|
|
||
| ``` | ||
| az import-export delete \ | ||
| --resource-group groupName \ | ||
| --name jobName | ||
| ``` | ||
|
|
||
| ##### List bit locker keys of a Job | ||
|
|
||
| ``` | ||
| az import-export bit-locker-key list \ | ||
| --resource-group groupName \ | ||
| --job-name jobName | ||
| ``` | ||
|
|
||
|
|
||
| If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues. | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from azure.cli.core import AzCommandsLoader | ||
| from .generated._help import helps # pylint: disable=unused-import | ||
|
|
||
|
|
||
| class ImportExportCommandsLoader(AzCommandsLoader): | ||
|
|
||
| def __init__(self, cli_ctx=None): | ||
| from azure.cli.core.commands import CliCommandType | ||
| from .generated._client_factory import cf_import_export | ||
| import_export_custom = CliCommandType( | ||
| operations_tmpl='azext_import_export.custom#{}', | ||
| client_factory=cf_import_export) | ||
| super(ImportExportCommandsLoader, self).__init__(cli_ctx=cli_ctx, custom_command_type=import_export_custom) | ||
|
|
||
| def load_command_table(self, args): | ||
| from .generated.commands import load_command_table | ||
| load_command_table(self, args) | ||
| return self.command_table | ||
|
|
||
| def load_arguments(self, command): | ||
| from .generated._params import load_arguments | ||
| load_arguments(self, command) | ||
|
|
||
|
|
||
| COMMAND_LOADER_CLS = ImportExportCommandsLoader |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| # pylint: disable=wildcard-import | ||
| # pylint: disable=unused-wildcard-import | ||
|
|
||
| from .generated.action import * # noqa: F403 | ||
| try: | ||
| from .manual.action import * # noqa: F403 | ||
| except ImportError: | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "azext.isExperimental": true, | ||
| "azext.minCliCoreVersion": "2.3.1" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| # pylint: disable=wildcard-import | ||
| # pylint: disable=unused-wildcard-import | ||
|
|
||
| from .generated.commands import * # noqa: F403 | ||
| try: | ||
| from .manual.commands import * # noqa: F403 | ||
| except ImportError: | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| # pylint: disable=wildcard-import | ||
| # pylint: disable=unused-wildcard-import | ||
|
|
||
| from .generated.custom import * # noqa: F403 | ||
| try: | ||
| from .manual.custom import * # noqa: F403 | ||
| except ImportError: | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| def cf_import_export(cli_ctx, *_): | ||
| from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
| from ..vendored_sdks.storageimportexport import StorageImportExport | ||
| return get_mgmt_service_client(cli_ctx, StorageImportExport) | ||
|
|
||
|
|
||
| def cf_job(cli_ctx, *_): | ||
| return cf_import_export(cli_ctx).job | ||
|
|
||
|
|
||
| def cf_bit_locker_key(cli_ctx, *_): | ||
| return cf_import_export(cli_ctx).bit_locker_key |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| # pylint: disable=line-too-long | ||
| # pylint: disable=too-many-lines | ||
|
|
||
| from knack.help_files import helps | ||
|
|
||
|
|
||
| helps['import-export'] = """ | ||
| type: group | ||
| short-summary: Manage Import Export | ||
| """ | ||
|
|
||
| helps['import-export list'] = """ | ||
| type: command | ||
| short-summary: Returns all active and completed jobs in a subscription. | ||
| examples: | ||
| - name: List jobs in a resource group | ||
| text: |- | ||
| az import-export list --resource-group "myResourceGroup" | ||
| - name: List jobs in current subscription | ||
| text: |- | ||
| az import-export list | ||
| """ | ||
|
|
||
| helps['import-export show'] = """ | ||
| type: command | ||
| short-summary: Gets information about an existing job. | ||
| examples: | ||
| - name: Get job | ||
| text: |- | ||
| az import-export show --resource-group "myResourceGroup" --name "myJob" | ||
| """ | ||
|
|
||
| helps['import-export create'] = """ | ||
| type: command | ||
| short-summary: Creates a new job or updates an existing job in the specified subscription. | ||
| examples: | ||
| - name: Create an import job | ||
| text: |- | ||
| az import-export create --resource-group "myResourceGroup" --name "myJob" | ||
| --location "West US" --backup-drive-manifest true --diagnostics-path "waimportexport" | ||
| --drive-list bit-locker-key=238810-662376-448998-450120-652806-203390-606320-483076 | ||
| drive-header-hash= drive-id=9CA995BB manifest-file=\\\\DriveManifest.xml | ||
| manifest-hash=109B21108597EF36D5785F08303F3638 --type "Import" --log-level "Verbose" | ||
| --return-address city=Redmond country-or-region=USA [email protected] phone=4250000000 | ||
| postal-code=98007 recipient-name=Tests state-or-province=wa street-address1=Street1 | ||
| street-address2=street2 --storage-account-id "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-\\ | ||
| xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.ClassicStorage/storageAccounts/test" | ||
| """ | ||
|
|
||
| helps['import-export update'] = """ | ||
| type: command | ||
| short-summary: Updates specific properties of a job. You can call this operation to notify the Import/Export service that the hard drives comprising the import or export job have been shipped to the Microsoft data center. It can also be used to cancel an existing job. | ||
| examples: | ||
| - name: Update job | ||
| text: |- | ||
| az import-export update --resource-group "myResourceGroup" --name "myJob" | ||
| --backup-drive-manifest true --log-level "Verbose" --state "" | ||
| """ | ||
|
|
||
| helps['import-export delete'] = """ | ||
| type: command | ||
| short-summary: Deletes an existing job. Only jobs in the Creating or Completed states can be deleted. | ||
| examples: | ||
| - name: Delete job | ||
| text: |- | ||
| az import-export delete --resource-group "myResourceGroup" --name "myJob" | ||
| """ | ||
|
|
||
| helps['import-export bit-locker-key'] = """ | ||
| type: group | ||
| short-summary: import-export bit-locker-key | ||
| """ | ||
|
|
||
| helps['import-export bit-locker-key list'] = """ | ||
| type: command | ||
| short-summary: Returns the BitLocker Keys for all drives in the specified job. | ||
| examples: | ||
| - name: List BitLocker Keys for drives in a job | ||
| text: |- | ||
| az import-export bit-locker-key list --resource-group "myResourceGroup" --job-name "myJob" | ||
| """ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| # pylint: disable=line-too-long | ||
| # pylint: disable=too-many-lines | ||
| # pylint: disable=too-many-statements | ||
|
|
||
| from knack.arguments import CLIArgumentType | ||
| from azure.cli.core.commands.parameters import ( | ||
| tags_type, | ||
| get_three_state_flag, | ||
| get_location_type | ||
| ) | ||
| from azure.cli.core.commands.validators import get_default_location_from_resource_group | ||
| from azext_import_export.action import ( | ||
| AddReturnAddress, | ||
| AddReturnShipping, | ||
| AddShippingInformation, | ||
| AddDeliveryPackage, | ||
| AddReturnPackage, | ||
| AddDriveList, | ||
| AddExport | ||
| ) | ||
|
|
||
|
|
||
| def load_arguments(self, _): | ||
|
|
||
| with self.argument_context('import-export list') as c: | ||
| pass | ||
|
|
||
| with self.argument_context('import-export show') as c: | ||
| c.argument('name', options_list=['--name', '-n'], help='The name of the import/export job.') | ||
|
|
||
| with self.argument_context('import-export create') as c: | ||
| c.argument('name', options_list=['--name', '-n'], help='The name of the import/export job.') | ||
| c.argument('client_tenant_id', help='The tenant ID of the client making the request.') | ||
| c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group) | ||
| c.argument('tags', tags_type) | ||
| c.argument('storage_account_id', help='The resource identifier of the storage account where data will be imported to or exported from.') | ||
|
||
| c.argument('type', help='The type of job') | ||
| c.argument('return_address', action=AddReturnAddress, nargs='+', help='Specifies the return address information for the job.') | ||
| c.argument('return_shipping', action=AddReturnShipping, nargs='+', help='Specifies the return carrier and customer\'s account with the carrier.') | ||
| c.argument('shipping_information', action=AddShippingInformation, nargs='+', help='Contains information about the Microsoft datacenter to which the drives should be shipped.') | ||
| c.argument('delivery_package', action=AddDeliveryPackage, nargs='+', help='Contains information about the package being shipped by the customer to the Microsoft data center.') | ||
| c.argument('return_package', action=AddReturnPackage, nargs='+', help='Contains information about the package being shipped by the customer to the Microsoft data center.') | ||
| c.argument('diagnostics_path', help='The virtual blob directory to which the copy logs and backups of drive manifest files (if enabled) will be stored.') | ||
| c.argument('log_level', help='Default value is Error. Indicates whether error logging or verbose logging will be enabled.') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this enum in swagger? if yes, pls feedback to code gen team.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's defined as |
||
| c.argument('backup_drive_manifest', arg_type=get_three_state_flag(), help='Default value is false. Indicates whether the manifest files on the drives should be copied to block blobs.') | ||
| c.argument('state', help='Current state of the job.') | ||
| c.argument('cancel_requested', arg_type=get_three_state_flag(), help='Indicates whether a request has been submitted to cancel the job.') | ||
| c.argument('percent_complete', help='Overall percentage completed for the job.') | ||
| c.argument('incomplete_blob_list_uri', help='A blob path that points to a block blob containing a list of blob names that were not exported due to insufficient drive space. If all blobs were exported successfully, then this element is not included in the response.') | ||
| c.argument('drive_list', action=AddDriveList, nargs='+', help='List of up to ten drives that comprise the job. The drive list is a required element for an import job; it is not specified for export jobs.') | ||
| c.argument('export', action=AddExport, nargs='+', help='A property containing information about the blobs to be exported for an export job. This property is required for export jobs, but must not be specified for import jobs.') | ||
| c.argument('provisioning_state', help='Specifies the provisioning state of the job.') | ||
|
||
|
|
||
| with self.argument_context('import-export update') as c: | ||
| c.argument('name', options_list=['--name', '-n'], help='The name of the import/export job.') | ||
| c.argument('tags', tags_type) | ||
| c.argument('cancel_requested', arg_type=get_three_state_flag(), help='If specified, the value must be true. The service will attempt to cancel the job.') | ||
| c.argument('state', help='If specified, the value must be Shipping, which tells the Import/Export service that the package for the job has been shipped. The ReturnAddress and DeliveryPackage properties must have been set either in this request or in a previous request, otherwise the request will fail.') | ||
| c.argument('return_address', action=AddReturnAddress, nargs='+', help='Specifies the return address information for the job.') | ||
| c.argument('return_shipping', action=AddReturnShipping, nargs='+', help='Specifies the return carrier and customer\'s account with the carrier.') | ||
| c.argument('delivery_package', action=AddDeliveryPackage, nargs='+', help='Contains information about the package being shipped by the customer to the Microsoft data center.') | ||
| c.argument('log_level', help='Indicates whether error logging or verbose logging is enabled.') | ||
| c.argument('backup_drive_manifest', arg_type=get_three_state_flag(), help='Indicates whether the manifest files on the drives should be copied to block blobs.') | ||
| c.argument('drive_list', action=AddDriveList, nargs='+', help='List of drives that comprise the job.') | ||
|
|
||
| with self.argument_context('import-export delete') as c: | ||
| c.argument('name', options_list=['--name', '-n'], help='The name of the import/export job.') | ||
|
|
||
| with self.argument_context('import-export bit-locker-key list') as c: | ||
| c.argument('job_name', help='The name of the import/export job.') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| def example_name_or_id_validator(cmd, namespace): | ||
|
||
| from azure.cli.core.commands.client_factory import get_subscription_id | ||
| from msrestazure.tools import is_valid_resource_id, resource_id | ||
| if namespace.storage_account_id: | ||
| if not is_valid_resource_id(namespace.RESOURCE): | ||
| 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_id | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive-list is an array right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we can specify multi --dirve-list here.