Add logging to FakeLoggingVolumeDriver

Now each method is wrapped with utils.trace_method to get logs during
tests and debugging if needed.

Change-Id: I2d84716eeb2a528bc2d0cb230fda051704a32737
This commit is contained in:
Ivan Kolodyazhny 2016-11-29 13:34:51 +02:00
parent 03f9de7fb7
commit adcc5c7ff0
1 changed files with 17 additions and 1 deletions

View File

@ -18,12 +18,12 @@ from cinder import exception
from cinder import objects
from cinder.objects import fields
from cinder.tests.unit.brick import fake_lvm
from cinder import utils
from cinder.volume import driver
from cinder.volume.drivers import lvm
from cinder.zonemanager import utils as fczm_utils
# TODO(e0ne): add logging to FakeLoggingVolumeDriver and remove this one.
# TODO(e0ne): inherit from driver.VolumeDriver and fix unit-tests
class FakeLoggingVolumeDriver(lvm.LVMVolumeDriver):
"""Logs calls instead of executing."""
@ -37,46 +37,60 @@ class FakeLoggingVolumeDriver(lvm.LVMVolumeDriver):
None, 'default',
self.fake_execute)
@utils.trace_method
def check_for_setup_error(self):
"""No setup necessary in fake mode."""
pass
@utils.trace_method
def create_volume(self, volume):
pass
@utils.trace_method
def delete_volume(self, volume):
pass
@utils.trace_method
def create_snapshot(self, snapshot):
pass
@utils.trace_method
def delete_snapshot(self, snapshot):
pass
@utils.trace_method
def ensure_export(self, context, volume):
pass
@utils.trace_method
def create_export(self, context, volume, connector):
pass
@utils.trace_method
def remove_export(self, context, volume):
pass
@utils.trace_method
def create_export_snapshot(self, context, snapshot):
pass
@utils.trace_method
def remove_export_snapshot(self, context, snapshot):
pass
@utils.trace_method
def terminate_connection_snapshot(self, snapshot, connector):
pass
@utils.trace_method
def create_cloned_volume(self, volume, src_vol):
pass
@utils.trace_method
def create_volume_from_snapshot(self, volume, snapshot):
pass
@utils.trace_method
def initialize_connection(self, volume, connector):
# NOTE(thangp): There are several places in the core cinder code where
# the volume passed through is a dict and not an oslo_versionedobject.
@ -98,11 +112,13 @@ class FakeLoggingVolumeDriver(lvm.LVMVolumeDriver):
return {'driver_volume_type': 'iscsi',
'data': {'access_mode': access_mode}}
@utils.trace_method
def initialize_connection_snapshot(self, snapshot, connector):
return {
'driver_volume_type': 'iscsi',
}
@utils.trace_method
def terminate_connection(self, volume, connector, **kwargs):
pass