Fixes bug with path to ssh keys

Adds expansion of '~', if it is used in path to ssh key

Closes: bug 1282031
Change-Id: I82cc98908bbd547dfa42d2d0da68fab3601b0406
This commit is contained in:
Andrei V. Ostapenko 2014-02-19 12:52:17 +02:00
parent e0efa6e563
commit e416fc97ff
1 changed files with 7 additions and 3 deletions

View File

@ -457,8 +457,12 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver):
if not self.configuration.path_to_public_key or \
not self.configuration.path_to_private_key:
return
if not os.path.exists(self.configuration.path_to_public_key) or \
not os.path.exists(self.configuration.path_to_private_key):
path_to_public_key = \
os.path.expanduser(self.configuration.path_to_public_key)
path_to_private_key = \
os.path.expanduser(self.configuration.path_to_private_key)
if not os.path.exists(path_to_public_key) or \
not os.path.exists(path_to_private_key):
return
keypair_name = self.configuration.manila_service_keypair_name
keypairs = [k for k in self.compute_api.keypair_list(context)
@ -467,7 +471,7 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver):
raise exception.ManilaException(_('Ambiguous keypairs'))
public_key, _ = self._execute('cat',
self.configuration.path_to_public_key,
path_to_public_key,
run_as_root=True)
if not keypairs:
keypair = self.compute_api.keypair_import(context, keypair_name,