Merge "Remove unused methods from NovaHelper"

This commit is contained in:
Zuul
2026-03-04 21:52:25 +00:00
committed by Gerrit Code Review
4 changed files with 16 additions and 60 deletions

View File

@@ -0,0 +1,15 @@
---
upgrade:
- |
Three unused methods have been removed from the ``NovaHelper`` class in
``watcher.common.nova_helper``:
* ``get_aggregate_detail``
* ``wait_for_volume_status``
* ``_check_nova_api_version``
These methods were only used in unit tests and provided no value to the
production codebase. If you have custom code or plugins that depend on
these methods, you will need to implement equivalent functionality
directly. The methods were not part of the stable public API and their
removal should not affect normal Watcher operations.

View File

@@ -613,17 +613,6 @@ class NovaHelper:
aggregates = self.connection.compute.aggregates()
return [Aggregate.from_openstacksdk(a) for a in aggregates]
@nova_retries
@handle_nova_error("Aggregate")
def get_aggregate_detail(self, aggregate_id):
"""Get details of a specific host aggregate.
:param aggregate_id: the ID of the aggregate to get
:returns: Aggregate wrapper object if found, None if not found
"""
return Aggregate.from_openstacksdk(
self.connection.compute.get_aggregate(aggregate_id))
@nova_retries
@handle_nova_error("Service")
def get_service_list(self):
@@ -761,28 +750,6 @@ class NovaHelper:
"instance %s", instance_id)
return False
def wait_for_volume_status(self, volume, status, timeout=60,
poll_interval=1):
"""Wait until volume reaches given status.
:param volume: volume resource
:param status: expected status of volume
:param timeout: timeout in seconds
:param poll_interval: poll interval in seconds
"""
start_time = time.time()
while time.time() - start_time < timeout:
volume = self.cinder.volumes.get(volume.id)
if volume.status == status:
break
time.sleep(poll_interval)
else:
raise exception.VolumeNotReachedStatus(
volume.id,
status
)
return volume.status == status
def watcher_non_live_migrate_instance(self, instance_id, dest_hostname,
retry=None, interval=None):
"""This method migrates a given instance

View File

@@ -23,7 +23,6 @@ from unittest import mock
from keystoneauth1 import exceptions as ksa_exc
from openstack import exceptions as sdk_exc
from watcher.common import clients
from watcher.common import exception
from watcher.common import nova_helper
@@ -1018,30 +1017,6 @@ class TestNovaHelper(test_utils.NovaResourcesMixin, base.TestCase):
volume.availability_zone = kwargs.get('availability_zone', 'nova')
return volume
def test_wait_for_volume_status(self, mock_cinder):
nova_util = nova_helper.NovaHelper()
# verify that the method will return True when the status of volume
# is in the expected status.
fake_volume_1 = self.fake_volume(status='in-use')
nova_util.cinder.volumes.get.return_value = fake_volume_1
result = nova_util.wait_for_volume_status(
fake_volume_1,
"in-use",
timeout=2)
self.assertTrue(result)
# verify that the method will raise Exception when the status of
# volume is not in the expected status.
fake_volume_2 = self.fake_volume(status='fake-use')
nova_util.cinder.volumes.get.return_value = fake_volume_2
self.assertRaises(
Exception,
nova_util.wait_for_volume_status,
fake_volume_1,
"in-use",
timeout=2)
@mock.patch.object(
nova_helper.NovaHelper, '_instance_confirm_resize', autospec=True
)

View File

@@ -290,10 +290,9 @@ class TestComputeScope(base.TestCase):
'd010ef1f-dc19-4982-9383-087498bfde03'
).watcher_exclude)
@mock.patch.object(nova_helper.NovaHelper, 'get_aggregate_detail')
@mock.patch.object(nova_helper.NovaHelper, 'get_aggregate_list')
def test_get_scoped_model_with_hostaggregate_null(
self, mock_list, mock_detail):
self, mock_list):
cluster = self.fake_cluster.generate_scenario_1()
audit_scope = fake_scopes.fake_scope_3
mock_list.return_value = [mock.Mock(id=i,