Browse Source

add support for subnets

Change-Id: I32edbd237ac8481182a1a452df85c08845e86036
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Doug Hellmann 2 years ago
parent
commit
b18df373d3
1 changed files with 24 additions and 1 deletions
  1. 24
    1
      downpour/resolver.py

+ 24
- 1
downpour/resolver.py View File

@@ -139,6 +139,30 @@ class Resolver:
139 139
             'register': self._mk_var_name('net'),
140 140
         }
141 141
         yield self._map_uuids('network', network.name, network.id, 'network.id')
142
+        for subnet_id in network.subnets:
143
+            subnet = self.cloud.get_subnet(subnet_id)
144
+            os_subnet = {
145
+                'name': subnet.name,
146
+                'network_name': network.name,
147
+                'cidr': subnet.cidr,
148
+                'state': 'present',
149
+                'allocation_pool_start': subnet.allocation_pools[0]['start'],
150
+                'allocation_pool_end': subnet.allocation_pools[0]['end'],
151
+                'dns_nameservers': subnet.dns_nameservers,
152
+                'ip_version': subnet.ip_version,
153
+            }
154
+            if subnet.gateway_ip:
155
+                os_subnet['gateway_ip'] = subnet.gateway_ip
156
+            if subnet.ip_version == 6:
157
+                os_subnet['ipv6_ra_mode'] = subnet.ipv6_ra_mode
158
+                os_subnet['ipv6_address_mode'] = subnet.ipv6_address_mode
159
+            yield {
160
+                'name': 'Create subnet {} on network {}'.format(subnet.name,
161
+                                                                network.name),
162
+                'os_subnet': os_subnet,
163
+                'register': self._mk_var_name('subnet'),
164
+            }
165
+            yield self._map_uuids('subnet', subnet.name, subnet.id, 'subnet.id')
142 166
 
143 167
     def server(self, server, save_state):
144 168
         for sg in server.security_groups:
@@ -152,7 +176,6 @@ class Resolver:
152 176
         for net_name in server.networks:
153 177
             net_data = self.cloud.get_network(net_name)
154 178
             yield from self.network(net_data)
155
-        # FIXME(dhellmann): Need to handle networks other than 'public'.
156 179
         # FIXME(dhellmann): Need to handle public IPs. Use auto_ip?
157 180
         # FIXME(dhellmann): For now assume the image exists, but we may
158 181
         #                   have to dump and recreate it.

Loading…
Cancel
Save