Attach an attached/detached volume from OpenStack VM’s should return similar information (#21558)

Currently, attach an attached volume from OpenStack VM’s returns only
argument data. It is better to return full data as attaching a detached
volume.

In my use case, I need the extra data to mount and format the volume.
This commit is contained in:
phongle1205 2019-10-20 14:06:50 +07:00 committed by Abhijeet Kasurde
parent 78158c2e63
commit 331d51fb16
2 changed files with 8 additions and 7 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- Attach an attached/detached volume from OpenStack VM's should return similar information in os_server_volume module.

View file

@ -110,19 +110,18 @@ def main():
module.exit_json(changed=_system_state_change(state, dev))
if state == 'present':
if dev:
# Volume is already attached to this server
module.exit_json(changed=False)
cloud.attach_volume(server, volume, module.params['device'],
wait=wait, timeout=timeout)
changed = False
if not dev:
changed = True
cloud.attach_volume(server, volume, module.params['device'],
wait=wait, timeout=timeout)
server = cloud.get_server(module.params['server']) # refresh
volume = cloud.get_volume(module.params['volume']) # refresh
hostvars = cloud.get_openstack_vars(server)
module.exit_json(
changed=True,
changed=changed,
id=volume['id'],
attachments=volume['attachments'],
openstack=hostvars