From 99870625aa9b4235ff992f34acdffe701d2babc7 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Wed, 25 Jan 2017 09:41:57 +0200 Subject: [PATCH] Add a get method to retrieve the SSH public key contents. This will be used later to install hosts using public key, for Ansible, etc. --- lago/prefix.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lago/prefix.py b/lago/prefix.py index 54ebbab6..55360cdd 100644 --- a/lago/prefix.py +++ b/lago/prefix.py @@ -1040,6 +1040,19 @@ def get_nets(self): """ return self.virt_env.get_nets() + def get_ssh_pub_key(self): + """ + Returns the contents of the SSH public key. + To be used to install hosts with public key, or + set cloud-init configuration with public key, or + for Ansible integration + + Returns: + str: SSH public key + """ + with open(self.paths.ssh_id_rsa_pub()) as pub_key: + return pub_key.read() + @classmethod def resolve_prefix_path(cls, start_path=None): """