Set backup import volume id to real uuid
When we import a backup we put a manufactured volume id in the imported record. This commit ensures that we use a genuine uuid rather than the value '0000-0000-0000-0000'. Change-Id: I0ab7d5e2d55fe007d35bd0fd2ffcccfc919eb667
This commit is contained in:
parent
ed125612d9
commit
5a0640eb41
@ -52,6 +52,7 @@ CONF = cfg.CONF
|
|||||||
CONF.register_opts(backup_api_opts)
|
CONF.register_opts(backup_api_opts)
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
QUOTAS = quota.QUOTAS
|
QUOTAS = quota.QUOTAS
|
||||||
|
IMPORT_VOLUME_ID = '00000000-0000-0000-0000-000000000000'
|
||||||
|
|
||||||
|
|
||||||
def check_policy(context, action):
|
def check_policy(context, action):
|
||||||
@ -550,7 +551,7 @@ class API(base.Base):
|
|||||||
kwargs = {
|
kwargs = {
|
||||||
'user_id': context.user_id,
|
'user_id': context.user_id,
|
||||||
'project_id': context.project_id,
|
'project_id': context.project_id,
|
||||||
'volume_id': '0000-0000-0000-0000',
|
'volume_id': IMPORT_VOLUME_ID,
|
||||||
'status': fields.BackupStatus.CREATING,
|
'status': fields.BackupStatus.CREATING,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import webob
|
|||||||
|
|
||||||
# needed for stubs to work
|
# needed for stubs to work
|
||||||
import cinder.backup
|
import cinder.backup
|
||||||
|
from cinder.backup import api as backup_api
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import db
|
from cinder import db
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
@ -1911,7 +1912,7 @@ class BackupsAPITestCase(test.TestCase):
|
|||||||
db_backup = objects.Backup.get_by_id(ctx, 'id')
|
db_backup = objects.Backup.get_by_id(ctx, 'id')
|
||||||
self.assertEqual(ctx.project_id, db_backup.project_id)
|
self.assertEqual(ctx.project_id, db_backup.project_id)
|
||||||
self.assertEqual(ctx.user_id, db_backup.user_id)
|
self.assertEqual(ctx.user_id, db_backup.user_id)
|
||||||
self.assertEqual('0000-0000-0000-0000', db_backup.volume_id)
|
self.assertEqual(backup_api.IMPORT_VOLUME_ID, db_backup.volume_id)
|
||||||
self.assertEqual(fields.BackupStatus.CREATING, db_backup.status)
|
self.assertEqual(fields.BackupStatus.CREATING, db_backup.status)
|
||||||
|
|
||||||
@mock.patch('cinder.backup.api.API._list_backup_hosts')
|
@mock.patch('cinder.backup.api.API._list_backup_hosts')
|
||||||
@ -1954,7 +1955,7 @@ class BackupsAPITestCase(test.TestCase):
|
|||||||
db_backup = objects.Backup.get_by_id(ctx, 'id')
|
db_backup = objects.Backup.get_by_id(ctx, 'id')
|
||||||
self.assertEqual(ctx.project_id, db_backup.project_id)
|
self.assertEqual(ctx.project_id, db_backup.project_id)
|
||||||
self.assertEqual(ctx.user_id, db_backup.user_id)
|
self.assertEqual(ctx.user_id, db_backup.user_id)
|
||||||
self.assertEqual('0000-0000-0000-0000', db_backup.volume_id)
|
self.assertEqual(backup_api.IMPORT_VOLUME_ID, db_backup.volume_id)
|
||||||
self.assertEqual(fields.BackupStatus.CREATING, db_backup.status)
|
self.assertEqual(fields.BackupStatus.CREATING, db_backup.status)
|
||||||
|
|
||||||
db.backup_destroy(context.get_admin_context(), backup_id)
|
db.backup_destroy(context.get_admin_context(), backup_id)
|
||||||
@ -1998,7 +1999,7 @@ class BackupsAPITestCase(test.TestCase):
|
|||||||
db_backup = objects.Backup.get_by_id(ctx, 'id')
|
db_backup = objects.Backup.get_by_id(ctx, 'id')
|
||||||
self.assertEqual(ctx.project_id, db_backup.project_id)
|
self.assertEqual(ctx.project_id, db_backup.project_id)
|
||||||
self.assertEqual(ctx.user_id, db_backup.user_id)
|
self.assertEqual(ctx.user_id, db_backup.user_id)
|
||||||
self.assertEqual('0000-0000-0000-0000', db_backup.volume_id)
|
self.assertEqual(backup_api.IMPORT_VOLUME_ID, db_backup.volume_id)
|
||||||
self.assertEqual(fields.BackupStatus.CREATING, db_backup.status)
|
self.assertEqual(fields.BackupStatus.CREATING, db_backup.status)
|
||||||
|
|
||||||
# Verify the response
|
# Verify the response
|
||||||
|
Loading…
Reference in New Issue
Block a user