Skip to content
Draft
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
8 changes: 7 additions & 1 deletion src/aks-preview/azext_aks_preview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# pylint: disable=unused-import
import azext_aks_preview._help
from azext_aks_preview._client_factory import CUSTOM_MGMT_AKS_PREVIEW
from azext_aks_preview._client_factory import CUSTOM_MGMT_AKS_PREVIEW, CUSTOM_MGMT_AKS_PIS_PREVIEW


def register_aks_preview_resource_type():
Expand All @@ -19,6 +19,12 @@ def register_aks_preview_resource_type():
None,
)

register_resource_type(
"latest",
CUSTOM_MGMT_AKS_PIS_PREVIEW,
None,
)


class ContainerServiceCommandsLoader(AzCommandsLoader):

Expand Down
11 changes: 11 additions & 0 deletions src/aks-preview/azext_aks_preview/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
CUSTOM_MGMT_AKS_PREVIEW = CustomResourceType('azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks',
'ContainerServiceClient')

CUSTOM_MGMT_AKS_PIS_PREVIEW = CustomResourceType('azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks_pis',
'ContainerServiceClient')

# Note: cf_xxx, as the client_factory option value of a command group at command declaration, it should ignore
# parameters other than cli_ctx; get_xxx_client is used as the client of other services in the command implementation,
# and usually accepts subscription_id as a parameter to reconfigure the subscription when sending the request
Expand All @@ -23,6 +26,10 @@ def get_container_service_client(cli_ctx, subscription_id=None):
return get_mgmt_service_client(cli_ctx, CUSTOM_MGMT_AKS_PREVIEW, subscription_id=subscription_id)


def get_container_service_pis_client(cli_ctx, subscription_id=None):
return get_mgmt_service_client(cli_ctx, CUSTOM_MGMT_AKS_PIS_PREVIEW, subscription_id=subscription_id)


def cf_container_services(cli_ctx, *_):
return get_container_service_client(cli_ctx).container_services

Expand Down Expand Up @@ -163,3 +170,7 @@ def cf_jwt_authenticators(cli_ctx, *_):

def cf_vm_skus(cli_ctx, *_):
return get_container_service_client(cli_ctx).vm_skus


def cf_prepared_image_specifications(cli_ctx, *_):
return get_container_service_pis_client(cli_ctx).prepared_image_specifications
50 changes: 50 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -4656,3 +4656,53 @@
- name: Show a specific JWT authenticator configuration
text: az aks jwtauthenticator show -g MyResourceGroup --cluster-name MyCluster --name myjwt
"""

helps['aks prepared-image-specification'] = """
type: group
short-summary: Commands to manage prepared image specifications.
"""

helps['aks prepared-image-specification create'] = """
type: command
short-summary: Create a new prepared image specification.
"""

helps['aks prepared-image-specification update'] = """
type: command
short-summary: Update a prepared image specification.
"""

helps['aks prepared-image-specification delete'] = """
type: command
short-summary: Delete a prepared image specification.
"""

helps['aks prepared-image-specification list'] = """
type: command
short-summary: List prepared image specifications.
"""

helps['aks prepared-image-specification show'] = """
type: command
short-summary: Show a prepared image specification.
"""

helps['aks prepared-image-specification version'] = """
type: group
short-summary: Commands to manage prepared image specification versions.
"""

helps['aks prepared-image-specification version delete'] = """
type: command
short-summary: Delete a prepared image specification version.
"""

helps['aks prepared-image-specification version list'] = """
type: command
short-summary: List prepared image specification versions.
"""

helps['aks prepared-image-specification version show'] = """
type: command
short-summary: Show a prepared image specification version.
"""
85 changes: 85 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
tags_type,
zones_type,
)
from azure.cli.core.commands.validators import validate_file_or_dict
from azext_aks_preview._validators import (
validate_nat_gateway_managed_outbound_ipv6_count,
validate_nat_gateway_v2_params,
Expand Down Expand Up @@ -3398,6 +3399,90 @@ def load_arguments(self, _):
help="Show all VM SKU information including those not available for the current subscription.",
)

with self.argument_context("aks prepared-image-specification create") as c:
c.argument(
"name",
options_list=["--name", "-n"],
required=True,
help="The prepared image specification name.",
)
c.argument(
"container_images",
nargs="+",
help="Container images.",
)
c.argument(
"customization_scripts",
type=validate_file_or_dict,
help="Customization scripts. Expected value: json-string/@json-file.",
)
c.argument(
"assign_identity",
help="Specify an existing user assigned identity.",
)
c.argument(
"version",
required=True,
help="The prepared image specification version.",
)

with self.argument_context("aks prepared-image-specification update") as c:
c.argument(
"name",
options_list=["--name", "-n"],
required=True,
help="The prepared image specification name.",
)

with self.argument_context("aks prepared-image-specification delete") as c:
c.argument(
"name",
options_list=["--name", "-n"],
required=True,
help="The prepared image specification name.",
)

with self.argument_context("aks prepared-image-specification show") as c:
c.argument(
"name",
options_list=["--name", "-n"],
required=True,
help="The prepared image specification name.",
)

with self.argument_context("aks prepared-image-specification version delete") as c:
c.argument(
"pis_name",
required=True,
help="The prepared image specification name.",
)
c.argument(
"name",
options_list=["--name", "-n"],
required=True,
help="The version name.",
)

with self.argument_context("aks prepared-image-specification version list") as c:
c.argument(
"pis_name",
required=True,
help="The prepared image specification name.",
)

with self.argument_context("aks prepared-image-specification version show") as c:
c.argument(
"pis_name",
required=True,
help="The prepared image specification name.",
)
c.argument(
"name",
options_list=["--name", "-n"],
required=True,
help="The version name.",
)


def _get_default_install_location(exe_name):
system = platform.system()
Expand Down
50 changes: 50 additions & 0 deletions src/aks-preview/azext_aks_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
cf_identity_bindings,
cf_jwt_authenticators,
cf_vm_skus,
cf_prepared_image_specifications,
)

from azext_aks_preview._format import (
Expand Down Expand Up @@ -159,6 +160,12 @@ def load_command_table(self, _):
client_factory=cf_vm_skus,
)

prepared_image_specifications_sdk = CliCommandType(
operations_tmpl="azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks_pis."
"operations._operations#PreparedImageSpecificationsOperations.{}",
client_factory=cf_prepared_image_specifications,
)

# AKS managed cluster commands
with self.command_group(
"aks",
Expand Down Expand Up @@ -636,3 +643,46 @@ def load_command_table(self, _):
self.command_table["aks safeguards delete"] = Delete(loader=self)
self.command_table["aks safeguards list"] = List(loader=self)
self.command_table["aks safeguards wait"] = Wait(loader=self)

with self.command_group("aks prepared-image-specification", prepared_image_specifications_sdk,
client_factory=cf_prepared_image_specifications) as g:
g.custom_command(
"create",
"aks_prepared_image_specification_create",
supports_no_wait=True,
)
g.custom_command(
"update",
"aks_prepared_image_specification_update",
)
g.custom_command(
"delete",
"aks_prepared_image_specification_delete",
supports_no_wait=True,
confirmation=True,
)
g.custom_command(
"list",
"aks_prepared_image_specification_list",
)
g.custom_show_command(
"show",
"aks_prepared_image_specification_show",
)

with self.command_group("aks prepared-image-specification version", prepared_image_specifications_sdk,
client_factory=cf_prepared_image_specifications) as g:
g.custom_command(
"delete",
"aks_prepared_image_specification_version_delete",
supports_no_wait=True,
confirmation=True,
)
g.custom_command(
"list",
"aks_prepared_image_specification_version_list",
)
g.custom_show_command(
"show",
"aks_prepared_image_specification_version_show",
)
103 changes: 103 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from azext_aks_preview._client_factory import (
CUSTOM_MGMT_AKS_PREVIEW,
CUSTOM_MGMT_AKS_PIS_PREVIEW,
cf_agent_pools,
get_compute_client,
)
Expand Down Expand Up @@ -5667,3 +5668,105 @@ def aks_jwtauthenticator_list(cmd, client, resource_group_name, cluster_name, ak
def aks_jwtauthenticator_show(cmd, client, resource_group_name, cluster_name, name, aks_custom_headers=None):
headers = get_aks_custom_headers(aks_custom_headers)
return client.get(resource_group_name, cluster_name, name, headers=headers)


def aks_prepared_image_specification_create(
cmd,
client,
resource_group_name,
name,
location=None,
tags=None,
container_images=None,
customization_scripts=None,
assign_identity=None,
version=None,
no_wait=False,
):
PreparedImageSpecification = cmd.get_models(
"PreparedImageSpecification",
resource_type=CUSTOM_MGMT_AKS_PIS_PREVIEW,
operation_group="prepared_image_specifications",
)

PreparedImageSpecificationProperties = cmd.get_models(
"PreparedImageSpecificationProperties",
resource_type=CUSTOM_MGMT_AKS_PIS_PREVIEW,
operation_group="prepared_image_specifications",
)

PreparedImageSpecificationManagedIdentityProfile = cmd.get_models(
"PreparedImageSpecificationManagedIdentityProfile",
resource_type=CUSTOM_MGMT_AKS_PIS_PREVIEW,
operation_group="prepared_image_specifications",
)

if location is None:
location = get_rg_location(cmd.cli_ctx, resource_group_name)

identity_profile = None
if assign_identity is not None:
identity_profile = PreparedImageSpecificationManagedIdentityProfile(
resource_id=assign_identity,
)

pis = PreparedImageSpecification(
name=name,
location=location,
tags=tags,
properties=PreparedImageSpecificationProperties(
container_images=container_images,
customization_scripts=customization_scripts,
identity_profile=identity_profile,
version=version,
),
)

return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, name, pis)


def aks_prepared_image_specification_update(
cmd,
client,
resource_group_name,
name,
tags=None,
):
PreparedImageSpecificationPatch = cmd.get_models(
"PreparedImageSpecificationPatch",
resource_type=CUSTOM_MGMT_AKS_PIS_PREVIEW,
operation_group="prepared_image_specifications",
)

patch = PreparedImageSpecificationPatch(
tags=tags,
)

return client.update(resource_group_name, name, patch)


def aks_prepared_image_specification_delete(cmd, client, resource_group_name, name, no_wait=False):
return sdk_no_wait(no_wait, client.begin_delete, resource_group_name, name)


def aks_prepared_image_specification_show(cmd, client, resource_group_name, name):
return client.get(resource_group_name, name)


def aks_prepared_image_specification_list(cmd, client, resource_group_name=None):
if resource_group_name is None:
return client.list_by_subscription()

return client.list_by_resource_group(resource_group_name)


def aks_prepared_image_specification_version_delete(cmd, client, resource_group_name, pis_name, name, no_wait=False):
return sdk_no_wait(no_wait, client.begin_delete_version, resource_group_name, pis_name, name)


def aks_prepared_image_specification_version_show(cmd, client, resource_group_name, pis_name, name):
return client.get_version(resource_group_name, pis_name, name)


def aks_prepared_image_specification_version_list(cmd, client, resource_group_name, pis_name):
return client.list_versions(resource_group_name, pis_name)
Loading
Loading