Merge "Add new ec2 volume db API calls"
This commit is contained in:
commit
9b33819455
|
@ -1188,6 +1188,14 @@ def ec2_volume_create(context, volume_id, forced_id=None):
|
|||
return IMPL.ec2_volume_create(context, volume_id, forced_id)
|
||||
|
||||
|
||||
def ec2_volume_get_by_id(context, volume_id):
|
||||
return IMPL.ec2_volume_get_by_id(context, volume_id)
|
||||
|
||||
|
||||
def ec2_volume_get_by_uuid(context, volume_uuid):
|
||||
return IMPL.ec2_volume_get_by_uuid(context, volume_uuid)
|
||||
|
||||
|
||||
def get_snapshot_uuid_by_ec2_id(context, ec2_id):
|
||||
return IMPL.get_snapshot_uuid_by_ec2_id(context, ec2_id)
|
||||
|
||||
|
|
|
@ -3397,26 +3397,38 @@ def ec2_volume_create(context, volume_uuid, id=None):
|
|||
|
||||
|
||||
@require_context
|
||||
def get_ec2_volume_id_by_uuid(context, volume_id):
|
||||
def ec2_volume_get_by_uuid(context, volume_uuid):
|
||||
result = _ec2_volume_get_query(context).\
|
||||
filter_by(uuid=volume_id).\
|
||||
filter_by(uuid=volume_uuid).\
|
||||
first()
|
||||
|
||||
if not result:
|
||||
raise exception.VolumeNotFound(volume_id=volume_uuid)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@require_context
|
||||
def get_ec2_volume_id_by_uuid(context, volume_id):
|
||||
result = ec2_volume_get_by_uuid(context, volume_id)
|
||||
return result['id']
|
||||
|
||||
|
||||
@require_context
|
||||
def ec2_volume_get_by_id(context, volume_id):
|
||||
result = _ec2_volume_get_query(context).\
|
||||
filter_by(id=volume_id).\
|
||||
first()
|
||||
|
||||
if not result:
|
||||
raise exception.VolumeNotFound(volume_id=volume_id)
|
||||
|
||||
return result['id']
|
||||
return result
|
||||
|
||||
|
||||
@require_context
|
||||
def get_volume_uuid_by_ec2_id(context, ec2_id):
|
||||
result = _ec2_volume_get_query(context).\
|
||||
filter_by(id=ec2_id).\
|
||||
first()
|
||||
|
||||
if not result:
|
||||
raise exception.VolumeNotFound(volume_id=ec2_id)
|
||||
|
||||
result = ec2_volume_get_by_id(context, ec2_id)
|
||||
return result['uuid']
|
||||
|
||||
|
||||
|
|
|
@ -6255,6 +6255,16 @@ class Ec2TestCase(test.TestCase):
|
|||
vol_uuid = db.get_volume_uuid_by_ec2_id(self.ctxt, vol['id'])
|
||||
self.assertEqual(vol_uuid, 'fake-uuid')
|
||||
|
||||
def test_ec2_volume_get_by_id(self):
|
||||
vol = db.ec2_volume_create(self.ctxt, 'fake-uuid')
|
||||
vol2 = db.ec2_volume_get_by_id(self.ctxt, vol['id'])
|
||||
self.assertEqual(vol2['uuid'], vol['uuid'])
|
||||
|
||||
def test_ec2_volume_get_by_uuid(self):
|
||||
vol = db.ec2_volume_create(self.ctxt, 'fake-uuid')
|
||||
vol2 = db.ec2_volume_get_by_uuid(self.ctxt, vol['uuid'])
|
||||
self.assertEqual(vol2['id'], vol['id'])
|
||||
|
||||
def test_get_ec2_volume_id_by_uuid_not_found(self):
|
||||
self.assertRaises(exception.VolumeNotFound,
|
||||
db.get_ec2_volume_id_by_uuid,
|
||||
|
|
Loading…
Reference in New Issue