|
|
@ -86,6 +86,12 @@ options:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Ignored. Present for backwards compatability
|
|
|
|
- Ignored. Present for backwards compatability
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
extra_specs:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Metadata dictionary
|
|
|
|
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: None
|
|
|
|
|
|
|
|
version_added: "2.3"
|
|
|
|
requirements: ["shade"]
|
|
|
|
requirements: ["shade"]
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
@ -105,6 +111,18 @@ EXAMPLES = '''
|
|
|
|
cloud: mycloud
|
|
|
|
cloud: mycloud
|
|
|
|
state: absent
|
|
|
|
state: absent
|
|
|
|
name: tiny
|
|
|
|
name: tiny
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Create flavor with metadata
|
|
|
|
|
|
|
|
os_nova_flavor:
|
|
|
|
|
|
|
|
cloud: mycloud
|
|
|
|
|
|
|
|
state: present
|
|
|
|
|
|
|
|
name: tiny
|
|
|
|
|
|
|
|
ram: 1024
|
|
|
|
|
|
|
|
vcpus: 1
|
|
|
|
|
|
|
|
disk: 10
|
|
|
|
|
|
|
|
extra_specs:
|
|
|
|
|
|
|
|
"quota:disk_read_iops_sec": 5000
|
|
|
|
|
|
|
|
"aggregate_instance_extra_specs:pinned": false
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
RETURN = '''
|
|
|
@ -153,6 +171,13 @@ flavor:
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
sample: true
|
|
|
|
sample: true
|
|
|
|
|
|
|
|
extra_specs:
|
|
|
|
|
|
|
|
description: Flavor metadata
|
|
|
|
|
|
|
|
returned: success
|
|
|
|
|
|
|
|
type: dict
|
|
|
|
|
|
|
|
sample:
|
|
|
|
|
|
|
|
"quota:disk_read_iops_sec": 5000
|
|
|
|
|
|
|
|
"aggregate_instance_extra_specs:pinned": false
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -187,6 +212,7 @@ def main():
|
|
|
|
rxtx_factor = dict(required=False, default=1.0, type='float'),
|
|
|
|
rxtx_factor = dict(required=False, default=1.0, type='float'),
|
|
|
|
is_public = dict(required=False, default=True, type='bool'),
|
|
|
|
is_public = dict(required=False, default=True, type='bool'),
|
|
|
|
flavorid = dict(required=False, default="auto"),
|
|
|
|
flavorid = dict(required=False, default="auto"),
|
|
|
|
|
|
|
|
extra_specs = dict(required=False, default=None, type='dict'),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
module_kwargs = openstack_module_kwargs()
|
|
|
|
module_kwargs = openstack_module_kwargs()
|
|
|
@ -203,6 +229,7 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
state = module.params['state']
|
|
|
|
state = module.params['state']
|
|
|
|
name = module.params['name']
|
|
|
|
name = module.params['name']
|
|
|
|
|
|
|
|
extra_specs = module.params['extra_specs'] or {}
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
cloud = shade.operator_cloud(**module.params)
|
|
|
|
cloud = shade.operator_cloud(**module.params)
|
|
|
@ -228,6 +255,18 @@ def main():
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
changed=False
|
|
|
|
changed=False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
old_extra_specs = flavor['extra_specs']
|
|
|
|
|
|
|
|
new_extra_specs = dict([(k, str(v)) for k, v in extra_specs.items()])
|
|
|
|
|
|
|
|
unset_keys = set(flavor['extra_specs'].keys()) - set(extra_specs.keys())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if unset_keys:
|
|
|
|
|
|
|
|
cloud.unset_flavor_specs(flavor['id'], unset_keys)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if old_extra_specs != new_extra_specs:
|
|
|
|
|
|
|
|
cloud.set_flavor_specs(flavor['id'], extra_specs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
changed = (changed or old_extra_specs != new_extra_specs)
|
|
|
|
|
|
|
|
|
|
|
|
module.exit_json(changed=changed,
|
|
|
|
module.exit_json(changed=changed,
|
|
|
|
flavor=flavor,
|
|
|
|
flavor=flavor,
|
|
|
|
id=flavor['id'])
|
|
|
|
id=flavor['id'])
|
|
|
|