Skip to content

Commit 61fdcc4

Browse files
committed
fix tests
1 parent bbee6a0 commit 61fdcc4

7 files changed

Lines changed: 2886 additions & 2520 deletions

File tree

src/appservice-kube/azext_appservice_kube/_create_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def get_site_availability(cmd, name):
1414
""" This is used by az webapp up to verify if a site needs to be created or should just be deployed"""
1515
client = web_client_factory(cmd.cli_ctx)
16-
availability = client.check_name_availability(name, 'Site')
16+
availability = client.check_name_availability(request={"name": name, "type": "Site"})
1717

1818
# check for "." in app name. it is valid for hostnames to contain it, but not allowed for webapp names
1919
if "." in name:

src/appservice-kube/azext_appservice_kube/custom.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,10 @@ def _get_custom_location_id_from_kube_env(kube):
535535
def _ensure_kube_settings_in_json(appservice_plan_json, extended_location=None, kube_env=None):
536536
if appservice_plan_json.get("properties") and (appservice_plan_json["properties"].get("kubeEnvironmentProfile")
537537
is None and kube_env is not None):
538-
appservice_plan_json["properties"]["kubeEnvironmentProfile"] = kube_env.serialize()
538+
appservice_plan_json["properties"]["kubeEnvironmentProfile"] = kube_env.as_dict()
539539

540540
if appservice_plan_json.get("extendedLocation") is None and extended_location is not None:
541-
appservice_plan_json["extendedLocation"] = extended_location.serialize()
541+
appservice_plan_json["extendedLocation"] = extended_location.as_dict()
542542

543543
appservice_plan_json['type'] = 'Microsoft.Web/serverfarms'
544544
if appservice_plan_json.get("extendedLocation") is not None:
@@ -611,7 +611,7 @@ def create_app_service_plan_inner(cmd, resource_group_name, name, is_linux, hype
611611
reserved=(is_linux or None), hyper_v=(hyper_v or None), name=name,
612612
per_site_scaling=per_site_scaling, hosting_environment_profile=ase_def,
613613
kube_environment_profile=kube_def, extended_location=extended_location_envelope)
614-
plan_json = plan_def.serialize()
614+
plan_json = plan_def.as_dict()
615615
_ensure_kube_settings_in_json(appservice_plan_json=plan_json,
616616
extended_location=extended_location_envelope, kube_env=kube_def)
617617

@@ -621,7 +621,7 @@ def create_app_service_plan_inner(cmd, resource_group_name, name, is_linux, hype
621621

622622
def update_app_service_plan(cmd, resource_group_name, name, sku=None, number_of_workers=None, no_wait=False):
623623
client = web_client_factory(cmd.cli_ctx)
624-
plan = client.app_service_plans.get(resource_group_name, name).serialize()
624+
plan = client.app_service_plans.get(resource_group_name, name).as_dict()
625625
plan_with_kube_env = AppServiceClient.show(cmd=cmd, name=name, resource_group_name=resource_group_name)
626626

627627
if number_of_workers is None and sku is None:
@@ -770,14 +770,23 @@ def create_webapp(cmd, resource_group_name, name, plan=None, runtime=None, custo
770770
client = web_client_factory(cmd.cli_ctx)
771771
if is_valid_resource_id(plan):
772772
parse_result = parse_resource_id(plan)
773-
plan_info = AppServicePlan.from_dict(AppServiceClient.show(cmd=cmd, name=parse_result['name'],
774-
resource_group_name=parse_result["resource_group"]))
773+
plan_info = client.app_service_plans.get(parse_result["resource_group"], parse_result['name'])
775774
else:
776-
plan_info = AppServicePlan.from_dict(AppServiceClient.show(cmd=cmd,
777-
name=plan, resource_group_name=resource_group_name))
775+
plan_info = client.app_service_plans.get(resource_group_name, plan)
778776
if not plan_info:
779777
raise CLIError("The plan '{}' doesn't exist in the resource group '{}".format(plan, resource_group_name))
780778

779+
# Get extended location from raw API if needed for kube scenarios
780+
plan_raw = None
781+
if custom_location or (hasattr(plan_info, 'extended_location') and plan_info.extended_location):
782+
if is_valid_resource_id(plan):
783+
parse_result = parse_resource_id(plan)
784+
plan_raw = AppServiceClient.show(cmd=cmd, name=parse_result['name'],
785+
resource_group_name=parse_result["resource_group"])
786+
else:
787+
plan_raw = AppServiceClient.show(cmd=cmd, name=plan, resource_group_name=resource_group_name)
788+
raise CLIError("The plan '{}' doesn't exist in the resource group '{}".format(plan, resource_group_name))
789+
781790
if custom_location:
782791
_validate_asp_sku(app_service_environment=None, custom_location=custom_location, sku=plan_info.sku.name)
783792

@@ -805,8 +814,9 @@ def create_webapp(cmd, resource_group_name, name, plan=None, runtime=None, custo
805814
extended_loc = {'name': custom_location_id, 'type': 'CustomLocation'}
806815
webapp_def.additional_properties["extendedLocation"] = extended_loc
807816
else:
808-
extended_loc = plan_info.additional_properties["extendedLocation"]
809-
webapp_def.additional_properties["extendedLocation"] = extended_loc
817+
extended_loc = plan_raw.get("extendedLocation") if plan_raw else None
818+
if extended_loc:
819+
webapp_def.additional_properties["extendedLocation"] = extended_loc
810820

811821
if is_kube:
812822
if min_worker_count is not None:
@@ -1778,7 +1788,7 @@ def _update_host_name_ssl_state(cmd, resource_group_name, webapp_name, webapp,
17781788
thumbprint=thumbprint,
17791789
to_update=True)]
17801790

1781-
webapp_dict = webapp.serialize()
1791+
webapp_dict = webapp.as_dict()
17821792

17831793
if webapp.extended_location is not None:
17841794
webapp_dict["extendedLocation"]["type"] = "customLocation"

0 commit comments

Comments
 (0)