From 36bd8f5c9773caf3c87e4683948bd32ed99ac3cf Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Tue, 13 Jul 2021 10:45:37 -0400 Subject: [PATCH] Remove various unused code Remove code that does not appear to be called/used. Change-Id: Iea1f29ce269107cd6422c40ca2e42ddb7354486b --- cinder/scheduler/filter_scheduler.py | 1 - .../api/contrib/test_volume_image_metadata.py | 6 --- cinder/volume/api.py | 23 --------- cinder/volume/driver.py | 34 ------------- cinder/volume/volume_utils.py | 50 ------------------- 5 files changed, 114 deletions(-) diff --git a/cinder/scheduler/filter_scheduler.py b/cinder/scheduler/filter_scheduler.py index 760c0794bec..70d99cfa83c 100644 --- a/cinder/scheduler/filter_scheduler.py +++ b/cinder/scheduler/filter_scheduler.py @@ -44,7 +44,6 @@ class FilterScheduler(driver.Scheduler): """Scheduler that can be used for filtering and weighing.""" def __init__(self, *args, **kwargs): super(FilterScheduler, self).__init__(*args, **kwargs) - self.cost_function_cache = None self.options = scheduler_options.SchedulerOptions() self.max_attempts = self._max_attempts() diff --git a/cinder/tests/unit/api/contrib/test_volume_image_metadata.py b/cinder/tests/unit/api/contrib/test_volume_image_metadata.py index 466e9f3f0f7..16b77d75efd 100644 --- a/cinder/tests/unit/api/contrib/test_volume_image_metadata.py +++ b/cinder/tests/unit/api/contrib/test_volume_image_metadata.py @@ -84,10 +84,6 @@ def fake_get_volume_image_metadata(*args, **kwargs): return fake_image_metadata -def fake_get_volumes_image_metadata(*args, **kwargs): - return {'fake': fake_image_metadata} - - def return_empty_image_metadata(*args, **kwargs): return {} @@ -114,8 +110,6 @@ class VolumeImageMetadataTest(test.TestCase): self.mock_object(volume.api.API, 'get_all', fake_volume_get_all) self.mock_object(volume.api.API, 'get_volume_image_metadata', fake_get_volume_image_metadata) - self.mock_object(volume.api.API, 'get_volumes_image_metadata', - fake_get_volumes_image_metadata) self.UUID = uuid.uuid4() self.controller = (volume_image_metadata. VolumeImageMetadataController()) diff --git a/cinder/volume/api.py b/cinder/volume/api.py index 650f11ecc2c..f2e6429188d 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -1315,15 +1315,6 @@ class API(base.Base): resource=volume) return db_meta - def get_volume_admin_metadata(self, - context: context.RequestContext, - volume: objects.Volume) -> dict: - """Get all administration metadata associated with a volume.""" - rv = self.db.volume_admin_metadata_get(context, volume['id']) - LOG.info("Get volume admin metadata completed successfully.", - resource=volume) - return dict(rv) - def update_volume_admin_metadata(self, context: context.RequestContext, volume: objects.Volume, @@ -2545,17 +2536,3 @@ class HostAPI(base.Base): def set_host_enabled(self, context, host, enabled): """Sets the specified host's ability to accept new volumes.""" raise NotImplementedError() - - def get_host_uptime(self, context, host): - """Returns the result of calling "uptime" on the target host.""" - raise NotImplementedError() - - def host_power_action(self, context, host, action): - raise NotImplementedError() - - def set_host_maintenance(self, context, host, mode): - """Start/Stop host maintenance window. - - On start, it triggers volume evacuation. - """ - raise NotImplementedError() diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 683803019ff..77767b21a36 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -646,15 +646,6 @@ class BaseVD(object, metaclass=abc.ABCMeta): return self._stats - def get_prefixed_property(self, property): - """Return prefixed property name - - :returns: a prefixed property name string or None - """ - - if property and self.capabilities.get('vendor_prefix'): - return self.capabilities.get('vendor_prefix') + ':' + property - def _set_property(self, properties, entry, title, description, type, **kwargs): prop = dict(title=title, description=description, type=type) @@ -1187,11 +1178,6 @@ class BaseVD(object, metaclass=abc.ABCMeta): # this method. return True - def snapshot_remote_attachable(self): - # TODO(lixiaoy1): the method will be deleted later when remote - # attach snapshot is implemented. - return False - def get_backup_device(self, context, backup): """Get a backup device from an existing volume. @@ -1722,10 +1708,6 @@ class BaseVD(object, metaclass=abc.ABCMeta): method_name = cls.REPLICATION_FEATURE_CHECKERS[feature] return not cls._is_base_method(method_name) - def get_replication_updates(self, context): - """Old replication update method, deprecate.""" - raise NotImplementedError() - def create_group(self, context, group): """Creates a group. @@ -2763,22 +2745,6 @@ class ISCSIDriver(VolumeDriver): {'command': iscsi_command, 'out': out, 'err': err}) return (out, err) - def _run_iscsiadm_bare(self, iscsi_command, **kwargs): - check_exit_code = kwargs.pop('check_exit_code', 0) - (out, err) = self._execute('iscsiadm', - *iscsi_command, - run_as_root=True, - check_exit_code=check_exit_code) - LOG.debug("iscsiadm %(command)s: stdout=%(out)s stderr=%(err)s", - {'command': iscsi_command, 'out': out, 'err': err}) - return (out, err) - - def _iscsiadm_update(self, iscsi_properties, property_key, property_value, - **kwargs): - iscsi_command = ('--op', 'update', '-n', property_key, - '-v', property_value) - return self._run_iscsiadm(iscsi_properties, iscsi_command, **kwargs) - def initialize_connection(self, volume, connector): """Initializes the connection and returns connection info. diff --git a/cinder/volume/volume_utils.py b/cinder/volume/volume_utils.py index ae5a42d7ad3..e4997c4aa8c 100644 --- a/cinder/volume/volume_utils.py +++ b/cinder/volume/volume_utils.py @@ -278,46 +278,6 @@ def notify_about_capacity_usage(context: context.RequestContext, usage_info) -@utils.if_notifications_enabled -def notify_about_replication_usage(context: context.RequestContext, - volume: 'objects.Volume', - suffix: str, - extra_usage_info: dict = None, - host: str = None) -> None: - if not host: - host = CONF.host - - if not extra_usage_info: - extra_usage_info = {} - - usage_info = _usage_from_volume(context, volume, - **extra_usage_info) - - rpc.get_notifier('replication', host).info(context, - 'replication.%s' % suffix, - usage_info) - - -@utils.if_notifications_enabled -def notify_about_replication_error(context: context.RequestContext, - volume: 'objects.Volume', - suffix: str, - extra_error_info: dict = None, - host: str = None) -> None: - if not host: - host = CONF.host - - if not extra_error_info: - extra_error_info = {} - - usage_info = _usage_from_volume(context, volume, - **extra_error_info) - - rpc.get_notifier('replication', host).error(context, - 'replication.%s' % suffix, - usage_info) - - def _usage_from_consistencygroup(group_ref: 'objects.Group', **kw) -> dict: usage_info = dict(tenant_id=group_ref.project_id, user_id=group_ref.user_id, @@ -872,16 +832,6 @@ def hosts_are_equivalent(host_1: str, host_2: str) -> bool: return extract_host(host_1) == extract_host(host_2) -def read_proc_mounts() -> List[str]: - """Read the /proc/mounts file. - - It's a dummy function but it eases the writing of unit tests as mocking - __builtin__open() for a specific file only is not trivial. - """ - with open('/proc/mounts') as mounts: - return mounts.readlines() - - def extract_id_from_volume_name(vol_name: str) -> Optional[str]: regex: typing.Pattern = re.compile( CONF.volume_name_template.replace('%s', r'(?P.+)'))