mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cs_service_offering: Implement customizable compute offers (#54597)
This commit is contained in:
parent
2ef0946370
commit
b0d0a3a2f8
2 changed files with 64 additions and 1 deletions
|
@ -162,6 +162,11 @@ options:
|
||||||
type: list
|
type: list
|
||||||
aliases:
|
aliases:
|
||||||
- storage_tag
|
- storage_tag
|
||||||
|
is_customized:
|
||||||
|
description:
|
||||||
|
- Whether the offering is customizable or not.
|
||||||
|
type: bool
|
||||||
|
version_added: '2.8'
|
||||||
extends_documentation_fragment: cloudstack
|
extends_documentation_fragment: cloudstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -203,6 +208,16 @@ EXAMPLES = '''
|
||||||
storage_tags: eco
|
storage_tags: eco
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Create or update a custom compute service offering
|
||||||
|
cs_service_offering:
|
||||||
|
name: custom
|
||||||
|
display_text: custom compute offer
|
||||||
|
is_customized: yes
|
||||||
|
storage_type: shared
|
||||||
|
host_tags: eco
|
||||||
|
storage_tags: eco
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Remove a compute service offering
|
- name: Remove a compute service offering
|
||||||
cs_service_offering:
|
cs_service_offering:
|
||||||
name: Tiny
|
name: Tiny
|
||||||
|
@ -362,6 +377,12 @@ network_rate:
|
||||||
returned: success
|
returned: success
|
||||||
type: int
|
type: int
|
||||||
sample: 1000
|
sample: 1000
|
||||||
|
is_customized:
|
||||||
|
description: Whether the offering is customizable or not
|
||||||
|
returned: success
|
||||||
|
type: bool
|
||||||
|
sample: false
|
||||||
|
version_added: '2.8'
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
@ -470,7 +491,8 @@ class AnsibleCloudStackServiceOffering(AnsibleCloudStack):
|
||||||
'storagetype': self.module.params.get('storage_type'),
|
'storagetype': self.module.params.get('storage_type'),
|
||||||
'systemvmtype': system_vm_type,
|
'systemvmtype': system_vm_type,
|
||||||
'tags': self.module.params.get('storage_tags'),
|
'tags': self.module.params.get('storage_tags'),
|
||||||
'limitcpuuse': self.module.params.get('limit_cpu_usage')
|
'limitcpuuse': self.module.params.get('limit_cpu_usage'),
|
||||||
|
'customized': self.module.params.get('is_customized')
|
||||||
}
|
}
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
res = self.query_api('createServiceOffering', **args)
|
res = self.query_api('createServiceOffering', **args)
|
||||||
|
@ -536,6 +558,7 @@ def main():
|
||||||
system_vm_type=dict(choices=['domainrouter', 'consoleproxy', 'secondarystoragevm']),
|
system_vm_type=dict(choices=['domainrouter', 'consoleproxy', 'secondarystoragevm']),
|
||||||
storage_tags=dict(type='list', aliases=['storage_tag']),
|
storage_tags=dict(type='list', aliases=['storage_tag']),
|
||||||
state=dict(choices=['present', 'absent'], default='present'),
|
state=dict(choices=['present', 'absent'], default='present'),
|
||||||
|
is_customized=dict(type='bool'),
|
||||||
))
|
))
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|
|
@ -181,3 +181,43 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- so is not changed
|
- so is not changed
|
||||||
|
|
||||||
|
- name: create custom service offering
|
||||||
|
cs_service_offering:
|
||||||
|
name: custom
|
||||||
|
display_text: custom offer
|
||||||
|
is_customized: yes
|
||||||
|
host_tags: eco
|
||||||
|
storage_tags:
|
||||||
|
- eco
|
||||||
|
- backup
|
||||||
|
storage_type: local
|
||||||
|
register: so
|
||||||
|
- name: verify create custom service offering
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- so is changed
|
||||||
|
- so.name == "custom"
|
||||||
|
- so.display_text == "custom offer"
|
||||||
|
- so.is_customized == True
|
||||||
|
- so.cpu_number is not defined
|
||||||
|
- so.cpu_speed is not defined
|
||||||
|
- so.memory is not defined
|
||||||
|
- so.host_tags == ['eco']
|
||||||
|
- so.storage_tags == ['eco', 'backup']
|
||||||
|
- so.storage_type == "local"
|
||||||
|
|
||||||
|
- name: remove custom service offering
|
||||||
|
cs_service_offering:
|
||||||
|
name: custom
|
||||||
|
state: absent
|
||||||
|
register: so
|
||||||
|
- name: verify remove service offering
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- so is changed
|
||||||
|
- so.name == "custom"
|
||||||
|
- so.display_text == "custom offer"
|
||||||
|
- so.host_tags == ['eco']
|
||||||
|
- so.storage_tags == ['eco', 'backup']
|
||||||
|
- so.storage_type == "local"
|
||||||
|
|
Loading…
Reference in a new issue