@ -61,8 +61,7 @@ options:
security_groups :
security_groups :
description :
description :
- Security group ( s ) ID ( s ) or name ( s ) associated with the port ( comma
- Security group ( s ) ID ( s ) or name ( s ) associated with the port ( comma
separated for multiple security groups - no spaces between comma ( s )
separated string or YAML list )
or YAML list ) .
required : false
required : false
default : None
default : None
no_security_groups :
no_security_groups :
@ -220,7 +219,7 @@ def _needs_update(module, port, cloud):
' device_id ' ]
' device_id ' ]
compare_dict = [ ' allowed_address_pairs ' ,
compare_dict = [ ' allowed_address_pairs ' ,
' extra_dhcp_opt ' ]
' extra_dhcp_opt ' ]
compare_ comma_separated_ list = [ ' security_groups ' ]
compare_ list = [ ' security_groups ' ]
for key in compare_simple :
for key in compare_simple :
if module . params [ key ] is not None and module . params [ key ] != port [ key ] :
if module . params [ key ] is not None and module . params [ key ] != port [ key ] :
@ -229,7 +228,7 @@ def _needs_update(module, port, cloud):
if module . params [ key ] is not None and cmp ( module . params [ key ] ,
if module . params [ key ] is not None and cmp ( module . params [ key ] ,
port [ key ] ) != 0 :
port [ key ] ) != 0 :
return True
return True
for key in compare_ comma_separated_ list:
for key in compare_ list:
if module . params [ key ] is not None and ( set ( module . params [ key ] ) !=
if module . params [ key ] is not None and ( set ( module . params [ key ] ) !=
set ( port [ key ] ) ) :
set ( port [ key ] ) ) :
return True
return True
@ -309,7 +308,7 @@ def main():
fixed_ips = dict ( default = None ) ,
fixed_ips = dict ( default = None ) ,
admin_state_up = dict ( default = None ) ,
admin_state_up = dict ( default = None ) ,
mac_address = dict ( default = None ) ,
mac_address = dict ( default = None ) ,
security_groups = dict ( default = None ),
security_groups = dict ( default = None , type = ' list ' ),
no_security_groups = dict ( default = False , type = ' bool ' ) ,
no_security_groups = dict ( default = False , type = ' bool ' ) ,
allowed_address_pairs = dict ( default = None ) ,
allowed_address_pairs = dict ( default = None ) ,
extra_dhcp_opt = dict ( default = None ) ,
extra_dhcp_opt = dict ( default = None ) ,
@ -336,13 +335,11 @@ def main():
try :
try :
cloud = shade . openstack_cloud ( * * module . params )
cloud = shade . openstack_cloud ( * * module . params )
if module . params [ ' security_groups ' ] :
if module . params [ ' security_groups ' ] :
if type ( module . params [ ' security_groups ' ] ) == str :
module . params [ ' security_groups ' ] = module . params [
' security_groups ' ] . split ( ' , ' )
# translate security_groups to UUID's if names where provided
# translate security_groups to UUID's if names where provided
module . params [ ' security_groups ' ] = map (
module . params [ ' security_groups ' ] = [
lambda v : get_security_group_id ( module , cloud , v ) ,
get_security_group_id ( module , cloud , v )
module . params [ ' security_groups ' ] )
for v in module . params [ ' security_groups ' ]
]
port = None
port = None
network_id = None
network_id = None