Skip to content
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

{Compute} Revert "Direct Sharing support for Azure Shared Image Gallery" #18449

Merged
merged 1 commit into from
Jun 11, 2021
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
3 changes: 1 addition & 2 deletions src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,9 @@ def default_api_version(self):
'disk_encryption_sets': '2020-12-01',
'disk_accesses': '2020-05-01',
'snapshots': '2020-12-01',
'galleries': '2020-09-30',
'galleries': '2019-12-01',
'gallery_images': '2020-09-30',
'gallery_image_versions': '2020-09-30',
'shared_galleries': '2020-09-30',
'virtual_machine_scale_sets': '2021-03-01'
}),
ResourceType.MGMT_RESOURCE_FEATURES: '2015-12-01',
Expand Down
4 changes: 0 additions & 4 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def load_arguments(self, _):
DedicatedHostLicenseTypes = self.get_models('DedicatedHostLicenseTypes')
OrchestrationServiceNames, OrchestrationServiceStateAction = self.get_models('OrchestrationServiceNames', 'OrchestrationServiceStateAction', operation_group='virtual_machine_scale_sets')
RebootSetting, VMGuestPatchClassificationWindows, VMGuestPatchClassificationLinux = self.get_models('VMGuestPatchRebootSetting', 'VMGuestPatchClassificationWindows', 'VMGuestPatchClassificationLinux')
GallerySharingPermissionTypes = self.get_models('GallerySharingPermissionTypes', operation_group='shared_galleries')

# REUSABLE ARGUMENT DEFINITIONS
name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
Expand Down Expand Up @@ -933,9 +932,6 @@ def load_arguments(self, _):
c.argument('description', help='the description of the gallery')
with self.argument_context('sig update') as c:
c.ignore('gallery')
c.argument('permissions', arg_type=get_enum_type(GallerySharingPermissionTypes), arg_group='Sharing Profile',
min_api='2020-09-30', help='This property allows you to specify the permission of sharing gallery.')

with self.argument_context('sig image-definition create') as c:
c.argument('description', help='the description of the gallery image definition')
with self.argument_context('sig image-definition update') as c:
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/vm/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def load_command_table(self, _):
g.show_command('show', 'get')
g.custom_command('list', 'list_image_galleries')
g.command('delete', 'begin_delete')
g.generic_update_command('update', setter_type=compute_custom, setter_name='update_image_galleries', setter_arg_name='gallery')
g.generic_update_command('update', setter_name='begin_create_or_update', setter_arg_name='gallery')

with self.command_group('sig image-definition', compute_gallery_images_sdk, operation_group='gallery_images', min_api='2018-06-01') as g:
g.custom_command('create', 'create_gallery_image')
Expand Down
23 changes: 6 additions & 17 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@

from knack.log import get_logger
from knack.util import CLIError
from azure.cli.core.azclierror import CLIInternalError, ValidationError, RequiredArgumentMissingError
from azure.cli.core.azclierror import CLIInternalError

from azure.cli.command_modules.vm._validators import _get_resource_group_from_vault_name
from azure.cli.core.azclierror import ValidationError
from azure.cli.core.commands.validators import validate_file_or_dict

from azure.cli.core.commands import LongRunningOperation, DeploymentOutputLongRunningOperation
Expand Down Expand Up @@ -1816,7 +1817,8 @@ def list_vm_images(cmd, image_location=None, publisher_name=None, offer=None, sk
def show_vm_image(cmd, urn=None, publisher=None, offer=None, sku=None, version=None, location=None):
from azure.cli.core.commands.parameters import get_one_of_subscription_locations
from azure.cli.core.azclierror import (MutuallyExclusiveArgumentError,
InvalidArgumentValueError)
InvalidArgumentValueError,
RequiredArgumentMissingError)

location = location or get_one_of_subscription_locations(cmd.cli_ctx)
error_msg = 'Please specify all of (--publisher, --offer, --sku, --version), or --urn'
Expand All @@ -1840,7 +1842,8 @@ def accept_market_ordering_terms(cmd, urn=None, publisher=None, offer=None, plan
from azure.mgmt.marketplaceordering import MarketplaceOrderingAgreements
from azure.mgmt.marketplaceordering.models import OfferType
from azure.cli.core.azclierror import (MutuallyExclusiveArgumentError,
InvalidArgumentValueError)
InvalidArgumentValueError,
RequiredArgumentMissingError)

error_msg = 'Please specify all of (--plan, --offer, --publish), or --urn'
if urn:
Expand Down Expand Up @@ -3324,20 +3327,6 @@ def list_image_galleries(cmd, resource_group_name=None):
return client.galleries.list()


# from azure.mgmt.compute.models import Gallery, SharingProfile
def update_image_galleries(cmd, resource_group_name, gallery_name, gallery, permissions=None, **kwargs):
if permissions:
if gallery.sharing_profile is None:
SharingProfile = cmd.get_models('SharingProfile')
gallery.sharing_profile = SharingProfile(permissions=permissions)
else:
gallery.sharing_profile.permissions = permissions

client = _compute_client_factory(cmd.cli_ctx)

return client.galleries.begin_create_or_update(resource_group_name, gallery_name, gallery, **kwargs)


def create_image_gallery(cmd, resource_group_name, gallery_name, description=None,
location=None, no_wait=False, tags=None):
Gallery = cmd.get_models('Gallery')
Expand Down
Binary file modified src/azure-cli/azure/cli/command_modules/vm/gen.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,3 @@ def cf_vm_cl(cli_ctx, *_):

def cf_ssh_public_key(cli_ctx, *_):
return cf_vm_cl(cli_ctx).ssh_public_keys


def cf_gallery(cli_ctx, *_):
return cf_vm_cl(cli_ctx).galleries


def cf_shared_gallery_image(cli_ctx, *_):
return cf_vm_cl(cli_ctx).shared_gallery_images


def cf_shared_gallery_image_version(cli_ctx, *_):
return cf_vm_cl(cli_ctx).shared_gallery_image_versions
82 changes: 0 additions & 82 deletions src/azure-cli/azure/cli/command_modules/vm/generated/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,85 +52,3 @@
type: command
short-summary: "Delete an SSH public key."
"""

helps['sig'] = """
type: group
short-summary: Manage gallery with vm
"""

helps['sig image-definition'] = """
type: group
short-summary: Manage gallery with vm sub group image-definition
"""

helps['sig image-definition list-shared'] = """
type: command
short-summary: "List shared gallery images by subscription id or tenant id."
examples:
- name: Get a gallery.
text: |-
az sig image-definition list-shared --gallery-unique-name "galleryUniqueName" --location "myLocation"
"""

helps['sig image-version'] = """
type: group
short-summary: Manage gallery with vm sub group image-version
"""

helps['sig image-version list-shared'] = """
type: command
short-summary: "List shared gallery image versions by subscription id or tenant id."
examples:
- name: Get a gallery.
text: |-
az sig image-version list-shared --gallery-image-definition "myGalleryImageName" --gallery-unique-name \
"galleryUniqueName" --location "myLocation"
"""

helps['sig list-shared'] = """
type: command
short-summary: "List shared galleries by subscription id or tenant id."
examples:
- name: Get a gallery.
text: |-
az sig list-shared --location "myLocation"
"""

helps['sig show-shared'] = """
type: command
short-summary: "Get a shared gallery by subscription id or tenant id."
examples:
- name: Get a gallery.
text: |-
az sig show-shared --gallery-unique-name "galleryUniqueName" --location "myLocation"
"""

helps['sig image-definition'] = """
type: group
short-summary: Manage shared gallery image with vm
"""

helps['sig image-definition show-shared'] = """
type: command
short-summary: "Get a shared gallery image by subscription id or tenant id."
examples:
- name: Get a gallery.
text: |-
az sig image-definition show-shared --gallery-image-definition "myGalleryImageName" \
--gallery-unique-name "galleryUniqueName" --location "myLocation"
"""

helps['sig image-version'] = """
type: group
short-summary: Manage shared gallery image version with vm
"""

helps['sig image-version show-shared'] = """
type: command
short-summary: "Get a shared gallery image version by subscription id or tenant id."
examples:
- name: Get a gallery.
text: |-
az sig image-version show-shared --gallery-image-definition "myGalleryImageName" \
--gallery-image-version "myGalleryImageVersionName" --gallery-unique-name "galleryUniqueName" --location "myLocation"
"""
48 changes: 0 additions & 48 deletions src/azure-cli/azure/cli/command_modules/vm/generated/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from azure.cli.core.commands.parameters import (
tags_type,
get_enum_type,
resource_group_name_type,
get_location_type
)
Expand Down Expand Up @@ -55,50 +54,3 @@ def load_arguments(self, _):
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
'name of the SSH public key.', id_part='name')

with self.argument_context('sig image-definition list-shared') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name')
c.argument('gallery_unique_name', type=str, help='The unique name of the Shared Gallery.',
id_part='child_name_1')
c.argument('shared_to', arg_type=get_enum_type(['tenant']), help='The query parameter to decide what shared '
'galleries to fetch when doing listing operations.')

with self.argument_context('sig image-version list-shared') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name')
c.argument('gallery_unique_name', type=str, help='The unique name of the Shared Gallery.',
id_part='child_name_1')
c.argument('gallery_image_name', options_list=['--gallery-image-definition', '-i'], type=str, help='The name '
'of the Shared Gallery Image Definition from which the Image Versions are to be listed.',
id_part='child_name_2')
c.argument('shared_to', arg_type=get_enum_type(['tenant']), help='The query parameter to decide what shared '
'galleries to fetch when doing listing operations.')

with self.argument_context('sig list-shared') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx))
c.argument('shared_to', arg_type=get_enum_type(['tenant']), help='The query parameter to decide what shared '
'galleries to fetch when doing listing operations.')

with self.argument_context('sig show-shared') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name')
c.argument('gallery_unique_name', type=str, help='The unique name of the Shared Gallery.',
id_part='child_name_1')

with self.argument_context('sig image-definition show-shared') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name')
c.argument('gallery_unique_name', type=str, help='The unique name of the Shared Gallery.',
id_part='child_name_1')
c.argument('gallery_image_name', options_list=['--gallery-image-definition', '-i'], type=str, help='The name '
'of the Shared Gallery Image Definition from which the Image Versions are to be listed.',
id_part='child_name_2')

with self.argument_context('sig image-version show-shared') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='name')
c.argument('gallery_unique_name', type=str, help='The unique name of the Shared Gallery.',
id_part='child_name_1')
c.argument('gallery_image_name', options_list=['--gallery-image-definition', '-i'], type=str, help='The name '
'of the Shared Gallery Image Definition from which the Image Versions are to be listed.',
id_part='child_name_2')
c.argument('gallery_image_version_name', options_list=['--gallery-image-version', '-e'], type=str, 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')
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,14 @@
def load_command_table(self, _):

from ..generated._client_factory import cf_ssh_public_key

vm_ssh_public_key = CliCommandType(
operations_tmpl='azure.mgmt.compute.operations._ssh_public_keys_operations#SshPublicKeysOperations.{}',
client_factory=cf_ssh_public_key)
client_factory=cf_ssh_public_key,
)
with self.command_group('sshkey', vm_ssh_public_key, client_factory=cf_ssh_public_key) as g:
g.custom_command('list', 'sshkey_list')
g.custom_show_command('show', 'sshkey_show')
g.custom_command('create', 'sshkey_create')
g.custom_command('update', 'sshkey_update')
g.custom_command('delete', 'sshkey_delete', confirmation=True)

from ..generated._client_factory import cf_gallery
vm_gallery = CliCommandType(
operations_tmpl='azure.mgmt.compute.operations._galleries_operations#GalleriesOperations.{}',
client_factory=cf_gallery)
with self.command_group('sig', vm_gallery, client_factory=cf_gallery) as g:
g.custom_command('image-definition list-shared', 'sig_image_definition_list_shared')
g.custom_command('image-version list-shared', 'sig_image_version_list_shared')
g.custom_command('list-shared', 'sig_list_shared')
g.custom_command('show-shared', 'sig_show_shared')

from ..generated._client_factory import cf_shared_gallery_image
vm_shared_gallery_image = CliCommandType(
operations_tmpl='azure.mgmt.compute.operations._shared_gallery_images_operations#SharedGalleryImagesOperations.'
'{}',
client_factory=cf_shared_gallery_image)
with self.command_group('sig image-definition', vm_shared_gallery_image,
client_factory=cf_shared_gallery_image) as g:
g.custom_command('show-shared', 'sig_image_definition_show_shared', is_experimental=True)

from ..generated._client_factory import cf_shared_gallery_image_version
vm_shared_gallery_image_version = CliCommandType(
operations_tmpl='azure.mgmt.compute.operations._shared_gallery_image_versions_operations#SharedGalleryImageVers'
'ionsOperations.{}',
client_factory=cf_shared_gallery_image_version)
with self.command_group('sig image-version', vm_shared_gallery_image_version,
client_factory=cf_shared_gallery_image_version) as g:
g.custom_command('show-shared', 'sig_image_version_show_shared', is_experimental=True)
60 changes: 0 additions & 60 deletions src/azure-cli/azure/cli/command_modules/vm/generated/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,63 +57,3 @@ def sshkey_delete(client,
ssh_public_key_name):
return client.delete(resource_group_name=resource_group_name,
ssh_public_key_name=ssh_public_key_name)


def sig_image_definition_list_shared(client,
location,
gallery_unique_name,
shared_to=None):
if shared_to is None:
shared_to = "tenant"
return client.list(location=location,
gallery_unique_name=gallery_unique_name,
shared_to=shared_to)


def sig_image_version_list_shared(client,
location,
gallery_unique_name,
gallery_image_name,
shared_to=None):
if shared_to is None:
shared_to = "tenant"
return client.list(location=location,
gallery_unique_name=gallery_unique_name,
gallery_image_name=gallery_image_name,
shared_to=shared_to)


def sig_list_shared(client,
location,
shared_to=None):
if shared_to is None:
shared_to = "tenant"
return client.list(location=location,
shared_to=shared_to)


def sig_show_shared(client,
location,
gallery_unique_name):
return client.get(location=location,
gallery_unique_name=gallery_unique_name)


def sig_image_definition_show_shared(client,
location,
gallery_unique_name,
gallery_image_name):
return client.get(location=location,
gallery_unique_name=gallery_unique_name,
gallery_image_name=gallery_image_name)


def sig_image_version_show_shared(client,
location,
gallery_unique_name,
gallery_image_name,
gallery_image_version_name):
return client.get(location=location,
gallery_unique_name=gallery_unique_name,
gallery_image_name=gallery_image_name,
gallery_image_version_name=gallery_image_version_name)

This file was deleted.

Loading