Browse Source

add support for networks

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

+ 19
- 0
downpour/resolver.py View File

@@ -124,6 +124,22 @@ class Resolver:
124 124
         }
125 125
         yield self._map_uuids('volume', volume.name, volume.id, 'volume.id')
126 126
 
127
+    def network(self, network):
128
+        if ('network', network.name) in self._memo:
129
+            return
130
+        self._memo.add(('network', network.name))
131
+        yield {
132
+            'name': 'Create network {}'.format(network.name),
133
+            'os_network': {
134
+                'name': network.name,
135
+                'external': network.get('router:external', False),
136
+                'shared': network.shared,
137
+                'state': 'present',
138
+            },
139
+            'register': self._mk_var_name('net'),
140
+        }
141
+        yield self._map_uuids('network', network.name, network.id, 'network.id')
142
+
127 143
     def server(self, server, save_state):
128 144
         for sg in server.security_groups:
129 145
             sg_data = self.cloud.get_security_group(sg.name)
@@ -133,6 +149,9 @@ class Resolver:
133 149
             vol_data = self.cloud.get_volume(vol.id)
134 150
             vol_names.append(vol_data.name)
135 151
             yield from self.volume(vol_data, save_state)
152
+        for net_name in server.networks:
153
+            net_data = self.cloud.get_network(net_name)
154
+            yield from self.network(net_data)
136 155
         # FIXME(dhellmann): Need to handle networks other than 'public'.
137 156
         # FIXME(dhellmann): Need to handle public IPs. Use auto_ip?
138 157
         # FIXME(dhellmann): For now assume the image exists, but we may

Loading…
Cancel
Save