]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
OS::Quantum::Subnet resource, add enable_dhcp
authorSteven Hardy <shardy@redhat.com>
Tue, 25 Jun 2013 08:49:34 +0000 (09:49 +0100)
committerSteven Hardy <shardy@redhat.com>
Tue, 25 Jun 2013 08:53:30 +0000 (09:53 +0100)
Add enable_dhcp to the properties schema, since quantumclient
code indicates this is allowed in the body (not only expected
in the response as currently indicated by the docs)

Fixes bug #1194394

Change-Id: I19770b033696ea9a27b6e985a52bf2cfadb16f52

heat/engine/resources/quantum/subnet.py
heat/tests/test_quantum.py

index a75df953499ce28dccd936f71fd554046b9335ec..ee02e5ec01c8b96dc0d344993e7ddcf511a8d526 100644 (file)
@@ -42,6 +42,7 @@ class Subnet(quantum.QuantumResource):
                                         'Default': 4},
                          'dns_nameservers': {'Type': 'List'},
                          'gateway_ip': {'Type': 'String'},
+                         'enable_dhcp': {'Type': 'Boolean'},
                          'allocation_pools': {'Type': 'List',
                                               'Schema': {
                                               'Type': 'Map',
index 123ea01f21d6efd5593b0ce66ca123acfda0d778..0c44c8b8a26ba0bf47fadba94fcb9aaf3a4b5f9f 100644 (file)
@@ -366,7 +366,7 @@ class QuantumSubnetTest(HeatTestCase):
                     "cidr": "10.0.3.0/24",
                     "dns_nameservers": ["8.8.8.8"],
                     "id": "91e47a57-7508-46fe-afc9-fc454e8580e1",
-                    "enable_dhcp": False,
+                    "enable_dhcp": True,
                 }
             })
 
@@ -402,6 +402,70 @@ class QuantumSubnetTest(HeatTestCase):
         self.assertEqual(rsrc.delete(), None)
         self.m.VerifyAll()
 
+    def test_subnet_disable_dhcp(self):
+
+        quantumclient.Client.create_subnet({
+            'subnet': {
+                'name': utils.PhysName('test_stack', 'test_subnet'),
+                'network_id': u'None',
+                'dns_nameservers': [u'8.8.8.8'],
+                'allocation_pools': [
+                    {'start': u'10.0.3.20', 'end': u'10.0.3.150'}],
+                'ip_version': 4,
+                'enable_dhcp': False,
+                'cidr': u'10.0.3.0/24'
+            }
+        }).AndReturn({
+            "subnet": {
+                "allocation_pools": [
+                    {"start": "10.0.3.20", "end": "10.0.3.150"}],
+                "cidr": "10.0.3.0/24",
+                "dns_nameservers": ["8.8.8.8"],
+                "enable_dhcp": False,
+                "gateway_ip": "10.0.3.1",
+                "id": "91e47a57-7508-46fe-afc9-fc454e8580e1",
+                "ip_version": 4,
+                "name": "name",
+                "network_id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766",
+                "tenant_id": "c1210485b2424d48804aad5d39c61b8f"
+            }
+        })
+
+        quantumclient.Client.show_subnet(
+            '91e47a57-7508-46fe-afc9-fc454e8580e1').AndReturn({
+                "subnet": {
+                    "name": "name",
+                    "network_id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766",
+                    "tenant_id": "c1210485b2424d48804aad5d39c61b8f",
+                    "allocation_pools": [
+                        {"start": "10.0.3.20", "end": "10.0.3.150"}],
+                    "gateway_ip": "10.0.3.1",
+                    "ip_version": 4,
+                    "cidr": "10.0.3.0/24",
+                    "dns_nameservers": ["8.8.8.8"],
+                    "id": "91e47a57-7508-46fe-afc9-fc454e8580e1",
+                    "enable_dhcp": False,
+                }
+            })
+
+        quantumclient.Client.delete_subnet(
+            '91e47a57-7508-46fe-afc9-fc454e8580e1'
+        ).AndReturn(None)
+
+        self.m.ReplayAll()
+        t = template_format.parse(quantum_template)
+        t['Resources']['subnet']['Properties']['enable_dhcp'] = 'False'
+        stack = parse_stack(t)
+        rsrc = self.create_subnet(t, stack, 'subnet')
+
+        rsrc.validate()
+
+        ref_id = rsrc.FnGetRefId()
+        self.assertEqual('91e47a57-7508-46fe-afc9-fc454e8580e1', ref_id)
+        self.assertEqual(False, rsrc.FnGetAtt('enable_dhcp'))
+        self.assertEqual(rsrc.delete(), None)
+        self.m.VerifyAll()
+
 
 @skipIf(quantumclient is None, 'quantumclient unavailable')
 class QuantumRouterTest(HeatTestCase):