forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Compute] Create a new extension
image-gallery
(Azure#4050)
* Init image gallery extension * Skip tests and modify service_name.json * Add codeowner * CredScan suppression * Modify the statement of programming Language * Modify help description * Update src/image-gallery/azext_image_gallery/_help.py
- Loading branch information
1 parent
14dadfe
commit c2321b8
Showing
108 changed files
with
73,262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,3 +216,4 @@ | |
|
||
/src/elastic/ @kairu-ms @jsntcy | ||
|
||
/src/image-gallery/ @zhoxing-ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.. :changelog: | ||
Release History | ||
=============== | ||
|
||
0.1.0 | ||
+++++++++++++++ | ||
* Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Azure CLI image-gallery Extension # | ||
This package is for the 'image-gallery' extension, i.e. 'az sig' | ||
|
||
### How to use ### | ||
Install this extension using the below CLI command | ||
``` | ||
az extension add --name image-gallery | ||
``` | ||
|
||
### Included Features | ||
#### Image Gallery: | ||
Manage Image Gallery: [more info](https://docs.microsoft.com/en-us/azure/virtual-machines/shared-image-galleries) \ | ||
*Examples:* | ||
|
||
##### Get a gallery that has been community in the given location. | ||
``` | ||
az sig show-community --public-gallery-name publicGalleryName \ | ||
--location myLocation | ||
``` | ||
|
||
##### Get an image definition in a gallery community in the given location. | ||
``` | ||
az sig image-definition show-community --public-gallery-name publicGalleryName \ | ||
--gallery-image-definition myGalleryImageName \ | ||
--location myLocation | ||
``` | ||
|
||
##### Get an image version in a gallery community in the given location. | ||
``` | ||
az sig image-version show-community --public-gallery-name publicGalleryName \ | ||
--gallery-image-definition MyImage \ | ||
--gallery-image-version 1.0.0 \ | ||
--location myLocation | ||
``` | ||
|
||
If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# 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 ._help import helps # pylint: disable=unused-import | ||
|
||
|
||
class ImageGalleryCommandsLoader(AzCommandsLoader): | ||
|
||
def __init__(self, cli_ctx=None): | ||
from azure.cli.core.commands import CliCommandType | ||
from ._client_factory import cf_galleries | ||
image_gallery_custom = CliCommandType( | ||
operations_tmpl='azext_image_gallery.custom#{}', | ||
client_factory=cf_galleries) | ||
super(ImageGalleryCommandsLoader, self).__init__(cli_ctx=cli_ctx, custom_command_type=image_gallery_custom) | ||
|
||
def load_command_table(self, args): | ||
super(ImageGalleryCommandsLoader, self).load_command_table(args) | ||
from .commands import load_command_table | ||
load_command_table(self, args) | ||
return self.command_table | ||
|
||
def load_arguments(self, command): | ||
super(ImageGalleryCommandsLoader, self).load_arguments(command) | ||
from ._params import load_arguments | ||
load_arguments(self, command) | ||
|
||
|
||
COMMAND_LOADER_CLS = ImageGalleryCommandsLoader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
def _compute_client_factory(cli_ctx): | ||
from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
from .vendored_sdks.azure_mgmt_compute._compute_management_client import ComputeManagementClient | ||
return get_mgmt_service_client(cli_ctx, ComputeManagementClient) | ||
|
||
|
||
def cf_galleries(cli_ctx, _): | ||
return _compute_client_factory(cli_ctx).galleries | ||
|
||
|
||
def cf_gallery_images(cli_ctx, _): | ||
return _compute_client_factory(cli_ctx).gallery_images | ||
|
||
|
||
def cf_community_gallery(cli_ctx, *_): | ||
return _compute_client_factory(cli_ctx).community_galleries | ||
|
||
|
||
def cf_community_gallery_image(cli_ctx, *_): | ||
return _compute_client_factory(cli_ctx).community_gallery_images | ||
|
||
|
||
def cf_community_gallery_image_version(cli_ctx, *_): | ||
return _compute_client_factory(cli_ctx).community_gallery_image_versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
# pylint: disable=too-many-lines | ||
# pylint: disable=line-too-long | ||
from knack.help_files import helps # pylint: disable=unused-import | ||
|
||
|
||
helps['sig show-community'] = """ | ||
type: command | ||
short-summary: Get a gallery that has been community (preview). | ||
long-summary: Get a gallery that has been community (private preview feature, please contact community image gallery team by email sigpmdev@microsoft.com to register for preview if you're interested in using this feature). | ||
examples: | ||
- name: Get a gallery that has been community in the given location. | ||
text: | | ||
az sig show-community --public-gallery-name publicGalleryName --location myLocation | ||
""" | ||
|
||
helps['sig image-definition show-community'] = """ | ||
type: command | ||
short-summary: Get an image in a gallery community (preview). | ||
long-summary: Get an image in a gallery community (private preview feature, please contact community image gallery team by email sigpmdev@microsoft.com to register for preview if you're interested in using this feature). | ||
examples: | ||
- name: Get an image definition in a gallery community in the given location. | ||
text: | | ||
az sig image-definition show-community --public-gallery-name publicGalleryName \\ | ||
--gallery-image-definition myGalleryImageName --location myLocation | ||
""" | ||
|
||
# helps['sig image-definition list-community'] = """ | ||
# type: command | ||
# short-summary: List VM Image definitions in a gallery community (preview). | ||
# long-summary: List VM Image definitions in a gallery community (private preview feature, please contact community image gallery team by email sigpmdev@microsoft.com to register for preview if you're interested in using this feature). | ||
# examples: | ||
# - name: List an image definition in a gallery community. | ||
# text: | | ||
# az sig image-definition list-community --public-gallery-name publicGalleryName \\ | ||
# --location myLocation | ||
# """ | ||
|
||
helps['sig image-version show-community'] = """ | ||
type: command | ||
short-summary: Get an image version in a gallery community (preview). | ||
long-summary: Get an image version in a gallery community (private preview feature, please contact community image gallery team by email sigpmdev@microsoft.com to register for preview if you're interested in using this feature). | ||
examples: | ||
- name: Get an image version in a gallery community in the given location. | ||
text: | | ||
az sig image-version show-community --public-gallery-name publicGalleryName \\ | ||
--gallery-image-definition MyImage --gallery-image-version 1.0.0 --location myLocation | ||
""" | ||
|
||
# helps['sig image-version list-community'] = """ | ||
# type: command | ||
# short-summary: List VM Image Versions in a gallery community (preview). | ||
# long-summary: List VM Image Versions in a gallery community (private preview feature, please contact community image gallery team by email sigpmdev@microsoft.com to register for preview if you're interested in using this feature). | ||
# examples: | ||
# - name: List image versions in a gallery community. | ||
# text: | | ||
# az sig image-version list-community --public-gallery-name publicGalleryName \\ | ||
# --gallery-image-definition MyImage --location myLocation | ||
# """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# 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 get_location_type | ||
|
||
|
||
def load_arguments(self, _): | ||
|
||
public_gallery_name_type = CLIArgumentType(help='The public name of community gallery.', id_part='child_name_1') | ||
|
||
gallery_image_name_type = CLIArgumentType( | ||
options_list=['--gallery-image-definition', '-i'], | ||
help='The name of the community gallery image definition from which the image versions are to be listed.', | ||
id_part='child_name_2' | ||
) | ||
|
||
gallery_image_name_version_type = CLIArgumentType( | ||
options_list=['--gallery-image-version', '-e'], | ||
help='The name of the gallery image version to be created. Needs to follow semantic version name pattern: ' | ||
'The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. ' | ||
'Format: <MajorVersion>.<MinorVersion>.<Patch>', id_part='child_name_3' | ||
) | ||
|
||
with self.argument_context('sig show-community') as c: | ||
c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name') | ||
c.argument('public_gallery_name', public_gallery_name_type) | ||
|
||
with self.argument_context('sig image-definition show-community') as c: | ||
c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name') | ||
c.argument('public_gallery_name', public_gallery_name_type) | ||
c.argument('gallery_image_name', gallery_image_name_type) | ||
|
||
# with self.argument_context('sig image-definition list-community') as c: | ||
# c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name') | ||
# c.argument('public_gallery_name', public_gallery_name_type) | ||
|
||
with self.argument_context('sig image-version show-community') as c: | ||
c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name') | ||
c.argument('public_gallery_name', public_gallery_name_type) | ||
c.argument('gallery_image_name', gallery_image_name_type) | ||
c.argument('gallery_image_version_name', gallery_image_name_version_type) | ||
|
||
# with self.argument_context('sig image-version list-community') as c: | ||
# c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name') | ||
# c.argument('public_gallery_name', public_gallery_name_type) | ||
# c.argument('gallery_image_name', gallery_image_name_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"azext.isExperimental": true, | ||
"azext.minCliCoreVersion": "2.3.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# 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 | ||
# pylint: disable=too-many-locals | ||
from azure.cli.core.commands import CliCommandType | ||
from ._client_factory import cf_community_gallery, cf_community_gallery_image, cf_community_gallery_image_version | ||
|
||
|
||
def load_command_table(self, _): | ||
|
||
community_gallery_sdk = CliCommandType( | ||
operations_tmpl='azext_image_gallery.vendored_sdks.azure_mgmt_compute.operations._community_galleries_operations#CommunityGalleriesOperations.{}', | ||
client_factory=cf_community_gallery) | ||
|
||
community_gallery_image_sdk = CliCommandType( | ||
operations_tmpl='azext_image_gallery.vendored_sdks.azure_mgmt_compute.operations._community_gallery_images_operations#CommunityGalleryImagesOperations.{}', | ||
client_factory=cf_community_gallery_image) | ||
|
||
community_gallery_image_version_sdk = CliCommandType( | ||
operations_tmpl='azext_image_gallery.vendored_sdks.azure_mgmt_compute.operations._community_gallery_image_versions_operations#CommunityGalleryImageVersionsOperations.{}', | ||
client_factory=cf_community_gallery_image_version) | ||
|
||
with self.command_group('sig', community_gallery_sdk, client_factory=cf_community_gallery) as g: | ||
g.command('show-community', 'get', is_experimental=True) | ||
|
||
with self.command_group('sig image-definition', community_gallery_image_sdk, | ||
client_factory=cf_community_gallery_image) as g: | ||
g.command('show-community', 'get', is_experimental=True) | ||
# g.command('list-community', 'list', is_experimental=True) | ||
|
||
with self.command_group('sig image-version', community_gallery_image_version_sdk, | ||
client_factory=cf_community_gallery_image_version) as g: | ||
g.command('show-community', 'get', is_experimental=True) | ||
# g.command('list-community', 'list', is_experimental=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- |
4 changes: 4 additions & 0 deletions
4
src/image-gallery/azext_image_gallery/tests/latest/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- |
Oops, something went wrong.