فهرست منبع

Merged in alexpilotti/coriolis (pull request #27)

Adds logging when waiting for OpenStack resources
Alessandro Pilotti 9 سال پیش
والد
کامیت
7205f6b9f7
1فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 15 0
      coriolis/providers/openstack/common.py

+ 15 - 0
coriolis/providers/openstack/common.py

@@ -6,6 +6,7 @@ import math
 import time
 import uuid
 
+from oslo_log import log as logging
 from oslo_utils import units
 from swiftclient import client as swift_client
 
@@ -19,6 +20,8 @@ GLANCE_API_VERSION = 1
 NEUTRON_API_VERSION = '2.0'
 CINDER_API_VERSION = 2
 
+LOG = logging.getLogger(__name__)
+
 
 GlanceImage = collections.namedtuple(
     "GlanceImage", "id format size path os_type")
@@ -77,6 +80,8 @@ def _create_image_v1(glance, name, disk_path, disk_format, container_format,
 def wait_for_image(nova, image_id, expected_status='ACTIVE'):
     image = nova.images.get(image_id)
     while image.status not in [expected_status, 'ERROR']:
+        LOG.debug('Image %(id)s status: %(status)s',
+                  {'id': image_id, 'status': image.status})
         time.sleep(2)
         image = nova.images.get(image.id)
     if image.status != expected_status:
@@ -88,6 +93,8 @@ def wait_for_image(nova, image_id, expected_status='ACTIVE'):
 def wait_for_instance(nova, instance_id, expected_status='ACTIVE'):
     instance = nova.servers.get(instance_id)
     while instance.status not in [expected_status, 'ERROR']:
+        LOG.debug('Instance %(id)s status: %(status)s',
+                  {'id': instance_id, 'status': instance.status})
         time.sleep(2)
         instance = nova.servers.get(instance.id)
     if instance.status != expected_status:
@@ -99,6 +106,8 @@ def wait_for_instance(nova, instance_id, expected_status='ACTIVE'):
 def wait_for_instance_deletion(nova, instance_id):
     instances = nova.servers.findall(id=instance_id)
     while instances and instances[0].status != 'ERROR':
+        LOG.debug('Instance %(id)s status: %(status)s',
+                  {'id': instance_id, 'status': instances[0].status})
         time.sleep(2)
         instances = nova.servers.findall(id=instance_id)
     if instances:
@@ -168,6 +177,8 @@ def wait_for_volume(cinder, volume_id, expected_status='available'):
     volume = volumes[0]
 
     while volume.status not in [expected_status, 'error']:
+        LOG.debug('Volume %(id)s status: %(status)s',
+                  {'id': volume_id, 'status': volume.status})
         time.sleep(2)
         volume = cinder.volumes.get(volume.id)
     if volume.status != expected_status:
@@ -199,6 +210,8 @@ def wait_for_volume_snapshot(cinder, snapshot_id,
     snapshot = snapshots[0]
 
     while snapshot.status not in [expected_status, 'error']:
+        LOG.debug('Volume snapshot %(id)s status: %(status)s',
+                  {'id': snapshot_id, 'status': snapshot.status})
         time.sleep(2)
         if expected_status == 'deleted':
             snapshots = cinder.volume_snapshots.findall(id=snapshot_id)
@@ -242,6 +255,8 @@ def wait_for_volume_backup(cinder, backup_id, expected_status='available'):
     backup = backups[0]
 
     while backup.status not in [expected_status, 'error']:
+        LOG.debug('Volume backup %(id)s status: %(status)s',
+                  {'id': backup_id, 'status': backup.status})
         time.sleep(2)
         if expected_status == 'deleted':
             backups = cinder.backups.findall(id=backup_id)