Skip to content

Commit 1b6f4cc

Browse files
{Compute} Migrate vm validator function of calling Compute module to aaz-based implementation (#33348)
1 parent 819683e commit 1b6f4cc

3 files changed

Lines changed: 827 additions & 778 deletions

File tree

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,14 +2871,18 @@ def _validate_vm_vmss_update_ephemeral_placement(cmd, namespace): # pylint: dis
28712871

28722872
def _validate_community_gallery_legal_agreement_acceptance(cmd, namespace):
28732873
from ._vm_utils import is_community_gallery_image_id, parse_community_gallery_image_id
2874+
from .aaz.latest.sig import ShowCommunity as SigShowCommunity
28742875
if not is_community_gallery_image_id(namespace.image) or namespace.accept_term:
28752876
return
28762877

28772878
community_gallery_name, _ = parse_community_gallery_image_id(namespace.image)
2878-
from ._client_factory import cf_community_gallery
28792879
try:
2880-
community_gallery_info = cf_community_gallery(cmd.cli_ctx).get(namespace.location, community_gallery_name)
2881-
eula = community_gallery_info.additional_properties['communityMetadata']['eula']
2880+
command_args = {
2881+
'location': namespace.location,
2882+
'public_gallery_name': community_gallery_name
2883+
}
2884+
community_gallery_info = SigShowCommunity(cli_ctx=cmd.cli_ctx)(command_args=command_args)
2885+
eula = community_gallery_info['communityMetadata']['eula']
28822886
except Exception as err:
28832887
raise CLIInternalError('Get the eula from community gallery failed: {0}'.format(err))
28842888

src/azure-cli/azure/cli/command_modules/vm/aaz/latest/sig/_show_community.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class ShowCommunity(AAZCommand):
1919
"""
2020

2121
_aaz_info = {
22-
"version": "2022-01-03",
22+
"version": "2025-03-03",
2323
"resources": [
24-
["mgmt-plane", "/subscriptions/{}/providers/microsoft.compute/locations/{}/communitygalleries/{}", "2022-01-03"],
24+
["mgmt-plane", "/subscriptions/{}/providers/microsoft.compute/locations/{}/communitygalleries/{}", "2025-03-03"],
2525
]
2626
}
2727

@@ -118,7 +118,7 @@ def url_parameters(self):
118118
def query_parameters(self):
119119
parameters = {
120120
**self.serialize_query_param(
121-
"api-version", "2022-01-03",
121+
"api-version", "2025-03-03",
122122
required=True,
123123
),
124124
}
@@ -160,6 +160,9 @@ def _build_schema_on_200(cls):
160160
_schema_on_200.name = AAZStrType(
161161
flags={"read_only": True},
162162
)
163+
_schema_on_200.properties = AAZObjectType(
164+
flags={"client_flatten": True},
165+
)
163166
_schema_on_200.type = AAZStrType(
164167
flags={"read_only": True},
165168
)
@@ -169,6 +172,38 @@ def _build_schema_on_200(cls):
169172
serialized_name="uniqueId",
170173
)
171174

175+
properties = cls._schema_on_200.properties
176+
properties.artifact_tags = AAZDictType(
177+
serialized_name="artifactTags",
178+
)
179+
properties.community_metadata = AAZObjectType(
180+
serialized_name="communityMetadata",
181+
)
182+
properties.disclaimer = AAZStrType()
183+
184+
artifact_tags = cls._schema_on_200.properties.artifact_tags
185+
artifact_tags.Element = AAZStrType()
186+
187+
community_metadata = cls._schema_on_200.properties.community_metadata
188+
community_metadata.eula = AAZStrType()
189+
community_metadata.privacy_statement_uri = AAZStrType(
190+
serialized_name="privacyStatementUri",
191+
)
192+
community_metadata.public_names = AAZListType(
193+
serialized_name="publicNames",
194+
flags={"required": True},
195+
)
196+
community_metadata.publisher_contact = AAZStrType(
197+
serialized_name="publisherContact",
198+
flags={"required": True},
199+
)
200+
community_metadata.publisher_uri = AAZStrType(
201+
serialized_name="publisherUri",
202+
)
203+
204+
public_names = cls._schema_on_200.properties.community_metadata.public_names
205+
public_names.Element = AAZStrType()
206+
172207
return cls._schema_on_200
173208

174209

0 commit comments

Comments
 (0)