1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

use explict conversion instead of as_dict (#49046)

* use explict conversion instead of as_dict

* fix typo
This commit is contained in:
Yunge Zhu 2018-11-23 13:23:58 +08:00 committed by Zim Kalinowski
parent 438bd35729
commit 729d094a72

View file

@ -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)))