Skip to content

Commit 33d8835

Browse files
authored
[AKS] Migrate aks-preview module to track 2 SDK (Azure#3543)
1 parent 87e9cfa commit 33d8835

File tree

506 files changed

+29966
-113028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

506 files changed

+29966
-113028
lines changed

src/aks-preview/azext_aks_preview/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
from azure.cli.core import AzCommandsLoader
8-
from azure.cli.core.profiles import register_resource_type
8+
from azure.cli.core.profiles import register_resource_type, SDKProfile
99

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

1717
def __init__(self, cli_ctx=None):
1818
from azure.cli.core.commands import CliCommandType
19-
register_resource_type('latest', CUSTOM_MGMT_AKS_PREVIEW, '2021-05-01')
19+
register_resource_type(
20+
"latest",
21+
CUSTOM_MGMT_AKS_PREVIEW,
22+
SDKProfile("2021-05-01", {"container_services": "2017-07-01"}),
23+
)
2024

2125
acs_custom = CliCommandType(operations_tmpl='azext_aks_preview.custom#{}')
2226
super(ContainerServiceCommandsLoader, self).__init__(cli_ctx=cli_ctx,

src/aks-preview/azext_aks_preview/_client_factory.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
CUSTOM_MGMT_AKS_PREVIEW = CustomResourceType('azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks',
1414
'ContainerServiceClient')
15-
CUSTOM_MGMT_AKS = CustomResourceType('azext_aks_preview.vendored_sdks.azure_mgmt_aks',
16-
'ContainerServiceClient')
1715

1816

1917
def cf_storage(cli_ctx, subscription_id=None):

src/aks-preview/azext_aks_preview/_loadbalancer.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,20 @@ def configure_load_balancer_profile(managed_outbound_ip_count, outbound_ips, out
5858
outbound_ip_prefix_resources = _get_load_balancer_outbound_ip_prefixes(outbound_ip_prefixes)
5959

6060
if managed_outbound_ip_count or outbound_ip_resources or outbound_ip_prefix_resources:
61-
profile.managed_outbound_ips = None
62-
profile.outbound_ips = None
61+
# ips -> i_ps due to track 2 naming issue
62+
profile.managed_outbound_i_ps = None
63+
# ips -> i_ps due to track 2 naming issue
64+
profile.outbound_i_ps = None
6365
profile.outbound_ip_prefixes = None
6466
if managed_outbound_ip_count:
65-
profile.managed_outbound_ips = ManagedClusterLoadBalancerProfileManagedOutboundIPs(
67+
# ips -> i_ps due to track 2 naming issue
68+
profile.managed_outbound_i_ps = ManagedClusterLoadBalancerProfileManagedOutboundIPs(
6669
count=managed_outbound_ip_count
6770
)
6871
if outbound_ip_resources:
69-
profile.outbound_ips = ManagedClusterLoadBalancerProfileOutboundIPs(
70-
public_ips=outbound_ip_resources
72+
# ips -> i_ps due to track 2 naming issue
73+
profile.outbound_i_ps = ManagedClusterLoadBalancerProfileOutboundIPs(
74+
public_i_ps=outbound_ip_resources
7175
)
7276
if outbound_ip_prefix_resources:
7377
profile.outbound_ip_prefixes = ManagedClusterLoadBalancerProfileOutboundIPPrefixes(

src/aks-preview/azext_aks_preview/commands.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ def load_command_table(self, _):
2424
managed_clusters_sdk = CliCommandType(
2525
operations_tmpl='azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks.'
2626
'operations._managed_clusters_operations#ManagedClustersOperations.{}',
27+
operation_group='managed_clusters',
2728
client_factory=cf_managed_clusters
2829
)
2930

3031
container_services_sdk = CliCommandType(
3132
operations_tmpl='azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks.'
3233
'operations.container_service_operations#ContainerServicesOperations.{}',
34+
operation_group='container_services',
3335
client_factory=cf_container_services
3436
)
3537

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

7476
# AKS container service commands

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
ManagedClusterIdentity,
7474
ManagedClusterAPIServerAccessProfile,
7575
ManagedClusterSKU,
76-
ManagedClusterIdentityUserAssignedIdentitiesValue,
76+
Components1Umhcm8SchemasManagedclusteridentityPropertiesUserassignedidentitiesAdditionalproperties,
7777
ManagedClusterAutoUpgradeProfile,
7878
KubeletConfig,
7979
LinuxOSConfig,
@@ -83,7 +83,7 @@
8383
ManagedClusterPodIdentityException,
8484
UserAssignedIdentity,
8585
RunCommandRequest,
86-
ManagedClusterPropertiesIdentityProfileValue)
86+
ComponentsQit0EtSchemasManagedclusterpropertiesPropertiesIdentityprofileAdditionalproperties)
8787
from ._client_factory import cf_resource_groups
8888
from ._client_factory import get_auth_management_client
8989
from ._client_factory import get_graph_rbac_management_client
@@ -1293,7 +1293,8 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
12931293
aad_profile = ManagedClusterAADProfile(
12941294
managed=True,
12951295
enable_azure_rbac=enable_azure_rbac,
1296-
admin_group_object_ids=_parse_comma_separated_list(
1296+
# ids -> i_ds due to track 2 naming issue
1297+
admin_group_object_i_ds=_parse_comma_separated_list(
12971298
aad_admin_group_object_ids),
12981299
tenant_id=aad_tenant_id
12991300
)
@@ -1334,7 +1335,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
13341335
)
13351336
elif enable_managed_identity and assign_identity:
13361337
user_assigned_identity = {
1337-
assign_identity: ManagedClusterIdentityUserAssignedIdentitiesValue()
1338+
assign_identity: Components1Umhcm8SchemasManagedclusteridentityPropertiesUserassignedidentitiesAdditionalproperties()
13381339
}
13391340
identity = ManagedClusterIdentity(
13401341
type="UserAssigned",
@@ -1347,7 +1348,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
13471348
raise CLIError('--assign-kubelet-identity can only be specified when --assign-identity is specified')
13481349
kubelet_identity = _get_user_assigned_identity(cmd.cli_ctx, assign_kubelet_identity)
13491350
identity_profile = {
1350-
'kubeletidentity': ManagedClusterPropertiesIdentityProfileValue(
1351+
'kubeletidentity': ComponentsQit0EtSchemasManagedclusterpropertiesPropertiesIdentityprofileAdditionalproperties(
13511352
resource_id=assign_kubelet_identity,
13521353
client_id=kubelet_identity.client_id,
13531354
object_id=kubelet_identity.principal_id
@@ -1733,7 +1734,8 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
17331734
if aad_tenant_id is not None:
17341735
instance.aad_profile.tenant_id = aad_tenant_id
17351736
if aad_admin_group_object_ids is not None:
1736-
instance.aad_profile.admin_group_object_ids = _parse_comma_separated_list(
1737+
# ids -> i_ds due to track 2 naming issue
1738+
instance.aad_profile.admin_group_object_i_ds = _parse_comma_separated_list(
17371739
aad_admin_group_object_ids)
17381740
if enable_azure_rbac and disable_azure_rbac:
17391741
raise CLIError(
@@ -1807,7 +1809,7 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
18071809
)
18081810
elif goal_identity_type == "userassigned":
18091811
user_assigned_identity = {
1810-
assign_identity: ManagedClusterIdentityUserAssignedIdentitiesValue()
1812+
assign_identity: Components1Umhcm8SchemasManagedclusteridentityPropertiesUserassignedidentitiesAdditionalproperties()
18111813
}
18121814
instance.identity = ManagedClusterIdentity(
18131815
type="UserAssigned",
@@ -2171,7 +2173,7 @@ def aks_scale(cmd, # pylint: disable=unused-argument
21712173
# null out the SP and AAD profile because otherwise validation complains
21722174
instance.service_principal_profile = None
21732175
instance.aad_profile = None
2174-
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, name, instance)
2176+
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, name, instance)
21752177
raise CLIError('The nodepool "{}" was not found.'.format(nodepool_name))
21762178

21772179

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

22642266
headers = get_aks_custom_headers(aks_custom_headers)
22652267

2266-
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, name, instance, custom_headers=headers)
2268+
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, name, instance, headers=headers)
22672269

22682270

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

2283-
commandResultFuture = client.run_command(
2284-
resource_group_name, name, request_payload, long_running_operation_timeout=5, retry_total=0)
2285+
commandResultFuture = client.begin_run_command(
2286+
resource_group_name, name, request_payload, polling_interval=5, retry_total=0)
22852287

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

@@ -2376,7 +2378,7 @@ def _get_dataplane_aad_token(cli_ctx, serverAppId):
23762378

23772379

23782380
def _upgrade_single_nodepool_image_version(no_wait, client, resource_group_name, cluster_name, nodepool_name):
2379-
return sdk_no_wait(no_wait, client.upgrade_node_image_version, resource_group_name, cluster_name, nodepool_name)
2381+
return sdk_no_wait(no_wait, client.begin_upgrade_node_image_version, resource_group_name, cluster_name, nodepool_name)
23802382

23812383

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

31003102
headers = get_aks_custom_headers(aks_custom_headers)
3101-
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, nodepool_name, agent_pool, custom_headers=headers)
3103+
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, nodepool_name, agent_pool, headers=headers)
31023104

31033105

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

31213123

31223124
def aks_agentpool_upgrade(cmd, # pylint: disable=unused-argument
@@ -3148,7 +3150,7 @@ def aks_agentpool_upgrade(cmd, # pylint: disable=unused-argument
31483150
if max_surge:
31493151
instance.upgrade_settings.max_surge = max_surge
31503152

3151-
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, nodepool_name, instance)
3153+
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, nodepool_name, instance)
31523154

31533155

31543156
def aks_agentpool_get_upgrade_profile(cmd, # pylint: disable=unused-argument
@@ -3230,7 +3232,7 @@ def aks_agentpool_update(cmd, # pylint: disable=unused-argument
32303232
if mode is not None:
32313233
instance.mode = mode
32323234

3233-
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, cluster_name, nodepool_name, instance)
3235+
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, cluster_name, nodepool_name, instance)
32343236

32353237

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

3253-
return sdk_no_wait(no_wait, client.delete, resource_group_name, cluster_name, nodepool_name)
3255+
return sdk_no_wait(no_wait, client.begin_delete, resource_group_name, cluster_name, nodepool_name)
32543256

32553257

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

32713273
# send the managed cluster representation to update the addon profiles
3272-
return sdk_no_wait(no_wait, client.create_or_update, resource_group_name, name, instance)
3274+
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, name, instance)
32733275

32743276

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

33273329
else:
3328-
result = sdk_no_wait(no_wait, client.create_or_update,
3330+
result = sdk_no_wait(no_wait, client.begin_create_or_update,
33293331
resource_group_name, name, instance)
33303332
return result
33313333

33323334

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

33363338

33373339
def _update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements
@@ -3797,11 +3799,11 @@ def _put_managed_cluster_ensuring_permission(
37973799
need_grant_vnet_permission_to_cluster_identity)
37983800
if need_post_creation_role_assignment:
37993801
# adding a wait here since we rely on the result for role assignment
3800-
cluster = LongRunningOperation(cmd.cli_ctx)(client.create_or_update(
3802+
cluster = LongRunningOperation(cmd.cli_ctx)(client.begin_create_or_update(
38013803
resource_group_name=resource_group_name,
38023804
resource_name=name,
38033805
parameters=managed_cluster,
3804-
custom_headers=headers))
3806+
headers=headers))
38053807
cloud_name = cmd.cli_ctx.cloud.name
38063808
# add cluster spn/msi Monitoring Metrics Publisher role assignment to publish metrics to MDM
38073809
# mdm metrics is supported only in azure public cloud, so add the role assignment only in this cloud
@@ -3840,11 +3842,11 @@ def _put_managed_cluster_ensuring_permission(
38403842
acr_name_or_id=attach_acr,
38413843
subscription_id=subscription_id)
38423844
else:
3843-
cluster = sdk_no_wait(no_wait, client.create_or_update,
3845+
cluster = sdk_no_wait(no_wait, client.begin_create_or_update,
38443846
resource_group_name=resource_group_name,
38453847
resource_name=name,
38463848
parameters=managed_cluster,
3847-
custom_headers=headers)
3849+
headers=headers)
38483850

38493851
return cluster
38503852

@@ -4083,7 +4085,7 @@ def aks_pod_identity_add(cmd, client, resource_group_name, cluster_name,
40834085
)
40844086

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

40884090

40894091
def aks_pod_identity_delete(cmd, client, resource_group_name, cluster_name,
@@ -4107,7 +4109,7 @@ def aks_pod_identity_delete(cmd, client, resource_group_name, cluster_name,
41074109
)
41084110

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

41124114

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

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

41394141

41404142
def aks_pod_identity_exception_delete(cmd, client, resource_group_name, cluster_name,
@@ -4157,7 +4159,7 @@ def aks_pod_identity_exception_delete(cmd, client, resource_group_name, cluster_
41574159
)
41584160

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

41624164

41634165
def aks_pod_identity_exception_update(cmd, client, resource_group_name, cluster_name,
@@ -4188,7 +4190,7 @@ def aks_pod_identity_exception_update(cmd, client, resource_group_name, cluster_
41884190
)
41894191

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

41934195

41944196
def aks_pod_identity_exception_list(cmd, client, resource_group_name, cluster_name):

0 commit comments

Comments
 (0)