mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #19320 from manics/ansible-modules-core/pull/5176
Allow creation of Openstack volumes from an existing volume
This commit is contained in:
commit
c950767898
1 changed files with 14 additions and 1 deletions
|
@ -67,6 +67,12 @@ options:
|
|||
- Volume snapshot id to create from
|
||||
required: false
|
||||
default: None
|
||||
volume:
|
||||
description:
|
||||
- Volume name or id to create from
|
||||
required: false
|
||||
default: None
|
||||
version_added: "2.3"
|
||||
state:
|
||||
description:
|
||||
- Should the resource be present or absent.
|
||||
|
@ -109,6 +115,12 @@ def _present_volume(module, cloud):
|
|||
image_id = cloud.get_image_id(module.params['image'])
|
||||
volume_args['imageRef'] = image_id
|
||||
|
||||
if module.params['volume']:
|
||||
volume_id = cloud.get_volume_id(module.params['volume'])
|
||||
if not volume_id:
|
||||
module.fail_json(msg="Failed to find volume '%s'" % module.params['volume'])
|
||||
volume_args['source_volid'] = volume_id
|
||||
|
||||
volume = cloud.create_volume(
|
||||
wait=module.params['wait'], timeout=module.params['timeout'],
|
||||
**volume_args)
|
||||
|
@ -134,11 +146,12 @@ def main():
|
|||
display_description=dict(default=None, aliases=['description']),
|
||||
image=dict(default=None),
|
||||
snapshot_id=dict(default=None),
|
||||
volume=dict(default=None),
|
||||
state=dict(default='present', choices=['absent', 'present']),
|
||||
)
|
||||
module_kwargs = openstack_module_kwargs(
|
||||
mutually_exclusive=[
|
||||
['image', 'snapshot_id'],
|
||||
['image', 'snapshot_id', 'volume'],
|
||||
],
|
||||
)
|
||||
module = AnsibleModule(argument_spec=argument_spec, **module_kwargs)
|
||||
|
|
Loading…
Reference in a new issue