Update "if...if..." to "if...elif..."

Improved running efficiency  and  code structure is more clear.

Change-Id: Ib78ccc6c4c4885f7c39ef7db60585626aae95852
This commit is contained in:
caihui 2020-11-09 03:48:23 -08:00
parent cb0c79396c
commit 51b4d082d2
1 changed files with 6 additions and 3 deletions

View File

@ -482,9 +482,8 @@ class RestoreJob(Job):
"Backup Consistency Check failed: could not checksum file"
" {0} ({1})".format(e.filename, e.strerror))
return {}
res = restore.RestoreOs(conf.client_manager, conf.container,
self.storage)
if conf.backup_media == 'nova':
elif conf.backup_media == 'nova':
if self.conf.project_id:
return self.engine.restore_nova_tenant(
project_id=self.conf.project_id,
@ -560,6 +559,8 @@ class RestoreJob(Job):
backup_media=conf.mode)
elif conf.backup_media == 'cinder':
res = restore.RestoreOs(conf.client_manager, conf.container,
self.storage)
if conf.cinder_vol_id:
LOG.info("Restoring cinder backup from glance. "
"Volume ID: {0}, timestamp: {1}".format(
@ -575,6 +576,8 @@ class RestoreJob(Job):
res.restore_cinder_by_glance(instance_id,
restore_timestamp)
elif conf.backup_media == 'cindernative':
res = restore.RestoreOs(conf.client_manager, conf.container,
self.storage)
LOG.info("Restoring cinder native backup. Volume ID {0}, Backup ID"
" {1}, timestamp: {2}".format(conf.cindernative_vol_id,
conf.cindernative_backup_id,