Skip to content

Commit a4c1a13

Browse files
committed
latest profile
1 parent 1841ca4 commit a4c1a13

File tree

5 files changed

+193
-97
lines changed

5 files changed

+193
-97
lines changed

src/azure-cli/azure/cli/command_modules/vm/_client_factory.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,6 @@ def cf_shared_galleries(cli_ctx, *_):
161161
return cf_vm_cl(cli_ctx).shared_galleries
162162

163163

164-
def cf_gallery_sharing_profile(cli_ctx, *_):
165-
return cf_vm_cl(cli_ctx).gallery_sharing_profile
166-
167-
168164
def cf_shared_gallery_image(cli_ctx, *_):
169165
return cf_vm_cl(cli_ctx).shared_gallery_images
170166

src/azure-cli/azure/cli/command_modules/vm/_help.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,58 +1105,6 @@
11051105
az sig list-community --location myLocation --marker nextMarker
11061106
"""
11071107

1108-
helps['sig share'] = """
1109-
type: group
1110-
short-summary: Manage gallery sharing profile
1111-
"""
1112-
1113-
helps['sig share add'] = """
1114-
type: command
1115-
short-summary: Share gallery with subscriptions and tenants
1116-
examples:
1117-
- name: Share entire gallery with all members of a subscription and/or tenant.
1118-
text: |
1119-
az sig share add --resource-group MyResourceGroup --gallery-name MyGallery \\
1120-
--subscription-ids subId1 subId2 --tenant-ids tenantId1 tenantId2
1121-
"""
1122-
1123-
helps['sig share remove'] = """
1124-
type: command
1125-
short-summary: stop sharing gallery with a subscription or tenant
1126-
examples:
1127-
- name: Stop sharing with a subscription or tenant ID
1128-
text: |
1129-
az sig share remove --resource-group MyResourceGroup --gallery-name MyGallery \\
1130-
--subscription-ids subId1 subId2 --tenant-ids tenantId1 tenantId2
1131-
"""
1132-
1133-
helps['sig share reset'] = """
1134-
type: command
1135-
short-summary: disable gallery from being shared with subscription or tenant
1136-
examples:
1137-
- name: Reset sharing profile of a gallery.
1138-
text: |
1139-
az sig share reset --resource-group MyResourceGroup --gallery-name MyGallery
1140-
"""
1141-
1142-
helps['sig share enable-community'] = """
1143-
type: command
1144-
short-summary: Allow to share gallery to the community
1145-
examples:
1146-
- name: Allow to share gallery to the community
1147-
text: |
1148-
az sig share enable-community --resource-group MyResourceGroup --gallery-name MyGallery
1149-
"""
1150-
1151-
helps['sig share wait'] = """
1152-
type: command
1153-
short-summary: Place the CLI in a waiting state until a condition of a shared gallery is met.
1154-
examples:
1155-
- name: Place the CLI in a waiting state until the gallery sharing object is updated.
1156-
text: |
1157-
az sig share wait --updated --resource-group MyResourceGroup --gallery-name Gallery
1158-
"""
1159-
11601108
helps['sig gallery-application'] = """
11611109
type: group
11621110
short-summary: Manage gallery application

src/azure-cli/azure/cli/command_modules/vm/_params.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,23 +1253,6 @@ def load_arguments(self, _):
12531253
c.argument('gallery_image_name', options_list=['--gallery-image-definition', '-i'], help='gallery image definition')
12541254
c.argument('gallery_image_version', options_list=['--gallery-image-version', '-e'], help='gallery image version')
12551255

1256-
for scope in ['sig share add', 'sig share remove']:
1257-
with self.argument_context(scope) as c:
1258-
c.argument('gallery_name', type=str, help='The name of the Shared Image Gallery.', id_part='name')
1259-
c.argument('subscription_ids', nargs='+', help='A list of subscription ids to share the gallery.')
1260-
c.argument('tenant_ids', nargs='+', help='A list of tenant ids to share the gallery.')
1261-
1262-
with self.argument_context('sig share add') as c:
1263-
c.argument('op_type', default='Add', deprecate_info=c.deprecate(hide=True),
1264-
help='distinguish add operation and remove operation')
1265-
1266-
with self.argument_context('sig share remove') as c:
1267-
c.argument('op_type', default='Remove', deprecate_info=c.deprecate(hide=True),
1268-
help='distinguish add operation and remove operation')
1269-
1270-
with self.argument_context('sig share reset') as c:
1271-
c.argument('gallery_name', type=str, help='The name of the Shared Image Gallery.', id_part='name')
1272-
12731256
with self.argument_context('sig image-definition create') as c:
12741257
c.argument('offer', options_list=['--offer', '-f'], help='image offer')
12751258
c.argument('sku', options_list=['--sku', '-s'], help='image sku')
@@ -1414,13 +1397,6 @@ def load_arguments(self, _):
14141397
c.argument('marker', arg_type=marker_type)
14151398
c.argument('show_next_marker', action='store_true', help='Show nextMarker in result when specified.')
14161399

1417-
with self.argument_context('sig share enable-community') as c:
1418-
c.argument('gallery_name', type=str, help='The name of the Shared Image Gallery.', id_part='name')
1419-
c.argument('subscription_ids', nargs='+', help='A list of subscription ids to share the gallery.')
1420-
c.argument('tenant_ids', nargs='+', help='A list of tenant ids to share the gallery.')
1421-
c.argument('op_type', default='EnableCommunity', deprecate_info=c.deprecate(hide=True),
1422-
help='distinguish add operation and remove operation')
1423-
14241400
# endregion
14251401

14261402
# region Gallery applications

src/azure-cli/azure/cli/command_modules/vm/commands.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
cf_dedicated_hosts, cf_dedicated_host_groups,
1414
cf_log_analytics_data_plane,
1515
cf_disk_encryption_set,
16-
cf_gallery_sharing_profile, cf_shared_gallery_image,
16+
cf_shared_gallery_image,
1717
cf_shared_gallery_image_version,
1818
cf_capacity_reservation_groups, cf_capacity_reservations,
1919
cf_vmss_run_commands, cf_gallery_application,
@@ -523,22 +523,13 @@ def load_command_table(self, _):
523523
g.generic_update_command('update', getter_name='get_image_version_to_update', setter_arg_name='gallery_image_version', setter_name='update_image_version', setter_type=compute_custom, command_type=compute_custom, supports_no_wait=True, validator=process_image_version_update_namespace)
524524
g.wait_command('wait')
525525

526-
vm_gallery_sharing_profile = CliCommandType(
527-
operations_tmpl=(
528-
'azure.mgmt.compute.operations._gallery_sharing_profile_operations#GallerySharingProfileOperations.{}'
529-
),
530-
client_factory=cf_gallery_sharing_profile,
531-
operation_group='shared_galleries'
532-
)
533-
with self.command_group('sig share', vm_gallery_sharing_profile,
534-
client_factory=cf_gallery_sharing_profile,
535-
operation_group='shared_galleries',
536-
min_api='2020-09-30') as g:
537-
g.custom_command('add', 'sig_share_update', supports_no_wait=True)
538-
g.custom_command('remove', 'sig_share_update', supports_no_wait=True)
539-
g.custom_command('reset', 'sig_share_reset', supports_no_wait=True)
540-
g.custom_command('enable-community', 'sig_share_update', supports_no_wait=True)
541-
g.wait_command('wait', getter_name='get_gallery_instance', getter_type=compute_custom)
526+
with self.command_group('sig share'):
527+
from .operations.sig_share import SigShareAdd, SigShareRemove, SigShareReset, SigShareEnableCommunity, SigShareWait
528+
self.command_table['sig share add'] = SigShareAdd(loader=self)
529+
self.command_table['sig share remove'] = SigShareRemove(loader=self)
530+
self.command_table['sig share reset'] = SigShareReset(loader=self)
531+
self.command_table['sig share enable-community'] = SigShareEnableCommunity(loader=self)
532+
self.command_table['sig share wait'] = SigShareWait(loader=self)
542533

543534
vm_shared_gallery_image = CliCommandType(
544535
operations_tmpl='azure.mgmt.compute.operations._shared_gallery_images_operations#SharedGalleryImagesOperations.'
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
# pylint: disable=no-self-use, line-too-long, protected-access, too-few-public-methods, unused-argument
6+
from knack.log import get_logger
7+
8+
from azure.cli.core.aaz import register_command, AAZListArg, AAZStrArg
9+
from azure.cli.core.azclierror import CLIError
10+
from ..aaz.latest.sig.share import Update as _SigShareUpdate
11+
from ..aaz.latest.sig import Wait as _SigWait
12+
13+
logger = get_logger(__name__)
14+
15+
16+
@register_command(
17+
"sig shared add",
18+
)
19+
class SigShareAdd(_SigShareUpdate):
20+
"""Share gallery with subscriptions and tenants.
21+
22+
:example: Share entire gallery with all members of a subscription and/or tenant.
23+
az sig share add --resource-group MyResourceGroup --gallery-name MyGallery \\
24+
--subscription-ids subId1 subId2 --tenant-ids tenantId1 tenantId2
25+
"""
26+
27+
@classmethod
28+
def _build_arguments_schema(cls, *args, **kwargs):
29+
args_schema = super()._build_arguments_schema(*args, **kwargs)
30+
args_schema.subscription_ids = AAZListArg(
31+
options=["--subscription-ids"],
32+
help="A list of subscription ids to share the gallery with.",
33+
)
34+
subscription_ids = args_schema.subscription_ids
35+
subscription_ids.Element = AAZStrArg()
36+
37+
args_schema.tenant_ids = AAZListArg(
38+
options=["--tenant-ids"],
39+
help="A list of tenant ids to share the gallery with.",
40+
)
41+
tenant_ids = args_schema.tenant_ids
42+
tenant_ids.Element = AAZStrArg()
43+
44+
args_schema.operation_type._required = False
45+
args_schema.operation_type._registered = False
46+
args_schema.groups._required = False
47+
args_schema.groups._registered = False
48+
49+
return args_schema
50+
51+
def pre_operations(self):
52+
args = self.ctx.args
53+
if not args.subscription_ids and not args.tenant_ids:
54+
raise CLIError('At least one of subscription ids or tenant ids must be provided.')
55+
56+
args.operation_type = 'Add'
57+
args.groups = []
58+
if args.subscription_ids:
59+
args.groups.append({
60+
'type': 'Subscriptions',
61+
'ids': args.subscription_ids
62+
})
63+
if args.tenant_ids:
64+
args.groups.append({
65+
'type': 'AADTenants',
66+
'ids': args.tenant_ids
67+
})
68+
69+
70+
@register_command(
71+
"sig shared remove",
72+
)
73+
class SigShareRemove(_SigShareUpdate):
74+
"""Stop sharing gallery with a subscription or tenant.
75+
76+
:example: Stop sharing with a subscription or tenant ID
77+
az sig share remove --resource-group MyResourceGroup --gallery-name MyGallery \\
78+
--subscription-ids subId1 subId2 --tenant-ids tenantId1 tenantId2
79+
"""
80+
81+
@classmethod
82+
def _build_arguments_schema(cls, *args, **kwargs):
83+
args_schema = super()._build_arguments_schema(*args, **kwargs)
84+
args_schema.subscription_ids = AAZListArg(
85+
options=["--subscription-ids"],
86+
help="A list of subscription ids to share the gallery with.",
87+
)
88+
subscription_ids = args_schema.subscription_ids
89+
subscription_ids.Element = AAZStrArg()
90+
91+
args_schema.tenant_ids = AAZListArg(
92+
options=["--tenant-ids"],
93+
help="A list of tenant ids to share the gallery with.",
94+
)
95+
tenant_ids = args_schema.tenant_ids
96+
tenant_ids.Element = AAZStrArg()
97+
98+
args_schema.operation_type._required = False
99+
args_schema.operation_type._registered = False
100+
args_schema.groups._required = False
101+
args_schema.groups._registered = False
102+
103+
return args_schema
104+
105+
def pre_operations(self):
106+
args = self.ctx.args
107+
108+
if not args.subscription_ids and not args.tenant_ids:
109+
raise CLIError('At least one of subscription ids or tenant ids must be provided.')
110+
args.operation_type = 'Remove'
111+
args.groups = []
112+
if args.subscription_ids:
113+
args.groups.append({
114+
'type': 'Subscriptions',
115+
'ids': args.subscription_ids
116+
})
117+
if args.tenant_ids:
118+
args.groups.append({
119+
'type': 'AADTenants',
120+
'ids': args.tenant_ids
121+
})
122+
123+
124+
@register_command(
125+
"sig shared reset",
126+
)
127+
class SigShareReset(_SigShareUpdate):
128+
"""Disable gallery from being shared with subscription or tenant.
129+
130+
:example: Reset sharing profile of a gallery.
131+
az sig share reset --resource-group MyResourceGroup --gallery-name MyGallery
132+
"""
133+
134+
@classmethod
135+
def _build_arguments_schema(cls, *args, **kwargs):
136+
args_schema = super()._build_arguments_schema(*args, **kwargs)
137+
args_schema.operation_type._required = False
138+
args_schema.operation_type._registered = False
139+
args_schema.operation_type._default = 'Reset'
140+
args_schema.groups._required = False
141+
args_schema.groups._registered = False
142+
143+
return args_schema
144+
145+
146+
@register_command(
147+
"sig shared enable-community"
148+
)
149+
class SigShareEnableCommunity(_SigShareUpdate):
150+
"""Allow to share gallery to the community.
151+
152+
:example: Allow to share gallery to the community
153+
az sig share enable-community --resource-group MyResourceGroup --gallery-name MyGallery
154+
"""
155+
156+
@classmethod
157+
def _build_arguments_schema(cls, *args, **kwargs):
158+
args_schema = super()._build_arguments_schema(*args, **kwargs)
159+
args_schema.operation_type._required = False
160+
args_schema.operation_type._registered = False
161+
args_schema.operation_type._default = 'EnableCommunity'
162+
args_schema.groups._required = False
163+
args_schema.groups._registered = False
164+
165+
return args_schema
166+
167+
168+
@register_command(
169+
"sig shared wait2"
170+
)
171+
class SigShareWait(_SigWait):
172+
"""Place the CLI in a waiting state until a condition of a shared gallery is met.
173+
174+
:example: Place the CLI in a waiting state until the gallery sharing object is updated.
175+
az sig share wait --updated --resource-group MyResourceGroup --gallery-name Gallery
176+
"""
177+
178+
@classmethod
179+
def _build_arguments_schema(cls, *args, **kwargs):
180+
args_schema = super()._build_arguments_schema(*args, **kwargs)
181+
args_schema.gallery_name._help['short-summary'] = 'Gallery name.'
182+
args_schema.expand._registered = False
183+
args_schema.select._registered = False
184+
185+
return args_schema

0 commit comments

Comments
 (0)