Browse Source

Heat renaming of GBP resources

The following resources are being renamed:
Endpoints -> Policy Targets
Endpoints Groups -> Policy Target Groups
Contracts -> Policy Rule Sets
The changes to the spec are outlined in:
https://review.openstack.org/#/c/134747

Partially-implements: blueprint group-based-policy-abstraction

Change-Id: Idcabea87dbaf921b59c6c1f869b1ad971501d473
Susaant 4 years ago
parent
commit
5e0f00f815

+ 95
- 85
gbpautomation/heat/engine/resources/neutron/grouppolicy.py View File

@@ -21,12 +21,12 @@ from heat.engine import constraints
21 21
 from heat.engine import properties
22 22
 
23 23
 
24
-class Endpoint(gbpresource.GBPResource):
24
+class PolicyTarget(gbpresource.GBPResource):
25 25
 
26 26
     PROPERTIES = (
27
-        TENANT_ID, NAME, DESCRIPTION, ENDPOINT_GROUP_ID
27
+        TENANT_ID, NAME, DESCRIPTION, POLICY_TARGET_GROUP_ID
28 28
     ) = (
29
-        'tenant_id', 'name', 'description', 'endpoint_group_id'
29
+        'tenant_id', 'name', 'description', 'policy_target_group_id'
30 30
     )
31 31
 
32 32
     ATTRIBUTES = (
@@ -38,21 +38,21 @@ class Endpoint(gbpresource.GBPResource):
38 38
     properties_schema = {
39 39
         TENANT_ID: properties.Schema(
40 40
             properties.Schema.STRING,
41
-            _('Tenant id of the endpoint.')
41
+            _('Tenant id of the policy target.')
42 42
         ),
43 43
         NAME: properties.Schema(
44 44
             properties.Schema.STRING,
45
-            _('Name of the endpoint.'),
45
+            _('Name of the policy target.'),
46 46
             update_allowed=True
47 47
         ),
48 48
         DESCRIPTION: properties.Schema(
49 49
             properties.Schema.STRING,
50
-            _('Description of the endpoint.'),
50
+            _('Description of the policy target.'),
51 51
             update_allowed=True
52 52
         ),
53
-        ENDPOINT_GROUP_ID: properties.Schema(
53
+        POLICY_TARGET_GROUP_ID: properties.Schema(
54 54
             properties.Schema.STRING,
55
-            _('Endpoint group id of the endpoint.'),
55
+            _('Policy target group id of the policy target.'),
56 56
             required=True,
57 57
             update_allowed=True
58 58
         )
@@ -60,14 +60,14 @@ class Endpoint(gbpresource.GBPResource):
60 60
 
61 61
     attributes_schema = {
62 62
         PORT_ID: attributes.Schema(
63
-            _("Neutron port id of this endpoint")
63
+            _("Neutron port id of this policy target")
64 64
         )
65 65
     }
66 66
 
67 67
     def _show_resource(self):
68 68
         client = self.grouppolicy()
69
-        ep_id = self.resource_id
70
-        return client.show_endpoint(ep_id)['endpoint']
69
+        pt_id = self.resource_id
70
+        return client.show_policy_target(pt_id)['policy_target']
71 71
 
72 72
     def handle_create(self):
73 73
         client = self.grouppolicy()
@@ -77,24 +77,25 @@ class Endpoint(gbpresource.GBPResource):
77 77
             if self.properties.get(key) is not None:
78 78
                 props[key] = self.properties.get(key)
79 79
 
80
-        ep = client.create_endpoint({'endpoint': props})['endpoint']
80
+        pt = client.create_policy_target(
81
+            {'policy_target': props})['policy_target']
81 82
 
82
-        self.resource_id_set(ep['id'])
83
+        self.resource_id_set(pt['id'])
83 84
 
84 85
     def _resolve_attribute(self, name):
85 86
         client = self.grouppolicy()
86
-        ep_id = self.resource_id
87
+        pt_id = self.resource_id
87 88
         if name == 'port_id':
88
-            return client.show_endpoint(ep_id)['endpoint']['port_id']
89
-        return super(Endpoint, self)._resolve_attribute(name)
89
+            return client.show_policy_target(pt_id)['policy_target']['port_id']
90
+        return super(PolicyTarget, self)._resolve_attribute(name)
90 91
 
91 92
     def handle_delete(self):
92 93
 
93 94
         client = self.grouppolicy()
94
-        ep_id = self.resource_id
95
+        pt_id = self.resource_id
95 96
 
96 97
         try:
97
-            client.delete_endpoint(ep_id)
98
+            client.delete_policy_target(pt_id)
98 99
         except NeutronClientException as ex:
99 100
             self.client_plugin().ignore_not_found(ex)
100 101
         else:
@@ -102,61 +103,62 @@ class Endpoint(gbpresource.GBPResource):
102 103
 
103 104
     def handle_update(self, json_snippet, tmpl_diff, prop_diff):
104 105
         if prop_diff:
105
-            self.grouppolicy().update_endpoint(
106
-                self.resource_id, {'endpoint': prop_diff})
106
+            self.grouppolicy().update_policy_target(
107
+                self.resource_id, {'policy_target': prop_diff})
107 108
 
108 109
 
109
-class EndpointGroup(gbpresource.GBPResource):
110
+class PolicyTargetGroup(gbpresource.GBPResource):
110 111
 
111 112
     PROPERTIES = (
112
-        TENANT_ID, NAME, DESCRIPTION, L2_POLICY_ID,
113
-        PROVIDED_CONTRACTS, CONSUMED_CONTRACTS, NETWORK_SERVICE_POLICY_ID
113
+        TENANT_ID, NAME, DESCRIPTION, L2_POLICY_ID, PROVIDED_POLICY_RULE_SETS,
114
+        CONSUMED_POLICY_RULE_SETS, NETWORK_SERVICE_POLICY_ID
114 115
     ) = (
115 116
         'tenant_id', 'name', 'description', 'l2_policy_id',
116
-        'provided_contracts', 'consumed_contracts', 'network_service_policy_id'
117
+        'provided_policy_rule_sets', 'consumed_policy_rule_sets',
118
+        'network_service_policy_id'
117 119
     )
118 120
 
119 121
     properties_schema = {
120 122
         TENANT_ID: properties.Schema(
121 123
             properties.Schema.STRING,
122
-            _('Tenant id of the endpoint group.')
124
+            _('Tenant id of the policy target group.')
123 125
         ),
124 126
         NAME: properties.Schema(
125 127
             properties.Schema.STRING,
126
-            _('Name of the endpoint group.'),
128
+            _('Name of the policy target group.'),
127 129
             update_allowed=True
128 130
         ),
129 131
         DESCRIPTION: properties.Schema(
130 132
             properties.Schema.STRING,
131
-            _('Description of the endpoint group.'),
133
+            _('Description of the policy target group.'),
132 134
             update_allowed=True
133 135
         ),
134 136
         L2_POLICY_ID: properties.Schema(
135 137
             properties.Schema.STRING,
136
-            _('L2 policy id of the endpoint group.'),
138
+            _('L2 policy id of the policy target group.'),
137 139
             update_allowed=True
138 140
         ),
139
-        PROVIDED_CONTRACTS: properties.Schema(
141
+        PROVIDED_POLICY_RULE_SETS: properties.Schema(
140 142
             properties.Schema.LIST,
141
-            _('Provided contracts for the endpoint group.'),
143
+            _('Provided policy rule set for the policy target group.'),
142 144
             update_allowed=True
143 145
         ),
144
-        CONSUMED_CONTRACTS: properties.Schema(
146
+        CONSUMED_POLICY_RULE_SETS: properties.Schema(
145 147
             properties.Schema.LIST,
146
-            _('Consumed contracts for the endpoint group.'),
148
+            _('Consumed policy rule set for the policy target group.'),
147 149
             update_allowed=True
148 150
         ),
149 151
         NETWORK_SERVICE_POLICY_ID: properties.Schema(
150 152
             properties.Schema.STRING,
151
-            _('Network service policy id of the endpoint group.'),
153
+            _('Network service policy id of the policy target group.'),
152 154
             update_allowed=True, default=None
153 155
         )
154 156
     }
155 157
 
156 158
     def _show_resource(self):
157 159
         client = self.grouppolicy()
158
-        epg_id = self.resource_id
159
-        return client.show_endpoint_group(epg_id)['endpoint_group']
160
+        ptg_id = self.resource_id
161
+        return client.show_policy_target_group(ptg_id)['policy_target_group']
160 162
 
161 163
     def handle_create(self):
162 164
         client = self.grouppolicy()
@@ -166,38 +168,46 @@ class EndpointGroup(gbpresource.GBPResource):
166 168
             if self.properties.get(key) is not None:
167 169
                 props[key] = self.properties.get(key)
168 170
 
169
-        provided_contracts_list = {}
170
-        consumed_contracts_list = {}
171
-        props_provided_contracts = props.get('provided_contracts', [])
172
-        props_consumed_contracts = props.get('consumed_contracts', [])
173
-
174
-        for prop_prov_contract in props_provided_contracts:
175
-            contract_id = prop_prov_contract['contract_id']
176
-            contract_scope = prop_prov_contract['contract_scope']
177
-            provided_contracts_list.update({contract_id: contract_scope})
178
-
179
-        for prop_cons_contract in props_consumed_contracts:
180
-            contract_id = prop_cons_contract['contract_id']
181
-            contract_scope = prop_cons_contract['contract_scope']
182
-            consumed_contracts_list.update({contract_id: contract_scope})
183
-
184
-        if provided_contracts_list:
185
-            props['provided_contracts'] = provided_contracts_list
186
-        if consumed_contracts_list:
187
-            props['consumed_contracts'] = consumed_contracts_list
188
-
189
-        epg = client.create_endpoint_group(
190
-            {'endpoint_group': props})['endpoint_group']
191
-
192
-        self.resource_id_set(epg['id'])
171
+        provided_policy_rule_set_list = {}
172
+        consumed_policy_rule_set_list = {}
173
+        props_provided_policy_rule_sets = props.get(
174
+            'provided_policy_rule_sets', [])
175
+        props_consumed_policy_rule_sets = props.get(
176
+            'consumed_policy_rule_sets', [])
177
+
178
+        for prop_prov_policy_rule_set in props_provided_policy_rule_sets:
179
+            policy_rule_set_id = (
180
+                prop_prov_policy_rule_set['policy_rule_set_id'])
181
+            policy_rule_set_scope = (
182
+                prop_prov_policy_rule_set['policy_rule_set_scope'])
183
+            provided_policy_rule_set_list.update({policy_rule_set_id:
184
+                                                  policy_rule_set_scope})
185
+
186
+        for prop_cons_policy_rule_set in props_consumed_policy_rule_sets:
187
+            policy_rule_set_id = (
188
+                prop_cons_policy_rule_set['policy_rule_set_id'])
189
+            policy_rule_set_scope = (
190
+                prop_cons_policy_rule_set['policy_rule_set_scope'])
191
+            consumed_policy_rule_set_list.update({policy_rule_set_id:
192
+                                                  policy_rule_set_scope})
193
+
194
+        if provided_policy_rule_set_list:
195
+            props['provided_policy_rule_sets'] = provided_policy_rule_set_list
196
+        if consumed_policy_rule_set_list:
197
+            props['consumed_policy_rule_sets'] = consumed_policy_rule_set_list
198
+
199
+        ptg = client.create_policy_target_group(
200
+            {'policy_target_group': props})['policy_target_group']
201
+
202
+        self.resource_id_set(ptg['id'])
193 203
 
194 204
     def handle_delete(self):
195 205
 
196 206
         client = self.grouppolicy()
197
-        epg_id = self.resource_id
207
+        ptg_id = self.resource_id
198 208
 
199 209
         try:
200
-            client.delete_endpoint_group(epg_id)
210
+            client.delete_policy_target_group(ptg_id)
201 211
         except NeutronClientException as ex:
202 212
             self.client_plugin().ignore_not_found(ex)
203 213
         else:
@@ -205,8 +215,8 @@ class EndpointGroup(gbpresource.GBPResource):
205 215
 
206 216
     def handle_update(self, json_snippet, tmpl_diff, prop_diff):
207 217
         if prop_diff:
208
-            self.grouppolicy().update_endpoint_group(
209
-                self.resource_id, {'endpoint_group': prop_diff})
218
+            self.grouppolicy().update_policy_target_group(
219
+                self.resource_id, {'policy_target_group': prop_diff})
210 220
 
211 221
 
212 222
 class L2Policy(gbpresource.GBPResource):
@@ -590,39 +600,39 @@ class PolicyRule(gbpresource.GBPResource):
590 600
                 self.resource_id, {'policy_rule': prop_diff})
591 601
 
592 602
 
593
-class Contract(gbpresource.GBPResource):
603
+class PolicyRuleSet(gbpresource.GBPResource):
594 604
 
595 605
     PROPERTIES = (
596
-        TENANT_ID, NAME, DESCRIPTION, PARENT_ID, CHILD_CONTRACTS,
606
+        TENANT_ID, NAME, DESCRIPTION, PARENT_ID, CHILD_POLICY_RULE_SETS,
597 607
         POLICY_RULES
598 608
     ) = (
599
-        'tenant_id', 'name', 'description', 'parent_id', 'child_contracts',
600
-        'policy_rules'
609
+        'tenant_id', 'name', 'description', 'parent_id',
610
+        'child_policy_rule_sets', 'policy_rules'
601 611
     )
602 612
 
603 613
     properties_schema = {
604 614
         TENANT_ID: properties.Schema(
605 615
             properties.Schema.STRING,
606
-            _('Tenant id of the contract.')
616
+            _('Tenant id of the policy rule set.')
607 617
         ),
608 618
         NAME: properties.Schema(
609 619
             properties.Schema.STRING,
610
-            _('Name of the contract.'),
620
+            _('Name of the policy rule set.'),
611 621
             update_allowed=True
612 622
         ),
613 623
         DESCRIPTION: properties.Schema(
614 624
             properties.Schema.STRING,
615
-            _('Description of the contract.'),
625
+            _('Description of the policy rule set.'),
616 626
             update_allowed=True
617 627
         ),
618 628
         PARENT_ID: properties.Schema(
619 629
             properties.Schema.STRING,
620
-            _('Parent id of the contract.'),
630
+            _('Parent id of the policy rule set.'),
621 631
             update_allowed=False
622 632
         ),
623
-        CHILD_CONTRACTS: properties.Schema(
633
+        CHILD_POLICY_RULE_SETS: properties.Schema(
624 634
             properties.Schema.LIST,
625
-            _('List of child contracts.'),
635
+            _('List of child policy rule sets.'),
626 636
             default=None, update_allowed=True
627 637
         ),
628 638
         POLICY_RULES: properties.Schema(
@@ -634,8 +644,8 @@ class Contract(gbpresource.GBPResource):
634 644
 
635 645
     def _show_resource(self):
636 646
         client = self.grouppolicy()
637
-        contract_id = self.resource_id
638
-        return client.show_contract(contract_id)['contract']
647
+        prs_id = self.resource_id
648
+        return client.show_policy_rule_set(prs_id)['policy_rule_set']
639 649
 
640 650
     def handle_create(self):
641 651
         client = self.grouppolicy()
@@ -645,18 +655,18 @@ class Contract(gbpresource.GBPResource):
645 655
             if self.properties.get(key) is not None:
646 656
                 props[key] = self.properties.get(key)
647 657
 
648
-        contract = client.create_contract(
649
-            {'contract': props})['contract']
658
+        policy_rule_set = client.create_policy_rule_set(
659
+            {'policy_rule_set': props})['policy_rule_set']
650 660
 
651
-        self.resource_id_set(contract['id'])
661
+        self.resource_id_set(policy_rule_set['id'])
652 662
 
653 663
     def handle_delete(self):
654 664
 
655 665
         client = self.grouppolicy()
656
-        contract_id = self.resource_id
666
+        policy_rule_set_id = self.resource_id
657 667
 
658 668
         try:
659
-            client.delete_contract(contract_id)
669
+            client.delete_policy_rule_set(policy_rule_set_id)
660 670
         except NeutronClientException as ex:
661 671
             self.client_plugin().ignore_not_found(ex)
662 672
         else:
@@ -664,8 +674,8 @@ class Contract(gbpresource.GBPResource):
664 674
 
665 675
     def handle_update(self, json_snippet, tmpl_diff, prop_diff):
666 676
         if prop_diff:
667
-            self.grouppolicy().update_contract(
668
-                self.resource_id, {'contract': prop_diff})
677
+            self.grouppolicy().update_policy_rule_set(
678
+                self.resource_id, {'policy_rule_set': prop_diff})
669 679
 
670 680
 
671 681
 class NetworkServicePolicy(gbpresource.GBPResource):
@@ -737,13 +747,13 @@ class NetworkServicePolicy(gbpresource.GBPResource):
737 747
 
738 748
 def resource_mapping():
739 749
     return {
740
-        'OS::Neutron::Endpoint': Endpoint,
741
-        'OS::Neutron::EndpointGroup': EndpointGroup,
750
+        'OS::Neutron::PolicyTarget': PolicyTarget,
751
+        'OS::Neutron::PolicyTargetGroup': PolicyTargetGroup,
742 752
         'OS::Neutron::L2Policy': L2Policy,
743 753
         'OS::Neutron::L3Policy': L3Policy,
744 754
         'OS::Neutron::PolicyClassifier': PolicyClassifier,
745 755
         'OS::Neutron::PolicyAction': PolicyAction,
746 756
         'OS::Neutron::PolicyRule': PolicyRule,
747
-        'OS::Neutron::Contract': Contract,
757
+        'OS::Neutron::PolicyRuleSet': PolicyRuleSet,
748 758
         'OS::Neutron::NetworkServicePolicy': NetworkServicePolicy
749 759
     }

+ 156
- 148
gbpautomation/heat/tests/test_grouppolicy.py View File

@@ -23,43 +23,47 @@ from heat.engine import scheduler
23 23
 from heat.tests import utils
24 24
 
25 25
 
26
-endpoint_template = '''
26
+policy_target_template = '''
27 27
 {
28 28
   "AWSTemplateFormatVersion" : "2010-09-09",
29
-  "Description" : "Template to test neutron endpoint resource",
29
+  "Description" : "Template to test neutron policy target resource",
30 30
   "Parameters" : {},
31 31
   "Resources" : {
32
-    "endpoint": {
33
-      "Type": "OS::Neutron::Endpoint",
32
+    "policy_target": {
33
+      "Type": "OS::Neutron::PolicyTarget",
34 34
       "Properties": {
35
-        "name": "test-endpoint",
36
-        "endpoint_group_id": "epg-id",
37
-        "description": "test endpoint resource"
35
+        "name": "test-policy-target",
36
+        "policy_target_group_id": "ptg-id",
37
+        "description": "test policy target resource"
38 38
       }
39 39
     }
40 40
   }
41 41
 }
42 42
 '''
43 43
 
44
-endpoint_group_template = '''
44
+policy_target_group_template = '''
45 45
 {
46 46
   "AWSTemplateFormatVersion" : "2010-09-09",
47
-  "Description" : "Template to test neutron endpoint group resource",
47
+  "Description" : "Template to test neutron policy target group resource",
48 48
   "Parameters" : {},
49 49
   "Resources" : {
50
-    "endpoint_group": {
51
-      "Type": "OS::Neutron::EndpointGroup",
50
+    "policy_target_group": {
51
+      "Type": "OS::Neutron::PolicyTargetGroup",
52 52
       "Properties": {
53
-        "name": "test-endpoint-group",
54
-        "description": "test endpoint group resource",
53
+        "name": "test-policy-target-group",
54
+        "description": "test policy target group resource",
55 55
         "l2_policy_id": "l2-policy-id",
56
-        "provided_contracts": [
57
-            {"contract_id": "contract1", "contract_scope": "scope1"},
58
-            {"contract_id": "contract2", "contract_scope": "scope2"}
56
+        "provided_policy_rule_sets": [
57
+            {"policy_rule_set_id": "policy_rule_set1",
58
+             "policy_rule_set_scope": "scope1"},
59
+            {"policy_rule_set_id": "policy_rule_set2",
60
+             "policy_rule_set_scope": "scope2"}
59 61
         ],
60
-        "consumed_contracts": [
61
-            {"contract_id": "contract3", "contract_scope": "scope3"},
62
-            {"contract_id": "contract4", "contract_scope": "scope4"}
62
+        "consumed_policy_rule_sets": [
63
+            {"policy_rule_set_id": "policy_rule_set3",
64
+             "policy_rule_set_scope": "scope3"},
65
+            {"policy_rule_set_id": "policy_rule_set4",
66
+             "policy_rule_set_scope": "scope4"}
63 67
         ]
64 68
       }
65 69
     }
@@ -164,19 +168,19 @@ policy_rule_template = '''
164 168
 }
165 169
 '''
166 170
 
167
-contract_template = '''
171
+policy_rule_set_template = '''
168 172
 {
169 173
  "AWSTemplateFormatVersion" : "2010-09-09",
170
-  "Description" : "Template to test contract",
174
+  "Description" : "Template to test policy rule set",
171 175
   "Parameters" : {},
172 176
   "Resources" : {
173
-  "contract": {
174
-      "Type": "OS::Neutron::Contract",
177
+  "policy_rule_set": {
178
+      "Type": "OS::Neutron::PolicyRuleSet",
175 179
       "Properties": {
176
-          "name": "test-contract",
177
-          "description": "test contract resource",
180
+          "name": "test-policy-rule-set",
181
+          "description": "test policy rule set resource",
178 182
           "parent_id": "3456",
179
-          "child_contracts": ["7890", "1234"],
183
+          "child_policy_rule_sets": ["7890", "1234"],
180 184
           "policy_rules": ["2345", "6789"]
181 185
       }
182 186
     }
@@ -204,53 +208,53 @@ network_service_policy_template = '''
204 208
 '''
205 209
 
206 210
 
207
-class EndpointTest(HeatTestCase):
211
+class PolicyTargetTest(HeatTestCase):
208 212
 
209 213
     def setUp(self):
210
-        super(EndpointTest, self).setUp()
211
-        self.m.StubOutWithMock(gbpclient.Client, 'create_endpoint')
212
-        self.m.StubOutWithMock(gbpclient.Client, 'delete_endpoint')
213
-        self.m.StubOutWithMock(gbpclient.Client, 'show_endpoint')
214
-        self.m.StubOutWithMock(gbpclient.Client, 'update_endpoint')
214
+        super(PolicyTargetTest, self).setUp()
215
+        self.m.StubOutWithMock(gbpclient.Client, 'create_policy_target')
216
+        self.m.StubOutWithMock(gbpclient.Client, 'delete_policy_target')
217
+        self.m.StubOutWithMock(gbpclient.Client, 'show_policy_target')
218
+        self.m.StubOutWithMock(gbpclient.Client, 'update_policy_target')
215 219
         self.stub_keystoneclient()
216 220
 
217
-    def create_endpoint(self):
218
-        gbpclient.Client.create_endpoint({
219
-            'endpoint': {
220
-                'name': 'test-endpoint',
221
-                'endpoint_group_id': 'epg-id',
222
-                "description": "test endpoint resource"
221
+    def create_policy_target(self):
222
+        gbpclient.Client.create_policy_target({
223
+            'policy_target': {
224
+                'name': 'test-policy-target',
225
+                'policy_target_group_id': 'ptg-id',
226
+                "description": "test policy target resource"
223 227
             }
224
-        }).AndReturn({'endpoint': {'id': '5678'}})
228
+        }).AndReturn({'policy_target': {'id': '5678'}})
225 229
 
226
-        snippet = template_format.parse(endpoint_template)
230
+        snippet = template_format.parse(policy_target_template)
227 231
         stack = utils.parse_stack(snippet)
228 232
         resource_defns = stack.t.resource_definitions(stack)
229
-        return grouppolicy.Endpoint(
230
-            'endpoint', resource_defns['endpoint'], stack)
233
+        return grouppolicy.PolicyTarget(
234
+            'policy_target', resource_defns['policy_target'], stack)
231 235
 
232 236
     def test_create(self):
233
-        rsrc = self.create_endpoint()
237
+        rsrc = self.create_policy_target()
234 238
         self.m.ReplayAll()
235 239
         scheduler.TaskRunner(rsrc.create)()
236 240
         self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
237 241
         self.m.VerifyAll()
238 242
 
239 243
     def test_create_failed(self):
240
-        gbpclient.Client.create_endpoint({
241
-            'endpoint': {
242
-                'name': 'test-endpoint',
243
-                'endpoint_group_id': 'epg-id',
244
-                "description": "test endpoint resource"
244
+        gbpclient.Client.create_policy_target({
245
+            'policy_target': {
246
+                'name': 'test-policy-target',
247
+                'policy_target_group_id': 'ptg-id',
248
+                "description": "test policy target resource"
245 249
             }
246 250
         }).AndRaise(grouppolicy.NeutronClientException())
247 251
         self.m.ReplayAll()
248 252
 
249
-        snippet = template_format.parse(endpoint_template)
253
+        snippet = template_format.parse(policy_target_template)
250 254
         stack = utils.parse_stack(snippet)
251 255
         resource_defns = stack.t.resource_definitions(stack)
252
-        rsrc = grouppolicy.Endpoint(
253
-            'endpoint', resource_defns['endpoint'], stack)
256
+        rsrc = grouppolicy.PolicyTarget(
257
+            'policy_target', resource_defns['policy_target'], stack)
254 258
 
255 259
         error = self.assertRaises(exception.ResourceFailure,
256 260
                                   scheduler.TaskRunner(rsrc.create))
@@ -261,11 +265,11 @@ class EndpointTest(HeatTestCase):
261 265
         self.m.VerifyAll()
262 266
 
263 267
     def test_delete(self):
264
-        gbpclient.Client.delete_endpoint('5678')
265
-        gbpclient.Client.show_endpoint('5678').AndRaise(
268
+        gbpclient.Client.delete_policy_target('5678')
269
+        gbpclient.Client.show_policy_target('5678').AndRaise(
266 270
             grouppolicy.NeutronClientException(status_code=404))
267 271
 
268
-        rsrc = self.create_endpoint()
272
+        rsrc = self.create_policy_target()
269 273
         self.m.ReplayAll()
270 274
         scheduler.TaskRunner(rsrc.create)()
271 275
         scheduler.TaskRunner(rsrc.delete)()
@@ -273,10 +277,10 @@ class EndpointTest(HeatTestCase):
273 277
         self.m.VerifyAll()
274 278
 
275 279
     def test_delete_already_gone(self):
276
-        gbpclient.Client.delete_endpoint('5678').AndRaise(
280
+        gbpclient.Client.delete_policy_target('5678').AndRaise(
277 281
             grouppolicy.NeutronClientException(status_code=404))
278 282
 
279
-        rsrc = self.create_endpoint()
283
+        rsrc = self.create_policy_target()
280 284
         self.m.ReplayAll()
281 285
         scheduler.TaskRunner(rsrc.create)()
282 286
         scheduler.TaskRunner(rsrc.delete)()
@@ -284,10 +288,10 @@ class EndpointTest(HeatTestCase):
284 288
         self.m.VerifyAll()
285 289
 
286 290
     def test_delete_failed(self):
287
-        gbpclient.Client.delete_endpoint('5678').AndRaise(
291
+        gbpclient.Client.delete_policy_target('5678').AndRaise(
288 292
             grouppolicy.NeutronClientException(status_code=400))
289 293
 
290
-        rsrc = self.create_endpoint()
294
+        rsrc = self.create_policy_target()
291 295
         self.m.ReplayAll()
292 296
         scheduler.TaskRunner(rsrc.create)()
293 297
         error = self.assertRaises(exception.ResourceFailure,
@@ -299,103 +303,107 @@ class EndpointTest(HeatTestCase):
299 303
         self.m.VerifyAll()
300 304
 
301 305
     def test_attribute(self):
302
-        rsrc = self.create_endpoint()
303
-        gbpclient.Client.show_endpoint('5678').MultipleTimes(
306
+        rsrc = self.create_policy_target()
307
+        gbpclient.Client.show_policy_target('5678').MultipleTimes(
304 308
         ).AndReturn(
305
-            {'endpoint': {'port_id': '1234'}})
309
+            {'policy_target': {'port_id': '1234'}})
306 310
         self.m.ReplayAll()
307 311
         scheduler.TaskRunner(rsrc.create)()
308 312
         self.assertEqual('1234', rsrc.FnGetAtt('port_id'))
309 313
         self.m.VerifyAll()
310 314
 
311 315
     def test_attribute_failed(self):
312
-        rsrc = self.create_endpoint()
316
+        rsrc = self.create_policy_target()
313 317
         self.m.ReplayAll()
314 318
         scheduler.TaskRunner(rsrc.create)()
315 319
         error = self.assertRaises(exception.InvalidTemplateAttribute,
316 320
                                   rsrc.FnGetAtt, 'l2_policy_id')
317 321
         self.assertEqual(
318
-            'The Referenced Attribute (endpoint l2_policy_id) is '
322
+            'The Referenced Attribute (policy_target l2_policy_id) is '
319 323
             'incorrect.', str(error))
320 324
         self.m.VerifyAll()
321 325
 
322 326
     def test_update(self):
323
-        rsrc = self.create_endpoint()
324
-        gbpclient.Client.update_endpoint(
325
-            '5678', {'endpoint': {'endpoint_group_id': 'epg_id_update'}})
327
+        rsrc = self.create_policy_target()
328
+        gbpclient.Client.update_policy_target(
329
+            '5678', {'policy_target': {'policy_target_group_id':
330
+                                       'ptg_id_update'}})
326 331
         self.m.ReplayAll()
327 332
         scheduler.TaskRunner(rsrc.create)()
328 333
 
329 334
         update_template = copy.deepcopy(rsrc.t)
330
-        update_template['Properties']['endpoint_group_id'] = 'epg_id_update'
335
+        update_template['Properties']['policy_target_group_id'] = (
336
+            'ptg_id_update')
331 337
         scheduler.TaskRunner(rsrc.update, update_template)()
332 338
 
333 339
         self.m.VerifyAll()
334 340
 
335 341
 
336
-class EndpointGroupTest(HeatTestCase):
342
+class PolicyTargetGroupTest(HeatTestCase):
337 343
 
338 344
     def setUp(self):
339
-        super(EndpointGroupTest, self).setUp()
340
-        self.m.StubOutWithMock(gbpclient.Client, 'create_endpoint_group')
341
-        self.m.StubOutWithMock(gbpclient.Client, 'delete_endpoint_group')
342
-        self.m.StubOutWithMock(gbpclient.Client, 'show_endpoint_group')
343
-        self.m.StubOutWithMock(gbpclient.Client, 'update_endpoint_group')
345
+        super(PolicyTargetGroupTest, self).setUp()
346
+        self.m.StubOutWithMock(gbpclient.Client, 'create_policy_target_group')
347
+        self.m.StubOutWithMock(gbpclient.Client, 'delete_policy_target_group')
348
+        self.m.StubOutWithMock(gbpclient.Client, 'show_policy_target_group')
349
+        self.m.StubOutWithMock(gbpclient.Client, 'update_policy_target_group')
344 350
         self.stub_keystoneclient()
345 351
 
346
-    def create_endpoint_group(self):
347
-        gbpclient.Client.create_endpoint_group({
348
-            "endpoint_group": {
349
-                "name": "test-endpoint-group",
350
-                "description": "test endpoint group resource",
352
+    def create_policy_target_group(self):
353
+        gbpclient.Client.create_policy_target_group({
354
+            "policy_target_group": {
355
+                "name": "test-policy-target-group",
356
+                "description": "test policy target group resource",
351 357
                 "l2_policy_id": "l2-policy-id",
352
-                "provided_contracts": {
353
-                    "contract1": "scope1",
354
-                    "contract2": "scope2"
358
+                "provided_policy_rule_sets": {
359
+                    "policy_rule_set1": "scope1",
360
+                    "policy_rule_set2": "scope2"
355 361
                 },
356
-                "consumed_contracts": {
357
-                    "contract3": "scope3",
358
-                    "contract4": "scope4"
362
+                "consumed_policy_rule_sets": {
363
+                    "policy_rule_set3": "scope3",
364
+                    "policy_rule_set4": "scope4"
359 365
                 }
360 366
             }
361
-        }).AndReturn({'endpoint_group': {'id': '5678'}})
367
+        }).AndReturn({'policy_target_group': {'id': '5678'}})
362 368
 
363
-        snippet = template_format.parse(endpoint_group_template)
369
+        snippet = template_format.parse(policy_target_group_template)
364 370
         stack = utils.parse_stack(snippet)
365 371
         resource_defns = stack.t.resource_definitions(stack)
366
-        return grouppolicy.EndpointGroup(
367
-            'endpoint_group', resource_defns['endpoint_group'], stack)
372
+        return grouppolicy.PolicyTargetGroup(
373
+            'policy_target_group', resource_defns['policy_target_group'],
374
+            stack)
368 375
 
369 376
     def test_create(self):
370
-        rsrc = self.create_endpoint_group()
377
+        rsrc = self.create_policy_target_group()
371 378
         self.m.ReplayAll()
372 379
         scheduler.TaskRunner(rsrc.create)()
373 380
         self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
374 381
         self.m.VerifyAll()
375 382
 
376 383
     def test_create_failed(self):
377
-        gbpclient.Client.create_endpoint_group({
378
-            "endpoint_group": {
379
-                "name": "test-endpoint-group",
380
-                "description": "test endpoint group resource",
384
+        gbpclient.Client.create_policy_target_group({
385
+            "policy_target_group": {
386
+                "name": "test-policy-target-group",
387
+                "description": "test policy target group resource",
381 388
                 "l2_policy_id": "l2-policy-id",
382
-                "provided_contracts": {
383
-                    "contract1": "scope1",
384
-                    "contract2": "scope2"
389
+                "provided_policy_rule_sets": {
390
+                    "policy_rule_set1": "scope1",
391
+                    "policy_rule_set2": "scope2"
385 392
                 },
386
-                "consumed_contracts": {
387
-                    "contract3": "scope3",
388
-                    "contract4": "scope4"
393
+                "consumed_policy_rule_sets": {
394
+                    "policy_rule_set3": "scope3",
395
+                    "policy_rule_set4": "scope4"
389 396
                 }
390 397
             }
391 398
         }).AndRaise(grouppolicy.NeutronClientException())
392 399
         self.m.ReplayAll()
393 400
 
394
-        snippet = template_format.parse(endpoint_group_template)
401
+        snippet = template_format.parse(policy_target_group_template)
395 402
         stack = utils.parse_stack(snippet)
396 403
         resource_defns = stack.t.resource_definitions(stack)
397
-        rsrc = grouppolicy.EndpointGroup(
398
-            'endpoint_group', resource_defns['endpoint_group'], stack)
404
+        rsrc = grouppolicy.PolicyTargetGroup(
405
+            'policy_target_group', resource_defns['policy_target_group'],
406
+            stack)
399 407
 
400 408
         error = self.assertRaises(exception.ResourceFailure,
401 409
                                   scheduler.TaskRunner(rsrc.create))
@@ -406,11 +414,11 @@ class EndpointGroupTest(HeatTestCase):
406 414
         self.m.VerifyAll()
407 415
 
408 416
     def test_delete(self):
409
-        gbpclient.Client.delete_endpoint_group('5678')
410
-        gbpclient.Client.show_endpoint_group('5678').AndRaise(
417
+        gbpclient.Client.delete_policy_target_group('5678')
418
+        gbpclient.Client.show_policy_target_group('5678').AndRaise(
411 419
             grouppolicy.NeutronClientException(status_code=404))
412 420
 
413
-        rsrc = self.create_endpoint_group()
421
+        rsrc = self.create_policy_target_group()
414 422
         self.m.ReplayAll()
415 423
         scheduler.TaskRunner(rsrc.create)()
416 424
         scheduler.TaskRunner(rsrc.delete)()
@@ -418,10 +426,10 @@ class EndpointGroupTest(HeatTestCase):
418 426
         self.m.VerifyAll()
419 427
 
420 428
     def test_delete_already_gone(self):
421
-        gbpclient.Client.delete_endpoint_group('5678').AndRaise(
429
+        gbpclient.Client.delete_policy_target_group('5678').AndRaise(
422 430
             grouppolicy.NeutronClientException(status_code=404))
423 431
 
424
-        rsrc = self.create_endpoint_group()
432
+        rsrc = self.create_policy_target_group()
425 433
         self.m.ReplayAll()
426 434
         scheduler.TaskRunner(rsrc.create)()
427 435
         scheduler.TaskRunner(rsrc.delete)()
@@ -429,10 +437,10 @@ class EndpointGroupTest(HeatTestCase):
429 437
         self.m.VerifyAll()
430 438
 
431 439
     def test_delete_failed(self):
432
-        gbpclient.Client.delete_endpoint_group('5678').AndRaise(
440
+        gbpclient.Client.delete_policy_target_group('5678').AndRaise(
433 441
             grouppolicy.NeutronClientException(status_code=400))
434 442
 
435
-        rsrc = self.create_endpoint_group()
443
+        rsrc = self.create_policy_target_group()
436 444
         self.m.ReplayAll()
437 445
         scheduler.TaskRunner(rsrc.create)()
438 446
         error = self.assertRaises(exception.ResourceFailure,
@@ -444,9 +452,9 @@ class EndpointGroupTest(HeatTestCase):
444 452
         self.m.VerifyAll()
445 453
 
446 454
     def test_update(self):
447
-        rsrc = self.create_endpoint_group()
448
-        gbpclient.Client.update_endpoint_group(
449
-            '5678', {'endpoint_group': {'l2_policy_id': 'l2_id_update'}})
455
+        rsrc = self.create_policy_target_group()
456
+        gbpclient.Client.update_policy_target_group(
457
+            '5678', {'policy_target_group': {'l2_policy_id': 'l2_id_update'}})
450 458
         self.m.ReplayAll()
451 459
         scheduler.TaskRunner(rsrc.create)()
452 460
 
@@ -1015,57 +1023,57 @@ class PolicyRuleTest(HeatTestCase):
1015 1023
         self.m.VerifyAll()
1016 1024
 
1017 1025
 
1018
-class ContractTest(HeatTestCase):
1026
+class PolicyRuleSetTest(HeatTestCase):
1019 1027
 
1020 1028
     def setUp(self):
1021
-        super(ContractTest, self).setUp()
1022
-        self.m.StubOutWithMock(gbpclient.Client, 'create_contract')
1023
-        self.m.StubOutWithMock(gbpclient.Client, 'delete_contract')
1024
-        self.m.StubOutWithMock(gbpclient.Client, 'show_contract')
1025
-        self.m.StubOutWithMock(gbpclient.Client, 'update_contract')
1029
+        super(PolicyRuleSetTest, self).setUp()
1030
+        self.m.StubOutWithMock(gbpclient.Client, 'create_policy_rule_set')
1031
+        self.m.StubOutWithMock(gbpclient.Client, 'delete_policy_rule_set')
1032
+        self.m.StubOutWithMock(gbpclient.Client, 'show_policy_rule_set')
1033
+        self.m.StubOutWithMock(gbpclient.Client, 'update_policy_rule_set')
1026 1034
         self.stub_keystoneclient()
1027 1035
 
1028
-    def create_contract(self):
1029
-        gbpclient.Client.create_contract({
1030
-            'contract': {
1031
-                "name": "test-contract",
1032
-                "description": "test contract resource",
1036
+    def create_policy_rule_set(self):
1037
+        gbpclient.Client.create_policy_rule_set({
1038
+            'policy_rule_set': {
1039
+                "name": "test-policy-rule-set",
1040
+                "description": "test policy rule set resource",
1033 1041
                 "parent_id": "3456",
1034
-                "child_contracts": ["7890", "1234"],
1042
+                "child_policy_rule_sets": ["7890", "1234"],
1035 1043
                 "policy_rules": ["2345", "6789"]
1036 1044
             }
1037
-        }).AndReturn({'contract': {'id': '5678'}})
1045
+        }).AndReturn({'policy_rule_set': {'id': '5678'}})
1038 1046
 
1039
-        snippet = template_format.parse(contract_template)
1047
+        snippet = template_format.parse(policy_rule_set_template)
1040 1048
         stack = utils.parse_stack(snippet)
1041 1049
         resource_defns = stack.t.resource_definitions(stack)
1042
-        return grouppolicy.Contract(
1043
-            'contract', resource_defns['contract'], stack)
1050
+        return grouppolicy.PolicyRuleSet(
1051
+            'policy_rule_set', resource_defns['policy_rule_set'], stack)
1044 1052
 
1045 1053
     def test_create(self):
1046
-        rsrc = self.create_contract()
1054
+        rsrc = self.create_policy_rule_set()
1047 1055
         self.m.ReplayAll()
1048 1056
         scheduler.TaskRunner(rsrc.create)()
1049 1057
         self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
1050 1058
         self.m.VerifyAll()
1051 1059
 
1052 1060
     def test_create_failed(self):
1053
-        gbpclient.Client.create_contract({
1054
-            'contract': {
1055
-                "name": "test-contract",
1056
-                "description": "test contract resource",
1061
+        gbpclient.Client.create_policy_rule_set({
1062
+            'policy_rule_set': {
1063
+                "name": "test-policy-rule-set",
1064
+                "description": "test policy rule set resource",
1057 1065
                 "parent_id": "3456",
1058
-                "child_contracts": ["7890", "1234"],
1066
+                "child_policy_rule_sets": ["7890", "1234"],
1059 1067
                 "policy_rules": ["2345", "6789"]
1060 1068
             }
1061 1069
         }).AndRaise(grouppolicy.NeutronClientException())
1062 1070
         self.m.ReplayAll()
1063 1071
 
1064
-        snippet = template_format.parse(contract_template)
1072
+        snippet = template_format.parse(policy_rule_set_template)
1065 1073
         stack = utils.parse_stack(snippet)
1066 1074
         resource_defns = stack.t.resource_definitions(stack)
1067
-        rsrc = grouppolicy.Contract(
1068
-            'contract', resource_defns['contract'], stack)
1075
+        rsrc = grouppolicy.PolicyRuleSet(
1076
+            'policy_rule_set', resource_defns['policy_rule_set'], stack)
1069 1077
 
1070 1078
         error = self.assertRaises(exception.ResourceFailure,
1071 1079
                                   scheduler.TaskRunner(rsrc.create))
@@ -1076,11 +1084,11 @@ class ContractTest(HeatTestCase):
1076 1084
         self.m.VerifyAll()
1077 1085
 
1078 1086
     def test_delete(self):
1079
-        gbpclient.Client.delete_contract('5678')
1080
-        gbpclient.Client.show_contract('5678').AndRaise(
1087
+        gbpclient.Client.delete_policy_rule_set('5678')
1088
+        gbpclient.Client.show_policy_rule_set('5678').AndRaise(
1081 1089
             grouppolicy.NeutronClientException(status_code=404))
1082 1090
 
1083
-        rsrc = self.create_contract()
1091
+        rsrc = self.create_policy_rule_set()
1084 1092
         self.m.ReplayAll()
1085 1093
         scheduler.TaskRunner(rsrc.create)()
1086 1094
         scheduler.TaskRunner(rsrc.delete)()
@@ -1088,10 +1096,10 @@ class ContractTest(HeatTestCase):
1088 1096
         self.m.VerifyAll()
1089 1097
 
1090 1098
     def test_delete_already_gone(self):
1091
-        gbpclient.Client.delete_contract('5678').AndRaise(
1099
+        gbpclient.Client.delete_policy_rule_set('5678').AndRaise(
1092 1100
             grouppolicy.NeutronClientException(status_code=404))
1093 1101
 
1094
-        rsrc = self.create_contract()
1102
+        rsrc = self.create_policy_rule_set()
1095 1103
         self.m.ReplayAll()
1096 1104
         scheduler.TaskRunner(rsrc.create)()
1097 1105
         scheduler.TaskRunner(rsrc.delete)()
@@ -1099,10 +1107,10 @@ class ContractTest(HeatTestCase):
1099 1107
         self.m.VerifyAll()
1100 1108
 
1101 1109
     def test_delete_failed(self):
1102
-        gbpclient.Client.delete_contract('5678').AndRaise(
1110
+        gbpclient.Client.delete_policy_rule_set('5678').AndRaise(
1103 1111
             grouppolicy.NeutronClientException(status_code=400))
1104 1112
 
1105
-        rsrc = self.create_contract()
1113
+        rsrc = self.create_policy_rule_set()
1106 1114
         self.m.ReplayAll()
1107 1115
         scheduler.TaskRunner(rsrc.create)()
1108 1116
         error = self.assertRaises(exception.ResourceFailure,
@@ -1114,14 +1122,14 @@ class ContractTest(HeatTestCase):
1114 1122
         self.m.VerifyAll()
1115 1123
 
1116 1124
     def test_update(self):
1117
-        rsrc = self.create_contract()
1118
-        gbpclient.Client.update_contract(
1119
-            '5678', {'contract': {'child_contracts': ["1234"]}})
1125
+        rsrc = self.create_policy_rule_set()
1126
+        gbpclient.Client.update_policy_rule_set(
1127
+            '5678', {'policy_rule_set': {'child_policy_rule_sets': ["1234"]}})
1120 1128
         self.m.ReplayAll()
1121 1129
         scheduler.TaskRunner(rsrc.create)()
1122 1130
 
1123 1131
         update_template = copy.deepcopy(rsrc.t)
1124
-        update_template['Properties']['child_contracts'] = ["1234"]
1132
+        update_template['Properties']['child_policy_rule_sets'] = ["1234"]
1125 1133
         scheduler.TaskRunner(rsrc.update, update_template)()
1126 1134
 
1127 1135
         self.m.VerifyAll()

Loading…
Cancel
Save