keygen: Update the cached vars after a keygen
This makes sure we can just re-use the same keystore without having to
reinitialize it.
Change-Id: I15e54030a54c0176dc755d8a6704bd51ae90104a
diff --git a/mdt/keys.py b/mdt/keys.py
index ea8f399..ce2c5e5 100644
--- a/mdt/keys.py
+++ b/mdt/keys.py
@@ -17,6 +17,9 @@
self.private_key = self.config.getKey("mdt")
self.public_key = self.config.getKey("mdt.pub")
+ def privateKeyPath(self):
+ return os.path.join(config.CONFIG_KEYSDIR, "mdt")
+
def generateKey(self):
if platform.system() not in SUPPORTED_SYSTEMS:
print('Sorry, MDT doesn\'t support generating SSH keys on platforms other than:')
@@ -27,7 +30,7 @@
subprocess.run([
"ssh-keygen",
"-f",
- os.path.join(config.CONFIG_KEYSDIR, "mdt"),
+ self.privateKeyPath(),
"-P",
""
], check=True)
@@ -39,6 +42,9 @@
print('ssh-keygen failed with error code {0}'.format(e.returncode))
return False
+ self.private_key = self.config.getKey("mdt")
+ self.public_key = self.config.getKey("mdt.pub")
+
return True
def publicKey(self):