def test_filter_nodes(self): nodes = self.ironicclient_nodes.list() num_nodes = len(nodes) with patch('novaclient.v1_1.contrib.baremetal.' 'BareMetalNodeManager.list', return_value=nodes): all_nodes = api.filter_nodes(nodes) healthy_nodes = api.filter_nodes(nodes, healthy=True) defective_nodes = api.filter_nodes(nodes, healthy=False) self.assertEqual(len(all_nodes), num_nodes) self.assertEqual(len(healthy_nodes), num_nodes - 1) self.assertEqual(len(defective_nodes), 1)
def get_context_data(self, request): deployed_nodes = api.Node.list(request, associated=True) free_nodes = api.Node.list(request, associated=False) deployed_nodes_error = api.filter_nodes(deployed_nodes, healthy=False) free_nodes_error = api.filter_nodes(free_nodes, healthy=False) total_nodes = deployed_nodes + free_nodes total_nodes_error = deployed_nodes_error + free_nodes_error total_nodes_healthy = api.filter_nodes(total_nodes, healthy=True) return { 'total_nodes_healthy': total_nodes_healthy, 'total_nodes_error': total_nodes_error, 'deployed_nodes': deployed_nodes, 'deployed_nodes_error': deployed_nodes_error, 'free_nodes': free_nodes, 'free_nodes_error': free_nodes_error, }
def get_free_nodes_data(self): redirect = urlresolvers.reverse('horizon:infrastructure:nodes:index') free_nodes = api.Node.list(self.request, associated=False, _error_redirect=redirect) if 'errors' in self.request.GET: return api.filter_nodes(free_nodes, healthy=False) return free_nodes