fixed old key reference and made keypair name constistent -> key_pair
This commit is contained in:
@@ -604,9 +604,9 @@ class AuthManager(object):
|
|||||||
def delete_user(self, user):
|
def delete_user(self, user):
|
||||||
"""Deletes a user
|
"""Deletes a user
|
||||||
|
|
||||||
Additionally deletes all users keypairs"""
|
Additionally deletes all users key_pairs"""
|
||||||
uid = User.safe_id(user)
|
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:
|
with self.driver() as drv:
|
||||||
drv.delete_user(uid)
|
drv.delete_user(uid)
|
||||||
|
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ def _gen_key(context, user_id, key_name):
|
|||||||
it into a process pool."""
|
it into a process pool."""
|
||||||
try:
|
try:
|
||||||
# NOTE(vish): generating key pair is slow so check for legal
|
# NOTE(vish): generating key pair is slow so check for legal
|
||||||
# creation before creating keypair
|
# creation before creating key_pair
|
||||||
try:
|
try:
|
||||||
db.keypair_get(context, user_id, key_name)
|
db.key_pair_get(context, user_id, key_name)
|
||||||
raise exception.Duplicate("The keypair %s already exists"
|
raise exception.Duplicate("The key_pair %s already exists"
|
||||||
% key_name)
|
% key_name)
|
||||||
except exception.NotFound:
|
except exception.NotFound:
|
||||||
pass
|
pass
|
||||||
@@ -64,7 +64,7 @@ def _gen_key(context, user_id, key_name):
|
|||||||
key['name'] = key_name
|
key['name'] = key_name
|
||||||
key['public_key'] = public_key
|
key['public_key'] = public_key
|
||||||
key['fingerprint'] = fingerprint
|
key['fingerprint'] = fingerprint
|
||||||
db.keypair_create(context, key)
|
db.key_pair_create(context, key)
|
||||||
return {'private_key': private_key, 'fingerprint': fingerprint}
|
return {'private_key': private_key, 'fingerprint': fingerprint}
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
return {'exception': ex}
|
return {'exception': ex}
|
||||||
@@ -193,7 +193,7 @@ class CloudController(object):
|
|||||||
|
|
||||||
@rbac.allow('all')
|
@rbac.allow('all')
|
||||||
def describe_key_pairs(self, context, key_name=None, **kwargs):
|
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:
|
if not key_name is None:
|
||||||
key_pairs = [x for x in key_pairs if x['name'] in key_name]
|
key_pairs = [x for x in key_pairs if x['name'] in key_name]
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ class CloudController(object):
|
|||||||
@rbac.allow('all')
|
@rbac.allow('all')
|
||||||
def delete_key_pair(self, context, key_name, **kwargs):
|
def delete_key_pair(self, context, key_name, **kwargs):
|
||||||
try:
|
try:
|
||||||
db.keypair_destroy(context, context.user.id, key_name)
|
db.key_pair_destroy(context, context.user.id, key_name)
|
||||||
except exception.NotFound:
|
except exception.NotFound:
|
||||||
# aws returns true even if the key doesn't exist
|
# aws returns true even if the key doesn't exist
|
||||||
pass
|
pass
|
||||||
@@ -545,11 +545,10 @@ class CloudController(object):
|
|||||||
launch_time = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
|
launch_time = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
|
||||||
key_data = None
|
key_data = None
|
||||||
if kwargs.has_key('key_name'):
|
if kwargs.has_key('key_name'):
|
||||||
key_pair = context.user.get_key_pair(kwargs['key_name'])
|
key_pair_ref = db.key_pair_get(context,
|
||||||
if not key_pair:
|
context.user.id,
|
||||||
raise exception.ApiError('Key Pair %s not found' %
|
|
||||||
kwargs['key_name'])
|
kwargs['key_name'])
|
||||||
key_data = key_pair.public_key
|
key_data = key_pair_ref['public_key']
|
||||||
|
|
||||||
# TODO: Get the real security group of launch in here
|
# TODO: Get the real security group of launch in here
|
||||||
security_group = "default"
|
security_group = "default"
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class CloudTestCase(test.BaseTestCase):
|
|||||||
private_key = result['private_key']
|
private_key = result['private_key']
|
||||||
key = RSA.load_key_string(private_key, callback=lambda: None)
|
key = RSA.load_key_string(private_key, callback=lambda: None)
|
||||||
bio = BIO.MemoryBuffer()
|
bio = BIO.MemoryBuffer()
|
||||||
public_key = db.keypair_get(self.context,
|
public_key = db.key_pair_get(self.context,
|
||||||
self.context.user.id,
|
self.context.user.id,
|
||||||
'test')['public_key']
|
'test')['public_key']
|
||||||
key.save_pub_key_bio(bio)
|
key.save_pub_key_bio(bio)
|
||||||
|
|||||||
Reference in New Issue
Block a user