def get_available_resource(self, nodename): """Retrieve resource information. This method is called when nova-compute launches, and as part of a periodic task that records the results in the DB. :param nodename: node which the caller want to get resources from a driver that manages only one node can safely ignore this :returns: Dictionary describing resources """ return hostops.get_available_resource()
def test_get_available_resource(self, mock_host_info, mock_cpu_info, mock_hdd_info, mock_version, mock_json_utils): mock_host_info.return_value = fake.fake_host_info() mock_version.return_value = mock.sentinel.version mock_cpu_info.return_value = mock.sentinel.cpu_info mock_json_utils.return_value = mock.sentinel.cpu_info mock_hdd_info.return_value = (fake.FAKE_TOTAL, fake.FAKE_FREE, fake.FAKE_USED) expected = fake.fake_available_resources() response = hostops.get_available_resource() self.assertEqual(1, mock_host_info.call_count) self.assertEqual(1, mock_cpu_info.call_count) self.assertEqual(1, mock_hdd_info.call_count) mock_json_utils.assert_has_calls(mock.call(mock.sentinel.cpu_info)) for key, value in expected.items(): self.assertEqual(value, response[key])