Skip to content

Commit

Permalink
resolve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Li Ma committed May 11, 2022
1 parent d8681f5 commit fe6906e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ def load_arguments(self, _):
c.argument('uptime_sla', action='store_true')
c.argument('fqdn_subdomain')
c.argument('api_server_authorized_ip_ranges', validator=validate_ip_ranges)
c.argument('enable_apiserver_vnet_integration', action='store_true', is_preview=True)
c.argument('apiserver_subnet_id', validator=validate_apiserver_subnet_id, is_preview=True)
c.argument('enable_private_cluster', action='store_true')
c.argument('private_dns_zone')
c.argument('disable_public_fqdn', action='store_true')
Expand Down Expand Up @@ -296,6 +294,8 @@ def load_arguments(self, _):
c.argument('message_of_the_day')
c.argument('gpu_instance_profile', arg_type=get_enum_type(gpu_instance_profiles))
c.argument('workload_runtime', arg_type=get_enum_type(workload_runtimes), default=CONST_WORKLOAD_RUNTIME_OCI_CONTAINER)
c.argument('enable_apiserver_vnet_integration', action='store_true', is_preview=True)
c.argument('apiserver_subnet_id', validator=validate_apiserver_subnet_id, is_preview=True)

with self.argument_context('aks update') as c:
# managed cluster paramerters
Expand Down
4 changes: 2 additions & 2 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,6 @@ def aks_create(cmd,
node_resource_group=None,
uptime_sla=False,
attach_acr=None,
enable_apiserver_vnet_integration=False,
apiserver_subnet_id=None,
enable_private_cluster=False,
private_dns_zone=None,
enable_managed_identity=True,
Expand Down Expand Up @@ -802,6 +800,8 @@ def aks_create(cmd,
message_of_the_day=None,
enable_azure_keyvault_kms=False,
azure_keyvault_kms_key_id=None,
enable_apiserver_vnet_integration=False,
apiserver_subnet_id=None,
yes=False):
# DO NOT MOVE: get all the original parameters and save them as a dictionary
raw_parameters = locals()
Expand Down
12 changes: 4 additions & 8 deletions src/aks-preview/azext_aks_preview/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2456,14 +2456,13 @@ def set_up_azure_keyvault_kms(self, mc: ManagedCluster) -> ManagedCluster:

return mc

def set_up_apiserver_vnet_integration(self, mc: ManagedCluster) -> ManagedCluster:
def set_up_api_server_access_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Set up apiserverAccessProfile enableVnetIntegration and subnetId for the ManagedCluster object.
:return: the ManagedCluster object
"""
mc = super().set_up_api_server_access_profile(mc)
if self.context.get_enable_apiserver_vnet_integration():
if mc.api_server_access_profile is None:
mc.api_server_access_profile = self.models.ManagedClusterAPIServerAccessProfile()
mc.api_server_access_profile.enable_vnet_integration = True
if self.context.get_apiserver_subnet_id():
mc.api_server_access_profile.subnet_id = self.context.get_apiserver_subnet_id()
Expand Down Expand Up @@ -2502,7 +2501,6 @@ def construct_mc_preview_profile(self) -> ManagedCluster:

mc = self.set_up_storage_profile(mc)

mc = self.set_up_apiserver_vnet_integration(mc)
return mc

def create_mc_preview(self, mc: ManagedCluster) -> ManagedCluster:
Expand Down Expand Up @@ -2877,13 +2875,12 @@ def update_identity_profile(self, mc: ManagedCluster) -> ManagedCluster:
mc.identity_profile = identity_profile
return mc

def update_apiserver_vnet_integration(self, mc: ManagedCluster) -> ManagedCluster:
def update_api_server_access_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Update apiServerAccessProfile vnet integration related property for the ManagedCluster object.
:return: the ManagedCluster object
"""
self._ensure_mc(mc)

mc = super().update_api_server_access_profile(mc)
if self.context.get_enable_apiserver_vnet_integration():
if mc.api_server_access_profile is None:
mc.api_server_access_profile = self.models.ManagedClusterAPIServerAccessProfile()
Expand Down Expand Up @@ -2937,7 +2934,6 @@ def update_mc_preview_profile(self) -> ManagedCluster:
mc = self.update_azure_keyvault_kms(mc)
# update identity profile
mc = self.update_identity_profile(mc)
mc = self.update_apiserver_vnet_integration(mc)

mc = self.update_storage_profile(mc)

Expand Down
16 changes: 10 additions & 6 deletions src/aks-preview/azext_aks_preview/tests/latest/test_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3283,7 +3283,7 @@ def test_set_up_azure_keyvault_kms(self):

self.assertEqual(dec_mc_2, ground_truth_mc_2)

def test_set_up_apiserver_vnet_integration(self):
def test_set_up_api_server_access_profile(self):
dec_1 = AKSPreviewCreateDecorator(
self.cmd,
self.client,
Expand All @@ -3293,7 +3293,7 @@ def test_set_up_apiserver_vnet_integration(self):
mc_1 = self.models.ManagedCluster(
location="test_location"
)
dec_mc_1 = dec_1.set_up_apiserver_vnet_integration(mc_1)
dec_mc_1 = dec_1.set_up_api_server_access_profile(mc_1)
ground_truth_mc_1 = self.models.ManagedCluster(
location="test_location"
)
Expand All @@ -3313,15 +3313,19 @@ def test_set_up_apiserver_vnet_integration(self):
CUSTOM_MGMT_AKS_PREVIEW,
)
mc_2 = self.models.ManagedCluster(location="test_location")
dec_mc_2 = dec_2.set_up_apiserver_vnet_integration(mc_2)
dec_mc_2 = dec_2.set_up_api_server_access_profile(mc_2)
ground_truth_api_server_access_profile_2 = self.models.ManagedClusterAPIServerAccessProfile(
enable_vnet_integration=True,
subnet_id=apiserver_subnet_id,
enable_private_cluster=True,
authorized_ip_ranges=[],
)
ground_truth_mc_2 = self.models.ManagedCluster(
location="test_location",
api_server_access_profile=ground_truth_api_server_access_profile_2,
)
print(dec_mc_2.api_server_access_profile)
print(ground_truth_api_server_access_profile_2)
self.assertEqual(dec_mc_2, ground_truth_mc_2)

def test_set_up_creationdata_of_cluster_snapshot(self):
Expand Down Expand Up @@ -4499,7 +4503,7 @@ def test_update_azure_keyvault_kms(self):

self.assertEqual(dec_mc_2, ground_truth_mc_2)

def test_update_apiserver_vnet_integration(self):
def test_update_api_server_access_profile(self):
dec_1 = AKSPreviewUpdateDecorator(
self.cmd,
self.client,
Expand All @@ -4510,7 +4514,7 @@ def test_update_apiserver_vnet_integration(self):
location="test_location",
)
dec_1.context.attach_mc(mc_1)
dec_mc_1 = dec_1.update_apiserver_vnet_integration(mc_1)
dec_mc_1 = dec_1.update_api_server_access_profile(mc_1)
ground_truth_mc_1 = self.models.ManagedCluster(
location="test_location",
)
Expand All @@ -4528,7 +4532,7 @@ def test_update_apiserver_vnet_integration(self):
)
mc_2 = self.models.ManagedCluster(location="test_location")
dec_2.context.attach_mc(mc_2)
dec_mc_2 = dec_2.update_apiserver_vnet_integration(mc_2)
dec_mc_2 = dec_2.update_api_server_access_profile(mc_2)
ground_truth_api_server_access_profile_2 = self.models.ManagedClusterAPIServerAccessProfile(
enable_vnet_integration=True,
subnet_id=apiserver_subnet_id,
Expand Down

0 comments on commit fe6906e

Please sign in to comment.