summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorin Hochstein <lorinh@gmail.com>2015-03-07 16:46:39 -0500
committerLorin Hochstein <lorinh@gmail.com>2015-03-07 16:46:39 -0500
commitbfe8dcc397da0c9cc103752659022e0d0facf0b5 (patch)
tree3fcaf50e0461a341688019119e9c6c844add4e01
parent451dcdeadfd35615a867d5e59a684e4aa82959ae (diff)
parentda68aab8fb7c21729da3ca1a32b25a6c741ab235 (diff)
downloadopenstack-ansible-modules-bfe8dcc397da0c9cc103752659022e0d0facf0b5.tar.gz
Merge pull request #36 from ssssam/ssssam/allow-no-rules-update
neutron_sec_group: Fix error if 'rules' parameter isn't supplied
-rw-r--r--neutron_sec_group19
1 files changed, 16 insertions, 3 deletions
diff --git a/neutron_sec_group b/neutron_sec_group
index 518c50e..f397e0a 100644
--- a/neutron_sec_group
+++ b/neutron_sec_group
@@ -237,9 +237,21 @@ def _update_sg(module, network_client, sg):
sg = sg['security_group']
changed = True
- # Security rules group update
+ if module.params['rules'] is not None:
+ rules_changed = _update_sg_rules(module, network_client, sg,
+ module.params['rules'])
+ changed |= rules_changed
+
+ return changed, sg
+
+
+def _update_sg_rules(module, network_client, sg, wanted_rules):
+ """
+ Updates rules of a security group.
+ """
+
+ changed = False
existing_rules = sg['security_group_rules']
- wanted_rules = module.params['rules']
#check ok
ok_rules = []
@@ -286,7 +298,8 @@ def _update_sg(module, network_client, sg):
sg = network_client.delete_security_group_rule(rule['id'])
changed = True
- return changed, sg
+ return changed
+
def _create_sg_rules(network_client, sg, rules):
"""