Skip to content

Commit

Permalink
Remove update_service_capabilities from nova
Browse files Browse the repository at this point in the history
From the comments of update_service_capabilities, it is said that
once publish_service_capabilities was removed, then we can begin the
process of its removal.

publish_service_capabilities has been removed in patch
I31c21055163e94b712d337568b16b9b7a224b52f, so we can remove
update_service_capabilities now.

Change-Id: I46be33462321f5e3ff0904bdff8dbfe2fbe115cd
Closes-Bug: #1263569
  • Loading branch information
Jay Lau committed Dec 23, 2013
1 parent 2c85c48 commit 4b4f0d6
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 146 deletions.
5 changes: 0 additions & 5 deletions nova/scheduler/driver.py
Expand Up @@ -106,11 +106,6 @@ def __init__(self):
CONF.scheduler_host_manager)
self.servicegroup_api = servicegroup.API()

def update_service_capabilities(self, service_name, host, capabilities):
"""Process a capability update from a service node."""
self.host_manager.update_service_capabilities(service_name,
host, capabilities)

def hosts_up(self, context, topic):
"""Return the list of hosts that have a running service for topic."""

Expand Down
18 changes: 0 additions & 18 deletions nova/scheduler/host_manager.py
Expand Up @@ -431,24 +431,6 @@ def get_weighed_hosts(self, hosts, weight_properties):
return self.weight_handler.get_weighed_objects(self.weight_classes,
hosts, weight_properties)

def update_service_capabilities(self, service_name, host, capabilities):
"""Update the per-service capabilities based on this notification."""

if service_name != 'compute':
LOG.debug(_('Ignoring %(service_name)s service update '
'from %(host)s'), {'service_name': service_name,
'host': host})
return

state_key = (host, capabilities.get('hypervisor_hostname'))
LOG.debug(_("Received %(service_name)s service update from "
"%(state_key)s."), {'service_name': service_name,
'state_key': state_key})
# Copy the capabilities, so we don't modify the original dict
capab_copy = dict(capabilities)
capab_copy["timestamp"] = timeutils.utcnow() # Reported time
self.service_states[state_key] = capab_copy

def get_all_host_states(self, context):
"""Returns a list of HostStates that represents all the hosts
the HostManager knows about. Also, each of the consumable resources
Expand Down
14 changes: 0 additions & 14 deletions nova/scheduler/manager.py
Expand Up @@ -67,20 +67,6 @@ def __init__(self, scheduler_driver=None, *args, **kwargs):
super(SchedulerManager, self).__init__(service_name='scheduler',
*args, **kwargs)

def update_service_capabilities(self, context, service_name,
host, capabilities):
"""Process a capability update from a service node."""
#NOTE(jogo) This is deprecated, but is used by the deprecated
# publish_service_capabilities call. So this can begin its removal
# process once publish_service_capabilities is removed.
if not isinstance(capabilities, list):
capabilities = [capabilities]
for capability in capabilities:
if capability is None:
capability = {}
self.driver.update_service_capabilities(service_name, host,
capability)

def create_volume(self, context, volume_id, snapshot_id,
reservations=None, image_id=None):
#function removed in RPC API 2.3
Expand Down
48 changes: 0 additions & 48 deletions nova/tests/scheduler/test_host_manager.py
Expand Up @@ -24,7 +24,6 @@
from nova.scheduler import filters
from nova.scheduler import host_manager
from nova import test
from nova.tests import matchers
from nova.tests.scheduler import fakes
from nova import utils

Expand Down Expand Up @@ -267,53 +266,6 @@ def test_get_filtered_hosts_with_ignore_hosts_and_force_same_nodes(self):
fake_properties)
self._verify_result(info, result, False)

def test_update_service_capabilities(self):
service_states = self.host_manager.service_states
self.assertEqual(len(service_states.keys()), 0)
self.mox.StubOutWithMock(timeutils, 'utcnow')
timeutils.utcnow().AndReturn(31337)
timeutils.utcnow().AndReturn(31339)

host1_compute_capabs = dict(free_memory=1234, host_memory=5678,
timestamp=1, hypervisor_hostname='node1')
host2_compute_capabs = dict(free_memory=8756, timestamp=1,
hypervisor_hostname='node2')

self.mox.ReplayAll()
self.host_manager.update_service_capabilities('compute', 'host1',
host1_compute_capabs)
self.host_manager.update_service_capabilities('compute', 'host2',
host2_compute_capabs)

# Make sure original dictionary wasn't copied
self.assertEqual(host1_compute_capabs['timestamp'], 1)

host1_compute_capabs['timestamp'] = 31337
host2_compute_capabs['timestamp'] = 31339

expected = {('host1', 'node1'): host1_compute_capabs,
('host2', 'node2'): host2_compute_capabs}
self.assertThat(service_states, matchers.DictMatches(expected))

def test_update_service_capabilities_node_key(self):
service_states = self.host_manager.service_states
self.assertThat(service_states, matchers.DictMatches({}))

host1_cap = {'hypervisor_hostname': 'host1-hvhn'}
host2_cap = {}

timeutils.set_time_override(31337)
self.host_manager.update_service_capabilities('compute', 'host1',
host1_cap)
timeutils.set_time_override(31338)
self.host_manager.update_service_capabilities('compute', 'host2',
host2_cap)
host1_cap['timestamp'] = 31337
host2_cap['timestamp'] = 31338
expected = {('host1', 'host1-hvhn'): host1_cap,
('host2', None): host2_cap}
self.assertThat(service_states, matchers.DictMatches(expected))

def test_get_all_host_states(self):

context = 'fake_context'
Expand Down
61 changes: 0 additions & 61 deletions nova/tests/scheduler/test_scheduler.py
Expand Up @@ -72,53 +72,6 @@ def test_1_correct_init(self):
manager = self.manager
self.assertIsInstance(manager.driver, self.driver_cls)

def test_update_service_capabilities(self):
service_name = 'fake_service'
host = 'fake_host'

self.mox.StubOutWithMock(self.manager.driver,
'update_service_capabilities')

# Test no capabilities passes empty dictionary
self.manager.driver.update_service_capabilities(service_name,
host, {})
self.mox.ReplayAll()
self.manager.update_service_capabilities(self.context,
service_name=service_name, host=host, capabilities={})
self.mox.VerifyAll()

self.mox.ResetAll()
# Test capabilities passes correctly
capabilities = {'fake_capability': 'fake_value'}
self.manager.driver.update_service_capabilities(
service_name, host, capabilities)
self.mox.ReplayAll()
self.manager.update_service_capabilities(self.context,
service_name=service_name, host=host,
capabilities=capabilities)

def test_update_service_multiple_capabilities(self):
service_name = 'fake_service'
host = 'fake_host'

self.mox.StubOutWithMock(self.manager.driver,
'update_service_capabilities')

capab1 = {'fake_capability': 'fake_value1'},
capab2 = {'fake_capability': 'fake_value2'},
capab3 = None
self.manager.driver.update_service_capabilities(
service_name, host, capab1)
self.manager.driver.update_service_capabilities(
service_name, host, capab2)
# None is converted to {}
self.manager.driver.update_service_capabilities(
service_name, host, {})
self.mox.ReplayAll()
self.manager.update_service_capabilities(self.context,
service_name=service_name, host=host,
capabilities=[capab1, capab2, capab3])

def test_show_host_resources(self):
host = 'fake_host'

Expand Down Expand Up @@ -527,20 +480,6 @@ def fake_show(meh, context, id):
self.topic = 'fake_topic'
self.servicegroup_api = servicegroup.API()

def test_update_service_capabilities(self):
service_name = 'fake_service'
host = 'fake_host'

self.mox.StubOutWithMock(self.driver.host_manager,
'update_service_capabilities')

capabilities = {'fake_capability': 'fake_value'}
self.driver.host_manager.update_service_capabilities(
service_name, host, capabilities)
self.mox.ReplayAll()
self.driver.update_service_capabilities(service_name,
host, capabilities)

def test_hosts_up(self):
service1 = {'host': 'host1'}
service2 = {'host': 'host2'}
Expand Down

0 comments on commit 4b4f0d6

Please sign in to comment.