Skip to content

Commit

Permalink
Fix baremetal get_available_nodes
Browse files Browse the repository at this point in the history
Baremetal driver get_available_nodes was incorrectly returning only a
list of unprovisioned nodes, leading update_availabile_resources to
sometimes delete a baremetal node that had an instance provisioned
to it -- sometimes even while the provisioning was still in process.

Fix bug 1174952

Change-Id: I4f08a2f6539a5b6cd12245ac6b4dc308767ae0cd
(cherry picked from commit 75568fe)
  • Loading branch information
AevaOnline authored and russellb committed May 1, 2013
1 parent c185195 commit 79ad6cb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
30 changes: 1 addition & 29 deletions nova/tests/baremetal/test_driver.py
Expand Up @@ -283,38 +283,10 @@ def test_get_available_nodes(self):
node1 = self._create_node()
self.assertEqual(1, len(self.driver.get_available_nodes()))

node_info = bm_db_utils.new_bm_node(
id=456,
service_host='test_host',
cpus=2,
memory_mb=2048,
)
nic_info = [
{'address': 'cc:cc:cc', 'datapath_id': '0x1',
'port_no': 1},
{'address': 'dd:dd:dd', 'datapath_id': '0x2',
'port_no': 2},
]
node2 = self._create_node(node_info=node_info, nic_info=nic_info)
self.assertEqual(2, len(self.driver.get_available_nodes()))
self.assertEqual([node1['node']['uuid'], node2['node']['uuid']],
self.driver.get_available_nodes())

node1['instance']['hostname'] = 'test-host-1'
node2['instance']['hostname'] = 'test-host-2'

self.driver.spawn(**node1['spawn_params'])
self.assertEqual(1, len(self.driver.get_available_nodes()))

self.driver.spawn(**node2['spawn_params'])
self.assertEqual(0, len(self.driver.get_available_nodes()))

self.driver.destroy(**node1['destroy_params'])
self.assertEqual(1, len(self.driver.get_available_nodes()))

self.driver.destroy(**node2['destroy_params'])
self.assertEqual(2, len(self.driver.get_available_nodes()))
self.assertEqual([node1['node']['uuid'], node2['node']['uuid']],
self.assertEqual([node1['node']['uuid']],
self.driver.get_available_nodes())

def test_list_instances(self):
Expand Down
2 changes: 1 addition & 1 deletion nova/virt/baremetal/driver.py
Expand Up @@ -486,4 +486,4 @@ def get_console_output(self, instance):
def get_available_nodes(self):
context = nova_context.get_admin_context()
return [str(n['uuid']) for n in
db.bm_node_get_unassociated(context, service_host=CONF.host)]
db.bm_node_get_all(context, service_host=CONF.host)]

0 comments on commit 79ad6cb

Please sign in to comment.