def index(request): nodes = nm.list_all_nodes() clusters = cl.list_all() poll_result = file_ipc.read() node_details = {(n['host'], n['port']): n for n in poll_result['nodes']} proxy_details = {(p['host'], p['port']): p for p in poll_result['proxies']} proxies = [] for c in clusters: for p in c.proxies: p.detail = proxy_details.get((p.host, p.port), {}) p.stat = p.detail.get('stat', True) proxies.append({'host': p.host, 'port': p.port}) for n in nodes: detail = node_details.get((n.host, n.port), {}) n.node_id = detail.get('node_id') n.detail = detail n.stat = detail.get('stat', True) file_ipc.write_nodes([{'host': n.host, 'port': n.port} for n in nodes], proxies) clusters_json = {c.id: { 'descr': c.description, 'nodes': [{ 'node_id': n.node_id, 'host': n.host, 'port': n.port, 'slave': n.detail.get('slave', False), } for n in c.nodes], } for c in clusters} return request.render( 'index.html', nodes=nodes, clusters=clusters, clusters_json=clusters_json, stats_enabled=stats.db.client is not None)
def test_request_instance(self): nm.create_instance('10.1.201.10', 9000) nm.create_instance('10.1.201.10', 9001) nm.create_instance('10.1.201.12', 6376) i = sorted(list(nm.list_all_nodes()), key=lambda x: (x.host, x.port)) self.assertEqual(3, len(i)) self.assertEqual(('10.1.201.10', 9000, None), (i[0].host, i[0].port, i[0].assignee)) self.assertEqual(('10.1.201.10', 9001, None), (i[1].host, i[1].port, i[1].assignee)) self.assertEqual(('10.1.201.12', 6376, None), (i[2].host, i[2].port, i[2].assignee))
def test_request_instance(self): nm.create_instance('10.1.201.10', 9000, 536870912) nm.create_instance('10.1.201.10', 9001, 1000000000) nm.create_instance('10.1.201.12', 6376, 536870912) cluster_id = clu.create_cluster('forgot-me-not') i = sorted(list(nm.list_all_nodes()), key=lambda x: (x.host, x.port)) self.assertEqual(3, len(i)) self.assertEqual(('10.1.201.10', 9000, 536870912L, None), (i[0].host, i[0].port, i[0].max_mem, i[0].assignee)) self.assertEqual(('10.1.201.10', 9001, 1000000000L, None), (i[1].host, i[1].port, i[1].max_mem, i[1].assignee)) self.assertEqual(('10.1.201.12', 6376, 536870912L, None), (i[2].host, i[2].port, i[2].max_mem, i[2].assignee))
def index(request): nodes = nm.list_all_nodes() clusters = cl.list_all() poll_result = file_ipc.read_details() node_details = poll_result['nodes'] proxy_details = poll_result['proxies'] proxies = [] for c in clusters: for p in c.proxies: p.detail = proxy_details.get('%s:%d' % (p.host, p.port), {}) p.stat = p.detail.get('stat', True) proxies.extend(c.proxies) for n in nodes: detail = node_details.get('%s:%d' % (n.host, n.port), {}) n.node_id = detail.get('node_id') n.detail = detail n.stat = detail.get('stat', True) return request.render( 'index.html', nodes=nodes, clusters=clusters, stats_enabled=stats.client is not None)
def index(request): nodes = nm.list_all_nodes() clusters = cl.list_all() poll_result = file_ipc.read_details() node_details = poll_result['nodes'] proxy_details = poll_result['proxies'] proxies = [] for c in clusters: for p in c.proxies: p.detail = proxy_details.get('%s:%d' % (p.host, p.port), {}) p.stat = p.detail.get('stat', True) proxies.extend(c.proxies) for n in nodes: detail = node_details.get('%s:%d' % (n.host, n.port), {}) n.node_id = detail.get('node_id') n.detail = detail n.stat = detail.get('stat', True) return request.render('index.html', nodes=nodes, clusters=clusters, stats_enabled=stats.client is not None)
def index(request): nodes = nm.list_all_nodes() clusters = cl.list_all() poll_result = file_ipc.read() node_details = {(n['host'], n['port']): n for n in poll_result['nodes']} proxy_details = {(p['host'], p['port']): p for p in poll_result['proxies']} proxies = [] for c in clusters: for p in c.proxies: p.detail = proxy_details.get((p.host, p.port), {}) p.stat = p.detail.get('stat', True) proxies.extend(c.proxies) for n in nodes: detail = node_details.get((n.host, n.port), {}) n.node_id = detail.get('node_id') n.detail = detail n.stat = detail.get('stat', True) file_ipc.write_nodes(nodes, proxies) return request.render( 'index.html', nodes=nodes, clusters=clusters, stats_enabled=stats.db.client is not None)
def index(): nodes = nm.list_all_nodes() clusters = cl.list_all() poll_result = bp.app.polling_result() node_details = poll_result['nodes'] proxy_details = poll_result['proxies'] proxies = [] for c in clusters: for p in c.proxies: p.detail = proxy_details.get('%s:%d' % (p.host, p.port), {}) p.stat = p.detail.get('stat', True) proxies.extend(c.proxies) for n in nodes: detail = node_details.get('%s:%d' % (n.host, n.port), {}) n.node_id = detail.get('node_id') n.detail = detail n.stat = detail.get('stat', True) return render_template('index.html', nodes=nodes, clusters=clusters, stats_enabled=bp.app.stats_enabled())
def write_nodes_proxies_from_db(): import models.node as nm import models.proxy as pr write_nodes(nm.list_all_nodes(), pr.list_all())
def write_nodes_proxies_from_db(): import models.node as nm import models.proxy as pr write_poll([{'host': n.host, 'port': n.port} for n in nm.list_all_nodes()], [{'host': p.host, 'port': p.port} for p in pr.list_all()])
def write_nodes_proxies_from_db(): write_nodes(nm.list_all_nodes(), pr.list_all())