Optimize check_migrated in cinder_helper.py

There are more than one 'migrating' status in the volume migration.
Others include starting, completing and so on.
So we should check the final status 'success' and 'error'.

Change-Id: I8ee9330aa32ec4516f2bf9e046ea68a72bc8a53d
This commit is contained in:
licanwei
2017-10-16 00:55:55 -07:00
parent bf713ac7e1
commit d722b62b97

View File

@@ -165,7 +165,8 @@ class CinderHelper(object):
def check_migrated(self, volume, retry_interval=10):
volume = self.get_volume(volume)
while getattr(volume, 'migration_status') == 'migrating':
final_status = ('success', 'error')
while getattr(volume, 'migration_status') not in final_status:
volume = self.get_volume(volume.id)
LOG.debug('Waiting the migration of {0}'.format(volume))
time.sleep(retry_interval)