def test_servers(self): """Tests servers report.""" report = reports.servers(self.cell) pd.util.testing.assert_frame_equal( report, pd.DataFrame([ [ 'srv3', 'top/rack:rack2', '_default', 0, 'up', 3000, 10, 20, 30, 10, 20, 30 ], [ 'srv4', 'top/rack:rack2', '_default', 0, 'up', 4000, 10, 20, 30, 10, 20, 30 ], [ 'srv1', 'top/rack:rack1', 'part', 3, 'up', 1000, 10, 20, 30, 10, 20, 30 ], [ 'srv2', 'top/rack:rack1', 'part', 7, 'up', 2000, 10, 20, 30, 10, 20, 30 ], ], columns=[ 'name', 'location', 'partition', 'traits', 'state', 'valid_until', 'mem', 'cpu', 'disk', 'mem_free', 'cpu_free', 'disk_free' ]))
def test_servers(self): """Tests servers report.""" df = reports.servers(self.cell) # print df # Sample data frame to see that the values are correct. self.assertEqual(df.ix['srv1']['memory'], 10) self.assertEqual(df.ix['srv2']['rack'], 'rack:rack1')
def servers(features): """View servers report""" cell_master = _load() output = reports.servers(cell_master.cell) if features: feature_report = reports.node_features(cell_master.cell) _print_frame(pd.concat([output, feature_report], axis=1)) else: _print_frame(output)
def test_servers(self): """Tests servers report.""" df = reports.servers(self.cell) # print df # Sample data frame to see that the values are correct. self.assertEquals(df.ix['srv1']['memory'], 10) self.assertEquals(df.ix['srv2']['rack'], 'rack:rack1') df_features = reports.node_features(self.cell) # print df_features self.assertTrue(df_features.ix['srv1']['aaa']) self.assertTrue(df_features.ix['srv2']['ccc']) self.assertIs(df_features.ix['srv3']['ccc'], np.nan)
def test_empty_cell_reports(self): """Tests all reports for an empty cell.""" empty_cell = _construct_cell(empty=True) servers = reports.servers(empty_cell, self.trait_codes) empty_servers = pd.DataFrame(columns=[ 'name', 'location', 'partition', 'traits', 'state', 'valid_until', 'mem', 'cpu', 'disk', 'mem_free', 'cpu_free', 'disk_free' ]).astype({ 'mem': 'int', 'cpu': 'int', 'disk': 'int', 'mem_free': 'int', 'cpu_free': 'int', 'disk_free': 'int' }).reset_index(drop=True) pd.util.testing.assert_frame_equal(servers, empty_servers) allocations = reports.allocations(empty_cell, self.trait_codes) empty_allocations = pd.DataFrame(columns=[ 'partition', 'name', 'mem', 'cpu', 'disk', 'rank', 'rank_adj', 'traits', 'max_util' ]).astype({ 'mem': 'int', 'cpu': 'int', 'disk': 'int' }).reset_index(drop=True) pd.util.testing.assert_frame_equal(allocations, empty_allocations) apps = reports.apps(empty_cell, self.trait_codes) empty_apps = pd.DataFrame(columns=[ 'instance', 'allocation', 'rank', 'affinity', 'partition', 'identity_group', 'identity', 'order', 'lease', 'expires', 'data_retention', 'pending', 'server', 'util0', 'util1', 'mem', 'cpu', 'disk' ]).astype({ 'mem': 'int', 'cpu': 'int', 'disk': 'int', 'order': 'int', 'expires': 'int', 'data_retention': 'int', 'identity': 'int' }).reset_index(drop=True) pd.util.testing.assert_frame_equal(apps, empty_apps)
def scheduler(view, reschedule, csv): """Manage Treadmill server configuration.""" treadmill_sched.DIMENSION_COUNT = 3 cell_master = master.Master(context.GLOBAL.zk.conn, context.GLOBAL.cell) cell_master.load_buckets() cell_master.load_cell() cell_master.load_servers(readonly=True) cell_master.load_allocations() cell_master.load_strategies() cell_master.load_apps() if reschedule: cell_master.cell.schedule() output = None if view == 'servers': output = reports.servers(cell_master.cell) if view == 'features': output = reports.node_features(cell_master.cell) if view == 'allocs': allocs = reports.allocations(cell_master.cell) features = reports.allocation_features(cell_master.cell) # TODO: investigate why pd.concat returns series not df. # pylint: disable=R0204 output = pd.concat([allocs, features], axis=1) if view == 'apps': output = reports.apps(cell_master.cell) if view == 'util': apps = reports.apps(cell_master.cell) output = reports.utilization(None, apps) if output is not None and len(output): if csv: print output.to_csv() else: print output
def servers(): """View servers report""" cell_master = make_readonly_master(ctx['run_scheduler']) output = reports.servers(cell_master.cell, cell_master.trait_codes) output['valid_until'] = pd.to_datetime(output['valid_until'], unit='s') _print(output)