1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Deal with server.security_groups being None (#24742)

It shouldn't happen - but there is a bug in shade where it can be None
but should be [] instead. Work around it.

Fixes #24675
This commit is contained in:
Monty Taylor 2017-05-17 12:17:31 -05:00 committed by Matt Martz
parent 3ad09604f2
commit 6e85ac2ba6

View file

@ -631,7 +631,11 @@ def _check_security_groups(module, cloud, server):
return changed, server
module_security_groups = set(module.params['security_groups'])
server_security_groups = set(sg.name for sg in server.security_groups)
# Workaround a bug in shade <= 1.20.0
if server.security_groups is not None:
server_security_groups = set(sg.name for sg in server.security_groups)
else:
server_security_groups = set()
add_sgs = module_security_groups - server_security_groups
remove_sgs = server_security_groups - module_security_groups