Move trace methods from utils to volume_utils
This continues moving code only used by volume drivers or the volume manager to volume_utils. The result of this is that fewer drivers import cinder.utils (and everything it imports), and less code is loaded by non-volume cinder code (api service, cinder-manage, etc.) Closes-Bug: #1912278 Change-Id: I5aa82cf0de4c70f53ddc998bf25e64f4ad8f5774
This commit is contained in:
parent
4bea91f1da
commit
e28e1a2f41
|
@ -18,7 +18,6 @@ from cinder import exception
|
||||||
from cinder import objects
|
from cinder import objects
|
||||||
from cinder.objects import fields
|
from cinder.objects import fields
|
||||||
from cinder.tests.unit.brick import fake_lvm
|
from cinder.tests.unit.brick import fake_lvm
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers import lvm
|
from cinder.volume.drivers import lvm
|
||||||
from cinder.volume import volume_utils
|
from cinder.volume import volume_utils
|
||||||
|
@ -38,12 +37,12 @@ class FakeLoggingVolumeDriver(lvm.LVMVolumeDriver):
|
||||||
None, 'default',
|
None, 'default',
|
||||||
self.fake_execute)
|
self.fake_execute)
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
"""No setup necessary in fake mode."""
|
"""No setup necessary in fake mode."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
"""Creates a volume."""
|
"""Creates a volume."""
|
||||||
super(FakeLoggingVolumeDriver, self).create_volume(volume)
|
super(FakeLoggingVolumeDriver, self).create_volume(volume)
|
||||||
|
@ -60,51 +59,51 @@ class FakeLoggingVolumeDriver(lvm.LVMVolumeDriver):
|
||||||
if model_update:
|
if model_update:
|
||||||
return model_update
|
return model_update
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def create_snapshot(self, snapshot):
|
def create_snapshot(self, snapshot):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def delete_snapshot(self, snapshot):
|
def delete_snapshot(self, snapshot):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def ensure_export(self, context, volume):
|
def ensure_export(self, context, volume):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def create_export(self, context, volume, connector):
|
def create_export(self, context, volume, connector):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def remove_export(self, context, volume):
|
def remove_export(self, context, volume):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def create_export_snapshot(self, context, snapshot):
|
def create_export_snapshot(self, context, snapshot):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def remove_export_snapshot(self, context, snapshot):
|
def remove_export_snapshot(self, context, snapshot):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def terminate_connection_snapshot(self, snapshot, connector):
|
def terminate_connection_snapshot(self, snapshot, connector):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def create_cloned_volume(self, volume, src_vol):
|
def create_cloned_volume(self, volume, src_vol):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def create_volume_from_snapshot(self, volume, snapshot):
|
def create_volume_from_snapshot(self, volume, snapshot):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
# NOTE(thangp): There are several places in the core cinder code where
|
# NOTE(thangp): There are several places in the core cinder code where
|
||||||
# the volume passed through is a dict and not an oslo_versionedobject.
|
# the volume passed through is a dict and not an oslo_versionedobject.
|
||||||
|
@ -126,18 +125,18 @@ class FakeLoggingVolumeDriver(lvm.LVMVolumeDriver):
|
||||||
return {'driver_volume_type': 'iscsi',
|
return {'driver_volume_type': 'iscsi',
|
||||||
'data': {'access_mode': access_mode}}
|
'data': {'access_mode': access_mode}}
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def initialize_connection_snapshot(self, snapshot, connector):
|
def initialize_connection_snapshot(self, snapshot, connector):
|
||||||
return {
|
return {
|
||||||
'driver_volume_type': 'iscsi',
|
'driver_volume_type': 'iscsi',
|
||||||
}
|
}
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Replication Group (Tiramisu)
|
# Replication Group (Tiramisu)
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def enable_replication(self, context, group, volumes):
|
def enable_replication(self, context, group, volumes):
|
||||||
"""Enables replication for a group and volumes in the group."""
|
"""Enables replication for a group and volumes in the group."""
|
||||||
model_update = {
|
model_update = {
|
||||||
|
@ -152,7 +151,7 @@ class FakeLoggingVolumeDriver(lvm.LVMVolumeDriver):
|
||||||
return model_update, volume_model_updates
|
return model_update, volume_model_updates
|
||||||
|
|
||||||
# Replication Group (Tiramisu)
|
# Replication Group (Tiramisu)
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def disable_replication(self, context, group, volumes):
|
def disable_replication(self, context, group, volumes):
|
||||||
"""Disables replication for a group and volumes in the group."""
|
"""Disables replication for a group and volumes in the group."""
|
||||||
model_update = {
|
model_update = {
|
||||||
|
@ -167,7 +166,7 @@ class FakeLoggingVolumeDriver(lvm.LVMVolumeDriver):
|
||||||
return model_update, volume_model_updates
|
return model_update, volume_model_updates
|
||||||
|
|
||||||
# Replication Group (Tiramisu)
|
# Replication Group (Tiramisu)
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def failover_replication(self, context, group, volumes,
|
def failover_replication(self, context, group, volumes,
|
||||||
secondary_backend_id=None):
|
secondary_backend_id=None):
|
||||||
"""Fails over replication for a group and volumes in the group."""
|
"""Fails over replication for a group and volumes in the group."""
|
||||||
|
@ -183,7 +182,7 @@ class FakeLoggingVolumeDriver(lvm.LVMVolumeDriver):
|
||||||
return model_update, volume_model_updates
|
return model_update, volume_model_updates
|
||||||
|
|
||||||
# Replication Group (Tiramisu)
|
# Replication Group (Tiramisu)
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def create_group(self, context, group):
|
def create_group(self, context, group):
|
||||||
"""Creates a group."""
|
"""Creates a group."""
|
||||||
model_update = super(FakeLoggingVolumeDriver, self).create_group(
|
model_update = super(FakeLoggingVolumeDriver, self).create_group(
|
||||||
|
@ -424,6 +423,6 @@ class FakeGateDriver(lvm.LVMVolumeDriver):
|
||||||
class FakeHAReplicatedLoggingVolumeDriver(FakeLoggingVolumeDriver):
|
class FakeHAReplicatedLoggingVolumeDriver(FakeLoggingVolumeDriver):
|
||||||
SUPPORTS_ACTIVE_ACTIVE = True
|
SUPPORTS_ACTIVE_ACTIVE = True
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def failover_completed(self, context, active_backend_id=None):
|
def failover_completed(self, context, active_backend_id=None):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -13,11 +13,9 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import functools
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
|
@ -1060,328 +1058,7 @@ class TestRetryDecorator(test.TestCase):
|
||||||
|
|
||||||
|
|
||||||
@ddt.ddt
|
@ddt.ddt
|
||||||
class LogTracingTestCase(test.TestCase):
|
class TestCalculateVirtualFree(test.TestCase):
|
||||||
|
|
||||||
def test_utils_setup_tracing(self):
|
|
||||||
self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
utils.setup_tracing(None)
|
|
||||||
self.assertFalse(utils.TRACE_API)
|
|
||||||
self.assertFalse(utils.TRACE_METHOD)
|
|
||||||
self.assertEqual(0, utils.LOG.warning.call_count)
|
|
||||||
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
self.assertFalse(utils.TRACE_API)
|
|
||||||
self.assertTrue(utils.TRACE_METHOD)
|
|
||||||
self.assertEqual(0, utils.LOG.warning.call_count)
|
|
||||||
|
|
||||||
utils.setup_tracing(['method', 'api'])
|
|
||||||
self.assertTrue(utils.TRACE_API)
|
|
||||||
self.assertTrue(utils.TRACE_METHOD)
|
|
||||||
self.assertEqual(0, utils.LOG.warning.call_count)
|
|
||||||
|
|
||||||
def test_utils_setup_tracing_invalid_key(self):
|
|
||||||
self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
utils.setup_tracing(['fake'])
|
|
||||||
|
|
||||||
self.assertFalse(utils.TRACE_API)
|
|
||||||
self.assertFalse(utils.TRACE_METHOD)
|
|
||||||
self.assertEqual(1, utils.LOG.warning.call_count)
|
|
||||||
|
|
||||||
def test_utils_setup_tracing_valid_and_invalid_key(self):
|
|
||||||
self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
utils.setup_tracing(['method', 'fake'])
|
|
||||||
|
|
||||||
self.assertFalse(utils.TRACE_API)
|
|
||||||
self.assertTrue(utils.TRACE_METHOD)
|
|
||||||
self.assertEqual(1, utils.LOG.warning.call_count)
|
|
||||||
|
|
||||||
def test_trace_no_tracing(self):
|
|
||||||
self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
@utils.trace_method
|
|
||||||
def _trace_test_method(*args, **kwargs):
|
|
||||||
return 'OK'
|
|
||||||
|
|
||||||
utils.setup_tracing(None)
|
|
||||||
|
|
||||||
result = _trace_test_method()
|
|
||||||
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
self.assertEqual(0, utils.LOG.debug.call_count)
|
|
||||||
|
|
||||||
def test_utils_trace_method(self):
|
|
||||||
self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
@utils.trace_method
|
|
||||||
def _trace_test_method(*args, **kwargs):
|
|
||||||
return 'OK'
|
|
||||||
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
|
|
||||||
result = _trace_test_method()
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
self.assertEqual(2, utils.LOG.debug.call_count)
|
|
||||||
|
|
||||||
def test_utils_trace_api(self):
|
|
||||||
self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
@utils.trace_api
|
|
||||||
def _trace_test_api(*args, **kwargs):
|
|
||||||
return 'OK'
|
|
||||||
|
|
||||||
utils.setup_tracing(['api'])
|
|
||||||
|
|
||||||
result = _trace_test_api()
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
self.assertEqual(2, utils.LOG.debug.call_count)
|
|
||||||
|
|
||||||
def test_utils_trace_api_filtered(self):
|
|
||||||
self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
def filter_func(all_args):
|
|
||||||
return False
|
|
||||||
|
|
||||||
@utils.trace_api(filter_function=filter_func)
|
|
||||||
def _trace_test_api(*args, **kwargs):
|
|
||||||
return 'OK'
|
|
||||||
|
|
||||||
utils.setup_tracing(['api'])
|
|
||||||
|
|
||||||
result = _trace_test_api()
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
self.assertEqual(0, utils.LOG.debug.call_count)
|
|
||||||
|
|
||||||
def test_utils_trace_filtered(self):
|
|
||||||
self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
def filter_func(all_args):
|
|
||||||
return False
|
|
||||||
|
|
||||||
@utils.trace(filter_function=filter_func)
|
|
||||||
def _trace_test(*args, **kwargs):
|
|
||||||
return 'OK'
|
|
||||||
|
|
||||||
utils.setup_tracing(['api'])
|
|
||||||
|
|
||||||
result = _trace_test()
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
self.assertEqual(0, utils.LOG.debug.call_count)
|
|
||||||
|
|
||||||
def test_utils_trace_method_default_logger(self):
|
|
||||||
mock_log = self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
@utils.trace_method
|
|
||||||
def _trace_test_method_custom_logger(*args, **kwargs):
|
|
||||||
return 'OK'
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
|
|
||||||
result = _trace_test_method_custom_logger()
|
|
||||||
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
self.assertEqual(2, mock_log.debug.call_count)
|
|
||||||
|
|
||||||
def test_utils_trace_method_inner_decorator(self):
|
|
||||||
mock_logging = self.mock_object(utils, 'logging')
|
|
||||||
mock_log = mock.Mock()
|
|
||||||
mock_log.isEnabledFor = lambda x: True
|
|
||||||
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
|
||||||
|
|
||||||
def _test_decorator(f):
|
|
||||||
def blah(*args, **kwargs):
|
|
||||||
return f(*args, **kwargs)
|
|
||||||
return blah
|
|
||||||
|
|
||||||
@_test_decorator
|
|
||||||
@utils.trace_method
|
|
||||||
def _trace_test_method(*args, **kwargs):
|
|
||||||
return 'OK'
|
|
||||||
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
|
|
||||||
result = _trace_test_method(self)
|
|
||||||
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
self.assertEqual(2, mock_log.debug.call_count)
|
|
||||||
# Ensure the correct function name was logged
|
|
||||||
for call in mock_log.debug.call_args_list:
|
|
||||||
self.assertIn('_trace_test_method', str(call))
|
|
||||||
self.assertNotIn('blah', str(call))
|
|
||||||
|
|
||||||
def test_utils_trace_method_outer_decorator(self):
|
|
||||||
mock_logging = self.mock_object(utils, 'logging')
|
|
||||||
mock_log = mock.Mock()
|
|
||||||
mock_log.isEnabledFor = lambda x: True
|
|
||||||
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
|
||||||
|
|
||||||
def _test_decorator(f):
|
|
||||||
def blah(*args, **kwargs):
|
|
||||||
return f(*args, **kwargs)
|
|
||||||
return blah
|
|
||||||
|
|
||||||
@utils.trace_method
|
|
||||||
@_test_decorator
|
|
||||||
def _trace_test_method(*args, **kwargs):
|
|
||||||
return 'OK'
|
|
||||||
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
|
|
||||||
result = _trace_test_method(self)
|
|
||||||
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
self.assertEqual(2, mock_log.debug.call_count)
|
|
||||||
# Ensure the incorrect function name was logged
|
|
||||||
for call in mock_log.debug.call_args_list:
|
|
||||||
self.assertNotIn('_trace_test_method', str(call))
|
|
||||||
self.assertIn('blah', str(call))
|
|
||||||
|
|
||||||
def test_utils_trace_method_outer_decorator_with_functools(self):
|
|
||||||
mock_log = mock.Mock()
|
|
||||||
mock_log.isEnabledFor = lambda x: True
|
|
||||||
self.mock_object(utils.logging, 'getLogger', mock_log)
|
|
||||||
mock_log = self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
def _test_decorator(f):
|
|
||||||
@functools.wraps(f)
|
|
||||||
def wraps(*args, **kwargs):
|
|
||||||
return f(*args, **kwargs)
|
|
||||||
return wraps
|
|
||||||
|
|
||||||
@utils.trace_method
|
|
||||||
@_test_decorator
|
|
||||||
def _trace_test_method(*args, **kwargs):
|
|
||||||
return 'OK'
|
|
||||||
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
|
|
||||||
result = _trace_test_method()
|
|
||||||
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
self.assertEqual(2, mock_log.debug.call_count)
|
|
||||||
# Ensure the incorrect function name was logged
|
|
||||||
for call in mock_log.debug.call_args_list:
|
|
||||||
self.assertIn('_trace_test_method', str(call))
|
|
||||||
self.assertNotIn('wraps', str(call))
|
|
||||||
|
|
||||||
def test_utils_trace_method_with_exception(self):
|
|
||||||
self.LOG = self.mock_object(utils, 'LOG')
|
|
||||||
|
|
||||||
@utils.trace_method
|
|
||||||
def _trace_test_method(*args, **kwargs):
|
|
||||||
raise exception.APITimeout('test message')
|
|
||||||
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
|
|
||||||
self.assertRaises(exception.APITimeout, _trace_test_method)
|
|
||||||
|
|
||||||
exception_log = self.LOG.debug.call_args_list[1]
|
|
||||||
self.assertIn('exception', str(exception_log))
|
|
||||||
self.assertIn('test message', str(exception_log))
|
|
||||||
|
|
||||||
def test_utils_trace_method_with_time(self):
|
|
||||||
mock_logging = self.mock_object(utils, 'logging')
|
|
||||||
mock_log = mock.Mock()
|
|
||||||
mock_log.isEnabledFor = lambda x: True
|
|
||||||
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
|
||||||
|
|
||||||
mock_time = mock.Mock(side_effect=[3.1, 6])
|
|
||||||
self.mock_object(time, 'time', mock_time)
|
|
||||||
|
|
||||||
@utils.trace_method
|
|
||||||
def _trace_test_method(*args, **kwargs):
|
|
||||||
return 'OK'
|
|
||||||
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
|
|
||||||
result = _trace_test_method(self)
|
|
||||||
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
return_log = mock_log.debug.call_args_list[1]
|
|
||||||
self.assertIn('2900', str(return_log))
|
|
||||||
|
|
||||||
def test_utils_trace_wrapper_class(self):
|
|
||||||
mock_logging = self.mock_object(utils, 'logging')
|
|
||||||
mock_log = mock.Mock()
|
|
||||||
mock_log.isEnabledFor = lambda x: True
|
|
||||||
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
|
||||||
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
|
|
||||||
class MyClass(object, metaclass=utils.TraceWrapperMetaclass):
|
|
||||||
def trace_test_method(self):
|
|
||||||
return 'OK'
|
|
||||||
|
|
||||||
test_class = MyClass()
|
|
||||||
result = test_class.trace_test_method()
|
|
||||||
|
|
||||||
self.assertEqual('OK', result)
|
|
||||||
self.assertEqual(2, mock_log.debug.call_count)
|
|
||||||
|
|
||||||
def test_utils_trace_method_with_password_dict(self):
|
|
||||||
mock_logging = self.mock_object(utils, 'logging')
|
|
||||||
mock_log = mock.Mock()
|
|
||||||
mock_log.isEnabledFor = lambda x: True
|
|
||||||
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
|
||||||
|
|
||||||
@utils.trace_method
|
|
||||||
def _trace_test_method(*args, **kwargs):
|
|
||||||
return {'something': 'test',
|
|
||||||
'password': 'Now you see me'}
|
|
||||||
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
result = _trace_test_method(self)
|
|
||||||
expected_unmasked_dict = {'something': 'test',
|
|
||||||
'password': 'Now you see me'}
|
|
||||||
|
|
||||||
self.assertEqual(expected_unmasked_dict, result)
|
|
||||||
self.assertEqual(2, mock_log.debug.call_count)
|
|
||||||
self.assertIn("'password': '***'",
|
|
||||||
str(mock_log.debug.call_args_list[1]))
|
|
||||||
|
|
||||||
def test_utils_trace_method_with_password_str(self):
|
|
||||||
mock_logging = self.mock_object(utils, 'logging')
|
|
||||||
mock_log = mock.Mock()
|
|
||||||
mock_log.isEnabledFor = lambda x: True
|
|
||||||
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
|
||||||
|
|
||||||
@utils.trace_method
|
|
||||||
def _trace_test_method(*args, **kwargs):
|
|
||||||
return "'adminPass': 'Now you see me'"
|
|
||||||
|
|
||||||
utils.setup_tracing(['method'])
|
|
||||||
result = _trace_test_method(self)
|
|
||||||
expected_unmasked_str = "'adminPass': 'Now you see me'"
|
|
||||||
|
|
||||||
self.assertEqual(expected_unmasked_str, result)
|
|
||||||
self.assertEqual(2, mock_log.debug.call_count)
|
|
||||||
self.assertIn("'adminPass': '***'",
|
|
||||||
str(mock_log.debug.call_args_list[1]))
|
|
||||||
|
|
||||||
def test_utils_trace_method_with_password_in_formal_params(self):
|
|
||||||
mock_logging = self.mock_object(utils, 'logging')
|
|
||||||
mock_log = mock.Mock()
|
|
||||||
mock_log.isEnabledFor = lambda x: True
|
|
||||||
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
|
||||||
|
|
||||||
@utils.trace
|
|
||||||
def _trace_test_method(*args, **kwargs):
|
|
||||||
self.assertEqual('verybadpass',
|
|
||||||
kwargs['test_args']['data']['password'])
|
|
||||||
pass
|
|
||||||
|
|
||||||
test_args = {
|
|
||||||
'data': {
|
|
||||||
'password': 'verybadpass'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_trace_test_method(self, test_args=test_args)
|
|
||||||
|
|
||||||
self.assertEqual(2, mock_log.debug.call_count)
|
|
||||||
self.assertIn("'password': '***'",
|
|
||||||
str(mock_log.debug.call_args_list[0]))
|
|
||||||
|
|
||||||
@ddt.data(
|
@ddt.data(
|
||||||
{'total': 30.01, 'free': 28.01, 'provisioned': 2.0, 'max_ratio': 1.0,
|
{'total': 30.01, 'free': 28.01, 'provisioned': 2.0, 'max_ratio': 1.0,
|
||||||
'thin_support': False, 'thick_support': True,
|
'thin_support': False, 'thick_support': True,
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import functools
|
||||||
import io
|
import io
|
||||||
|
import time
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from castellan import key_manager
|
from castellan import key_manager
|
||||||
|
@ -1229,3 +1231,327 @@ class VolumeUtilsTestCase(test.TestCase):
|
||||||
volume_utils.get_backend_configuration('backendA')
|
volume_utils.get_backend_configuration('backendA')
|
||||||
mock_configuration.assert_called_with(driver.volume_opts,
|
mock_configuration.assert_called_with(driver.volume_opts,
|
||||||
config_group='backendA')
|
config_group='backendA')
|
||||||
|
|
||||||
|
|
||||||
|
@ddt.ddt
|
||||||
|
class LogTracingTestCase(test.TestCase):
|
||||||
|
|
||||||
|
def test_utils_setup_tracing(self):
|
||||||
|
self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(None)
|
||||||
|
self.assertFalse(volume_utils.TRACE_API)
|
||||||
|
self.assertFalse(volume_utils.TRACE_METHOD)
|
||||||
|
self.assertEqual(0, volume_utils.LOG.warning.call_count)
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
self.assertFalse(volume_utils.TRACE_API)
|
||||||
|
self.assertTrue(volume_utils.TRACE_METHOD)
|
||||||
|
self.assertEqual(0, volume_utils.LOG.warning.call_count)
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method', 'api'])
|
||||||
|
self.assertTrue(volume_utils.TRACE_API)
|
||||||
|
self.assertTrue(volume_utils.TRACE_METHOD)
|
||||||
|
self.assertEqual(0, volume_utils.LOG.warning.call_count)
|
||||||
|
|
||||||
|
def test_utils_setup_tracing_invalid_key(self):
|
||||||
|
self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['fake'])
|
||||||
|
|
||||||
|
self.assertFalse(volume_utils.TRACE_API)
|
||||||
|
self.assertFalse(volume_utils.TRACE_METHOD)
|
||||||
|
self.assertEqual(1, volume_utils.LOG.warning.call_count)
|
||||||
|
|
||||||
|
def test_utils_setup_tracing_valid_and_invalid_key(self):
|
||||||
|
self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method', 'fake'])
|
||||||
|
|
||||||
|
self.assertFalse(volume_utils.TRACE_API)
|
||||||
|
self.assertTrue(volume_utils.TRACE_METHOD)
|
||||||
|
self.assertEqual(1, volume_utils.LOG.warning.call_count)
|
||||||
|
|
||||||
|
def test_trace_no_tracing(self):
|
||||||
|
self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
@volume_utils.trace_method
|
||||||
|
def _trace_test_method(*args, **kwargs):
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(None)
|
||||||
|
|
||||||
|
result = _trace_test_method()
|
||||||
|
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
self.assertEqual(0, volume_utils.LOG.debug.call_count)
|
||||||
|
|
||||||
|
def test_utils_trace_method(self):
|
||||||
|
self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
@volume_utils.trace_method
|
||||||
|
def _trace_test_method(*args, **kwargs):
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
|
||||||
|
result = _trace_test_method()
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
self.assertEqual(2, volume_utils.LOG.debug.call_count)
|
||||||
|
|
||||||
|
def test_utils_trace_api(self):
|
||||||
|
self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
@volume_utils.trace_api
|
||||||
|
def _trace_test_api(*args, **kwargs):
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['api'])
|
||||||
|
|
||||||
|
result = _trace_test_api()
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
self.assertEqual(2, volume_utils.LOG.debug.call_count)
|
||||||
|
|
||||||
|
def test_utils_trace_api_filtered(self):
|
||||||
|
self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
def filter_func(all_args):
|
||||||
|
return False
|
||||||
|
|
||||||
|
@volume_utils.trace_api(filter_function=filter_func)
|
||||||
|
def _trace_test_api(*args, **kwargs):
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['api'])
|
||||||
|
|
||||||
|
result = _trace_test_api()
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
self.assertEqual(0, volume_utils.LOG.debug.call_count)
|
||||||
|
|
||||||
|
def test_utils_trace_filtered(self):
|
||||||
|
self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
def filter_func(all_args):
|
||||||
|
return False
|
||||||
|
|
||||||
|
@volume_utils.trace(filter_function=filter_func)
|
||||||
|
def _trace_test(*args, **kwargs):
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['api'])
|
||||||
|
|
||||||
|
result = _trace_test()
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
self.assertEqual(0, volume_utils.LOG.debug.call_count)
|
||||||
|
|
||||||
|
def test_utils_trace_method_default_logger(self):
|
||||||
|
mock_log = self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
@volume_utils.trace_method
|
||||||
|
def _trace_test_method_custom_logger(*args, **kwargs):
|
||||||
|
return 'OK'
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
|
||||||
|
result = _trace_test_method_custom_logger()
|
||||||
|
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
self.assertEqual(2, mock_log.debug.call_count)
|
||||||
|
|
||||||
|
def test_utils_trace_method_inner_decorator(self):
|
||||||
|
mock_logging = self.mock_object(volume_utils, 'logging')
|
||||||
|
mock_log = mock.Mock()
|
||||||
|
mock_log.isEnabledFor = lambda x: True
|
||||||
|
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
||||||
|
|
||||||
|
def _test_decorator(f):
|
||||||
|
def blah(*args, **kwargs):
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
return blah
|
||||||
|
|
||||||
|
@_test_decorator
|
||||||
|
@volume_utils.trace_method
|
||||||
|
def _trace_test_method(*args, **kwargs):
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
|
||||||
|
result = _trace_test_method(self)
|
||||||
|
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
self.assertEqual(2, mock_log.debug.call_count)
|
||||||
|
# Ensure the correct function name was logged
|
||||||
|
for call in mock_log.debug.call_args_list:
|
||||||
|
self.assertIn('_trace_test_method', str(call))
|
||||||
|
self.assertNotIn('blah', str(call))
|
||||||
|
|
||||||
|
def test_utils_trace_method_outer_decorator(self):
|
||||||
|
mock_logging = self.mock_object(volume_utils, 'logging')
|
||||||
|
mock_log = mock.Mock()
|
||||||
|
mock_log.isEnabledFor = lambda x: True
|
||||||
|
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
||||||
|
|
||||||
|
def _test_decorator(f):
|
||||||
|
def blah(*args, **kwargs):
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
return blah
|
||||||
|
|
||||||
|
@volume_utils.trace_method
|
||||||
|
@_test_decorator
|
||||||
|
def _trace_test_method(*args, **kwargs):
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
|
||||||
|
result = _trace_test_method(self)
|
||||||
|
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
self.assertEqual(2, mock_log.debug.call_count)
|
||||||
|
# Ensure the incorrect function name was logged
|
||||||
|
for call in mock_log.debug.call_args_list:
|
||||||
|
self.assertNotIn('_trace_test_method', str(call))
|
||||||
|
self.assertIn('blah', str(call))
|
||||||
|
|
||||||
|
def test_utils_trace_method_outer_decorator_with_functools(self):
|
||||||
|
mock_log = mock.Mock()
|
||||||
|
mock_log.isEnabledFor = lambda x: True
|
||||||
|
self.mock_object(utils.logging, 'getLogger', mock_log)
|
||||||
|
mock_log = self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
def _test_decorator(f):
|
||||||
|
@functools.wraps(f)
|
||||||
|
def wraps(*args, **kwargs):
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
return wraps
|
||||||
|
|
||||||
|
@volume_utils.trace_method
|
||||||
|
@_test_decorator
|
||||||
|
def _trace_test_method(*args, **kwargs):
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
|
||||||
|
result = _trace_test_method()
|
||||||
|
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
self.assertEqual(2, mock_log.debug.call_count)
|
||||||
|
# Ensure the incorrect function name was logged
|
||||||
|
for call in mock_log.debug.call_args_list:
|
||||||
|
self.assertIn('_trace_test_method', str(call))
|
||||||
|
self.assertNotIn('wraps', str(call))
|
||||||
|
|
||||||
|
def test_utils_trace_method_with_exception(self):
|
||||||
|
self.LOG = self.mock_object(volume_utils, 'LOG')
|
||||||
|
|
||||||
|
@volume_utils.trace_method
|
||||||
|
def _trace_test_method(*args, **kwargs):
|
||||||
|
raise exception.APITimeout('test message')
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
|
||||||
|
self.assertRaises(exception.APITimeout, _trace_test_method)
|
||||||
|
|
||||||
|
exception_log = self.LOG.debug.call_args_list[1]
|
||||||
|
self.assertIn('exception', str(exception_log))
|
||||||
|
self.assertIn('test message', str(exception_log))
|
||||||
|
|
||||||
|
def test_utils_trace_method_with_time(self):
|
||||||
|
mock_logging = self.mock_object(volume_utils, 'logging')
|
||||||
|
mock_log = mock.Mock()
|
||||||
|
mock_log.isEnabledFor = lambda x: True
|
||||||
|
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
||||||
|
|
||||||
|
mock_time = mock.Mock(side_effect=[3.1, 6])
|
||||||
|
self.mock_object(time, 'time', mock_time)
|
||||||
|
|
||||||
|
@volume_utils.trace_method
|
||||||
|
def _trace_test_method(*args, **kwargs):
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
|
||||||
|
result = _trace_test_method(self)
|
||||||
|
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
return_log = mock_log.debug.call_args_list[1]
|
||||||
|
self.assertIn('2900', str(return_log))
|
||||||
|
|
||||||
|
def test_utils_trace_wrapper_class(self):
|
||||||
|
mock_logging = self.mock_object(volume_utils, 'logging')
|
||||||
|
mock_log = mock.Mock()
|
||||||
|
mock_log.isEnabledFor = lambda x: True
|
||||||
|
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
|
||||||
|
class MyClass(object, metaclass=volume_utils.TraceWrapperMetaclass):
|
||||||
|
def trace_test_method(self):
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
test_class = MyClass()
|
||||||
|
result = test_class.trace_test_method()
|
||||||
|
|
||||||
|
self.assertEqual('OK', result)
|
||||||
|
self.assertEqual(2, mock_log.debug.call_count)
|
||||||
|
|
||||||
|
def test_utils_trace_method_with_password_dict(self):
|
||||||
|
mock_logging = self.mock_object(volume_utils, 'logging')
|
||||||
|
mock_log = mock.Mock()
|
||||||
|
mock_log.isEnabledFor = lambda x: True
|
||||||
|
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
||||||
|
|
||||||
|
@volume_utils.trace_method
|
||||||
|
def _trace_test_method(*args, **kwargs):
|
||||||
|
return {'something': 'test',
|
||||||
|
'password': 'Now you see me'}
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
result = _trace_test_method(self)
|
||||||
|
expected_unmasked_dict = {'something': 'test',
|
||||||
|
'password': 'Now you see me'}
|
||||||
|
|
||||||
|
self.assertEqual(expected_unmasked_dict, result)
|
||||||
|
self.assertEqual(2, mock_log.debug.call_count)
|
||||||
|
self.assertIn("'password': '***'",
|
||||||
|
str(mock_log.debug.call_args_list[1]))
|
||||||
|
|
||||||
|
def test_utils_trace_method_with_password_str(self):
|
||||||
|
mock_logging = self.mock_object(volume_utils, 'logging')
|
||||||
|
mock_log = mock.Mock()
|
||||||
|
mock_log.isEnabledFor = lambda x: True
|
||||||
|
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
||||||
|
|
||||||
|
@volume_utils.trace_method
|
||||||
|
def _trace_test_method(*args, **kwargs):
|
||||||
|
return "'adminPass': 'Now you see me'"
|
||||||
|
|
||||||
|
volume_utils.setup_tracing(['method'])
|
||||||
|
result = _trace_test_method(self)
|
||||||
|
expected_unmasked_str = "'adminPass': 'Now you see me'"
|
||||||
|
|
||||||
|
self.assertEqual(expected_unmasked_str, result)
|
||||||
|
self.assertEqual(2, mock_log.debug.call_count)
|
||||||
|
self.assertIn("'adminPass': '***'",
|
||||||
|
str(mock_log.debug.call_args_list[1]))
|
||||||
|
|
||||||
|
def test_utils_trace_method_with_password_in_formal_params(self):
|
||||||
|
mock_logging = self.mock_object(volume_utils, 'logging')
|
||||||
|
mock_log = mock.Mock()
|
||||||
|
mock_log.isEnabledFor = lambda x: True
|
||||||
|
mock_logging.getLogger = mock.Mock(return_value=mock_log)
|
||||||
|
|
||||||
|
@volume_utils.trace
|
||||||
|
def _trace_test_method(*args, **kwargs):
|
||||||
|
self.assertEqual('verybadpass',
|
||||||
|
kwargs['test_args']['data']['password'])
|
||||||
|
pass
|
||||||
|
|
||||||
|
test_args = {
|
||||||
|
'data': {
|
||||||
|
'password': 'verybadpass'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_trace_test_method(self, test_args=test_args)
|
||||||
|
|
||||||
|
self.assertEqual(2, mock_log.debug.call_count)
|
||||||
|
self.assertIn("'password': '***'",
|
||||||
|
str(mock_log.debug.call_args_list[0]))
|
||||||
|
|
163
cinder/utils.py
163
cinder/utils.py
|
@ -17,13 +17,11 @@
|
||||||
|
|
||||||
"""Utilities and helper functions."""
|
"""Utilities and helper functions."""
|
||||||
|
|
||||||
import abc
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import contextlib
|
import contextlib
|
||||||
import datetime
|
import datetime
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import logging as py_logging
|
|
||||||
import math
|
import math
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import operator
|
import operator
|
||||||
|
@ -34,8 +32,6 @@ import shutil
|
||||||
import stat
|
import stat
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
|
||||||
import types
|
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
from eventlet import tpool
|
from eventlet import tpool
|
||||||
|
@ -56,9 +52,6 @@ CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
|
ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
|
||||||
PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
|
PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
|
||||||
VALID_TRACE_FLAGS = {'method', 'api'}
|
|
||||||
TRACE_METHOD = False
|
|
||||||
TRACE_API = False
|
|
||||||
INITIAL_AUTO_MOSR = 20
|
INITIAL_AUTO_MOSR = 20
|
||||||
INFINITE_UNKNOWN_VALUES = ('infinite', 'unknown')
|
INFINITE_UNKNOWN_VALUES = ('infinite', 'unknown')
|
||||||
|
|
||||||
|
@ -629,162 +622,6 @@ def convert_str(text):
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def trace_method(f):
|
|
||||||
"""Decorates a function if TRACE_METHOD is true."""
|
|
||||||
@functools.wraps(f)
|
|
||||||
def trace_method_logging_wrapper(*args, **kwargs):
|
|
||||||
if TRACE_METHOD:
|
|
||||||
return trace(f)(*args, **kwargs)
|
|
||||||
return f(*args, **kwargs)
|
|
||||||
return trace_method_logging_wrapper
|
|
||||||
|
|
||||||
|
|
||||||
def trace_api(*dec_args, **dec_kwargs):
|
|
||||||
"""Decorates a function if TRACE_API is true."""
|
|
||||||
|
|
||||||
def _decorator(f):
|
|
||||||
@functools.wraps(f)
|
|
||||||
def trace_api_logging_wrapper(*args, **kwargs):
|
|
||||||
if TRACE_API:
|
|
||||||
return trace(f, *dec_args, **dec_kwargs)(*args, **kwargs)
|
|
||||||
return f(*args, **kwargs)
|
|
||||||
return trace_api_logging_wrapper
|
|
||||||
|
|
||||||
if len(dec_args) == 0:
|
|
||||||
# filter_function is passed and args does not contain f
|
|
||||||
return _decorator
|
|
||||||
else:
|
|
||||||
# filter_function is not passed
|
|
||||||
return _decorator(dec_args[0])
|
|
||||||
|
|
||||||
|
|
||||||
def trace(*dec_args, **dec_kwargs):
|
|
||||||
"""Trace calls to the decorated function.
|
|
||||||
|
|
||||||
This decorator should always be defined as the outermost decorator so it
|
|
||||||
is defined last. This is important so it does not interfere
|
|
||||||
with other decorators.
|
|
||||||
|
|
||||||
Using this decorator on a function will cause its execution to be logged at
|
|
||||||
`DEBUG` level with arguments, return values, and exceptions.
|
|
||||||
|
|
||||||
:returns: a function decorator
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _decorator(f):
|
|
||||||
|
|
||||||
func_name = f.__name__
|
|
||||||
|
|
||||||
@functools.wraps(f)
|
|
||||||
def trace_logging_wrapper(*args, **kwargs):
|
|
||||||
filter_function = dec_kwargs.get('filter_function')
|
|
||||||
|
|
||||||
if len(args) > 0:
|
|
||||||
maybe_self = args[0]
|
|
||||||
else:
|
|
||||||
maybe_self = kwargs.get('self', None)
|
|
||||||
|
|
||||||
if maybe_self and hasattr(maybe_self, '__module__'):
|
|
||||||
logger = logging.getLogger(maybe_self.__module__)
|
|
||||||
else:
|
|
||||||
logger = LOG
|
|
||||||
|
|
||||||
# NOTE(ameade): Don't bother going any further if DEBUG log level
|
|
||||||
# is not enabled for the logger.
|
|
||||||
if not logger.isEnabledFor(py_logging.DEBUG):
|
|
||||||
return f(*args, **kwargs)
|
|
||||||
|
|
||||||
all_args = inspect.getcallargs(f, *args, **kwargs)
|
|
||||||
|
|
||||||
pass_filter = filter_function is None or filter_function(all_args)
|
|
||||||
|
|
||||||
if pass_filter:
|
|
||||||
logger.debug('==> %(func)s: call %(all_args)r',
|
|
||||||
{'func': func_name,
|
|
||||||
'all_args': strutils.mask_password(
|
|
||||||
str(all_args))})
|
|
||||||
|
|
||||||
start_time = time.time() * 1000
|
|
||||||
try:
|
|
||||||
result = f(*args, **kwargs)
|
|
||||||
except Exception as exc:
|
|
||||||
total_time = int(round(time.time() * 1000)) - start_time
|
|
||||||
logger.debug('<== %(func)s: exception (%(time)dms) %(exc)r',
|
|
||||||
{'func': func_name,
|
|
||||||
'time': total_time,
|
|
||||||
'exc': exc})
|
|
||||||
raise
|
|
||||||
total_time = int(round(time.time() * 1000)) - start_time
|
|
||||||
|
|
||||||
if isinstance(result, dict):
|
|
||||||
mask_result = strutils.mask_dict_password(result)
|
|
||||||
elif isinstance(result, str):
|
|
||||||
mask_result = strutils.mask_password(result)
|
|
||||||
else:
|
|
||||||
mask_result = result
|
|
||||||
|
|
||||||
if pass_filter:
|
|
||||||
logger.debug('<== %(func)s: return (%(time)dms) %(result)r',
|
|
||||||
{'func': func_name,
|
|
||||||
'time': total_time,
|
|
||||||
'result': mask_result})
|
|
||||||
return result
|
|
||||||
return trace_logging_wrapper
|
|
||||||
|
|
||||||
if len(dec_args) == 0:
|
|
||||||
# filter_function is passed and args does not contain f
|
|
||||||
return _decorator
|
|
||||||
else:
|
|
||||||
# filter_function is not passed
|
|
||||||
return _decorator(dec_args[0])
|
|
||||||
|
|
||||||
|
|
||||||
class TraceWrapperMetaclass(type):
|
|
||||||
"""Metaclass that wraps all methods of a class with trace_method.
|
|
||||||
|
|
||||||
This metaclass will cause every function inside of the class to be
|
|
||||||
decorated with the trace_method decorator.
|
|
||||||
|
|
||||||
To use the metaclass you define a class like so:
|
|
||||||
class MyClass(object, metaclass=utils.TraceWrapperMetaclass):
|
|
||||||
"""
|
|
||||||
def __new__(meta, classname, bases, classDict):
|
|
||||||
newClassDict = {}
|
|
||||||
for attributeName, attribute in classDict.items():
|
|
||||||
if isinstance(attribute, types.FunctionType):
|
|
||||||
# replace it with a wrapped version
|
|
||||||
attribute = functools.update_wrapper(trace_method(attribute),
|
|
||||||
attribute)
|
|
||||||
newClassDict[attributeName] = attribute
|
|
||||||
|
|
||||||
return type.__new__(meta, classname, bases, newClassDict)
|
|
||||||
|
|
||||||
|
|
||||||
class TraceWrapperWithABCMetaclass(abc.ABCMeta, TraceWrapperMetaclass):
|
|
||||||
"""Metaclass that wraps all methods of a class with trace."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def setup_tracing(trace_flags):
|
|
||||||
"""Set global variables for each trace flag.
|
|
||||||
|
|
||||||
Sets variables TRACE_METHOD and TRACE_API, which represent
|
|
||||||
whether to log methods or api traces.
|
|
||||||
|
|
||||||
:param trace_flags: a list of strings
|
|
||||||
"""
|
|
||||||
global TRACE_METHOD
|
|
||||||
global TRACE_API
|
|
||||||
try:
|
|
||||||
trace_flags = [flag.strip() for flag in trace_flags]
|
|
||||||
except TypeError: # Handle when trace_flags is None or a test mock
|
|
||||||
trace_flags = []
|
|
||||||
for invalid_flag in (set(trace_flags) - VALID_TRACE_FLAGS):
|
|
||||||
LOG.warning('Invalid trace flag: %s', invalid_flag)
|
|
||||||
TRACE_METHOD = 'method' in trace_flags
|
|
||||||
TRACE_API = 'api' in trace_flags
|
|
||||||
|
|
||||||
|
|
||||||
def build_or_str(elements, str_format=None):
|
def build_or_str(elements, str_format=None):
|
||||||
"""Builds a string of elements joined by 'or'.
|
"""Builds a string of elements joined by 'or'.
|
||||||
|
|
||||||
|
|
|
@ -414,7 +414,8 @@ class BaseVD(object, metaclass=abc.ABCMeta):
|
||||||
self.configuration.append_config_values(backup_opts)
|
self.configuration.append_config_values(backup_opts)
|
||||||
self.configuration.append_config_values(image_opts)
|
self.configuration.append_config_values(image_opts)
|
||||||
self.configuration.append_config_values(fqdn_opts)
|
self.configuration.append_config_values(fqdn_opts)
|
||||||
utils.setup_tracing(self.configuration.safe_get('trace_flags'))
|
volume_utils.setup_tracing(
|
||||||
|
self.configuration.safe_get('trace_flags'))
|
||||||
|
|
||||||
# NOTE(geguileo): Don't allow to start if we are enabling
|
# NOTE(geguileo): Don't allow to start if we are enabling
|
||||||
# replication on a cluster service with a backend that doesn't
|
# replication on a cluster service with a backend that doesn't
|
||||||
|
|
|
@ -20,7 +20,6 @@ from oslo_utils import netutils
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume import configuration
|
from cinder.volume import configuration
|
||||||
from cinder.volume.drivers import rbd
|
from cinder.volume.drivers import rbd
|
||||||
from cinder.volume import volume_utils
|
from cinder.volume import volume_utils
|
||||||
|
@ -243,7 +242,7 @@ class RBDISCSIDriver(rbd.RBDDriver):
|
||||||
resp, disks = self.client.get_disks()
|
resp, disks = self.client.get_disks()
|
||||||
return disks['disks']
|
return disks['disks']
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_disk(self, volume_name):
|
def create_disk(self, volume_name):
|
||||||
"""Register the volume with the iscsi gateways.
|
"""Register the volume with the iscsi gateways.
|
||||||
|
|
||||||
|
@ -265,7 +264,7 @@ class RBDISCSIDriver(rbd.RBDDriver):
|
||||||
raise exception.VolumeBackendAPIException(
|
raise exception.VolumeBackendAPIException(
|
||||||
data=ex.get_description())
|
data=ex.get_description())
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def register_disk(self, target_iqn, volume_name):
|
def register_disk(self, target_iqn, volume_name):
|
||||||
"""Register the disk with the target_iqn."""
|
"""Register the disk with the target_iqn."""
|
||||||
lun_name = self._lun_name(volume_name)
|
lun_name = self._lun_name(volume_name)
|
||||||
|
@ -288,7 +287,7 @@ class RBDISCSIDriver(rbd.RBDDriver):
|
||||||
raise exception.VolumeBackendAPIException(
|
raise exception.VolumeBackendAPIException(
|
||||||
data=ex.get_description())
|
data=ex.get_description())
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def unregister_disk(self, target_iqn, volume_name):
|
def unregister_disk(self, target_iqn, volume_name):
|
||||||
"""Unregister the volume from the gateway."""
|
"""Unregister the volume from the gateway."""
|
||||||
lun_name = self._lun_name(volume_name)
|
lun_name = self._lun_name(volume_name)
|
||||||
|
@ -300,7 +299,7 @@ class RBDISCSIDriver(rbd.RBDDriver):
|
||||||
raise exception.VolumeBackendAPIException(
|
raise exception.VolumeBackendAPIException(
|
||||||
data=ex.get_description())
|
data=ex.get_description())
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def export_disk(self, initiator_iqn, volume_name, iscsi_config):
|
def export_disk(self, initiator_iqn, volume_name, iscsi_config):
|
||||||
"""Export a volume to an initiator."""
|
"""Export a volume to an initiator."""
|
||||||
lun_name = self._lun_name(volume_name)
|
lun_name = self._lun_name(volume_name)
|
||||||
|
@ -323,7 +322,7 @@ class RBDISCSIDriver(rbd.RBDDriver):
|
||||||
raise exception.VolumeBackendAPIException(
|
raise exception.VolumeBackendAPIException(
|
||||||
data=ex.get_description())
|
data=ex.get_description())
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def unexport_disk(self, initiator_iqn, volume_name, iscsi_config):
|
def unexport_disk(self, initiator_iqn, volume_name, iscsi_config):
|
||||||
"""Remove a volume from an initiator."""
|
"""Remove a volume from an initiator."""
|
||||||
lun_name = self._lun_name(volume_name)
|
lun_name = self._lun_name(volume_name)
|
||||||
|
@ -354,7 +353,7 @@ class RBDISCSIDriver(rbd.RBDDriver):
|
||||||
luns = client['luns']
|
luns = client['luns']
|
||||||
return luns
|
return luns
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
"""Export a volume to a host."""
|
"""Export a volume to a host."""
|
||||||
# create client
|
# create client
|
||||||
|
@ -480,7 +479,7 @@ class RBDISCSIDriver(rbd.RBDDriver):
|
||||||
|
|
||||||
self._delete_disk(volume)
|
self._delete_disk(volume)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Unexport the volume from the gateway."""
|
"""Unexport the volume from the gateway."""
|
||||||
iscsi_config = self._get_config()
|
iscsi_config = self._get_config()
|
||||||
|
|
|
@ -25,11 +25,11 @@ import six
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder import utils
|
|
||||||
import cinder.volume.drivers.datera.datera_api21 as api21
|
import cinder.volume.drivers.datera.datera_api21 as api21
|
||||||
import cinder.volume.drivers.datera.datera_api22 as api22
|
import cinder.volume.drivers.datera.datera_api22 as api22
|
||||||
import cinder.volume.drivers.datera.datera_common as datc
|
import cinder.volume.drivers.datera.datera_common as datc
|
||||||
from cinder.volume.drivers.san import san
|
from cinder.volume.drivers.san import san
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ CONF.import_opt('driver_use_ssl', 'cinder.volume.driver')
|
||||||
CONF.register_opts(d_opts)
|
CONF.register_opts(d_opts)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(utils.TraceWrapperWithABCMetaclass)
|
@six.add_metaclass(volume_utils.TraceWrapperWithABCMetaclass)
|
||||||
@interface.volumedriver
|
@interface.volumedriver
|
||||||
class DateraDriver(san.SanISCSIDriver, api21.DateraApi, api22.DateraApi):
|
class DateraDriver(san.SanISCSIDriver, api21.DateraApi, api22.DateraApi):
|
||||||
"""The OpenStack Datera iSCSI volume driver.
|
"""The OpenStack Datera iSCSI volume driver.
|
||||||
|
@ -211,7 +211,7 @@ class DateraDriver(san.SanISCSIDriver, api21.DateraApi, api22.DateraApi):
|
||||||
self.datera_debug = self.configuration.datera_debug
|
self.datera_debug = self.configuration.datera_debug
|
||||||
|
|
||||||
if self.datera_debug:
|
if self.datera_debug:
|
||||||
utils.setup_tracing(['method'])
|
volume_utils.setup_tracing(['method'])
|
||||||
self.tenant_id = self.configuration.datera_tenant_id
|
self.tenant_id = self.configuration.datera_tenant_id
|
||||||
if self.tenant_id is None:
|
if self.tenant_id is None:
|
||||||
self.tenant_id = ''
|
self.tenant_id = ''
|
||||||
|
|
|
@ -530,7 +530,7 @@ class CommonAdapter(object):
|
||||||
}
|
}
|
||||||
return conn_info
|
return conn_info
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
lun = self.client.get_lun(lun_id=self.get_lun_id(volume))
|
lun = self.client.get_lun(lun_id=self.get_lun_id(volume))
|
||||||
return self._initialize_connection(lun, connector, volume.id)
|
return self._initialize_connection(lun, connector, volume.id)
|
||||||
|
@ -578,7 +578,7 @@ class CommonAdapter(object):
|
||||||
'data': data,
|
'data': data,
|
||||||
}
|
}
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection(self, volume, connector):
|
def terminate_connection(self, volume, connector):
|
||||||
lun = self.client.get_lun(lun_id=self.get_lun_id(volume))
|
lun = self.client.get_lun(lun_id=self.get_lun_id(volume))
|
||||||
# None `connector` indicates force detach, then detach all even the
|
# None `connector` indicates force detach, then detach all even the
|
||||||
|
@ -952,17 +952,17 @@ class CommonAdapter(object):
|
||||||
def get_pool_id_by_name(self, name):
|
def get_pool_id_by_name(self, name):
|
||||||
return self.client.get_pool_id_by_name(name=name)
|
return self.client.get_pool_id_by_name(name=name)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection_snapshot(self, snapshot, connector):
|
def initialize_connection_snapshot(self, snapshot, connector):
|
||||||
snap = self.client.get_snap(snapshot.name)
|
snap = self.client.get_snap(snapshot.name)
|
||||||
return self._initialize_connection(snap, connector, snapshot.id)
|
return self._initialize_connection(snap, connector, snapshot.id)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection_snapshot(self, snapshot, connector):
|
def terminate_connection_snapshot(self, snapshot, connector):
|
||||||
snap = self.client.get_snap(snapshot.name)
|
snap = self.client.get_snap(snapshot.name)
|
||||||
return self._terminate_connection(snap, connector)
|
return self._terminate_connection(snap, connector)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def restore_snapshot(self, volume, snapshot):
|
def restore_snapshot(self, volume, snapshot):
|
||||||
return self.client.restore_snapshot(snapshot.name)
|
return self.client.restore_snapshot(snapshot.name)
|
||||||
|
|
||||||
|
@ -1265,7 +1265,7 @@ class CommonAdapter(object):
|
||||||
"""The failover only happens manually, no need to update the status."""
|
"""The failover only happens manually, no need to update the status."""
|
||||||
return [], []
|
return [], []
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def failover(self, volumes, secondary_id=None, groups=None):
|
def failover(self, volumes, secondary_id=None, groups=None):
|
||||||
# TODO(ryan) support group failover after group bp merges
|
# TODO(ryan) support group failover after group bp merges
|
||||||
# https://review.opendev.org/#/c/574119/
|
# https://review.opendev.org/#/c/574119/
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder import utils as cinder_utils
|
|
||||||
from cinder.volume import configuration
|
from cinder.volume import configuration
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers.hitachi import hbsd_common as common
|
from cinder.volume.drivers.hitachi import hbsd_common as common
|
||||||
from cinder.volume.drivers.hitachi import hbsd_utils as utils
|
from cinder.volume.drivers.hitachi import hbsd_utils as utils
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
FC_VOLUME_OPTS = [
|
FC_VOLUME_OPTS = [
|
||||||
cfg.BoolOpt(
|
cfg.BoolOpt(
|
||||||
|
@ -87,32 +87,32 @@ class HBSDFCDriver(driver.FibreChannelDriver):
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
"""Create a volume and return its properties."""
|
"""Create a volume and return its properties."""
|
||||||
return self.common.create_volume(volume)
|
return self.common.create_volume(volume)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def create_volume_from_snapshot(self, volume, snapshot):
|
def create_volume_from_snapshot(self, volume, snapshot):
|
||||||
"""Create a volume from a snapshot and return its properties."""
|
"""Create a volume from a snapshot and return its properties."""
|
||||||
return self.common.create_volume_from_snapshot(volume, snapshot)
|
return self.common.create_volume_from_snapshot(volume, snapshot)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def create_cloned_volume(self, volume, src_vref):
|
def create_cloned_volume(self, volume, src_vref):
|
||||||
"""Create a clone of the specified volume and return its properties."""
|
"""Create a clone of the specified volume and return its properties."""
|
||||||
return self.common.create_cloned_volume(volume, src_vref)
|
return self.common.create_cloned_volume(volume, src_vref)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
"""Delete the specified volume."""
|
"""Delete the specified volume."""
|
||||||
self.common.delete_volume(volume)
|
self.common.delete_volume(volume)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def create_snapshot(self, snapshot):
|
def create_snapshot(self, snapshot):
|
||||||
"""Create a snapshot from a volume and return its properties."""
|
"""Create a snapshot from a volume and return its properties."""
|
||||||
return self.common.create_snapshot(snapshot)
|
return self.common.create_snapshot(snapshot)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def delete_snapshot(self, snapshot):
|
def delete_snapshot(self, snapshot):
|
||||||
"""Delete the specified snapshot."""
|
"""Delete the specified snapshot."""
|
||||||
self.common.delete_snapshot(snapshot)
|
self.common.delete_snapshot(snapshot)
|
||||||
|
@ -129,7 +129,7 @@ class HBSDFCDriver(driver.FibreChannelDriver):
|
||||||
self.get_goodness_function())
|
self.get_goodness_function())
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def update_migrated_volume(
|
def update_migrated_volume(
|
||||||
self, ctxt, volume, new_volume, original_volume_status):
|
self, ctxt, volume, new_volume, original_volume_status):
|
||||||
"""Do any remaining jobs after migration."""
|
"""Do any remaining jobs after migration."""
|
||||||
|
@ -137,34 +137,34 @@ class HBSDFCDriver(driver.FibreChannelDriver):
|
||||||
super(HBSDFCDriver, self).update_migrated_volume(
|
super(HBSDFCDriver, self).update_migrated_volume(
|
||||||
ctxt, volume, new_volume, original_volume_status)
|
ctxt, volume, new_volume, original_volume_status)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def copy_image_to_volume(self, context, volume, image_service, image_id):
|
def copy_image_to_volume(self, context, volume, image_service, image_id):
|
||||||
"""Fetch the image from image_service and write it to the volume."""
|
"""Fetch the image from image_service and write it to the volume."""
|
||||||
super(HBSDFCDriver, self).copy_image_to_volume(
|
super(HBSDFCDriver, self).copy_image_to_volume(
|
||||||
context, volume, image_service, image_id)
|
context, volume, image_service, image_id)
|
||||||
self.common.discard_zero_page(volume)
|
self.common.discard_zero_page(volume)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def extend_volume(self, volume, new_size):
|
def extend_volume(self, volume, new_size):
|
||||||
"""Extend the specified volume to the specified size."""
|
"""Extend the specified volume to the specified size."""
|
||||||
self.common.extend_volume(volume, new_size)
|
self.common.extend_volume(volume, new_size)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing(self, volume, existing_ref):
|
def manage_existing(self, volume, existing_ref):
|
||||||
"""Return volume properties which Cinder needs to manage the volume."""
|
"""Return volume properties which Cinder needs to manage the volume."""
|
||||||
return self.common.manage_existing(volume, existing_ref)
|
return self.common.manage_existing(volume, existing_ref)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing_get_size(self, volume, existing_ref):
|
def manage_existing_get_size(self, volume, existing_ref):
|
||||||
"""Return the size[GB] of the specified volume."""
|
"""Return the size[GB] of the specified volume."""
|
||||||
return self.common.manage_existing_get_size(existing_ref)
|
return self.common.manage_existing_get_size(existing_ref)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def unmanage(self, volume):
|
def unmanage(self, volume):
|
||||||
"""Prepare the volume for removing it from Cinder management."""
|
"""Prepare the volume for removing it from Cinder management."""
|
||||||
self.common.unmanage(volume)
|
self.common.unmanage(volume)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def do_setup(self, context):
|
def do_setup(self, context):
|
||||||
"""Prepare for the startup of the driver."""
|
"""Prepare for the startup of the driver."""
|
||||||
self.common.do_setup(context)
|
self.common.do_setup(context)
|
||||||
|
@ -187,12 +187,12 @@ class HBSDFCDriver(driver.FibreChannelDriver):
|
||||||
def remove_export_snapshot(self, context, snapshot):
|
def remove_export_snapshot(self, context, snapshot):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
"""Initialize connection between the server and the volume."""
|
"""Initialize connection between the server and the volume."""
|
||||||
return self.common.initialize_connection(volume, connector)
|
return self.common.initialize_connection(volume, connector)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Terminate connection between the server and the volume."""
|
"""Terminate connection between the server and the volume."""
|
||||||
if connector is None:
|
if connector is None:
|
||||||
|
@ -201,22 +201,22 @@ class HBSDFCDriver(driver.FibreChannelDriver):
|
||||||
return
|
return
|
||||||
self.common.terminate_connection(volume, connector)
|
self.common.terminate_connection(volume, connector)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection_snapshot(self, snapshot, connector, **kwargs):
|
def initialize_connection_snapshot(self, snapshot, connector, **kwargs):
|
||||||
"""Initialize connection between the server and the snapshot."""
|
"""Initialize connection between the server and the snapshot."""
|
||||||
return self.common.initialize_connection(snapshot, connector)
|
return self.common.initialize_connection(snapshot, connector)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection_snapshot(self, snapshot, connector, **kwargs):
|
def terminate_connection_snapshot(self, snapshot, connector, **kwargs):
|
||||||
"""Terminate connection between the server and the snapshot."""
|
"""Terminate connection between the server and the snapshot."""
|
||||||
self.common.terminate_connection(snapshot, connector)
|
self.common.terminate_connection(snapshot, connector)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def unmanage_snapshot(self, snapshot):
|
def unmanage_snapshot(self, snapshot):
|
||||||
"""Prepare the snapshot for removing it from Cinder management."""
|
"""Prepare the snapshot for removing it from Cinder management."""
|
||||||
return self.common.unmanage_snapshot(snapshot)
|
return self.common.unmanage_snapshot(snapshot)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def retype(self, ctxt, volume, new_type, diff, host):
|
def retype(self, ctxt, volume, new_type, diff, host):
|
||||||
"""Retype the specified volume."""
|
"""Retype the specified volume."""
|
||||||
return self.common.retype()
|
return self.common.retype()
|
||||||
|
@ -224,7 +224,7 @@ class HBSDFCDriver(driver.FibreChannelDriver):
|
||||||
def backup_use_temp_snapshot(self):
|
def backup_use_temp_snapshot(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def revert_to_snapshot(self, context, volume, snapshot):
|
def revert_to_snapshot(self, context, volume, snapshot):
|
||||||
"""Rollback the specified snapshot"""
|
"""Rollback the specified snapshot"""
|
||||||
return self.common.revert_to_snapshot(volume, snapshot)
|
return self.common.revert_to_snapshot(volume, snapshot)
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
"""iSCSI module for Hitachi HBSD Driver."""
|
"""iSCSI module for Hitachi HBSD Driver."""
|
||||||
|
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder import utils as cinder_utils
|
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers.hitachi import hbsd_common as common
|
from cinder.volume.drivers.hitachi import hbsd_common as common
|
||||||
from cinder.volume.drivers.hitachi import hbsd_utils as utils
|
from cinder.volume.drivers.hitachi import hbsd_utils as utils
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
MSG = utils.HBSDMsg
|
MSG = utils.HBSDMsg
|
||||||
|
|
||||||
|
@ -71,32 +71,32 @@ class HBSDISCSIDriver(driver.ISCSIDriver):
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
"""Create a volume and return its properties."""
|
"""Create a volume and return its properties."""
|
||||||
return self.common.create_volume(volume)
|
return self.common.create_volume(volume)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def create_volume_from_snapshot(self, volume, snapshot):
|
def create_volume_from_snapshot(self, volume, snapshot):
|
||||||
"""Create a volume from a snapshot and return its properties."""
|
"""Create a volume from a snapshot and return its properties."""
|
||||||
return self.common.create_volume_from_snapshot(volume, snapshot)
|
return self.common.create_volume_from_snapshot(volume, snapshot)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def create_cloned_volume(self, volume, src_vref):
|
def create_cloned_volume(self, volume, src_vref):
|
||||||
"""Create a clone of the specified volume and return its properties."""
|
"""Create a clone of the specified volume and return its properties."""
|
||||||
return self.common.create_cloned_volume(volume, src_vref)
|
return self.common.create_cloned_volume(volume, src_vref)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
"""Delete the specified volume."""
|
"""Delete the specified volume."""
|
||||||
self.common.delete_volume(volume)
|
self.common.delete_volume(volume)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def create_snapshot(self, snapshot):
|
def create_snapshot(self, snapshot):
|
||||||
"""Create a snapshot from a volume and return its properties."""
|
"""Create a snapshot from a volume and return its properties."""
|
||||||
return self.common.create_snapshot(snapshot)
|
return self.common.create_snapshot(snapshot)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def delete_snapshot(self, snapshot):
|
def delete_snapshot(self, snapshot):
|
||||||
"""Delete the specified snapshot."""
|
"""Delete the specified snapshot."""
|
||||||
self.common.delete_snapshot(snapshot)
|
self.common.delete_snapshot(snapshot)
|
||||||
|
@ -113,7 +113,7 @@ class HBSDISCSIDriver(driver.ISCSIDriver):
|
||||||
self.get_goodness_function())
|
self.get_goodness_function())
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def update_migrated_volume(
|
def update_migrated_volume(
|
||||||
self, ctxt, volume, new_volume, original_volume_status):
|
self, ctxt, volume, new_volume, original_volume_status):
|
||||||
"""Do any remaining jobs after migration."""
|
"""Do any remaining jobs after migration."""
|
||||||
|
@ -121,34 +121,34 @@ class HBSDISCSIDriver(driver.ISCSIDriver):
|
||||||
super(HBSDISCSIDriver, self).update_migrated_volume(
|
super(HBSDISCSIDriver, self).update_migrated_volume(
|
||||||
ctxt, volume, new_volume, original_volume_status)
|
ctxt, volume, new_volume, original_volume_status)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def copy_image_to_volume(self, context, volume, image_service, image_id):
|
def copy_image_to_volume(self, context, volume, image_service, image_id):
|
||||||
"""Fetch the image from image_service and write it to the volume."""
|
"""Fetch the image from image_service and write it to the volume."""
|
||||||
super(HBSDISCSIDriver, self).copy_image_to_volume(
|
super(HBSDISCSIDriver, self).copy_image_to_volume(
|
||||||
context, volume, image_service, image_id)
|
context, volume, image_service, image_id)
|
||||||
self.common.discard_zero_page(volume)
|
self.common.discard_zero_page(volume)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def extend_volume(self, volume, new_size):
|
def extend_volume(self, volume, new_size):
|
||||||
"""Extend the specified volume to the specified size."""
|
"""Extend the specified volume to the specified size."""
|
||||||
self.common.extend_volume(volume, new_size)
|
self.common.extend_volume(volume, new_size)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing(self, volume, existing_ref):
|
def manage_existing(self, volume, existing_ref):
|
||||||
"""Return volume properties which Cinder needs to manage the volume."""
|
"""Return volume properties which Cinder needs to manage the volume."""
|
||||||
return self.common.manage_existing(volume, existing_ref)
|
return self.common.manage_existing(volume, existing_ref)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing_get_size(self, volume, existing_ref):
|
def manage_existing_get_size(self, volume, existing_ref):
|
||||||
"""Return the size[GB] of the specified volume."""
|
"""Return the size[GB] of the specified volume."""
|
||||||
return self.common.manage_existing_get_size(existing_ref)
|
return self.common.manage_existing_get_size(existing_ref)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def unmanage(self, volume):
|
def unmanage(self, volume):
|
||||||
"""Prepare the volume for removing it from Cinder management."""
|
"""Prepare the volume for removing it from Cinder management."""
|
||||||
self.common.unmanage(volume)
|
self.common.unmanage(volume)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def do_setup(self, context):
|
def do_setup(self, context):
|
||||||
"""Prepare for the startup of the driver."""
|
"""Prepare for the startup of the driver."""
|
||||||
self.common.do_setup(context)
|
self.common.do_setup(context)
|
||||||
|
@ -171,12 +171,12 @@ class HBSDISCSIDriver(driver.ISCSIDriver):
|
||||||
def remove_export_snapshot(self, context, snapshot):
|
def remove_export_snapshot(self, context, snapshot):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
"""Initialize connection between the server and the volume."""
|
"""Initialize connection between the server and the volume."""
|
||||||
return self.common.initialize_connection(volume, connector)
|
return self.common.initialize_connection(volume, connector)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Terminate connection between the server and the volume."""
|
"""Terminate connection between the server and the volume."""
|
||||||
if connector is None:
|
if connector is None:
|
||||||
|
@ -185,22 +185,22 @@ class HBSDISCSIDriver(driver.ISCSIDriver):
|
||||||
return
|
return
|
||||||
self.common.terminate_connection(volume, connector)
|
self.common.terminate_connection(volume, connector)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection_snapshot(self, snapshot, connector, **kwargs):
|
def initialize_connection_snapshot(self, snapshot, connector, **kwargs):
|
||||||
"""Initialize connection between the server and the snapshot."""
|
"""Initialize connection between the server and the snapshot."""
|
||||||
return self.common.initialize_connection(snapshot, connector)
|
return self.common.initialize_connection(snapshot, connector)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection_snapshot(self, snapshot, connector, **kwargs):
|
def terminate_connection_snapshot(self, snapshot, connector, **kwargs):
|
||||||
"""Terminate connection between the server and the snapshot."""
|
"""Terminate connection between the server and the snapshot."""
|
||||||
self.common.terminate_connection(snapshot, connector)
|
self.common.terminate_connection(snapshot, connector)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def unmanage_snapshot(self, snapshot):
|
def unmanage_snapshot(self, snapshot):
|
||||||
"""Prepare the snapshot for removing it from Cinder management."""
|
"""Prepare the snapshot for removing it from Cinder management."""
|
||||||
return self.common.unmanage_snapshot(snapshot)
|
return self.common.unmanage_snapshot(snapshot)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def retype(self, ctxt, volume, new_type, diff, host):
|
def retype(self, ctxt, volume, new_type, diff, host):
|
||||||
"""Retype the specified volume."""
|
"""Retype the specified volume."""
|
||||||
return self.common.retype()
|
return self.common.retype()
|
||||||
|
@ -208,7 +208,7 @@ class HBSDISCSIDriver(driver.ISCSIDriver):
|
||||||
def backup_use_temp_snapshot(self):
|
def backup_use_temp_snapshot(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def revert_to_snapshot(self, context, volume, snapshot):
|
def revert_to_snapshot(self, context, volume, snapshot):
|
||||||
"""Rollback the specified snapshot"""
|
"""Rollback the specified snapshot"""
|
||||||
return self.common.revert_to_snapshot(volume, snapshot)
|
return self.common.revert_to_snapshot(volume, snapshot)
|
||||||
|
|
|
@ -34,10 +34,10 @@ from oslo_log import log as logging
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers.hpe import hpe_3par_common as hpecommon
|
from cinder.volume.drivers.hpe import hpe_3par_common as hpecommon
|
||||||
from cinder.volume.drivers.san import san
|
from cinder.volume.drivers.san import san
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
return int(volume.get("replication_driver_data"))
|
return int(volume.get("replication_driver_data"))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def get_volume_stats(self, refresh=False):
|
def get_volume_stats(self, refresh=False):
|
||||||
# NOTE(geguileo): We don't need to login to the backed if we are not
|
# NOTE(geguileo): We don't need to login to the backed if we are not
|
||||||
# going to refresh the stats, furthermore if we login, then we'll
|
# going to refresh the stats, furthermore if we login, then we'll
|
||||||
|
@ -146,7 +146,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
"""Setup errors are already checked for in do_setup so return pass."""
|
"""Setup errors are already checked for in do_setup so return pass."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -154,7 +154,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_cloned_volume(self, volume, src_vref):
|
def create_cloned_volume(self, volume, src_vref):
|
||||||
"""Clone an existing volume."""
|
"""Clone an existing volume."""
|
||||||
common = self._login()
|
common = self._login()
|
||||||
|
@ -163,7 +163,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -171,7 +171,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume_from_snapshot(self, volume, snapshot):
|
def create_volume_from_snapshot(self, volume, snapshot):
|
||||||
"""Creates a volume from a snapshot.
|
"""Creates a volume from a snapshot.
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_snapshot(self, snapshot):
|
def create_snapshot(self, snapshot):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -191,7 +191,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_snapshot(self, snapshot):
|
def delete_snapshot(self, snapshot):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -199,7 +199,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def extend_volume(self, volume, new_size):
|
def extend_volume(self, volume, new_size):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -207,7 +207,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_group(self, context, group):
|
def create_group(self, context, group):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -215,7 +215,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_group_from_src(self, context, group, volumes,
|
def create_group_from_src(self, context, group, volumes,
|
||||||
group_snapshot=None, snapshots=None,
|
group_snapshot=None, snapshots=None,
|
||||||
source_group=None, source_vols=None):
|
source_group=None, source_vols=None):
|
||||||
|
@ -227,7 +227,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_group(self, context, group, volumes):
|
def delete_group(self, context, group, volumes):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -235,7 +235,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def update_group(self, context, group, add_volumes=None,
|
def update_group(self, context, group, add_volumes=None,
|
||||||
remove_volumes=None):
|
remove_volumes=None):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
|
@ -245,7 +245,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_group_snapshot(self, context, group_snapshot, snapshots):
|
def create_group_snapshot(self, context, group_snapshot, snapshots):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -254,7 +254,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_group_snapshot(self, context, group_snapshot, snapshots):
|
def delete_group_snapshot(self, context, group_snapshot, snapshots):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -263,7 +263,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing(self, volume, existing_ref):
|
def manage_existing(self, volume, existing_ref):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -271,7 +271,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing_snapshot(self, snapshot, existing_ref):
|
def manage_existing_snapshot(self, snapshot, existing_ref):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -279,7 +279,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing_get_size(self, volume, existing_ref):
|
def manage_existing_get_size(self, volume, existing_ref):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -287,7 +287,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing_snapshot_get_size(self, snapshot, existing_ref):
|
def manage_existing_snapshot_get_size(self, snapshot, existing_ref):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -296,7 +296,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def unmanage(self, volume):
|
def unmanage(self, volume):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -304,7 +304,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def unmanage_snapshot(self, snapshot):
|
def unmanage_snapshot(self, snapshot):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -312,7 +312,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def retype(self, context, volume, new_type, diff, host):
|
def retype(self, context, volume, new_type, diff, host):
|
||||||
"""Convert the volume to be of the new type."""
|
"""Convert the volume to be of the new type."""
|
||||||
common = self._login()
|
common = self._login()
|
||||||
|
@ -321,7 +321,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def migrate_volume(self, context, volume, host):
|
def migrate_volume(self, context, volume, host):
|
||||||
if volume['status'] == 'in-use':
|
if volume['status'] == 'in-use':
|
||||||
protocol = host['capabilities']['storage_protocol']
|
protocol = host['capabilities']['storage_protocol']
|
||||||
|
@ -339,7 +339,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def update_migrated_volume(self, context, volume, new_volume,
|
def update_migrated_volume(self, context, volume, new_volume,
|
||||||
original_volume_status):
|
original_volume_status):
|
||||||
"""Update the name of the migrated volume to it's new ID."""
|
"""Update the name of the migrated volume to it's new ID."""
|
||||||
|
@ -350,7 +350,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def get_pool(self, volume):
|
def get_pool(self, volume):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -362,7 +362,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def revert_to_snapshot(self, context, volume, snapshot):
|
def revert_to_snapshot(self, context, volume, snapshot):
|
||||||
"""Revert volume to snapshot."""
|
"""Revert volume to snapshot."""
|
||||||
common = self._login()
|
common = self._login()
|
||||||
|
@ -371,7 +371,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def failover_host(self, context, volumes, secondary_id=None, groups=None):
|
def failover_host(self, context, volumes, secondary_id=None, groups=None):
|
||||||
"""Force failover to a secondary replication target."""
|
"""Force failover to a secondary replication target."""
|
||||||
common = self._login(timeout=30)
|
common = self._login(timeout=30)
|
||||||
|
@ -455,7 +455,7 @@ class HPE3PARDriverBase(driver.ManageableVD,
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _init_vendor_properties(self):
|
def _init_vendor_properties(self):
|
||||||
"""Create a dictionary of vendor unique properties.
|
"""Create a dictionary of vendor unique properties.
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ from oslo_utils.excutils import save_and_reraise_exception
|
||||||
|
|
||||||
from cinder import coordination
|
from cinder import coordination
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume.drivers.hpe import hpe_3par_base as hpebasedriver
|
from cinder.volume.drivers.hpe import hpe_3par_base as hpebasedriver
|
||||||
|
from cinder.volume import volume_utils
|
||||||
from cinder.zonemanager import utils as fczm_utils
|
from cinder.zonemanager import utils as fczm_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -164,7 +164,7 @@ class HPE3PARFCDriver(hpebasedriver.HPE3PARDriverBase):
|
||||||
|
|
||||||
return info_backend
|
return info_backend
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
@coordination.synchronized('3par-{volume.id}')
|
@coordination.synchronized('3par-{volume.id}')
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
"""Assigns the volume to a server.
|
"""Assigns the volume to a server.
|
||||||
|
@ -292,7 +292,7 @@ class HPE3PARFCDriver(hpebasedriver.HPE3PARDriverBase):
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
@coordination.synchronized('3par-{volume.id}')
|
@coordination.synchronized('3par-{volume.id}')
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Driver entry point to detach a volume from an instance."""
|
"""Driver entry point to detach a volume from an instance."""
|
||||||
|
|
|
@ -42,7 +42,6 @@ from cinder import coordination
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume.drivers.hpe import hpe_3par_base as hpebasedriver
|
from cinder.volume.drivers.hpe import hpe_3par_base as hpebasedriver
|
||||||
from cinder.volume import volume_utils
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
|
@ -284,7 +283,7 @@ class HPE3PARISCSIDriver(hpebasedriver.HPE3PARDriverBase):
|
||||||
"hpe3par_iscsi_ips list defined in "
|
"hpe3par_iscsi_ips list defined in "
|
||||||
"cinder.conf.", iscsi_ip)
|
"cinder.conf.", iscsi_ip)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
@coordination.synchronized('3par-{volume.id}')
|
@coordination.synchronized('3par-{volume.id}')
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
"""Assigns the volume to a server.
|
"""Assigns the volume to a server.
|
||||||
|
@ -460,7 +459,7 @@ class HPE3PARISCSIDriver(hpebasedriver.HPE3PARDriverBase):
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
@coordination.synchronized('3par-{volume.id}')
|
@coordination.synchronized('3par-{volume.id}')
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Driver entry point to detach a volume from an instance."""
|
"""Driver entry point to detach a volume from an instance."""
|
||||||
|
@ -743,7 +742,7 @@ class HPE3PARISCSIDriver(hpebasedriver.HPE3PARDriverBase):
|
||||||
|
|
||||||
return model_update
|
return model_update
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_export(self, context, volume, connector):
|
def create_export(self, context, volume, connector):
|
||||||
common = self._login()
|
common = self._login()
|
||||||
try:
|
try:
|
||||||
|
@ -751,7 +750,7 @@ class HPE3PARISCSIDriver(hpebasedriver.HPE3PARDriverBase):
|
||||||
finally:
|
finally:
|
||||||
self._logout(common)
|
self._logout(common)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def ensure_export(self, context, volume):
|
def ensure_export(self, context, volume):
|
||||||
"""Ensure the volume still exists on the 3PAR.
|
"""Ensure the volume still exists on the 3PAR.
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ from cinder.i18n import _
|
||||||
from cinder import ssh_utils
|
from cinder import ssh_utils
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder.volume.drivers.ibm.storwize_svc import storwize_const
|
from cinder.volume.drivers.ibm.storwize_svc import storwize_const
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ class StorwizeSVCReplication(object):
|
||||||
self.driver = driver
|
self.driver = driver
|
||||||
self.target = replication_target or {}
|
self.target = replication_target or {}
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def failover_volume_host(self, context, vref):
|
def failover_volume_host(self, context, vref):
|
||||||
# Make the aux volume writeable.
|
# Make the aux volume writeable.
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1213,7 +1213,7 @@ class StorwizeHelpers(object):
|
||||||
|
|
||||||
return result_lun
|
return result_lun
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def map_vol_to_host(self, volume_name, host_name, multihostmap):
|
def map_vol_to_host(self, volume_name, host_name, multihostmap):
|
||||||
"""Create a mapping between a volume to a host."""
|
"""Create a mapping between a volume to a host."""
|
||||||
|
|
||||||
|
@ -2100,7 +2100,7 @@ class StorwizeHelpers(object):
|
||||||
return None
|
return None
|
||||||
return resp[0]
|
return resp[0]
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _check_delete_vdisk_fc_mappings(self, name, allow_snaps=True,
|
def _check_delete_vdisk_fc_mappings(self, name, allow_snaps=True,
|
||||||
allow_fctgt=False):
|
allow_fctgt=False):
|
||||||
"""FlashCopy mapping check helper."""
|
"""FlashCopy mapping check helper."""
|
||||||
|
@ -2188,7 +2188,7 @@ class StorwizeHelpers(object):
|
||||||
if not wait_for_copy or not len(mapping_ids):
|
if not wait_for_copy or not len(mapping_ids):
|
||||||
raise loopingcall.LoopingCallDone(retvalue=True)
|
raise loopingcall.LoopingCallDone(retvalue=True)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _check_vdisk_fc_mappings(self, name, allow_snaps=True,
|
def _check_vdisk_fc_mappings(self, name, allow_snaps=True,
|
||||||
allow_fctgt=False):
|
allow_fctgt=False):
|
||||||
"""FlashCopy mapping check helper."""
|
"""FlashCopy mapping check helper."""
|
||||||
|
@ -3636,7 +3636,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
||||||
LOG.debug("Exit: update volume copy status.")
|
LOG.debug("Exit: update volume copy status.")
|
||||||
|
|
||||||
# #### V2.1 replication methods #### #
|
# #### V2.1 replication methods #### #
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def failover_host(self, context, volumes, secondary_id=None, groups=None):
|
def failover_host(self, context, volumes, secondary_id=None, groups=None):
|
||||||
if not self._replica_enabled:
|
if not self._replica_enabled:
|
||||||
msg = _("Replication is not properly enabled on backend.")
|
msg = _("Replication is not properly enabled on backend.")
|
||||||
|
@ -4199,7 +4199,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
||||||
self._update_storwize_state(self._aux_state, self._aux_backend_helpers)
|
self._update_storwize_state(self._aux_state, self._aux_backend_helpers)
|
||||||
|
|
||||||
# Replication Group (Tiramisu)
|
# Replication Group (Tiramisu)
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def enable_replication(self, context, group, volumes):
|
def enable_replication(self, context, group, volumes):
|
||||||
"""Enables replication for a group and volumes in the group."""
|
"""Enables replication for a group and volumes in the group."""
|
||||||
model_update = {'replication_status': fields.ReplicationStatus.ENABLED}
|
model_update = {'replication_status': fields.ReplicationStatus.ENABLED}
|
||||||
|
@ -4233,7 +4233,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
||||||
'replication_status': model_update['replication_status']})
|
'replication_status': model_update['replication_status']})
|
||||||
return model_update, volumes_update
|
return model_update, volumes_update
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def disable_replication(self, context, group, volumes):
|
def disable_replication(self, context, group, volumes):
|
||||||
"""Disables replication for a group and volumes in the group."""
|
"""Disables replication for a group and volumes in the group."""
|
||||||
model_update = {
|
model_update = {
|
||||||
|
@ -4265,7 +4265,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
||||||
'replication_status': model_update['replication_status']})
|
'replication_status': model_update['replication_status']})
|
||||||
return model_update, volumes_update
|
return model_update, volumes_update
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def failover_replication(self, context, group, volumes,
|
def failover_replication(self, context, group, volumes,
|
||||||
secondary_backend_id=None):
|
secondary_backend_id=None):
|
||||||
"""Fails over replication for a group and volumes in the group."""
|
"""Fails over replication for a group and volumes in the group."""
|
||||||
|
@ -4356,7 +4356,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
||||||
raise exception.UnableToFailOver(reason=msg)
|
raise exception.UnableToFailOver(reason=msg)
|
||||||
return model_update
|
return model_update
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _rep_grp_failover(self, ctxt, group):
|
def _rep_grp_failover(self, ctxt, group):
|
||||||
"""Fail over all the volume in the replication group."""
|
"""Fail over all the volume in the replication group."""
|
||||||
model_update = {
|
model_update = {
|
||||||
|
@ -4374,7 +4374,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
||||||
LOG.exception(msg)
|
LOG.exception(msg)
|
||||||
raise exception.UnableToFailOver(reason=msg)
|
raise exception.UnableToFailOver(reason=msg)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _sync_with_aux_grp(self, ctxt, rccg_name):
|
def _sync_with_aux_grp(self, ctxt, rccg_name):
|
||||||
try:
|
try:
|
||||||
rccg = self._helpers.get_rccg(rccg_name)
|
rccg = self._helpers.get_rccg(rccg_name)
|
||||||
|
@ -5624,7 +5624,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
||||||
|
|
||||||
return model_update, snapshots_model
|
return model_update, snapshots_model
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def revert_to_snapshot(self, context, volume, snapshot):
|
def revert_to_snapshot(self, context, volume, snapshot):
|
||||||
"""Revert volume to snapshot."""
|
"""Revert volume to snapshot."""
|
||||||
if snapshot.volume_size != volume.size:
|
if snapshot.volume_size != volume.size:
|
||||||
|
|
|
@ -89,7 +89,7 @@ class RestAPIExecutor(object):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def do_request(cmd, url, header, data):
|
def do_request(cmd, url, header, data):
|
||||||
"""Send request to the storage and handle the response."""
|
"""Send request to the storage and handle the response."""
|
||||||
if cmd in ['post', 'get', 'put', 'delete']:
|
if cmd in ['post', 'get', 'put', 'delete']:
|
||||||
|
@ -113,7 +113,7 @@ class RestAPIExecutor(object):
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def send_api(self, method, params=None, request_type='post'):
|
def send_api(self, method, params=None, request_type='post'):
|
||||||
if params:
|
if params:
|
||||||
params = json.dumps(params)
|
params = json.dumps(params)
|
||||||
|
@ -205,7 +205,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
def get_driver_options():
|
def get_driver_options():
|
||||||
return inspur_as13000_opts
|
return inspur_as13000_opts
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def do_setup(self, context):
|
def do_setup(self, context):
|
||||||
# get tokens for the driver
|
# get tokens for the driver
|
||||||
self._rest.login()
|
self._rest.login()
|
||||||
|
@ -231,7 +231,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
|
|
||||||
self._check_meta_pool()
|
self._check_meta_pool()
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
"""Do check to make sure service is available."""
|
"""Do check to make sure service is available."""
|
||||||
# check the required flags in conf
|
# check the required flags in conf
|
||||||
|
@ -276,7 +276,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.InvalidInput(reason=msg)
|
raise exception.InvalidInput(reason=msg)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
"""Create volume in the backend."""
|
"""Create volume in the backend."""
|
||||||
pool = volume_utils.extract_host(volume.host, level='pool')
|
pool = volume_utils.extract_host(volume.host, level='pool')
|
||||||
|
@ -295,7 +295,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
self._rest.send_rest_api(method=method, params=params,
|
self._rest.send_rest_api(method=method, params=params,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume_from_snapshot(self, volume, snapshot):
|
def create_volume_from_snapshot(self, volume, snapshot):
|
||||||
"""Create a new volume base on a specific snapshot."""
|
"""Create a new volume base on a specific snapshot."""
|
||||||
if snapshot.volume_size > volume.size:
|
if snapshot.volume_size > volume.size:
|
||||||
|
@ -343,7 +343,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
if volume.size > snapshot.volume_size:
|
if volume.size > snapshot.volume_size:
|
||||||
self.extend_volume(volume, volume.size)
|
self.extend_volume(volume, volume.size)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_cloned_volume(self, volume, src_vref):
|
def create_cloned_volume(self, volume, src_vref):
|
||||||
"""Clone a volume."""
|
"""Clone a volume."""
|
||||||
if src_vref.size > volume.size:
|
if src_vref.size > volume.size:
|
||||||
|
@ -374,7 +374,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
if volume.size > src_vref.size:
|
if volume.size > src_vref.size:
|
||||||
self.extend_volume(volume, volume.size)
|
self.extend_volume(volume, volume.size)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def extend_volume(self, volume, new_size):
|
def extend_volume(self, volume, new_size):
|
||||||
"""Extend volume to new size."""
|
"""Extend volume to new size."""
|
||||||
name = self._trans_name_down(volume.name)
|
name = self._trans_name_down(volume.name)
|
||||||
|
@ -395,7 +395,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
params=params,
|
params=params,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
"""Delete volume from AS13000."""
|
"""Delete volume from AS13000."""
|
||||||
name = self._trans_name_down(volume.name)
|
name = self._trans_name_down(volume.name)
|
||||||
|
@ -412,7 +412,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
request_type = 'delete'
|
request_type = 'delete'
|
||||||
self._rest.send_rest_api(method=method, request_type=request_type)
|
self._rest.send_rest_api(method=method, request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_snapshot(self, snapshot):
|
def create_snapshot(self, snapshot):
|
||||||
"""Create snapshot of volume in backend.
|
"""Create snapshot of volume in backend.
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
self._rest.send_rest_api(method=method, params=params,
|
self._rest.send_rest_api(method=method, params=params,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_snapshot(self, snapshot):
|
def delete_snapshot(self, snapshot):
|
||||||
"""Delete snapshot of volume."""
|
"""Delete snapshot of volume."""
|
||||||
source_volume = snapshot.volume
|
source_volume = snapshot.volume
|
||||||
|
@ -457,7 +457,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
request_type = 'delete'
|
request_type = 'delete'
|
||||||
self._rest.send_rest_api(method=method, request_type=request_type)
|
self._rest.send_rest_api(method=method, request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _update_volume_stats(self):
|
def _update_volume_stats(self):
|
||||||
"""Update the backend stats including driver info and pools info."""
|
"""Update the backend stats including driver info and pools info."""
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
ipaddr = '[%s]' % ip
|
ipaddr = '[%s]' % ip
|
||||||
return '%(ip)s:%(port)s' % {'ip': ipaddr, 'port': port}
|
return '%(ip)s:%(port)s' % {'ip': ipaddr, 'port': port}
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection(self, volume, connector, **kwargs):
|
def initialize_connection(self, volume, connector, **kwargs):
|
||||||
"""Initialize connection steps:
|
"""Initialize connection steps:
|
||||||
|
|
||||||
|
@ -567,7 +567,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
|
|
||||||
return {'driver_volume_type': 'iscsi', 'data': connection_data}
|
return {'driver_volume_type': 'iscsi', 'data': connection_data}
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Delete lun from target.
|
"""Delete lun from target.
|
||||||
|
|
||||||
|
@ -613,7 +613,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
|
|
||||||
return pools_info
|
return pools_info
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _get_pools_stats(self):
|
def _get_pools_stats(self):
|
||||||
"""Generate the pool stat information."""
|
"""Generate the pool stat information."""
|
||||||
pools_info = self._get_pools_info(self.pools)
|
pools_info = self._get_pools_info(self.pools)
|
||||||
|
@ -637,7 +637,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
|
|
||||||
return pools
|
return pools
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _get_target_from_conn(self, host_ip):
|
def _get_target_from_conn(self, host_ip):
|
||||||
"""Get target information base on the host ip."""
|
"""Get target information base on the host ip."""
|
||||||
host_exist = False
|
host_exist = False
|
||||||
|
@ -654,7 +654,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
|
|
||||||
return host_exist, target_name, node
|
return host_exist, target_name, node
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _get_target_list(self):
|
def _get_target_list(self):
|
||||||
"""Get a list of all targets in the backend."""
|
"""Get a list of all targets in the backend."""
|
||||||
method = 'block/target/detail'
|
method = 'block/target/detail'
|
||||||
|
@ -663,7 +663,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _create_target(self, target_name, target_node):
|
def _create_target(self, target_name, target_node):
|
||||||
"""Create a target on the specified node."""
|
"""Create a target on the specified node."""
|
||||||
method = 'block/target'
|
method = 'block/target'
|
||||||
|
@ -673,7 +673,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
params=params,
|
params=params,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _delete_target(self, target_name):
|
def _delete_target(self, target_name):
|
||||||
"""Delete all target of all the node."""
|
"""Delete all target of all the node."""
|
||||||
method = 'block/target?name=%s' % target_name
|
method = 'block/target?name=%s' % target_name
|
||||||
|
@ -681,7 +681,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
self._rest.send_rest_api(method=method,
|
self._rest.send_rest_api(method=method,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _add_chap_to_target(self, target_name, chap_username, chap_password):
|
def _add_chap_to_target(self, target_name, chap_username, chap_password):
|
||||||
"""Add CHAP to target."""
|
"""Add CHAP to target."""
|
||||||
method = 'block/chap/bond'
|
method = 'block/chap/bond'
|
||||||
|
@ -693,7 +693,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
params=params,
|
params=params,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _add_host_to_target(self, host_ip, target_name):
|
def _add_host_to_target(self, host_ip, target_name):
|
||||||
"""Add the authority of host to target."""
|
"""Add the authority of host to target."""
|
||||||
method = 'block/host'
|
method = 'block/host'
|
||||||
|
@ -703,7 +703,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
params=params,
|
params=params,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
@utils.retry(exceptions=exception.VolumeDriverException,
|
@utils.retry(exceptions=exception.VolumeDriverException,
|
||||||
interval=1,
|
interval=1,
|
||||||
retries=3)
|
retries=3)
|
||||||
|
@ -721,14 +721,14 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
params=params,
|
params=params,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _delete_lun_from_target(self, target_name, lun_id):
|
def _delete_lun_from_target(self, target_name, lun_id):
|
||||||
"""Delete lun from target_name."""
|
"""Delete lun from target_name."""
|
||||||
method = 'block/lun?name=%s&id=%s&force=1' % (target_name, lun_id)
|
method = 'block/lun?name=%s&id=%s&force=1' % (target_name, lun_id)
|
||||||
request_type = 'delete'
|
request_type = 'delete'
|
||||||
self._rest.send_rest_api(method=method, request_type=request_type)
|
self._rest.send_rest_api(method=method, request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _get_lun_list(self, target_name):
|
def _get_lun_list(self, target_name):
|
||||||
"""Get all lun list of the target."""
|
"""Get all lun list of the target."""
|
||||||
method = 'block/lun?name=%s' % target_name
|
method = 'block/lun?name=%s' % target_name
|
||||||
|
@ -736,7 +736,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
return self._rest.send_rest_api(method=method,
|
return self._rest.send_rest_api(method=method,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _snapshot_lock_op(self, op, vol_name, snap_name, pool_name):
|
def _snapshot_lock_op(self, op, vol_name, snap_name, pool_name):
|
||||||
"""Lock or unlock a snapshot to protect the snapshot.
|
"""Lock or unlock a snapshot to protect the snapshot.
|
||||||
|
|
||||||
|
@ -751,7 +751,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
params=params,
|
params=params,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _filling_volume(self, name, pool):
|
def _filling_volume(self, name, pool):
|
||||||
"""Filling a volume so that make it independently."""
|
"""Filling a volume so that make it independently."""
|
||||||
method = 'block/lvm/filling'
|
method = 'block/lvm/filling'
|
||||||
|
@ -774,7 +774,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
msg = (_('Volume %s is not filled.') % name)
|
msg = (_('Volume %s is not filled.') % name)
|
||||||
raise exception.VolumeDriverException(msg)
|
raise exception.VolumeDriverException(msg)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _check_volume(self, volume):
|
def _check_volume(self, volume):
|
||||||
"""Check if the volume exists in the backend."""
|
"""Check if the volume exists in the backend."""
|
||||||
pool = volume_utils.extract_host(volume.host, 'pool')
|
pool = volume_utils.extract_host(volume.host, 'pool')
|
||||||
|
@ -789,7 +789,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
eventlet.sleep(1)
|
eventlet.sleep(1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _get_volumes(self, pool):
|
def _get_volumes(self, pool):
|
||||||
"""Get all the volumes in the pool."""
|
"""Get all the volumes in the pool."""
|
||||||
method = 'block/lvm?pool=%s' % pool
|
method = 'block/lvm?pool=%s' % pool
|
||||||
|
@ -797,7 +797,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
return self._rest.send_rest_api(method=method,
|
return self._rest.send_rest_api(method=method,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _get_cluster_status(self):
|
def _get_cluster_status(self):
|
||||||
"""Get all nodes of the backend."""
|
"""Get all nodes of the backend."""
|
||||||
method = 'cluster/node'
|
method = 'cluster/node'
|
||||||
|
@ -805,7 +805,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
return self._rest.send_rest_api(method=method,
|
return self._rest.send_rest_api(method=method,
|
||||||
request_type=request_type)
|
request_type=request_type)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _get_lun_id(self, volume, target_name):
|
def _get_lun_id(self, volume, target_name):
|
||||||
"""Get lun id of the voluem in a target."""
|
"""Get lun id of the voluem in a target."""
|
||||||
pool = volume_utils.extract_host(volume.host, level='pool')
|
pool = volume_utils.extract_host(volume.host, level='pool')
|
||||||
|
@ -827,7 +827,7 @@ class AS13000Driver(san.SanISCSIDriver):
|
||||||
"""
|
"""
|
||||||
return name.replace('-', '_')
|
return name.replace('-', '_')
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _unit_convert(self, capacity):
|
def _unit_convert(self, capacity):
|
||||||
"""Convert all units to GB.
|
"""Convert all units to GB.
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
def get_driver_options():
|
def get_driver_options():
|
||||||
return instorage_mcs_opts
|
return instorage_mcs_opts
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def do_setup(self, ctxt):
|
def do_setup(self, ctxt):
|
||||||
"""Check that we have all configuration details from the storage."""
|
"""Check that we have all configuration details from the storage."""
|
||||||
# InStorage has the limitation that can not burst more than 3 new ssh
|
# InStorage has the limitation that can not burst more than 3 new ssh
|
||||||
|
@ -239,7 +239,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
msg = _('Failed getting details for pool %s.') % pool
|
msg = _('Failed getting details for pool %s.') % pool
|
||||||
raise exception.InvalidInput(reason=msg)
|
raise exception.InvalidInput(reason=msg)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
"""Ensure that the flags are set properly."""
|
"""Ensure that the flags are set properly."""
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
volume_type=volume_type,
|
volume_type=volume_type,
|
||||||
volume_metadata=volume_metadata)
|
volume_metadata=volume_metadata)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
opts = self._get_vdisk_params(
|
opts = self._get_vdisk_params(
|
||||||
volume.volume_type_id,
|
volume.volume_type_id,
|
||||||
|
@ -527,7 +527,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
def extend_volume(self, volume, new_size):
|
def extend_volume(self, volume, new_size):
|
||||||
self._extend_volume_op(volume, new_size)
|
self._extend_volume_op(volume, new_size)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _extend_volume_op(self, volume, new_size, old_size=None):
|
def _extend_volume_op(self, volume, new_size, old_size=None):
|
||||||
volume_name = self._get_target_vol(volume)
|
volume_name = self._get_target_vol(volume)
|
||||||
ret = self._assistant.ensure_vdisk_no_lc_mappings(volume_name,
|
ret = self._assistant.ensure_vdisk_no_lc_mappings(volume_name,
|
||||||
|
@ -568,7 +568,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
else:
|
else:
|
||||||
self._assistant.extend_vdisk(volume_name, extend_amt)
|
self._assistant.extend_vdisk(volume_name, extend_amt)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
copy_op[1])
|
copy_op[1])
|
||||||
LOG.debug("Exit: update volume copy status.")
|
LOG.debug("Exit: update volume copy status.")
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def migrate_volume(self, ctxt, volume, host):
|
def migrate_volume(self, ctxt, volume, host):
|
||||||
"""Migrate directly if source and dest are managed by same storage.
|
"""Migrate directly if source and dest are managed by same storage.
|
||||||
|
|
||||||
|
@ -719,7 +719,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
self._add_vdisk_copy_op(ctxt, volume, new_op)
|
self._add_vdisk_copy_op(ctxt, volume, new_op)
|
||||||
return (True, None)
|
return (True, None)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def retype(self, ctxt, volume, new_type, diff, host):
|
def retype(self, ctxt, volume, new_type, diff, host):
|
||||||
"""Convert the volume to be of the new type.
|
"""Convert the volume to be of the new type.
|
||||||
|
|
||||||
|
@ -1270,7 +1270,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
return vdisk
|
return vdisk
|
||||||
|
|
||||||
# #### V2.1 replication methods #### #
|
# #### V2.1 replication methods #### #
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def failover_host(self, context, volumes, secondary_id=None):
|
def failover_host(self, context, volumes, secondary_id=None):
|
||||||
if not self._replica_enabled:
|
if not self._replica_enabled:
|
||||||
msg = _("Replication is not properly enabled on backend.")
|
msg = _("Replication is not properly enabled on backend.")
|
||||||
|
@ -1329,7 +1329,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
self._update_volume_stats()
|
self._update_volume_stats()
|
||||||
return instorage_const.FAILBACK_VALUE, volumes_update
|
return instorage_const.FAILBACK_VALUE, volumes_update
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _failback_replica_volumes(self, ctxt, rep_volumes):
|
def _failback_replica_volumes(self, ctxt, rep_volumes):
|
||||||
volumes_update = []
|
volumes_update = []
|
||||||
|
|
||||||
|
@ -1389,7 +1389,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
'replication_driver_data': ''}})
|
'replication_driver_data': ''}})
|
||||||
return volumes_update
|
return volumes_update
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _sync_with_aux(self, ctxt, volumes):
|
def _sync_with_aux(self, ctxt, volumes):
|
||||||
try:
|
try:
|
||||||
rep_mgr = self._get_replica_mgr()
|
rep_mgr = self._get_replica_mgr()
|
||||||
|
@ -1443,7 +1443,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
'error:%(err)s.', {'volume': tgt_volume,
|
'error:%(err)s.', {'volume': tgt_volume,
|
||||||
'err': ex})
|
'err': ex})
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _wait_replica_vol_ready(self, ctxt, volume):
|
def _wait_replica_vol_ready(self, ctxt, volume):
|
||||||
def _replica_vol_ready():
|
def _replica_vol_ready():
|
||||||
rep_info = self._assistant.get_relationship_info(volume)
|
rep_info = self._assistant.get_relationship_info(volume)
|
||||||
|
@ -1509,7 +1509,7 @@ class InStorageMCSCommonDriver(driver.VolumeDriver, san.SanDriver):
|
||||||
self._update_volume_stats()
|
self._update_volume_stats()
|
||||||
return self._active_backend_id, volumes_update
|
return self._active_backend_id, volumes_update
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _failover_replica_volumes(self, ctxt, rep_volumes):
|
def _failover_replica_volumes(self, ctxt, rep_volumes):
|
||||||
volumes_update = []
|
volumes_update = []
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ from cinder import coordination
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder import utils as cinder_utils
|
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers.inspur.instorage import instorage_common
|
from cinder.volume.drivers.inspur.instorage import instorage_common
|
||||||
|
from cinder.volume import volume_utils
|
||||||
from cinder.zonemanager import utils as fczm_utils
|
from cinder.zonemanager import utils as fczm_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -67,7 +67,7 @@ class InStorageMCSFCDriver(instorage_common.InStorageMCSCommonDriver,
|
||||||
|
|
||||||
return i_t_map
|
return i_t_map
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
@coordination.synchronized('instorage-host'
|
@coordination.synchronized('instorage-host'
|
||||||
'{self._state[system_id]}'
|
'{self._state[system_id]}'
|
||||||
'{connector[host]}')
|
'{connector[host]}')
|
||||||
|
@ -185,7 +185,7 @@ class InStorageMCSFCDriver(instorage_common.InStorageMCSCommonDriver,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
return _do_terminate_connection_locked()
|
return _do_terminate_connection_locked()
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _do_terminate_connection(self, volume, connector, **kwargs):
|
def _do_terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Cleanup after an FC connection has been terminated.
|
"""Cleanup after an FC connection has been terminated.
|
||||||
|
|
||||||
|
|
|
@ -50,9 +50,9 @@ from cinder import coordination
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder import utils as cinder_utils
|
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers.inspur.instorage import instorage_common
|
from cinder.volume.drivers.inspur.instorage import instorage_common
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class InStorageMCSISCSIDriver(instorage_common.InStorageMCSCommonDriver,
|
||||||
self.configuration.append_config_values(
|
self.configuration.append_config_values(
|
||||||
instorage_mcs_iscsi_opts)
|
instorage_mcs_iscsi_opts)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
@coordination.synchronized('instorage-host'
|
@coordination.synchronized('instorage-host'
|
||||||
'{self._state[system_id]}'
|
'{self._state[system_id]}'
|
||||||
'{connector[host]}')
|
'{connector[host]}')
|
||||||
|
@ -132,7 +132,7 @@ class InStorageMCSISCSIDriver(instorage_common.InStorageMCSCommonDriver,
|
||||||
|
|
||||||
return {'driver_volume_type': 'iscsi', 'data': properties}
|
return {'driver_volume_type': 'iscsi', 'data': properties}
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _get_single_iscsi_data(self, volume, connector, lun_id, chap_secret):
|
def _get_single_iscsi_data(self, volume, connector, lun_id, chap_secret):
|
||||||
volume_name = self._get_target_vol(volume)
|
volume_name = self._get_target_vol(volume)
|
||||||
volume_attributes = self._assistant.get_vdisk_attributes(volume_name)
|
volume_attributes = self._assistant.get_vdisk_attributes(volume_name)
|
||||||
|
@ -200,7 +200,7 @@ class InStorageMCSISCSIDriver(instorage_common.InStorageMCSCommonDriver,
|
||||||
discovery_auth_password=chap_secret)
|
discovery_auth_password=chap_secret)
|
||||||
return properties
|
return properties
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _get_multi_iscsi_data(self, volume, connector, lun_id, properties):
|
def _get_multi_iscsi_data(self, volume, connector, lun_id, properties):
|
||||||
try:
|
try:
|
||||||
resp = self._assistant.ssh.lsportip()
|
resp = self._assistant.ssh.lsportip()
|
||||||
|
@ -256,7 +256,7 @@ class InStorageMCSISCSIDriver(instorage_common.InStorageMCSCommonDriver,
|
||||||
return self._do_terminate_connection(volume, connector, **kwargs)
|
return self._do_terminate_connection(volume, connector, **kwargs)
|
||||||
return _do_terminate_connection_locked()
|
return _do_terminate_connection_locked()
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def _do_terminate_connection(self, volume, connector, **kwargs):
|
def _do_terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Cleanup after an iSCSI connection has been terminated.
|
"""Cleanup after an iSCSI connection has been terminated.
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ from cinder.objects import fields
|
||||||
from cinder import ssh_utils
|
from cinder import ssh_utils
|
||||||
from cinder import utils as cinder_utils
|
from cinder import utils as cinder_utils
|
||||||
from cinder.volume.drivers.inspur.instorage import instorage_const
|
from cinder.volume.drivers.inspur.instorage import instorage_const
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ class InStorageMCSReplication(object):
|
||||||
self.target = replication_target or {}
|
self.target = replication_target or {}
|
||||||
self.target_assistant = target_assistant
|
self.target_assistant = target_assistant
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def volume_replication_setup(self, context, vref):
|
def volume_replication_setup(self, context, vref):
|
||||||
target_vol_name = instorage_const.REPLICA_AUX_VOL_PREFIX + vref.name
|
target_vol_name = instorage_const.REPLICA_AUX_VOL_PREFIX + vref.name
|
||||||
try:
|
try:
|
||||||
|
@ -167,7 +168,7 @@ class InStorageMCSReplication(object):
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.VolumeDriverException(message=msg)
|
raise exception.VolumeDriverException(message=msg)
|
||||||
|
|
||||||
@cinder_utils.trace
|
@volume_utils.trace
|
||||||
def failover_volume_host(self, context, vref):
|
def failover_volume_host(self, context, vref):
|
||||||
target_vol = instorage_const.REPLICA_AUX_VOL_PREFIX + vref.name
|
target_vol = instorage_const.REPLICA_AUX_VOL_PREFIX + vref.name
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
'volume_dd_blocksize', 'unique_fqdn_network')
|
'volume_dd_blocksize', 'unique_fqdn_network')
|
||||||
return kaminario_opts + additional_opts
|
return kaminario_opts + additional_opts
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
if krest is None:
|
if krest is None:
|
||||||
msg = _("Unable to import 'krest' python module.")
|
msg = _("Unable to import 'krest' python module.")
|
||||||
|
@ -183,12 +183,12 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
raise exception.InvalidInput(reason=msg)
|
raise exception.InvalidInput(reason=msg)
|
||||||
self.replica = Replication(replica[0])
|
self.replica = Replication(replica[0])
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def do_setup(self, context):
|
def do_setup(self, context):
|
||||||
super(KaminarioCinderDriver, self).do_setup(context)
|
super(KaminarioCinderDriver, self).do_setup(context)
|
||||||
self._check_ops()
|
self._check_ops()
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
"""Volume creation in K2 needs a volume group.
|
"""Volume creation in K2 needs a volume group.
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
if self._get_is_replica(volume.volume_type) and self.replica:
|
if self._get_is_replica(volume.volume_type) and self.replica:
|
||||||
self._create_volume_replica(volume, vg, vol, self.replica.rpo)
|
self._create_volume_replica(volume, vg, vol, self.replica.rpo)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _create_volume_replica(self, volume, vg, vol, rpo):
|
def _create_volume_replica(self, volume, vg, vol, rpo):
|
||||||
"""Volume replica creation in K2 needs session and remote volume.
|
"""Volume replica creation in K2 needs session and remote volume.
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
self._delete_by_ref(self.client, "volume_groups", vg.name, "vg")
|
self._delete_by_ref(self.client, "volume_groups", vg.name, "vg")
|
||||||
raise KaminarioCinderDriverException(reason=ex)
|
raise KaminarioCinderDriverException(reason=ex)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _create_failover_volume_replica(self, volume, vg_name, vol_name):
|
def _create_failover_volume_replica(self, volume, vg_name, vol_name):
|
||||||
"""Volume replica creation in K2 needs session and remote volume.
|
"""Volume replica creation in K2 needs session and remote volume.
|
||||||
|
|
||||||
|
@ -335,14 +335,14 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
self._delete_by_ref(self.client, "volume_groups", vg_name, "vg")
|
self._delete_by_ref(self.client, "volume_groups", vg_name, "vg")
|
||||||
raise KaminarioCinderDriverException(reason=ex)
|
raise KaminarioCinderDriverException(reason=ex)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _delete_by_ref(self, device, url, name, msg):
|
def _delete_by_ref(self, device, url, name, msg):
|
||||||
rs = device.search(url, name=name)
|
rs = device.search(url, name=name)
|
||||||
for result in rs.hits:
|
for result in rs.hits:
|
||||||
result.delete()
|
result.delete()
|
||||||
LOG.debug("Deleting %(msg)s: %(name)s", {'msg': msg, 'name': name})
|
LOG.debug("Deleting %(msg)s: %(name)s", {'msg': msg, 'name': name})
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _failover_volume(self, volume):
|
def _failover_volume(self, volume):
|
||||||
"""Promoting a secondary volume to primary volume."""
|
"""Promoting a secondary volume to primary volume."""
|
||||||
session_name = self.get_session_name(volume.id)
|
session_name = self.get_session_name(volume.id)
|
||||||
|
@ -355,7 +355,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
LOG.debug("The target session: %s state is "
|
LOG.debug("The target session: %s state is "
|
||||||
"changed to failed_over ", rsession_name)
|
"changed to failed_over ", rsession_name)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def failover_host(self, context, volumes, secondary_id=None, groups=None):
|
def failover_host(self, context, volumes, secondary_id=None, groups=None):
|
||||||
"""Failover to replication target."""
|
"""Failover to replication target."""
|
||||||
volume_updates = []
|
volume_updates = []
|
||||||
|
@ -509,7 +509,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
back_end_ip = self.replica.backend_id
|
back_end_ip = self.replica.backend_id
|
||||||
return back_end_ip, volume_updates, []
|
return back_end_ip, volume_updates, []
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _create_volume_replica_user_snap(self, k2, sess):
|
def _create_volume_replica_user_snap(self, k2, sess):
|
||||||
snap = k2.new("snapshots")
|
snap = k2.new("snapshots")
|
||||||
snap.is_application_consistent = "False"
|
snap.is_application_consistent = "False"
|
||||||
|
@ -538,7 +538,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
self.snap_updates.remove(update)
|
self.snap_updates.remove(update)
|
||||||
eventlet.sleep(1)
|
eventlet.sleep(1)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume_from_snapshot(self, volume, snapshot):
|
def create_volume_from_snapshot(self, volume, snapshot):
|
||||||
"""Create volume from snapshot.
|
"""Create volume from snapshot.
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
"failed", {"vol": vol_name, "view": view_name})
|
"failed", {"vol": vol_name, "view": view_name})
|
||||||
raise KaminarioCinderDriverException(reason=ex)
|
raise KaminarioCinderDriverException(reason=ex)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_cloned_volume(self, volume, src_vref):
|
def create_cloned_volume(self, volume, src_vref):
|
||||||
"""Create a clone from source volume.
|
"""Create a clone from source volume.
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
LOG.exception("Create a clone: %s failed.", clone_name)
|
LOG.exception("Create a clone: %s failed.", clone_name)
|
||||||
raise KaminarioCinderDriverException(reason=ex)
|
raise KaminarioCinderDriverException(reason=ex)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
"""Volume in K2 exists in a volume group.
|
"""Volume in K2 exists in a volume group.
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
LOG.exception("Deletion of volume %s failed.", vol_name)
|
LOG.exception("Deletion of volume %s failed.", vol_name)
|
||||||
raise KaminarioCinderDriverException(reason=ex)
|
raise KaminarioCinderDriverException(reason=ex)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _delete_volume_replica(self, volume, vg_name, vol_name):
|
def _delete_volume_replica(self, volume, vg_name, vol_name):
|
||||||
rvg_name = self.get_rep_name(vg_name)
|
rvg_name = self.get_rep_name(vg_name)
|
||||||
rvol_name = self.get_rep_name(vol_name)
|
rvol_name = self.get_rep_name(vol_name)
|
||||||
|
@ -707,7 +707,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
self._delete_by_ref(self.target, "volume_groups",
|
self._delete_by_ref(self.target, "volume_groups",
|
||||||
rvg_name, "remote vg")
|
rvg_name, "remote vg")
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _delete_failover_volume_replica(self, volume, vg_name, vol_name):
|
def _delete_failover_volume_replica(self, volume, vg_name, vol_name):
|
||||||
rvg_name = self.get_rep_name(vg_name)
|
rvg_name = self.get_rep_name(vg_name)
|
||||||
rvol_name = self.get_rep_name(vol_name)
|
rvol_name = self.get_rep_name(vol_name)
|
||||||
|
@ -732,7 +732,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
obj.refresh()
|
obj.refresh()
|
||||||
eventlet.sleep(1)
|
eventlet.sleep(1)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def get_volume_stats(self, refresh=False):
|
def get_volume_stats(self, refresh=False):
|
||||||
if refresh:
|
if refresh:
|
||||||
self.update_volume_stats()
|
self.update_volume_stats()
|
||||||
|
@ -754,7 +754,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
def remove_export(self, context, volume):
|
def remove_export(self, context, volume):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_snapshot(self, snapshot):
|
def create_snapshot(self, snapshot):
|
||||||
"""Create a snapshot from a volume_group."""
|
"""Create a snapshot from a volume_group."""
|
||||||
vg_name = self.get_volume_group_name(snapshot.volume_id)
|
vg_name = self.get_volume_group_name(snapshot.volume_id)
|
||||||
|
@ -772,7 +772,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
LOG.exception("Creation of snapshot: %s failed.", snap_name)
|
LOG.exception("Creation of snapshot: %s failed.", snap_name)
|
||||||
raise KaminarioCinderDriverException(reason=ex)
|
raise KaminarioCinderDriverException(reason=ex)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_snapshot(self, snapshot):
|
def delete_snapshot(self, snapshot):
|
||||||
"""Delete a snapshot."""
|
"""Delete a snapshot."""
|
||||||
snap_name = self.get_snap_name(snapshot.id)
|
snap_name = self.get_snap_name(snapshot.id)
|
||||||
|
@ -785,7 +785,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
LOG.exception("Deletion of snapshot: %s failed.", snap_name)
|
LOG.exception("Deletion of snapshot: %s failed.", snap_name)
|
||||||
raise KaminarioCinderDriverException(reason=ex)
|
raise KaminarioCinderDriverException(reason=ex)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def extend_volume(self, volume, new_size):
|
def extend_volume(self, volume, new_size):
|
||||||
"""Extend volume."""
|
"""Extend volume."""
|
||||||
vol_name = self.get_volume_name(volume.id)
|
vol_name = self.get_volume_name(volume.id)
|
||||||
|
@ -867,7 +867,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
"""Return the corresponding replication names."""
|
"""Return the corresponding replication names."""
|
||||||
return "r{0}".format(name)
|
return "r{0}".format(name)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _delete_host_by_name(self, name):
|
def _delete_host_by_name(self, name):
|
||||||
"""Deleting host by name."""
|
"""Deleting host by name."""
|
||||||
host_rs = self.client.search("hosts", name=name)
|
host_rs = self.client.search("hosts", name=name)
|
||||||
|
@ -911,7 +911,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection(self, volume, connector):
|
def terminate_connection(self, volume, connector):
|
||||||
"""Terminate connection of volume from host."""
|
"""Terminate connection of volume from host."""
|
||||||
# Get volume object
|
# Get volume object
|
||||||
|
@ -947,7 +947,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
else:
|
else:
|
||||||
LOG.warning("Host: %s not found on K2.", host_name)
|
LOG.warning("Host: %s not found on K2.", host_name)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def k2_initialize_connection(self, volume, connector):
|
def k2_initialize_connection(self, volume, connector):
|
||||||
# Get volume object.
|
# Get volume object.
|
||||||
if type(volume).__name__ != 'RestObject':
|
if type(volume).__name__ != 'RestObject':
|
||||||
|
@ -1006,7 +1006,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing(self, volume, existing_ref):
|
def manage_existing(self, volume, existing_ref):
|
||||||
vol_name = existing_ref['source-name']
|
vol_name = existing_ref['source-name']
|
||||||
new_name = self.get_volume_name(volume.id)
|
new_name = self.get_volume_name(volume.id)
|
||||||
|
@ -1057,7 +1057,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
vg.save()
|
vg.save()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing_get_size(self, volume, existing_ref):
|
def manage_existing_get_size(self, volume, existing_ref):
|
||||||
vol_name = existing_ref['source-name']
|
vol_name = existing_ref['source-name']
|
||||||
v_rs = self.client.search("volumes", name=vol_name)
|
v_rs = self.client.search("volumes", name=vol_name)
|
||||||
|
@ -1070,7 +1070,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
existing_ref=existing_ref,
|
existing_ref=existing_ref,
|
||||||
reason=_('Unable to get size of manage volume.'))
|
reason=_('Unable to get size of manage volume.'))
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def after_volume_copy(self, ctxt, volume, new_volume, remote=None):
|
def after_volume_copy(self, ctxt, volume, new_volume, remote=None):
|
||||||
self.delete_volume(volume)
|
self.delete_volume(volume)
|
||||||
vg_name_old = self.get_volume_group_name(volume.id)
|
vg_name_old = self.get_volume_group_name(volume.id)
|
||||||
|
@ -1084,7 +1084,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||||
vol_new.name = vol_name_old
|
vol_new.name = vol_name_old
|
||||||
vol_new.save()
|
vol_new.save()
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def retype(self, ctxt, volume, new_type, diff, host):
|
def retype(self, ctxt, volume, new_type, diff, host):
|
||||||
old_type = volume.get('volume_type')
|
old_type = volume.get('volume_type')
|
||||||
vg_name = self.get_volume_group_name(volume.id)
|
vg_name = self.get_volume_group_name(volume.id)
|
||||||
|
|
|
@ -18,8 +18,8 @@ from oslo_log import log as logging
|
||||||
from cinder import coordination
|
from cinder import coordination
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder.objects import fields
|
from cinder.objects import fields
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume.drivers.kaminario import kaminario_common as common
|
from cinder.volume.drivers.kaminario import kaminario_common as common
|
||||||
|
from cinder.volume import volume_utils
|
||||||
from cinder.zonemanager import utils as fczm_utils
|
from cinder.zonemanager import utils as fczm_utils
|
||||||
|
|
||||||
K2_REP_FAILED_OVER = fields.ReplicationStatus.FAILED_OVER
|
K2_REP_FAILED_OVER = fields.ReplicationStatus.FAILED_OVER
|
||||||
|
@ -42,13 +42,13 @@ class KaminarioFCDriver(common.KaminarioCinderDriver):
|
||||||
# ThirdPartySystems wiki page name
|
# ThirdPartySystems wiki page name
|
||||||
CI_WIKI_NAME = "Kaminario_K2_CI"
|
CI_WIKI_NAME = "Kaminario_K2_CI"
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(KaminarioFCDriver, self).__init__(*args, **kwargs)
|
super(KaminarioFCDriver, self).__init__(*args, **kwargs)
|
||||||
self._protocol = 'FC'
|
self._protocol = 'FC'
|
||||||
self.lookup_service = fczm_utils.create_lookup_service()
|
self.lookup_service = fczm_utils.create_lookup_service()
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
@coordination.synchronized('{self.k2_lock_name}')
|
@coordination.synchronized('{self.k2_lock_name}')
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
"""Attach K2 volume to host."""
|
"""Attach K2 volume to host."""
|
||||||
|
@ -98,7 +98,7 @@ class KaminarioFCDriver(common.KaminarioCinderDriver):
|
||||||
init_pwwn.append((port.pwwn).replace(':', ''))
|
init_pwwn.append((port.pwwn).replace(':', ''))
|
||||||
return init_host_name, init_pwwn
|
return init_host_name, init_pwwn
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
@coordination.synchronized('{self.k2_lock_name}')
|
@coordination.synchronized('{self.k2_lock_name}')
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
if connector is None:
|
if connector is None:
|
||||||
|
@ -147,7 +147,7 @@ class KaminarioFCDriver(common.KaminarioCinderDriver):
|
||||||
raise common.KaminarioCinderDriverException(reason=msg)
|
raise common.KaminarioCinderDriverException(reason=msg)
|
||||||
return target_wwpns
|
return target_wwpns
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _get_host_object(self, connector):
|
def _get_host_object(self, connector):
|
||||||
host_name = self.get_initiator_host_name(connector)
|
host_name = self.get_initiator_host_name(connector)
|
||||||
LOG.debug("Searching initiator hostname: %s in K2.", host_name)
|
LOG.debug("Searching initiator hostname: %s in K2.", host_name)
|
||||||
|
|
|
@ -19,13 +19,12 @@ from cinder import coordination
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder.objects import fields
|
from cinder.objects import fields
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume.drivers.kaminario import kaminario_common as common
|
from cinder.volume.drivers.kaminario import kaminario_common as common
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
ISCSI_TCP_PORT = "3260"
|
ISCSI_TCP_PORT = "3260"
|
||||||
K2_REP_FAILED_OVER = fields.ReplicationStatus.FAILED_OVER
|
K2_REP_FAILED_OVER = fields.ReplicationStatus.FAILED_OVER
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
utils.trace = common.utils.trace
|
|
||||||
|
|
||||||
|
|
||||||
@interface.volumedriver
|
@interface.volumedriver
|
||||||
|
@ -48,12 +47,12 @@ class KaminarioISCSIDriver(common.KaminarioCinderDriver):
|
||||||
# ThirdPartySystems wiki page name
|
# ThirdPartySystems wiki page name
|
||||||
CI_WIKI_NAME = "Kaminario_K2_CI"
|
CI_WIKI_NAME = "Kaminario_K2_CI"
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(KaminarioISCSIDriver, self).__init__(*args, **kwargs)
|
super(KaminarioISCSIDriver, self).__init__(*args, **kwargs)
|
||||||
self._protocol = 'iSCSI'
|
self._protocol = 'iSCSI'
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
@coordination.synchronized('{self.k2_lock_name}')
|
@coordination.synchronized('{self.k2_lock_name}')
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
"""Attach K2 volume to host."""
|
"""Attach K2 volume to host."""
|
||||||
|
@ -83,7 +82,7 @@ class KaminarioISCSIDriver(common.KaminarioCinderDriver):
|
||||||
target_luns=[lun] * len(target_iqns))
|
target_luns=[lun] * len(target_iqns))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
@coordination.synchronized('{self.k2_lock_name}')
|
@coordination.synchronized('{self.k2_lock_name}')
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
# To support replication failback
|
# To support replication failback
|
||||||
|
@ -122,7 +121,7 @@ class KaminarioISCSIDriver(common.KaminarioCinderDriver):
|
||||||
raise common.KaminarioCinderDriverException(reason=msg)
|
raise common.KaminarioCinderDriverException(reason=msg)
|
||||||
return iscsi_portals, target_iqns
|
return iscsi_portals, target_iqns
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _get_host_object(self, connector):
|
def _get_host_object(self, connector):
|
||||||
host_name = self.get_initiator_host_name(connector)
|
host_name = self.get_initiator_host_name(connector)
|
||||||
LOG.debug("Searching initiator hostname: %s in K2.", host_name)
|
LOG.debug("Searching initiator hostname: %s in K2.", host_name)
|
||||||
|
|
|
@ -411,7 +411,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
"""Create a volume."""
|
"""Create a volume."""
|
||||||
name = volume['name']
|
name = volume['name']
|
||||||
|
@ -466,7 +466,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
"""Delete a volume."""
|
"""Delete a volume."""
|
||||||
name = self._volume_name(volume)
|
name = self._volume_name(volume)
|
||||||
|
@ -525,7 +525,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_snapshot(self, snapshot):
|
def create_snapshot(self, snapshot):
|
||||||
"""Create a snapshot."""
|
"""Create a snapshot."""
|
||||||
volume = snapshot['volume']
|
volume = snapshot['volume']
|
||||||
|
@ -554,7 +554,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_snapshot(self, snapshot):
|
def delete_snapshot(self, snapshot):
|
||||||
"""Delete a snapshot."""
|
"""Delete a snapshot."""
|
||||||
volume = snapshot['volume']
|
volume = snapshot['volume']
|
||||||
|
@ -606,7 +606,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume_from_snapshot(self, volume, snapshot):
|
def create_volume_from_snapshot(self, volume, snapshot):
|
||||||
"""Create a volume from a snapshot."""
|
"""Create a volume from a snapshot."""
|
||||||
snapshot_volume = snapshot['volume']
|
snapshot_volume = snapshot['volume']
|
||||||
|
@ -647,7 +647,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
self._delete_snapshot(snp_name, src_vol_name, pointid)
|
self._delete_snapshot(snp_name, src_vol_name, pointid)
|
||||||
|
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_cloned_volume(self, volume, src_vref):
|
def create_cloned_volume(self, volume, src_vref):
|
||||||
"""Create a clone of the specified volume."""
|
"""Create a clone of the specified volume."""
|
||||||
vol_name = volume['id']
|
vol_name = volume['id']
|
||||||
|
@ -687,7 +687,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def extend_volume(self, volume, new_size):
|
def extend_volume(self, volume, new_size):
|
||||||
"""Extend a volume."""
|
"""Extend a volume."""
|
||||||
name = self._volume_name(volume)
|
name = self._volume_name(volume)
|
||||||
|
@ -747,7 +747,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
self._stats = data
|
self._stats = data
|
||||||
|
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def update_migrated_volume(self, ctxt, volume, new_volume,
|
def update_migrated_volume(self, ctxt, volume, new_volume,
|
||||||
original_volume_status=None):
|
original_volume_status=None):
|
||||||
"""Return model update for migrated volume."""
|
"""Return model update for migrated volume."""
|
||||||
|
@ -772,7 +772,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection_snapshot(self, snapshot, connector, **kwargs):
|
def initialize_connection_snapshot(self, snapshot, connector, **kwargs):
|
||||||
volume = snapshot['volume']
|
volume = snapshot['volume']
|
||||||
provider = snapshot['provider_location']
|
provider = snapshot['provider_location']
|
||||||
|
@ -811,7 +811,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing(self, volume, external_ref):
|
def manage_existing(self, volume, external_ref):
|
||||||
vol_params = self._parse_volume_params(volume)
|
vol_params = self._parse_volume_params(volume)
|
||||||
self._check_volume_params(vol_params)
|
self._check_volume_params(vol_params)
|
||||||
|
@ -901,7 +901,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def manage_existing_snapshot(self, snapshot, existing_ref):
|
def manage_existing_snapshot(self, snapshot, existing_ref):
|
||||||
volume = snapshot['volume']
|
volume = snapshot['volume']
|
||||||
src_name = self._get_existing_snapname(existing_ref).lstrip('_')
|
src_name = self._get_existing_snapname(existing_ref).lstrip('_')
|
||||||
|
@ -948,7 +948,7 @@ class MacroSANBaseDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def migrate_volume(self, ctxt, volume, host):
|
def migrate_volume(self, ctxt, volume, host):
|
||||||
if not self.migration_valid(volume, host):
|
if not self.migration_valid(volume, host):
|
||||||
return False, None
|
return False, None
|
||||||
|
@ -1148,7 +1148,7 @@ class MacroSANISCSIDriver(MacroSANBaseDriver, driver.ISCSIDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
"""Allow connection to connector and return connection info."""
|
"""Allow connection to connector and return connection info."""
|
||||||
|
|
||||||
|
@ -1184,7 +1184,7 @@ class MacroSANISCSIDriver(MacroSANBaseDriver, driver.ISCSIDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Disallow connection from connector."""
|
"""Disallow connection from connector."""
|
||||||
|
|
||||||
|
@ -1433,7 +1433,7 @@ class MacroSANFCDriver(MacroSANBaseDriver, driver.FibreChannelDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
"""Allow connection to connector and return connection info."""
|
"""Allow connection to connector and return connection info."""
|
||||||
|
|
||||||
|
@ -1496,7 +1496,7 @@ class MacroSANFCDriver(MacroSANBaseDriver, driver.FibreChannelDriver):
|
||||||
|
|
||||||
@synchronized(lock_name)
|
@synchronized(lock_name)
|
||||||
@record_request_id
|
@record_request_id
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
"""Disallow connection from connector."""
|
"""Disallow connection from connector."""
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ from oslo_utils import units
|
||||||
from cinder import coordination
|
from cinder import coordination
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume.drivers.nec import cli
|
from cinder.volume.drivers.nec import cli
|
||||||
from cinder.volume.drivers.nec import volume_common
|
from cinder.volume.drivers.nec import volume_common
|
||||||
from cinder.volume import volume_utils
|
from cinder.volume import volume_utils
|
||||||
|
@ -1322,7 +1321,7 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
|
||||||
'(%(msgparm)s) (%(exception)s)',
|
'(%(msgparm)s) (%(exception)s)',
|
||||||
{'msgparm': msgparm, 'exception': e})
|
{'msgparm': msgparm, 'exception': e})
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _fc_terminate_connection(self, vol_or_snap, connector,
|
def _fc_terminate_connection(self, vol_or_snap, connector,
|
||||||
is_snapshot=False):
|
is_snapshot=False):
|
||||||
"""Disallow connection from connector."""
|
"""Disallow connection from connector."""
|
||||||
|
|
|
@ -38,7 +38,6 @@ import six
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume.drivers.netapp.dataontap.client import api as netapp_api
|
from cinder.volume.drivers.netapp.dataontap.client import api as netapp_api
|
||||||
from cinder.volume.drivers.netapp.dataontap.utils import loopingcalls
|
from cinder.volume.drivers.netapp.dataontap.utils import loopingcalls
|
||||||
from cinder.volume.drivers.netapp import options as na_opts
|
from cinder.volume.drivers.netapp import options as na_opts
|
||||||
|
@ -71,7 +70,7 @@ class NetAppLun(object):
|
||||||
self.handle, self.name, self.size, self.metadata)
|
self.handle, self.name, self.size, self.metadata)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(utils.TraceWrapperMetaclass)
|
@six.add_metaclass(volume_utils.TraceWrapperMetaclass)
|
||||||
class NetAppBlockStorageLibrary(object):
|
class NetAppBlockStorageLibrary(object):
|
||||||
"""NetApp block storage library for Data ONTAP."""
|
"""NetApp block storage library for Data ONTAP."""
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ import six
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder.objects import fields
|
from cinder.objects import fields
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume.drivers.netapp.dataontap import block_base
|
from cinder.volume.drivers.netapp.dataontap import block_base
|
||||||
from cinder.volume.drivers.netapp.dataontap.performance import perf_cmode
|
from cinder.volume.drivers.netapp.dataontap.performance import perf_cmode
|
||||||
from cinder.volume.drivers.netapp.dataontap.utils import capabilities
|
from cinder.volume.drivers.netapp.dataontap.utils import capabilities
|
||||||
|
@ -46,7 +45,7 @@ from cinder.volume import volume_utils
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(utils.TraceWrapperMetaclass)
|
@six.add_metaclass(volume_utils.TraceWrapperMetaclass)
|
||||||
class NetAppBlockStorageCmodeLibrary(block_base.NetAppBlockStorageLibrary,
|
class NetAppBlockStorageCmodeLibrary(block_base.NetAppBlockStorageLibrary,
|
||||||
data_motion.DataMotionMixin):
|
data_motion.DataMotionMixin):
|
||||||
"""NetApp block storage library for Data ONTAP (Cluster-mode)."""
|
"""NetApp block storage library for Data ONTAP (Cluster-mode)."""
|
||||||
|
|
|
@ -32,8 +32,8 @@ from six.moves import urllib
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import ssh_utils
|
from cinder import ssh_utils
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume.drivers.netapp import utils as na_utils
|
from cinder.volume.drivers.netapp import utils as na_utils
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ class NaServer(object):
|
||||||
"""Set the vserver to use if tunneling gets enabled."""
|
"""Set the vserver to use if tunneling gets enabled."""
|
||||||
self._vserver = vserver
|
self._vserver = vserver
|
||||||
|
|
||||||
@utils.trace_api(filter_function=na_utils.trace_filter_func_api)
|
@volume_utils.trace_api(filter_function=na_utils.trace_filter_func_api)
|
||||||
def send_http_request(self, na_element, enable_tunneling=False):
|
def send_http_request(self, na_element, enable_tunneling=False):
|
||||||
"""Invoke the API on the server."""
|
"""Invoke the API on the server."""
|
||||||
if not na_element or not isinstance(na_element, NaElement):
|
if not na_element or not isinstance(na_element, NaElement):
|
||||||
|
|
|
@ -26,6 +26,7 @@ from cinder.i18n import _
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder.volume.drivers.netapp.dataontap.client import api as netapp_api
|
from cinder.volume.drivers.netapp.dataontap.client import api as netapp_api
|
||||||
from cinder.volume.drivers.netapp import utils as na_utils
|
from cinder.volume.drivers.netapp import utils as na_utils
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ DELETED_PREFIX = 'deleted_cinder_'
|
||||||
MAX_SIZE_FOR_A_LUN = '17555678822400'
|
MAX_SIZE_FOR_A_LUN = '17555678822400'
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(utils.TraceWrapperMetaclass)
|
@six.add_metaclass(volume_utils.TraceWrapperMetaclass)
|
||||||
class Client(object):
|
class Client(object):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
|
@ -27,7 +27,6 @@ import six
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume.drivers.netapp.dataontap.client import api as netapp_api
|
from cinder.volume.drivers.netapp.dataontap.client import api as netapp_api
|
||||||
from cinder.volume.drivers.netapp.dataontap.client import client_base
|
from cinder.volume.drivers.netapp.dataontap.client import client_base
|
||||||
from cinder.volume.drivers.netapp import utils as na_utils
|
from cinder.volume.drivers.netapp import utils as na_utils
|
||||||
|
@ -37,7 +36,7 @@ LOG = logging.getLogger(__name__)
|
||||||
DEFAULT_MAX_PAGE_LENGTH = 50
|
DEFAULT_MAX_PAGE_LENGTH = 50
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(utils.TraceWrapperMetaclass)
|
@six.add_metaclass(volume_utils.TraceWrapperMetaclass)
|
||||||
class Client(client_base.Client):
|
class Client(client_base.Client):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
@ -1334,7 +1333,7 @@ class Client(client_base.Client):
|
||||||
}
|
}
|
||||||
self.connection.send_request('sis-set-config', api_args)
|
self.connection.send_request('sis-set-config', api_args)
|
||||||
|
|
||||||
@utils.trace_method
|
@volume_utils.trace_method
|
||||||
def delete_file(self, path_to_file):
|
def delete_file(self, path_to_file):
|
||||||
"""Delete file at path."""
|
"""Delete file at path."""
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ CONF = cfg.CONF
|
||||||
HOUSEKEEPING_INTERVAL_SECONDS = 600 # ten minutes
|
HOUSEKEEPING_INTERVAL_SECONDS = 600 # ten minutes
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(utils.TraceWrapperWithABCMetaclass)
|
@six.add_metaclass(volume_utils.TraceWrapperWithABCMetaclass)
|
||||||
class NetAppNfsDriver(driver.ManageableVD,
|
class NetAppNfsDriver(driver.ManageableVD,
|
||||||
driver.CloneableImageVD,
|
driver.CloneableImageVD,
|
||||||
nfs.NfsDriver):
|
nfs.NfsDriver):
|
||||||
|
|
|
@ -33,7 +33,6 @@ from cinder.i18n import _
|
||||||
from cinder.image import image_utils
|
from cinder.image import image_utils
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder.objects import fields
|
from cinder.objects import fields
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume.drivers.netapp.dataontap import nfs_base
|
from cinder.volume.drivers.netapp.dataontap import nfs_base
|
||||||
from cinder.volume.drivers.netapp.dataontap.performance import perf_cmode
|
from cinder.volume.drivers.netapp.dataontap.performance import perf_cmode
|
||||||
from cinder.volume.drivers.netapp.dataontap.utils import capabilities
|
from cinder.volume.drivers.netapp.dataontap.utils import capabilities
|
||||||
|
@ -49,7 +48,7 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@interface.volumedriver
|
@interface.volumedriver
|
||||||
@six.add_metaclass(utils.TraceWrapperWithABCMetaclass)
|
@six.add_metaclass(volume_utils.TraceWrapperWithABCMetaclass)
|
||||||
class NetAppCmodeNfsDriver(nfs_base.NetAppNfsDriver,
|
class NetAppCmodeNfsDriver(nfs_base.NetAppNfsDriver,
|
||||||
data_motion.DataMotionMixin):
|
data_motion.DataMotionMixin):
|
||||||
"""NetApp NFS driver for Data ONTAP (Cluster-mode)."""
|
"""NetApp NFS driver for Data ONTAP (Cluster-mode)."""
|
||||||
|
|
|
@ -23,11 +23,11 @@ from oslo_config import cfg
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume import configuration
|
from cinder.volume import configuration
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers.netapp.dataontap.client import client_cmode
|
from cinder.volume.drivers.netapp.dataontap.client import client_cmode
|
||||||
from cinder.volume.drivers.netapp import options as na_opts
|
from cinder.volume.drivers.netapp import options as na_opts
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ def get_client_for_backend(backend_name, vserver_name=None):
|
||||||
hostname=config.netapp_server_hostname,
|
hostname=config.netapp_server_hostname,
|
||||||
port=config.netapp_server_port,
|
port=config.netapp_server_port,
|
||||||
vserver=vserver_name or config.netapp_vserver,
|
vserver=vserver_name or config.netapp_vserver,
|
||||||
trace=utils.TRACE_API,
|
trace=volume_utils.TRACE_API,
|
||||||
api_trace_pattern=config.netapp_api_trace_pattern)
|
api_trace_pattern=config.netapp_api_trace_pattern)
|
||||||
|
|
||||||
return client
|
return client
|
||||||
|
|
|
@ -181,7 +181,7 @@ class RemoteFSDriver(driver.BaseVD):
|
||||||
"""Just to override parent behavior."""
|
"""Just to override parent behavior."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection(self, volume, connector):
|
def initialize_connection(self, volume, connector):
|
||||||
"""Allow connection to connector and return connection info.
|
"""Allow connection to connector and return connection info.
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ class RemoteFSDriver(driver.BaseVD):
|
||||||
acceptable_states=acceptable_states,
|
acceptable_states=acceptable_states,
|
||||||
current_state=current_state))
|
current_state=current_state))
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
"""Creates a volume.
|
"""Creates a volume.
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ class RemoteFSDriver(driver.BaseVD):
|
||||||
|
|
||||||
LOG.debug('Available shares %s', self._mounted_shares)
|
LOG.debug('Available shares %s', self._mounted_shares)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
"""Deletes a logical volume.
|
"""Deletes a logical volume.
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ from cinder.i18n import _
|
||||||
from cinder import interface
|
from cinder import interface
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -539,7 +540,7 @@ class RSDDriver(driver.VolumeDriver):
|
||||||
def get_driver_options():
|
def get_driver_options():
|
||||||
return RSD_OPTS
|
return RSD_OPTS
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def do_setup(self, context):
|
def do_setup(self, context):
|
||||||
self.rsdClient = RSDClient.initialize(
|
self.rsdClient = RSDClient.initialize(
|
||||||
self.configuration.podm_url,
|
self.configuration.podm_url,
|
||||||
|
@ -550,13 +551,13 @@ class RSDDriver(driver.VolumeDriver):
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
size_in_gb = int(volume['size'])
|
size_in_gb = int(volume['size'])
|
||||||
volume_url = self.rsdClient.create_volume(size_in_gb)
|
volume_url = self.rsdClient.create_volume(size_in_gb)
|
||||||
return {'provider_location': volume_url}
|
return {'provider_location': volume_url}
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
volume_url = volume['provider_location']
|
volume_url = volume['provider_location']
|
||||||
if not volume_url:
|
if not volume_url:
|
||||||
|
@ -570,7 +571,7 @@ class RSDDriver(driver.VolumeDriver):
|
||||||
volume_name=volume.name,
|
volume_name=volume.name,
|
||||||
ignore_non_exist=True)
|
ignore_non_exist=True)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def _update_volume_stats(self):
|
def _update_volume_stats(self):
|
||||||
backend_name = (
|
backend_name = (
|
||||||
self.configuration.safe_get('volume_backend_name') or 'RSD')
|
self.configuration.safe_get('volume_backend_name') or 'RSD')
|
||||||
|
@ -597,7 +598,7 @@ class RSDDriver(driver.VolumeDriver):
|
||||||
# SinglePool
|
# SinglePool
|
||||||
self._stats['pools'] = [spool]
|
self._stats['pools'] = [spool]
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def initialize_connection(self, volume, connector, **kwargs):
|
def initialize_connection(self, volume, connector, **kwargs):
|
||||||
uuid = connector.get("system uuid")
|
uuid = connector.get("system uuid")
|
||||||
if not uuid:
|
if not uuid:
|
||||||
|
@ -626,7 +627,7 @@ class RSDDriver(driver.VolumeDriver):
|
||||||
}
|
}
|
||||||
return conn_info
|
return conn_info
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def terminate_connection(self, volume, connector, **kwargs):
|
def terminate_connection(self, volume, connector, **kwargs):
|
||||||
if connector is None:
|
if connector is None:
|
||||||
# None connector means force-detach
|
# None connector means force-detach
|
||||||
|
@ -658,7 +659,7 @@ class RSDDriver(driver.VolumeDriver):
|
||||||
def remove_export(self, context, volume):
|
def remove_export(self, context, volume):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_volume_from_snapshot(self, volume, snapshot):
|
def create_volume_from_snapshot(self, volume, snapshot):
|
||||||
snap_url = snapshot.provider_location
|
snap_url = snapshot.provider_location
|
||||||
old_size_in_gb = snapshot.volume_size
|
old_size_in_gb = snapshot.volume_size
|
||||||
|
@ -673,14 +674,14 @@ class RSDDriver(driver.VolumeDriver):
|
||||||
raise
|
raise
|
||||||
return {'provider_location': volume_url}
|
return {'provider_location': volume_url}
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_snapshot(self, snapshot):
|
def create_snapshot(self, snapshot):
|
||||||
volume_url = snapshot.volume.provider_location
|
volume_url = snapshot.volume.provider_location
|
||||||
snap_url = self.rsdClient.create_snap(volume_url)
|
snap_url = self.rsdClient.create_snap(volume_url)
|
||||||
snapshot.provider_location = snap_url
|
snapshot.provider_location = snap_url
|
||||||
snapshot.save()
|
snapshot.save()
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def delete_snapshot(self, snapshot):
|
def delete_snapshot(self, snapshot):
|
||||||
snap_url = snapshot.provider_location
|
snap_url = snapshot.provider_location
|
||||||
if not snap_url:
|
if not snap_url:
|
||||||
|
@ -689,7 +690,7 @@ class RSDDriver(driver.VolumeDriver):
|
||||||
volume_name=snapshot.name,
|
volume_name=snapshot.name,
|
||||||
ignore_non_exist=True)
|
ignore_non_exist=True)
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def extend_volume(self, volume, new_size):
|
def extend_volume(self, volume, new_size):
|
||||||
volume_url = volume.provider_location
|
volume_url = volume.provider_location
|
||||||
self.rsdClient.extend_volume(volume_url, new_size)
|
self.rsdClient.extend_volume(volume_url, new_size)
|
||||||
|
@ -699,7 +700,7 @@ class RSDDriver(driver.VolumeDriver):
|
||||||
image_service):
|
image_service):
|
||||||
return None, False
|
return None, False
|
||||||
|
|
||||||
@utils.trace
|
@volume_utils.trace
|
||||||
def create_cloned_volume(self, volume, src_vref):
|
def create_cloned_volume(self, volume, src_vref):
|
||||||
volume_url = src_vref.provider_location
|
volume_url = src_vref.provider_location
|
||||||
old_size_in_gb = src_vref.size
|
old_size_in_gb = src_vref.size
|
||||||
|
|
|
@ -29,13 +29,13 @@ import six
|
||||||
|
|
||||||
from cinder import coordination
|
from cinder import coordination
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import utils
|
|
||||||
import cinder.volume.drivers.stx.exception as stx_exception
|
import cinder.volume.drivers.stx.exception as stx_exception
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(utils.TraceWrapperMetaclass)
|
@six.add_metaclass(volume_utils.TraceWrapperMetaclass)
|
||||||
class STXClient(object):
|
class STXClient(object):
|
||||||
def __init__(self, host, login, password, protocol, ssl_verify):
|
def __init__(self, host, login, password, protocol, ssl_verify):
|
||||||
self._mgmt_ip_addrs = list(map(str.strip, host.split(',')))
|
self._mgmt_ip_addrs = list(map(str.strip, host.split(',')))
|
||||||
|
|
|
@ -26,10 +26,10 @@ import six
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder.objects import fields
|
from cinder.objects import fields
|
||||||
from cinder import utils
|
|
||||||
from cinder.volume import configuration
|
from cinder.volume import configuration
|
||||||
import cinder.volume.drivers.stx.client as client
|
import cinder.volume.drivers.stx.client as client
|
||||||
import cinder.volume.drivers.stx.exception as stx_exception
|
import cinder.volume.drivers.stx.exception as stx_exception
|
||||||
|
from cinder.volume import volume_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ CONF.register_opts(common_opts, group=configuration.SHARED_CONF_GROUP)
|
||||||
CONF.register_opts(iscsi_opts, group=configuration.SHARED_CONF_GROUP)
|
CONF.register_opts(iscsi_opts, group=configuration.SHARED_CONF_GROUP)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(utils.TraceWrapperMetaclass)
|
@six.add_metaclass(volume_utils.TraceWrapperMetaclass)
|
||||||
class STXCommon(object):
|
class STXCommon(object):
|
||||||
VERSION = "2.0"
|
VERSION = "2.0"
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,7 @@ class Acs5000CommonDriver(san.SanDriver,
|
||||||
'code_level': None,
|
'code_level': None,
|
||||||
'version': None}
|
'version': None}
|
||||||
|
|
||||||
@cinder_utils.trace_method
|
@volume_utils.trace_method
|
||||||
def do_setup(self, ctxt):
|
def do_setup(self, ctxt):
|
||||||
"""Check that we have all configuration details from the storage."""
|
"""Check that we have all configuration details from the storage."""
|
||||||
self._validate_pools_exist()
|
self._validate_pools_exist()
|
||||||
|
@ -383,7 +383,7 @@ class Acs5000CommonDriver(san.SanDriver,
|
||||||
raise exception.InvalidInput(reason=msg)
|
raise exception.InvalidInput(reason=msg)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@cinder_utils.trace_method
|
@volume_utils.trace_method
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
"""Ensure that the params are set properly."""
|
"""Ensure that the params are set properly."""
|
||||||
if self._state['system_name'] is None:
|
if self._state['system_name'] is None:
|
||||||
|
|
|
@ -14,9 +14,12 @@
|
||||||
|
|
||||||
"""Volume-related Utilities and helpers."""
|
"""Volume-related Utilities and helpers."""
|
||||||
|
|
||||||
|
import abc
|
||||||
import ast
|
import ast
|
||||||
import functools
|
import functools
|
||||||
|
import inspect
|
||||||
import json
|
import json
|
||||||
|
import logging as py_logging
|
||||||
import math
|
import math
|
||||||
import operator
|
import operator
|
||||||
import os
|
import os
|
||||||
|
@ -26,6 +29,7 @@ import re
|
||||||
import socket
|
import socket
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
import types
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from castellan.common.credentials import keystone_password
|
from castellan.common.credentials import keystone_password
|
||||||
|
@ -76,6 +80,9 @@ IMAGE_ATTRIBUTES = (
|
||||||
'min_ram',
|
'min_ram',
|
||||||
'size',
|
'size',
|
||||||
)
|
)
|
||||||
|
VALID_TRACE_FLAGS = {'method', 'api'}
|
||||||
|
TRACE_API = False
|
||||||
|
TRACE_METHOD = False
|
||||||
|
|
||||||
|
|
||||||
def null_safe_str(s):
|
def null_safe_str(s):
|
||||||
|
@ -1363,3 +1370,163 @@ def brick_detach_volume_encryptor(attach_info, encryption):
|
||||||
encryptor = brick_get_encryptor(connection_info,
|
encryptor = brick_get_encryptor(connection_info,
|
||||||
**encryption)
|
**encryption)
|
||||||
encryptor.detach_volume(**encryption)
|
encryptor.detach_volume(**encryption)
|
||||||
|
|
||||||
|
|
||||||
|
# NOTE: the trace methods are included in volume_utils because
|
||||||
|
# they are currently only called by code in the volume area
|
||||||
|
# of Cinder. These can be moved to a different file if they
|
||||||
|
# are needed elsewhere.
|
||||||
|
def trace(*dec_args, **dec_kwargs):
|
||||||
|
"""Trace calls to the decorated function.
|
||||||
|
|
||||||
|
This decorator should always be defined as the outermost decorator so it
|
||||||
|
is defined last. This is important so it does not interfere
|
||||||
|
with other decorators.
|
||||||
|
|
||||||
|
Using this decorator on a function will cause its execution to be logged at
|
||||||
|
`DEBUG` level with arguments, return values, and exceptions.
|
||||||
|
|
||||||
|
:returns: a function decorator
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _decorator(f):
|
||||||
|
|
||||||
|
func_name = f.__name__
|
||||||
|
|
||||||
|
@functools.wraps(f)
|
||||||
|
def trace_logging_wrapper(*args, **kwargs):
|
||||||
|
filter_function = dec_kwargs.get('filter_function')
|
||||||
|
|
||||||
|
if len(args) > 0:
|
||||||
|
maybe_self = args[0]
|
||||||
|
else:
|
||||||
|
maybe_self = kwargs.get('self', None)
|
||||||
|
|
||||||
|
if maybe_self and hasattr(maybe_self, '__module__'):
|
||||||
|
logger = logging.getLogger(maybe_self.__module__)
|
||||||
|
else:
|
||||||
|
logger = LOG
|
||||||
|
|
||||||
|
# NOTE(ameade): Don't bother going any further if DEBUG log level
|
||||||
|
# is not enabled for the logger.
|
||||||
|
if not logger.isEnabledFor(py_logging.DEBUG):
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
|
||||||
|
all_args = inspect.getcallargs(f, *args, **kwargs)
|
||||||
|
|
||||||
|
pass_filter = filter_function is None or filter_function(all_args)
|
||||||
|
|
||||||
|
if pass_filter:
|
||||||
|
logger.debug('==> %(func)s: call %(all_args)r',
|
||||||
|
{'func': func_name,
|
||||||
|
'all_args': strutils.mask_password(
|
||||||
|
str(all_args))})
|
||||||
|
|
||||||
|
start_time = time.time() * 1000
|
||||||
|
try:
|
||||||
|
result = f(*args, **kwargs)
|
||||||
|
except Exception as exc:
|
||||||
|
total_time = int(round(time.time() * 1000)) - start_time
|
||||||
|
logger.debug('<== %(func)s: exception (%(time)dms) %(exc)r',
|
||||||
|
{'func': func_name,
|
||||||
|
'time': total_time,
|
||||||
|
'exc': exc})
|
||||||
|
raise
|
||||||
|
total_time = int(round(time.time() * 1000)) - start_time
|
||||||
|
|
||||||
|
if isinstance(result, dict):
|
||||||
|
mask_result = strutils.mask_dict_password(result)
|
||||||
|
elif isinstance(result, str):
|
||||||
|
mask_result = strutils.mask_password(result)
|
||||||
|
else:
|
||||||
|
mask_result = result
|
||||||
|
|
||||||
|
if pass_filter:
|
||||||
|
logger.debug('<== %(func)s: return (%(time)dms) %(result)r',
|
||||||
|
{'func': func_name,
|
||||||
|
'time': total_time,
|
||||||
|
'result': mask_result})
|
||||||
|
return result
|
||||||
|
return trace_logging_wrapper
|
||||||
|
|
||||||
|
if len(dec_args) == 0:
|
||||||
|
# filter_function is passed and args does not contain f
|
||||||
|
return _decorator
|
||||||
|
else:
|
||||||
|
# filter_function is not passed
|
||||||
|
return _decorator(dec_args[0])
|
||||||
|
|
||||||
|
|
||||||
|
def trace_api(*dec_args, **dec_kwargs):
|
||||||
|
"""Decorates a function if TRACE_API is true."""
|
||||||
|
|
||||||
|
def _decorator(f):
|
||||||
|
@functools.wraps(f)
|
||||||
|
def trace_api_logging_wrapper(*args, **kwargs):
|
||||||
|
if TRACE_API:
|
||||||
|
return trace(f, *dec_args, **dec_kwargs)(*args, **kwargs)
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
return trace_api_logging_wrapper
|
||||||
|
|
||||||
|
if len(dec_args) == 0:
|
||||||
|
# filter_function is passed and args does not contain f
|
||||||
|
return _decorator
|
||||||
|
else:
|
||||||
|
# filter_function is not passed
|
||||||
|
return _decorator(dec_args[0])
|
||||||
|
|
||||||
|
|
||||||
|
def trace_method(f):
|
||||||
|
"""Decorates a function if TRACE_METHOD is true."""
|
||||||
|
@functools.wraps(f)
|
||||||
|
def trace_method_logging_wrapper(*args, **kwargs):
|
||||||
|
if TRACE_METHOD:
|
||||||
|
return trace(f)(*args, **kwargs)
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
return trace_method_logging_wrapper
|
||||||
|
|
||||||
|
|
||||||
|
class TraceWrapperMetaclass(type):
|
||||||
|
"""Metaclass that wraps all methods of a class with trace_method.
|
||||||
|
|
||||||
|
This metaclass will cause every function inside of the class to be
|
||||||
|
decorated with the trace_method decorator.
|
||||||
|
|
||||||
|
To use the metaclass you define a class like so:
|
||||||
|
class MyClass(object, metaclass=utils.TraceWrapperMetaclass):
|
||||||
|
"""
|
||||||
|
def __new__(meta, classname, bases, classDict):
|
||||||
|
newClassDict = {}
|
||||||
|
for attributeName, attribute in classDict.items():
|
||||||
|
if isinstance(attribute, types.FunctionType):
|
||||||
|
# replace it with a wrapped version
|
||||||
|
attribute = functools.update_wrapper(trace_method(attribute),
|
||||||
|
attribute)
|
||||||
|
newClassDict[attributeName] = attribute
|
||||||
|
|
||||||
|
return type.__new__(meta, classname, bases, newClassDict)
|
||||||
|
|
||||||
|
|
||||||
|
class TraceWrapperWithABCMetaclass(abc.ABCMeta, TraceWrapperMetaclass):
|
||||||
|
"""Metaclass that wraps all methods of a class with trace."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def setup_tracing(trace_flags):
|
||||||
|
"""Set global variables for each trace flag.
|
||||||
|
|
||||||
|
Sets variables TRACE_METHOD and TRACE_API, which represent
|
||||||
|
whether to log methods or api traces.
|
||||||
|
|
||||||
|
:param trace_flags: a list of strings
|
||||||
|
"""
|
||||||
|
global TRACE_METHOD
|
||||||
|
global TRACE_API
|
||||||
|
try:
|
||||||
|
trace_flags = [flag.strip() for flag in trace_flags]
|
||||||
|
except TypeError: # Handle when trace_flags is None or a test mock
|
||||||
|
trace_flags = []
|
||||||
|
for invalid_flag in (set(trace_flags) - VALID_TRACE_FLAGS):
|
||||||
|
LOG.warning('Invalid trace flag: %s', invalid_flag)
|
||||||
|
TRACE_METHOD = 'method' in trace_flags
|
||||||
|
TRACE_API = 'api' in trace_flags
|
||||||
|
|
Loading…
Reference in New Issue