Finds a betterr solution to handle keypari

This commit is contained in:
Sahid Orentino Ferdjaoui 2013-10-11 11:05:41 +02:00
parent 6560500f28
commit e54b2f1840
1 changed files with 6 additions and 4 deletions

View File

@ -116,10 +116,12 @@ class Key(Base):
whitelist = dict(
name=options["name"],
path=options.get("path", "."))
key = self._agent.client.compute.keypairs.create(whitelist["name"])
f = open("%(path)s/%(name)s.pem" % whitelist, 'w')
f.write(key.private_key)
f.close
key = self._agent.client.compute.keypairs.get(whitelist["name"])
if not key:
key = self._agent.client.compute.keypairs.create(whitelist["name"])
f = open("%(path)s/%(name)s.pem" % whitelist, 'w')
f.write(key.private_key)
f.close
return key
class Image(Base):