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
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