summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-04-03 17:36:49 +0000
committerGerrit Code Review <review@openstack.org>2015-04-03 17:36:49 +0000
commit2461883e499be5e3b6fb326aeef5a4b34d1ef174 (patch)
tree7e714d67e928c817e35dce0bd01545e73123fae4
parent58ae2c79768deaf9d2281272145de5b3d0b8b05e (diff)
parenta02fb68229346efe3764bf5f3caf4a724279dc3a (diff)
Merge "Fix GBP heat stack update handling"
-rw-r--r--gbpautomation/heat/engine/resources/neutron/grouppolicy.py60
-rw-r--r--gbpautomation/heat/tests/test_grouppolicy.py60
2 files changed, 117 insertions, 3 deletions
diff --git a/gbpautomation/heat/engine/resources/neutron/grouppolicy.py b/gbpautomation/heat/engine/resources/neutron/grouppolicy.py
index 932be8e..29b16c2 100644
--- a/gbpautomation/heat/engine/resources/neutron/grouppolicy.py
+++ b/gbpautomation/heat/engine/resources/neutron/grouppolicy.py
@@ -221,6 +221,36 @@ class PolicyTargetGroup(gbpresource.GBPResource):
221 221
222 def handle_update(self, json_snippet, tmpl_diff, prop_diff): 222 def handle_update(self, json_snippet, tmpl_diff, prop_diff):
223 if prop_diff: 223 if prop_diff:
224 provided_policy_rule_set_list = {}
225 consumed_policy_rule_set_list = {}
226 props_provided_policy_rule_sets = prop_diff.get(
227 'provided_policy_rule_sets', [])
228 props_consumed_policy_rule_sets = prop_diff.get(
229 'consumed_policy_rule_sets', [])
230
231 for prop_prov_policy_rule_set in props_provided_policy_rule_sets:
232 policy_rule_set_id = (
233 prop_prov_policy_rule_set['policy_rule_set_id'])
234 policy_rule_set_scope = (
235 prop_prov_policy_rule_set['policy_rule_set_scope'])
236 provided_policy_rule_set_list.update({policy_rule_set_id:
237 policy_rule_set_scope})
238
239 for prop_cons_policy_rule_set in props_consumed_policy_rule_sets:
240 policy_rule_set_id = (
241 prop_cons_policy_rule_set['policy_rule_set_id'])
242 policy_rule_set_scope = (
243 prop_cons_policy_rule_set['policy_rule_set_scope'])
244 consumed_policy_rule_set_list.update({policy_rule_set_id:
245 policy_rule_set_scope})
246
247 if provided_policy_rule_set_list:
248 prop_diff['provided_policy_rule_sets'] = (
249 provided_policy_rule_set_list)
250 if consumed_policy_rule_set_list:
251 prop_diff['consumed_policy_rule_sets'] = (
252 consumed_policy_rule_set_list)
253
224 self.grouppolicy().update_policy_target_group( 254 self.grouppolicy().update_policy_target_group(
225 self.resource_id, {'policy_target_group': prop_diff}) 255 self.resource_id, {'policy_target_group': prop_diff})
226 256
@@ -900,6 +930,36 @@ class ExternalPolicy(gbpresource.GBPResource):
900 930
901 def handle_update(self, json_snippet, tmpl_diff, prop_diff): 931 def handle_update(self, json_snippet, tmpl_diff, prop_diff):
902 if prop_diff: 932 if prop_diff:
933 provided_policy_rule_set_list = {}
934 consumed_policy_rule_set_list = {}
935 props_provided_policy_rule_sets = prop_diff.get(
936 'provided_policy_rule_sets', [])
937 props_consumed_policy_rule_sets = prop_diff.get(
938 'consumed_policy_rule_sets', [])
939
940 for prop_prov_policy_rule_set in props_provided_policy_rule_sets:
941 policy_rule_set_id = (
942 prop_prov_policy_rule_set['policy_rule_set_id'])
943 policy_rule_set_scope = (
944 prop_prov_policy_rule_set['policy_rule_set_scope'])
945 provided_policy_rule_set_list.update({policy_rule_set_id:
946 policy_rule_set_scope})
947
948 for prop_cons_policy_rule_set in props_consumed_policy_rule_sets:
949 policy_rule_set_id = (
950 prop_cons_policy_rule_set['policy_rule_set_id'])
951 policy_rule_set_scope = (
952 prop_cons_policy_rule_set['policy_rule_set_scope'])
953 consumed_policy_rule_set_list.update({policy_rule_set_id:
954 policy_rule_set_scope})
955
956 if provided_policy_rule_set_list:
957 prop_diff['provided_policy_rule_sets'] = (
958 provided_policy_rule_set_list)
959 if consumed_policy_rule_set_list:
960 prop_diff['consumed_policy_rule_sets'] = (
961 consumed_policy_rule_set_list)
962
903 self.grouppolicy().update_external_policy( 963 self.grouppolicy().update_external_policy(
904 self.resource_id, {'external_policy': prop_diff}) 964 self.resource_id, {'external_policy': prop_diff})
905 965
diff --git a/gbpautomation/heat/tests/test_grouppolicy.py b/gbpautomation/heat/tests/test_grouppolicy.py
index 922b44f..686ce8f 100644
--- a/gbpautomation/heat/tests/test_grouppolicy.py
+++ b/gbpautomation/heat/tests/test_grouppolicy.py
@@ -547,12 +547,40 @@ class PolicyTargetGroupTest(HeatTestCase):
547 def test_update(self): 547 def test_update(self):
548 rsrc = self.create_policy_target_group() 548 rsrc = self.create_policy_target_group()
549 gbpclient.Client.update_policy_target_group( 549 gbpclient.Client.update_policy_target_group(
550 '5678', {'policy_target_group': {'l2_policy_id': 'l2_id_update'}}) 550 '5678', {'policy_target_group': {
551 'l2_policy_id': 'l2_id_update',
552 'provided_policy_rule_sets': {
553 'policy_rule_set1': 'scope1',
554 'policy_rule_set2': 'scope2',
555 'policy_rule_set5': 'scope5'
556 },
557 'consumed_policy_rule_sets': {
558 'policy_rule_set3': 'scope3',
559 'policy_rule_set4': 'scope4',
560 'policy_rule_set6': 'scope6'
561 },
562 }})
551 self.m.ReplayAll() 563 self.m.ReplayAll()
552 scheduler.TaskRunner(rsrc.create)() 564 scheduler.TaskRunner(rsrc.create)()
553 565
554 update_template = copy.deepcopy(rsrc.t) 566 update_template = copy.deepcopy(rsrc.t)
555 update_template['Properties']['l2_policy_id'] = 'l2_id_update' 567 update_template['Properties']['l2_policy_id'] = 'l2_id_update'
568 update_template['Properties']['provided_policy_rule_sets'] = [
569 {'policy_rule_set_id': 'policy_rule_set1',
570 'policy_rule_set_scope': 'scope1'},
571 {'policy_rule_set_id': 'policy_rule_set2',
572 'policy_rule_set_scope': 'scope2'},
573 {'policy_rule_set_id': 'policy_rule_set5',
574 'policy_rule_set_scope': 'scope5'}
575 ]
576 update_template['Properties']['consumed_policy_rule_sets'] = [
577 {'policy_rule_set_id': 'policy_rule_set3',
578 'policy_rule_set_scope': 'scope3'},
579 {'policy_rule_set_id': 'policy_rule_set4',
580 'policy_rule_set_scope': 'scope4'},
581 {'policy_rule_set_id': 'policy_rule_set6',
582 'policy_rule_set_scope': 'scope6'}
583 ]
556 scheduler.TaskRunner(rsrc.update, update_template)() 584 scheduler.TaskRunner(rsrc.update, update_template)()
557 585
558 self.m.VerifyAll() 586 self.m.VerifyAll()
@@ -1483,14 +1511,40 @@ class ExternalPolicyTest(HeatTestCase):
1483 def test_update(self): 1511 def test_update(self):
1484 rsrc = self.create_external_policy() 1512 rsrc = self.create_external_policy()
1485 gbpclient.Client.update_external_policy( 1513 gbpclient.Client.update_external_policy(
1486 '5678', {'external_policy': 1514 '5678', {'external_policy': {
1487 {'external_segments': ['9876']}}) 1515 'external_segments': ['9876'],
1516 'provided_policy_rule_sets': {
1517 '2345': 'scope1',
1518 '8901': 'scope2',
1519 '1122': 'scope5'},
1520 'consumed_policy_rule_sets': {
1521 '9012': 'scope3',
1522 '9210': 'scope4',
1523 '9900': 'scope6'
1524 }
1525 }})
1488 self.m.ReplayAll() 1526 self.m.ReplayAll()
1489 scheduler.TaskRunner(rsrc.create)() 1527 scheduler.TaskRunner(rsrc.create)()
1490 1528
1491 update_template = copy.deepcopy(rsrc.t) 1529 update_template = copy.deepcopy(rsrc.t)
1492 update_template['Properties']['external_segments'] = [ 1530 update_template['Properties']['external_segments'] = [
1493 '9876'] 1531 '9876']
1532 update_template['Properties']['provided_policy_rule_sets'] = [
1533 {'policy_rule_set_id': '2345',
1534 'policy_rule_set_scope': 'scope1'},
1535 {'policy_rule_set_id': '8901',
1536 'policy_rule_set_scope': 'scope2'},
1537 {'policy_rule_set_id': '1122',
1538 'policy_rule_set_scope': 'scope5'}
1539 ]
1540 update_template['Properties']['consumed_policy_rule_sets'] = [
1541 {'policy_rule_set_id': '9012',
1542 'policy_rule_set_scope': 'scope3'},
1543 {'policy_rule_set_id': '9210',
1544 'policy_rule_set_scope': 'scope4'},
1545 {'policy_rule_set_id': '9900',
1546 'policy_rule_set_scope': 'scope6'}
1547 ]
1494 scheduler.TaskRunner(rsrc.update, update_template)() 1548 scheduler.TaskRunner(rsrc.update, update_template)()
1495 1549
1496 self.m.VerifyAll() 1550 self.m.VerifyAll()