From 443bf7854283b4f317261377d512601ef8850e6a Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 11 Sep 2015 10:00:59 +0100 Subject: Ensure directory exists before creating known_hosts. --- openstack/tester | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openstack/tester b/openstack/tester index 583eb80..1643537 100755 --- a/openstack/tester +++ b/openstack/tester @@ -281,7 +281,12 @@ class Deployment(object): def _update_known_hosts(self): if not self._ssh_host_key_exists(self.host_machine.address): - with open('/root/.ssh/known_hosts', 'a') as known_hosts: + filename = '/root/.ssh/known_hosts'; + print("No known_hosts: ensuring path"); + if not os.path.exists(os.path.dirname(filename)): + os.makedirs(os.path.dirname(filename)) + with open(filename, 'a') as known_hosts: + print("Generating known_hosts"); cliapp.runcmd(['ssh-keyscan', self.host_machine.address], stdout=known_hosts) -- cgit v1.2.1