summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/auth/manager.py4
-rw-r--r--nova/cloudpipe/pipelib.py4
-rw-r--r--nova/crypto.py2
-rw-r--r--nova/db/api.py30
-rw-r--r--nova/db/sqlalchemy/api.py28
-rw-r--r--nova/db/sqlalchemy/models.py6
-rw-r--r--nova/endpoint/cloud.py21
-rw-r--r--nova/tests/cloud_unittest.py2
8 files changed, 48 insertions, 49 deletions
diff --git a/nova/auth/manager.py b/nova/auth/manager.py
index fb87847d5..4e321c1bd 100644
--- a/nova/auth/manager.py
+++ b/nova/auth/manager.py
@@ -604,9 +604,9 @@ class AuthManager(object):
def delete_user(self, user):
"""Deletes a user
- Additionally deletes all users keypairs"""
+ Additionally deletes all users key_pairs"""
uid = User.safe_id(user)
- db.keypair_destroy_all_by_user(None, uid)
+ db.key_pair_destroy_all_by_user(None, uid)
with self.driver() as drv:
drv.delete_user(uid)
diff --git a/nova/cloudpipe/pipelib.py b/nova/cloudpipe/pipelib.py
index 2867bcb21..de6a97fb6 100644
--- a/nova/cloudpipe/pipelib.py
+++ b/nova/cloudpipe/pipelib.py
@@ -58,7 +58,7 @@ class CloudPipe(object):
z.write(FLAGS.boot_script_template,'autorun.sh')
z.close()
- key_name = self.setup_keypair(project.project_manager_id, project_id)
+ key_name = self.setup_key_pair(project.project_manager_id, project_id)
zippy = open(zippath, "r")
context = api.APIRequestContext(handler=None, user=project.project_manager, project=project)
@@ -74,7 +74,7 @@ class CloudPipe(object):
security_groups=["vpn-secgroup"])
zippy.close()
- def setup_keypair(self, user_id, project_id):
+ def setup_key_pair(self, user_id, project_id):
key_name = '%s%s' % (project_id, FLAGS.vpn_key_suffix)
try:
private_key, fingerprint = self.manager.generate_key_pair(user_id, key_name)
diff --git a/nova/crypto.py b/nova/crypto.py
index b05548ea1..1c6fe57ad 100644
--- a/nova/crypto.py
+++ b/nova/crypto.py
@@ -18,7 +18,7 @@
"""
Wrappers around standard crypto, including root and intermediate CAs,
-SSH keypairs and x509 certificates.
+SSH key_pairs and x509 certificates.
"""
import base64
diff --git a/nova/db/api.py b/nova/db/api.py
index e96d803db..507f70dd5 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -257,29 +257,29 @@ def instance_update(context, instance_id, values):
###################
-def keypair_create(context, values):
- """Create a keypair from the values dictionary."""
- return IMPL.keypair_create(context, values)
+def key_pair_create(context, values):
+ """Create a key_pair from the values dictionary."""
+ return IMPL.key_pair_create(context, values)
-def keypair_destroy(context, user_id, name):
- """Destroy the keypair or raise if it does not exist."""
- return IMPL.keypair_destroy(context, user_id, name)
+def key_pair_destroy(context, user_id, name):
+ """Destroy the key_pair or raise if it does not exist."""
+ return IMPL.key_pair_destroy(context, user_id, name)
-def keypair_destroy_all_by_user(context, user_id):
- """Destroy all keypairs by user."""
- return IMPL.keypair_destroy_all_by_user(context, user_id)
+def key_pair_destroy_all_by_user(context, user_id):
+ """Destroy all key_pairs by user."""
+ return IMPL.key_pair_destroy_all_by_user(context, user_id)
-def keypair_get(context, user_id, name):
- """Get a keypair or raise if it does not exist."""
- return IMPL.keypair_get(context, user_id, name)
+def key_pair_get(context, user_id, name):
+ """Get a key_pair or raise if it does not exist."""
+ return IMPL.key_pair_get(context, user_id, name)
-def keypair_get_all_by_user(context, user_id):
- """Get all keypairs by user."""
- return IMPL.keypair_get_all_by_user(context, user_id)
+def key_pair_get_all_by_user(context, user_id):
+ """Get all key_pairs by user."""
+ return IMPL.key_pair_get_all_by_user(context, user_id)
####################
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 4fd1bf216..ce97f6710 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -355,38 +355,38 @@ def instance_update(_context, instance_id, values):
###################
-def keypair_create(_context, values):
- keypair_ref = models.Keypair()
+def key_pair_create(_context, values):
+ key_pair_ref = models.KeyPair()
for (key, value) in values.iteritems():
- keypair_ref[key] = value
- keypair_ref.save()
- return keypair_ref
+ key_pair_ref[key] = value
+ key_pair_ref.save()
+ return key_pair_ref
-def keypair_destroy(_context, user_id, name):
+def key_pair_destroy(_context, user_id, name):
session = get_session()
with session.begin():
- keypair_ref = models.Keypair.find_by_args(user_id,
+ key_pair_ref = models.KeyPair.find_by_args(user_id,
name,
session=session)
- keypair_ref.delete(session=session)
+ key_pair_ref.delete(session=session)
-def keypair_destroy_all_by_user(_context, user_id):
+def key_pair_destroy_all_by_user(_context, user_id):
session = get_session()
with session.begin():
# TODO(vish): do we have to use sql here?
- session.execute('update keypairs set deleted=1 where user_id=:id',
+ session.execute('update key_pairs set deleted=1 where user_id=:id',
{'id': user_id})
-def keypair_get(_context, user_id, name):
- return models.Keypair.find_by_args(user_id, name)
+def key_pair_get(_context, user_id, name):
+ return models.KeyPair.find_by_args(user_id, name)
-def keypair_get_all_by_user(_context, user_id):
+def key_pair_get_all_by_user(_context, user_id):
session = get_session()
- return session.query(models.Keypair
+ return session.query(models.KeyPair
).filter_by(user_id=user_id
).filter_by(deleted=False
).all()
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 81c0a77a8..0ecc48bae 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -284,9 +284,9 @@ class ExportDevice(BASE, NovaBase):
uselist=False))
-class Keypair(BASE, NovaBase):
- """Represents a keypair"""
- __tablename__ = 'keypairs'
+class KeyPair(BASE, NovaBase):
+ """Represents a public key pair for ssh"""
+ __tablename__ = 'key_pairs'
id = Column(Integer, primary_key=True)
name = Column(String(255))
diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py
index 172c65d79..f30565aca 100644
--- a/nova/endpoint/cloud.py
+++ b/nova/endpoint/cloud.py
@@ -51,10 +51,10 @@ def _gen_key(context, user_id, key_name):
it into a process pool."""
try:
# NOTE(vish): generating key pair is slow so check for legal
- # creation before creating keypair
+ # creation before creating key_pair
try:
- db.keypair_get(context, user_id, key_name)
- raise exception.Duplicate("The keypair %s already exists"
+ db.key_pair_get(context, user_id, key_name)
+ raise exception.Duplicate("The key_pair %s already exists"
% key_name)
except exception.NotFound:
pass
@@ -64,7 +64,7 @@ def _gen_key(context, user_id, key_name):
key['name'] = key_name
key['public_key'] = public_key
key['fingerprint'] = fingerprint
- db.keypair_create(context, key)
+ db.key_pair_create(context, key)
return {'private_key': private_key, 'fingerprint': fingerprint}
except Exception as ex:
return {'exception': ex}
@@ -193,7 +193,7 @@ class CloudController(object):
@rbac.allow('all')
def describe_key_pairs(self, context, key_name=None, **kwargs):
- key_pairs = db.keypair_get_all_by_user(context, context.user.id)
+ key_pairs = db.key_pair_get_all_by_user(context, context.user.id)
if not key_name is None:
key_pairs = [x for x in key_pairs if x['name'] in key_name]
@@ -228,7 +228,7 @@ class CloudController(object):
@rbac.allow('all')
def delete_key_pair(self, context, key_name, **kwargs):
try:
- db.keypair_destroy(context, context.user.id, key_name)
+ db.key_pair_destroy(context, context.user.id, key_name)
except exception.NotFound:
# aws returns true even if the key doesn't exist
pass
@@ -545,11 +545,10 @@ class CloudController(object):
launch_time = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
key_data = None
if kwargs.has_key('key_name'):
- key_pair = context.user.get_key_pair(kwargs['key_name'])
- if not key_pair:
- raise exception.ApiError('Key Pair %s not found' %
- kwargs['key_name'])
- key_data = key_pair.public_key
+ key_pair_ref = db.key_pair_get(context,
+ context.user.id,
+ kwargs['key_name'])
+ key_data = key_pair_ref['public_key']
# TODO: Get the real security group of launch in here
security_group = "default"
diff --git a/nova/tests/cloud_unittest.py b/nova/tests/cloud_unittest.py
index 4bad25c2b..e56ea6ac2 100644
--- a/nova/tests/cloud_unittest.py
+++ b/nova/tests/cloud_unittest.py
@@ -92,7 +92,7 @@ class CloudTestCase(test.BaseTestCase):
private_key = result['private_key']
key = RSA.load_key_string(private_key, callback=lambda: None)
bio = BIO.MemoryBuffer()
- public_key = db.keypair_get(self.context,
+ public_key = db.key_pair_get(self.context,
self.context.user.id,
'test')['public_key']
key.save_pub_key_bio(bio)