From 729d094a728bb3ccb31307f72d8a9d10ff441dea Mon Sep 17 00:00:00 2001 From: Yunge Zhu <37337818+yungezz@users.noreply.github.com> Date: Fri, 23 Nov 2018 13:23:58 +0800 Subject: [PATCH] use explict conversion instead of as_dict (#49046) * use explict conversion instead of as_dict * fix typo --- .../cloud/azure/azure_rm_appserviceplan.py | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_appserviceplan.py b/lib/ansible/modules/cloud/azure/azure_rm_appserviceplan.py index d96833a801a..37886c4d568 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_appserviceplan.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_appserviceplan.py @@ -150,6 +150,30 @@ def get_sku_name(tier): return None +def appserviceplan_to_dict(plan): + return dict( + id=plan.id, + name=plan.name, + kind=plan.kind, + location=plan.location, + reserved=plan.reserved, + is_linux=plan.reserved, + provisioning_state=plan.provisioning_state, + status=plan.status, + target_worker_count=plan.target_worker_count, + sku=dict( + name=plan.sku.name, + size=plan.sku.size, + tier=plan.sku.tier, + family=plan.sku.family, + capacity=plan.sku.capacity + ), + resource_group=plan.resource_group, + number_of_sites=plan.number_of_sites, + tags=plan.tags if plan.tags else None + ) + + class AzureRMAppServicePlans(AzureRMModuleBase): """Configuration class for an Azure RM App Service Plan resource""" @@ -294,7 +318,7 @@ class AzureRMAppServicePlans(AzureRMModuleBase): self.log("Response : {0}".format(response)) self.log("App Service Plan : {0} found".format(response.name)) - return response.as_dict() + return appserviceplan_to_dict(response) except CloudError as ex: self.log("Didn't find app service plan {0} in resource group {1}".format(self.name, self.resource_group)) @@ -323,7 +347,7 @@ class AzureRMAppServicePlans(AzureRMModuleBase): self.log("Response : {0}".format(response)) - return response.as_dict() + return appserviceplan_to_dict(response) except CloudError as ex: self.fail("Failed to create app service plan {0} in resource group {1}: {2}".format(self.name, self.resource_group, str(ex)))