Exemplo n.º 1
0
    def test_ec2_uuid_mapping(self):
        ec2_vol = db.ec2_volume_create(context.get_admin_context(), "aaaaaaaa-bbbb-bbbb-bbbb-aaaaaaaaaaaa", 5)
        self.assertEqual(5, ec2_vol["id"])
        self.assertEqual(
            "aaaaaaaa-bbbb-bbbb-bbbb-aaaaaaaaaaaa", db.get_volume_uuid_by_ec2_id(context.get_admin_context(), 5)
        )

        ec2_vol = db.ec2_volume_create(context.get_admin_context(), "aaaaaaaa-bbbb-bbbb-bbbb-aaaaaaaaaaaa", 1)
        self.assertEqual(1, ec2_vol["id"])

        ec2_vol = db.ec2_volume_create(context.get_admin_context(), "aaaaaaaa-bbbb-bbbb-bbbb-aaaaaaaaazzz")
        self.assertEqual(6, ec2_vol["id"])
Exemplo n.º 2
0
    def test_ec2_uuid_mapping(self):
        ec2_vol = db.ec2_volume_create(context.get_admin_context(),
                'aaaaaaaa-bbbb-bbbb-bbbb-aaaaaaaaaaaa', 5)
        self.assertEqual(5, ec2_vol['id'])
        self.assertEqual('aaaaaaaa-bbbb-bbbb-bbbb-aaaaaaaaaaaa',
                db.get_volume_uuid_by_ec2_id(context.get_admin_context(), 5))

        ec2_vol = db.ec2_volume_create(context.get_admin_context(),
                'aaaaaaaa-bbbb-bbbb-bbbb-aaaaaaaaaaaa', 1)
        self.assertEqual(1, ec2_vol['id'])

        ec2_vol = db.ec2_volume_create(context.get_admin_context(),
                'aaaaaaaa-bbbb-bbbb-bbbb-aaaaaaaaazzz')
        self.assertEqual(6, ec2_vol['id'])
Exemplo n.º 3
0
def get_int_id_from_volume_uuid(context, volume_uuid):
    if volume_uuid is None:
        return
    try:
        return db.get_ec2_volume_id_by_uuid(context, volume_uuid)
    except exception.NotFound:
        return db.ec2_volume_create(context, volume_uuid)['id']
Exemplo n.º 4
0
def get_int_id_from_volume_uuid(context, volume_uuid):
    if volume_uuid is None:
        return
    try:
        return db.get_ec2_volume_id_by_uuid(context, volume_uuid)
    except exception.NotFound:
        return db.ec2_volume_create(context, volume_uuid)['id']
Exemplo n.º 5
0
 def create(self, context):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason='already created')
     db_vmap = db.ec2_volume_create(context, self.uuid)
     self._from_db_object(context, self, db_vmap)
Exemplo n.º 6
0
 def test_get_vol_mapping_non_admin(self):
     ref = db.ec2_volume_create(self.context, 'fake-uuid')
     ec2_id = db.get_ec2_volume_id_by_uuid(self.context, 'fake-uuid')
     self.assertEqual(ref['id'], ec2_id)
Exemplo n.º 7
0
 def test_get_vol_mapping_non_admin(self):
     ref = db.ec2_volume_create(self.context, 'fake-uuid')
     ec2_id = db.get_ec2_volume_id_by_uuid(self.context, 'fake-uuid')
     self.assertEqual(ref['id'], ec2_id)