Skip to content

Commit

Permalink
Add new feature storage_profile (#563)
Browse files Browse the repository at this point in the history
* Add new feature storage_profile

* remove ignore

* remove ignore 02
  • Loading branch information
Fred-sun authored Jul 22, 2021
1 parent 356c17e commit adf6c9d
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 39 deletions.
4 changes: 2 additions & 2 deletions plugins/modules/azure_rm_apimanagementservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
- present
extends_documentation_fragment:
- azure
- azure_tags
- azure.azcollection.azure
- azure.azcollection.azure_tags
author:
- Nikhil Patne (@nikhilpatne)
- Sakar Mehra (@sakar97)
Expand Down
77 changes: 68 additions & 9 deletions plugins/modules/azure_rm_mysqlserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,71 @@
description:
- The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
required: True
type: str
name:
description:
- The name of the server.
required: True
type: str
sku:
description:
- The SKU (pricing tier) of the server.
type: dict
suboptions:
name:
description:
- The name of the sku, typically, tier + family + cores, for example C(B_Gen4_1), C(GP_Gen5_8).
type: str
tier:
description:
- The tier of the particular SKU, for example C(Basic).
type: str
choices:
- basic
- standard
capacity:
description:
- The scale up/out capacity, representing server's compute units.
type: str
size:
description:
- The size code, to be interpreted by resource as appropriate.
type: int
location:
description:
- Resource location. If not set, location from the resource group will be used as default.
storage_mb:
type: str
storage_profile:
description:
- The maximum storage allowed for a server.
type: int
- Storage Profile properties of a server.
type: dict
suboptions:
storage_mb:
description:
- The maximum storage allowed for a server.
type: int
backup_retention_days:
description:
- Backup retention days for the server
type: int
geo_redundant_backup:
description:
- Enable Geo-redundant or not for server backup.
type: str
choices:
- Disabled
- Enabled
storage_autogrow:
description:
- Enable Storage Auto Grow.
type: str
choices:
- Disabled
- Enabled
version:
description:
- Server version.
type: str
choices:
- 5.6
- 5.7
Expand All @@ -65,18 +97,23 @@
default: False
admin_username:
description:
- The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation).
- The administrator's login name of a server.
- Can only be specified when the server is being created (and is required for creation).
type: str
admin_password:
description:
- The password of the administrator login.
type: str
create_mode:
description:
- Create mode of SQL Server.
default: Default
type: str
state:
description:
- Assert the state of the MySQL Server. Use C(present) to create or update a server and C(absent) to delete it.
default: present
type: str
choices:
- absent
- present
Expand All @@ -99,7 +136,11 @@
name: B_Gen5_1
tier: Basic
location: eastus
storage_mb: 1024
storage_profile:
storage_mb: 51200
backup_retention_days: 7
geo_redundant_backup: Disabled
storage_autogrow: Disabled
enforce_ssl: True
version: 5.6
admin_username: cloudsa
Expand Down Expand Up @@ -145,6 +186,23 @@
# This is handled in azure_rm_common
pass

storage_profile_spec = dict(
storage_mb=dict(
type='int'
),
backup_retention_days=dict(
type='int'
),
geo_redundant_backup=dict(
type='str',
choices=['Disabled', 'Enabled']
),
storage_autogrow=dict(
type='str',
choices=['Disabled', 'Enabled']
)
)


class Actions:
NoAction, Create, Update, Delete = range(4)
Expand All @@ -169,8 +227,9 @@ def __init__(self):
location=dict(
type='str'
),
storage_mb=dict(
type='int'
storage_profile=dict(
type='dict',
options=storage_profile_spec
),
version=dict(
type='str',
Expand Down Expand Up @@ -228,8 +287,8 @@ def exec_module(self, **kwargs):
self.parameters["sku"] = ev
elif key == "location":
self.parameters["location"] = kwargs[key]
elif key == "storage_mb":
self.parameters.setdefault("properties", {}).setdefault("storage_profile", {})["storage_mb"] = kwargs[key]
elif key == "storage_profile":
self.parameters.setdefault("properties", {})["storage_profile"] = kwargs[key]
elif key == "version":
self.parameters.setdefault("properties", {})["version"] = kwargs[key]
elif key == "enforce_ssl":
Expand Down
44 changes: 31 additions & 13 deletions plugins/modules/azure_rm_mysqlserver_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@
description:
- The name of the server.
type: str
tags:
description:
- Limit results by providing a list of tags. Format tags as 'key' or 'key:value'.
type: list
extends_documentation_fragment:
- azure.azcollection.azure
- azure.azcollection.azure_tags
author:
- Zim Kalinowski (@zikalino)
Expand Down Expand Up @@ -105,12 +102,36 @@
returned: always
type: int
sample: 2
storage_mb:
storage_profile:
description:
- The maximum storage allowed for a server.
- Storage Profile properties of a server.
type: complex
returned: always
type: int
sample: 128000
contains:
storage_mb:
description:
- The maximum storage allowed for a server.
returned: always
type: int
sample: 128000
backup_retention_days:
description:
- Backup retention days for the server
returned: always
type: int
sample: 7
geo_redundant_backup:
description:
- Enable Geo-redundant or not for server backup.
returned: always
type: str
sample: Disabled
storage_autogrow:
description:
- Enable Storage Auto Grow.
returned: always
type: str
sample: Disabled
enforce_ssl:
description:
- Enable SSL enforcement.
Expand Down Expand Up @@ -168,9 +189,6 @@ def __init__(self):
),
name=dict(
type='str'
),
tags=dict(
type='list'
)
)
# store the results of the module operation
Expand All @@ -180,7 +198,7 @@ def __init__(self):
self.resource_group = None
self.name = None
self.tags = None
super(AzureRMMySqlServerInfo, self).__init__(self.module_arg_spec, supports_tags=False)
super(AzureRMMySqlServerInfo, self).__init__(self.module_arg_spec, supports_tags=True)

def exec_module(self, **kwargs):
is_old_facts = self.module._name == 'azure_rm_mysqlserver_facts'
Expand Down Expand Up @@ -236,7 +254,7 @@ def format_item(self, item):
'name': d['name'],
'sku': d['sku'],
'location': d['location'],
'storage_mb': d['storage_profile']['storage_mb'],
'storage_profile': d['storage_profile'],
'version': d['version'],
'enforce_ssl': (d['ssl_enforcement'] == 'Enabled'),
'admin_username': d['administrator_login'],
Expand Down
38 changes: 31 additions & 7 deletions tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
name: B_Gen5_1
tier: Basic
location: westus2
storage_mb: 51200
storage_profile:
storage_mb: 51200
backup_retention_days: 7
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.6
enforce_ssl: True
admin_username: zimxyz
Expand All @@ -31,7 +35,11 @@
name: B_Gen5_1
tier: Basic
location: westus2
storage_mb: 51200
storage_profile:
storage_mb: 51200
backup_retention_days: 7
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.6
enforce_ssl: True
admin_username: zimxyz
Expand All @@ -51,7 +59,11 @@
name: B_Gen5_1
tier: Basic
location: westus2
storage_mb: 51200
storage_profile:
storage_mb: 51200
backup_retention_days: 7
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.6
enforce_ssl: True
admin_username: zimxyz
Expand All @@ -71,7 +83,11 @@
name: B_Gen5_1
tier: Basic
location: westus2
storage_mb: 128000
storage_profile:
storage_mb: 128000
backup_retention_days: 7
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.6
enforce_ssl: True
admin_username: zimxyz
Expand All @@ -93,7 +109,7 @@
- name: Assert that storage size is correct
assert:
that:
- output.servers[0]['storage_mb'] == 128000
- output.servers[0]['storage_profile']['storage_mb'] == 128000

- name: Create second instance of MySQL Server
azure_rm_mysqlserver:
Expand All @@ -103,7 +119,11 @@
name: B_Gen5_1
tier: Basic
location: westus2
storage_mb: 51200
storage_profile:
storage_mb: 51200
backup_retention_days: 7
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.6
enforce_ssl: True
admin_username: zimxyz
Expand All @@ -119,7 +139,11 @@
name: B_Gen5_1
tier: Basic
location: westus2
storage_mb: 51200
storage_profile:
storage_mb: 51200
backup_retention_days: 7
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.6
enforce_ssl: True
admin_username: zimxyz
Expand Down
2 changes: 0 additions & 2 deletions tests/sanity/ignore-2.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ plugins/modules/azure_rm_mysqlconfiguration_info.py validate-modules:return-synt
plugins/modules/azure_rm_mysqldatabase.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:doc-required-mismatch
plugins/modules/azure_rm_mysqlserver.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlserver_info.py validate-modules:parameter-list-no-elements
plugins/modules/azure_rm_postgresqlconfiguration.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_postgresqlconfiguration_info.py validate-modules:return-syntax-error
plugins/modules/azure_rm_postgresqldatabase.py validate-modules:parameter-type-not-in-doc
Expand Down
2 changes: 0 additions & 2 deletions tests/sanity/ignore-2.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ plugins/modules/azure_rm_mysqlconfiguration_info.py validate-modules:return-synt
plugins/modules/azure_rm_mysqldatabase.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:doc-required-mismatch
plugins/modules/azure_rm_mysqlserver.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlserver_info.py validate-modules:parameter-list-no-elements
plugins/modules/azure_rm_postgresqlconfiguration.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_postgresqlconfiguration_info.py validate-modules:return-syntax-error
plugins/modules/azure_rm_postgresqldatabase.py validate-modules:parameter-type-not-in-doc
Expand Down
2 changes: 0 additions & 2 deletions tests/sanity/ignore-2.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ plugins/modules/azure_rm_mysqlconfiguration_info.py validate-modules:return-synt
plugins/modules/azure_rm_mysqldatabase.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:doc-required-mismatch
plugins/modules/azure_rm_mysqlserver.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlserver_info.py validate-modules:parameter-list-no-elements
plugins/modules/azure_rm_postgresqlconfiguration.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_postgresqlconfiguration_info.py validate-modules:return-syntax-error
plugins/modules/azure_rm_postgresqldatabase.py validate-modules:parameter-type-not-in-doc
Expand Down
2 changes: 0 additions & 2 deletions tests/sanity/ignore-2.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ plugins/modules/azure_rm_mariadbserver.py validate-modules:parameter-type-not-in
plugins/modules/azure_rm_mysqlconfiguration.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqldatabase.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_mysqlserver.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_postgresqlconfiguration.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_postgresqldatabase.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_postgresqlfirewallrule.py validate-modules:parameter-type-not-in-doc
Expand Down Expand Up @@ -164,7 +163,6 @@ plugins/modules/azure_rm_cdnprofile.py validate-modules:parameter-type-not-in-do
plugins/modules/azure_rm_cosmosdbaccount.py validate-modules:nonexistent-parameter-documented
plugins/modules/azure_rm_cosmosdbaccount_info.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_devtestlabschedule.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_apimanagementservice.py validate-modules:doc-default-does-not-match-spec
plugins/modules/azure_rm_hdinsightcluster_info.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_loadbalancer_info.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_loganalyticsworkspace_info.py validate-modules:parameter-type-not-in-doc
Expand Down

0 comments on commit adf6c9d

Please sign in to comment.