summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJeffrey Zhang <zhang.lei.fly@gmail.com>2018-05-26 23:32:12 +0800
committerMonty Taylor <mordred@redhat.com>2018-05-26 08:32:12 -0700
commitf488d3cf79767482e9e07ef23215a6058f7722fc (patch)
tree684224637a5a04fbfcfb88208d5340cfe2b6927f /lib
parent78023e79d75ca98cf76c2ff24fae517c4a2d8da5 (diff)
downloadansible-f488d3cf79767482e9e07ef23215a6058f7722fc.tar.gz
Fail with more meaningful message when the volume can not be found (#37508)
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/modules/cloud/openstack/os_server_volume.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/ansible/modules/cloud/openstack/os_server_volume.py b/lib/ansible/modules/cloud/openstack/os_server_volume.py
index 5191115538..ded0b5c9c3 100644
--- a/lib/ansible/modules/cloud/openstack/os_server_volume.py
+++ b/lib/ansible/modules/cloud/openstack/os_server_volume.py
@@ -100,6 +100,10 @@ def main():
try:
server = cloud.get_server(module.params['server'])
volume = cloud.get_volume(module.params['volume'])
+
+ if not volume:
+ module.fail_json(msg='volume %s is not found' % module.params['volume'])
+
dev = cloud.get_volume_attach_device(volume, server.id)
if module.check_mode: