Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 6 additions & 2 deletions src/aks-preview/azext_aks_preview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


from azure.cli.core import AzCommandsLoader
from azure.cli.core.profiles import register_resource_type
from azure.cli.core.profiles import register_resource_type, SDKProfile

# pylint: disable=unused-import
import azext_aks_preview._help
Expand All @@ -16,7 +16,11 @@ class ContainerServiceCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
register_resource_type('latest', CUSTOM_MGMT_AKS_PREVIEW, '2021-05-01')
register_resource_type(
"latest",
CUSTOM_MGMT_AKS_PREVIEW,
SDKProfile("2021-05-01", {"container_services": "2017-07-01"}),
)

acs_custom = CliCommandType(operations_tmpl='azext_aks_preview.custom#{}')
super(ContainerServiceCommandsLoader, self).__init__(cli_ctx=cli_ctx,
Expand Down
2 changes: 0 additions & 2 deletions src/aks-preview/azext_aks_preview/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

CUSTOM_MGMT_AKS_PREVIEW = CustomResourceType('azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks',
'ContainerServiceClient')
CUSTOM_MGMT_AKS = CustomResourceType('azext_aks_preview.vendored_sdks.azure_mgmt_aks',
'ContainerServiceClient')


def cf_storage(cli_ctx, subscription_id=None):
Expand Down
14 changes: 9 additions & 5 deletions src/aks-preview/azext_aks_preview/_loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,20 @@ def configure_load_balancer_profile(managed_outbound_ip_count, outbound_ips, out
outbound_ip_prefix_resources = _get_load_balancer_outbound_ip_prefixes(outbound_ip_prefixes)

if managed_outbound_ip_count or outbound_ip_resources or outbound_ip_prefix_resources:
profile.managed_outbound_ips = None
profile.outbound_ips = None
# ips -> i_ps due to track 2 naming issue
profile.managed_outbound_i_ps = None
# ips -> i_ps due to track 2 naming issue
profile.outbound_i_ps = None
profile.outbound_ip_prefixes = None
if managed_outbound_ip_count:
profile.managed_outbound_ips = ManagedClusterLoadBalancerProfileManagedOutboundIPs(
# ips -> i_ps due to track 2 naming issue
profile.managed_outbound_i_ps = ManagedClusterLoadBalancerProfileManagedOutboundIPs(
count=managed_outbound_ip_count
)
if outbound_ip_resources:
profile.outbound_ips = ManagedClusterLoadBalancerProfileOutboundIPs(
public_ips=outbound_ip_resources
# ips -> i_ps due to track 2 naming issue
profile.outbound_i_ps = ManagedClusterLoadBalancerProfileOutboundIPs(
public_i_ps=outbound_ip_resources
)
if outbound_ip_prefix_resources:
profile.outbound_ip_prefixes = ManagedClusterLoadBalancerProfileOutboundIPPrefixes(
Expand Down
6 changes: 4 additions & 2 deletions src/aks-preview/azext_aks_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ def load_command_table(self, _):
managed_clusters_sdk = CliCommandType(
operations_tmpl='azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks.'
'operations._managed_clusters_operations#ManagedClustersOperations.{}',
operation_group='managed_clusters',
client_factory=cf_managed_clusters
)

container_services_sdk = CliCommandType(
operations_tmpl='azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks.'
'operations.container_service_operations#ContainerServicesOperations.{}',
operation_group='container_services',
client_factory=cf_container_services
)

Expand Down Expand Up @@ -67,8 +69,8 @@ def load_command_table(self, _):
confirmation='Kubernetes will be unavailable during certificate rotation process.\n' +
'Are you sure you want to perform this operation?')
g.wait_command('wait')
g.command('stop', 'stop', supports_no_wait=True)
g.command('start', 'start', supports_no_wait=True)
g.command('stop', 'begin_stop', supports_no_wait=True)
g.command('start', 'begin_start', supports_no_wait=True)
g.custom_command('get-os-options', 'aks_get_os_options')

# AKS container service commands
Expand Down
62 changes: 32 additions & 30 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
ManagedClusterIdentity,
ManagedClusterAPIServerAccessProfile,
ManagedClusterSKU,
ManagedClusterIdentityUserAssignedIdentitiesValue,
Components1Umhcm8SchemasManagedclusteridentityPropertiesUserassignedidentitiesAdditionalproperties,
ManagedClusterAutoUpgradeProfile,
KubeletConfig,
LinuxOSConfig,
Expand All @@ -83,7 +83,7 @@
ManagedClusterPodIdentityException,
UserAssignedIdentity,
RunCommandRequest,
ManagedClusterPropertiesIdentityProfileValue)
ComponentsQit0EtSchemasManagedclusterpropertiesPropertiesIdentityprofileAdditionalproperties)
from ._client_factory import cf_resource_groups
from ._client_factory import get_auth_management_client
from ._client_factory import get_graph_rbac_management_client
Expand Down Expand Up @@ -1293,7 +1293,8 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
aad_profile = ManagedClusterAADProfile(
managed=True,
enable_azure_rbac=enable_azure_rbac,
admin_group_object_ids=_parse_comma_separated_list(
# ids -> i_ds due to track 2 naming issue
admin_group_object_i_ds=_parse_comma_separated_list(
aad_admin_group_object_ids),
tenant_id=aad_tenant_id
)
Expand Down Expand Up @@ -1334,7 +1335,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
)
elif enable_managed_identity and assign_identity:
user_assigned_identity = {
assign_identity: ManagedClusterIdentityUserAssignedIdentitiesValue()
assign_identity: Components1Umhcm8SchemasManagedclusteridentityPropertiesUserassignedidentitiesAdditionalproperties()
}
identity = ManagedClusterIdentity(
type="UserAssigned",
Expand All @@ -1347,7 +1348,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
raise CLIError('--assign-kubelet-identity can only be specified when --assign-identity is specified')
kubelet_identity = _get_user_assigned_identity(cmd.cli_ctx, assign_kubelet_identity)
identity_profile = {
'kubeletidentity': ManagedClusterPropertiesIdentityProfileValue(
'kubeletidentity': ComponentsQit0EtSchemasManagedclusterpropertiesPropertiesIdentityprofileAdditionalproperties(
resource_id=assign_kubelet_identity,
client_id=kubelet_identity.client_id,
object_id=kubelet_identity.principal_id
Expand Down Expand Up @@ -1733,7 +1734,8 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
if aad_tenant_id is not None:
instance.aad_profile.tenant_id = aad_tenant_id
if aad_admin_group_object_ids is not None:
instance.aad_profile.admin_group_object_ids = _parse_comma_separated_list(
# ids -> i_ds due to track 2 naming issue
instance.aad_profile.admin_group_object_i_ds = _parse_comma_separated_list(
aad_admin_group_object_ids)
if enable_azure_rbac and disable_azure_rbac:
raise CLIError(
Expand Down Expand Up @@ -1807,7 +1809,7 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
)
elif goal_identity_type == "userassigned":
user_assigned_identity = {
assign_identity: ManagedClusterIdentityUserAssignedIdentitiesValue()
assign_identity: Components1Umhcm8SchemasManagedclusteridentityPropertiesUserassignedidentitiesAdditionalproperties()
}
instance.identity = ManagedClusterIdentity(
type="UserAssigned",
Expand Down Expand Up @@ -2171,7 +2173,7 @@ def aks_scale(cmd, # pylint: disable=unused-argument
# null out the SP and AAD profile because otherwise validation complains
instance.service_principal_profile = None
instance.aad_profile = None
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, name, instance)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, name, instance)
raise CLIError('The nodepool "{}" was not found.'.format(nodepool_name))


Expand Down Expand Up @@ -2263,7 +2265,7 @@ def aks_upgrade(cmd, # pylint: disable=unused-argument, too-many-return-state

headers = get_aks_custom_headers(aks_custom_headers)

return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, name, instance, custom_headers=headers)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, name, instance, headers=headers)


def aks_runcommand(cmd, client, resource_group_name, name, command_string="", command_files=None):
Expand All @@ -2280,8 +2282,8 @@ def aks_runcommand(cmd, client, resource_group_name, name, command_string="", co
request_payload.cluster_token = _get_dataplane_aad_token(
cmd.cli_ctx, "6dae42f8-4368-4678-94ff-3960e28e3630")

commandResultFuture = client.run_command(
resource_group_name, name, request_payload, long_running_operation_timeout=5, retry_total=0)
commandResultFuture = client.begin_run_command(
resource_group_name, name, request_payload, polling_interval=5, retry_total=0)

return _print_command_result(cmd.cli_ctx, commandResultFuture.result(300))

Expand Down Expand Up @@ -2376,7 +2378,7 @@ def _get_dataplane_aad_token(cli_ctx, serverAppId):


def _upgrade_single_nodepool_image_version(no_wait, client, resource_group_name, cluster_name, nodepool_name):
return sdk_no_wait(no_wait, client.upgrade_node_image_version, resource_group_name, cluster_name, nodepool_name)
return sdk_no_wait(no_wait, client.begin_upgrade_node_image_version, resource_group_name, cluster_name, nodepool_name)


def _handle_addons_args(cmd, # pylint: disable=too-many-statements
Expand Down Expand Up @@ -3098,7 +3100,7 @@ def aks_agentpool_add(cmd, # pylint: disable=unused-argument,too-many-local
agent_pool.linux_os_config = _get_linux_os_config(linux_os_config)

headers = get_aks_custom_headers(aks_custom_headers)
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, nodepool_name, agent_pool, custom_headers=headers)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, nodepool_name, agent_pool, headers=headers)


def aks_agentpool_scale(cmd, # pylint: disable=unused-argument
Expand All @@ -3116,7 +3118,7 @@ def aks_agentpool_scale(cmd, # pylint: disable=unused-argument
raise CLIError(
"The new node count is the same as the current node count.")
instance.count = new_node_count # pylint: disable=no-member
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, nodepool_name, instance)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, nodepool_name, instance)


def aks_agentpool_upgrade(cmd, # pylint: disable=unused-argument
Expand Down Expand Up @@ -3148,7 +3150,7 @@ def aks_agentpool_upgrade(cmd, # pylint: disable=unused-argument
if max_surge:
instance.upgrade_settings.max_surge = max_surge

return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, nodepool_name, instance)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, nodepool_name, instance)


def aks_agentpool_get_upgrade_profile(cmd, # pylint: disable=unused-argument
Expand Down Expand Up @@ -3230,7 +3232,7 @@ def aks_agentpool_update(cmd, # pylint: disable=unused-argument
if mode is not None:
instance.mode = mode

return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, nodepool_name, instance)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, nodepool_name, instance)


def aks_agentpool_delete(cmd, # pylint: disable=unused-argument
Expand All @@ -3250,7 +3252,7 @@ def aks_agentpool_delete(cmd, # pylint: disable=unused-argument
raise CLIError("Node pool {} doesnt exist, "
"use 'aks nodepool list' to get current node pool list".format(nodepool_name))

return sdk_no_wait(no_wait, client.delete, resource_group_name, cluster_name, nodepool_name)
return sdk_no_wait(no_wait, client.begin_delete, resource_group_name, cluster_name, nodepool_name)


def aks_disable_addons(cmd, client, resource_group_name, name, addons, no_wait=False):
Expand All @@ -3269,7 +3271,7 @@ def aks_disable_addons(cmd, client, resource_group_name, name, addons, no_wait=F
)

# send the managed cluster representation to update the addon profiles
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, name, instance)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, name, instance)


def aks_enable_addons(cmd, client, resource_group_name, name, addons, workspace_resource_id=None,
Expand Down Expand Up @@ -3300,7 +3302,7 @@ def aks_enable_addons(cmd, client, resource_group_name, name, addons, workspace_
if need_post_creation_role_assignment:
# adding a wait here since we rely on the result for role assignment
result = LongRunningOperation(cmd.cli_ctx)(
client.create_or_update(resource_group_name, name, instance))
client.begin_create_or_update(resource_group_name, name, instance))
cloud_name = cmd.cli_ctx.cloud.name
# mdm metrics supported only in Azure Public cloud so add the role assignment only in this cloud
if monitoring and cloud_name.lower() == 'azurecloud':
Expand All @@ -3325,13 +3327,13 @@ def aks_enable_addons(cmd, client, resource_group_name, name, addons, workspace_
# we don't need to handle it in client side in this case.

else:
result = sdk_no_wait(no_wait, client.create_or_update,
result = sdk_no_wait(no_wait, client.begin_create_or_update,
resource_group_name, name, instance)
return result


def aks_rotate_certs(cmd, client, resource_group_name, name, no_wait=True): # pylint: disable=unused-argument
return sdk_no_wait(no_wait, client.rotate_cluster_certificates, resource_group_name, name)
return sdk_no_wait(no_wait, client.begin_rotate_cluster_certificates, resource_group_name, name)


def _update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements
Expand Down Expand Up @@ -3797,11 +3799,11 @@ def _put_managed_cluster_ensuring_permission(
need_grant_vnet_permission_to_cluster_identity)
if need_post_creation_role_assignment:
# adding a wait here since we rely on the result for role assignment
cluster = LongRunningOperation(cmd.cli_ctx)(client.create_or_update(
cluster = LongRunningOperation(cmd.cli_ctx)(client.begin_create_or_update(
resource_group_name=resource_group_name,
resource_name=name,
parameters=managed_cluster,
custom_headers=headers))
headers=headers))
cloud_name = cmd.cli_ctx.cloud.name
# add cluster spn/msi Monitoring Metrics Publisher role assignment to publish metrics to MDM
# mdm metrics is supported only in azure public cloud, so add the role assignment only in this cloud
Expand Down Expand Up @@ -3840,11 +3842,11 @@ def _put_managed_cluster_ensuring_permission(
acr_name_or_id=attach_acr,
subscription_id=subscription_id)
else:
cluster = sdk_no_wait(no_wait, client.create_or_update,
cluster = sdk_no_wait(no_wait, client.begin_create_or_update,
resource_group_name=resource_group_name,
resource_name=name,
parameters=managed_cluster,
custom_headers=headers)
headers=headers)

return cluster

Expand Down Expand Up @@ -4083,7 +4085,7 @@ def aks_pod_identity_add(cmd, client, resource_group_name, cluster_name,
)

# send the managed cluster represeentation to update the pod identity addon
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, instance)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, instance)


def aks_pod_identity_delete(cmd, client, resource_group_name, cluster_name,
Expand All @@ -4107,7 +4109,7 @@ def aks_pod_identity_delete(cmd, client, resource_group_name, cluster_name,
)

# send the managed cluster represeentation to update the pod identity addon
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, instance)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, instance)


def aks_pod_identity_list(cmd, client, resource_group_name, cluster_name): # pylint: disable=unused-argument
Expand All @@ -4134,7 +4136,7 @@ def aks_pod_identity_exception_add(cmd, client, resource_group_name, cluster_nam
)

# send the managed cluster represeentation to update the pod identity addon
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, instance)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, instance)


def aks_pod_identity_exception_delete(cmd, client, resource_group_name, cluster_name,
Expand All @@ -4157,7 +4159,7 @@ def aks_pod_identity_exception_delete(cmd, client, resource_group_name, cluster_
)

# send the managed cluster represeentation to update the pod identity addon
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, instance)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, instance)


def aks_pod_identity_exception_update(cmd, client, resource_group_name, cluster_name,
Expand Down Expand Up @@ -4188,7 +4190,7 @@ def aks_pod_identity_exception_update(cmd, client, resource_group_name, cluster_
)

# send the managed cluster represeentation to update the pod identity addon
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, instance)
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, instance)


def aks_pod_identity_exception_list(cmd, client, resource_group_name, cluster_name):
Expand Down
Loading