Browse Source

Do not set default fixed_ips for policy_target

When fixed_ips is not specified, this attribute should
not be sent to the backend. Currently a default value of
empty list is being sent which is interpreted as an
actual value by the backend.

Change-Id: I91ca5c1f9d86dc81f47fbb79eb8723bd21c6bd50
Sumit Naiksatam 2 years ago
parent
commit
40345ee068

+ 0
- 1
gbpautomation/heat/engine/resources/grouppolicy.py View File

@@ -72,7 +72,6 @@ class PolicyTarget(gbpresource.GBPResource):
72 72
         FIXED_IPS: properties.Schema(
73 73
             properties.Schema.LIST,
74 74
             _('Desired IPs for this port.'),
75
-            default=[],
76 75
             schema=properties.Schema(
77 76
                 properties.Schema.MAP,
78 77
                 schema={

+ 42
- 0
gbpautomation/heat/tests/test_grouppolicy.py View File

@@ -46,6 +46,25 @@ policy_target_template = '''
46 46
 }
47 47
 '''
48 48
 
49
+
50
+policy_target_no_port_no_fixed_ip_template = '''
51
+{
52
+  "AWSTemplateFormatVersion" : "2010-09-09",
53
+  "Description" : "Template to test neutron policy target resource",
54
+  "Parameters" : {},
55
+  "Resources" : {
56
+    "policy_target": {
57
+      "Type": "OS::GroupBasedPolicy::PolicyTarget",
58
+      "Properties": {
59
+        "name": "test-policy-target",
60
+        "policy_target_group_id": "ptg-id",
61
+        "description": "test policy target resource",
62
+      }
63
+    }
64
+  }
65
+}
66
+'''
67
+
49 68
 policy_target_group_template = '''
50 69
 {
51 70
   "AWSTemplateFormatVersion" : "2010-09-09",
@@ -345,6 +364,29 @@ class PolicyTargetTest(HeatTestCase):
345 364
         self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
346 365
         self.m.VerifyAll()
347 366
 
367
+    def create_policy_target_no_port_no_fixed_ip(self):
368
+        gbpclient.Client.create_policy_target({
369
+            'policy_target': {
370
+                'name': 'test-policy-target',
371
+                'policy_target_group_id': 'ptg-id',
372
+                "description": "test policy target resource",
373
+            }
374
+        }).AndReturn({'policy_target': {'id': '5678'}})
375
+
376
+        snippet = template_format.parse(
377
+            policy_target_no_port_no_fixed_ip_template)
378
+        self.stack = utils.parse_stack(snippet)
379
+        resource_defns = self.stack.t.resource_definitions(self.stack)
380
+        return grouppolicy.PolicyTarget(
381
+            'policy_target', resource_defns['policy_target'], self.stack)
382
+
383
+    def test_create_no_port_no_fixed_ip(self):
384
+        rsrc = self.create_policy_target_no_port_no_fixed_ip()
385
+        self.m.ReplayAll()
386
+        scheduler.TaskRunner(rsrc.create)()
387
+        self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
388
+        self.m.VerifyAll()
389
+
348 390
     def test_create_failed(self):
349 391
         gbpclient.Client.create_policy_target({
350 392
             'policy_target': {

Loading…
Cancel
Save