Browse Source

add support for ssh keypairs

Change-Id: Idf34efddd04862b9a840ce4fa3023f1126779215
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Doug Hellmann 2 years ago
parent
commit
d37455e88a
3 changed files with 22 additions and 0 deletions
  1. 2
    0
      demo/tiny-resources.yml
  2. 4
    0
      downpour/export.py
  3. 16
    0
      downpour/resolver.py

+ 2
- 0
demo/tiny-resources.yml View File

@@ -1,3 +1,5 @@
1 1
 # Resource file for downpour using the instance created in tiny.yml.
2 2
 servers:
3 3
   - name: downpour-demo-tiny
4
+keypairs:
5
+  - name: downpour-demo

+ 4
- 0
downpour/export.py View File

@@ -42,6 +42,10 @@ def export_data(cloud, config, args):
42 42
     # automatically.
43 43
     to_export = resources.load(args.resource_file)
44 44
 
45
+    for keypair_info in to_export.keypairs:
46
+        keypair = cloud.get_keypair(keypair_info.name)
47
+        tasks.extend(res.keypair(keypair))
48
+
45 49
     for image_info in to_export.images:
46 50
         image = cloud.get_image(image_info.name)
47 51
         tasks.extend(res.image(image))

+ 16
- 0
downpour/resolver.py View File

@@ -61,6 +61,22 @@ class Resolver:
61 61
             },
62 62
         }
63 63
 
64
+    def keypair(self, keypair):
65
+        if ('keypair', keypair.name) in self._memo:
66
+            return
67
+        self._memo.add(('keypair', keypair.name))
68
+        yield {
69
+            'name': 'Add public key {}'.format(keypair.name),
70
+            'os_keypair': {
71
+                'name': keypair.name,
72
+                'public_key': keypair.public_key,
73
+            },
74
+            'register': self._mk_var_name('key'),
75
+        }
76
+        yield self._map_uuids(
77
+            'keypair', keypair.name, keypair.id, 'key.id',
78
+        )
79
+
64 80
     def security_group(self, group):
65 81
         if ('security_group', group.id) in self._memo:
66 82
             return

Loading…
Cancel
Save