def test_allocations(self): """Tests allocations report.""" df = reports.allocations(self.cell) # cpu disk max_utilization memory rank # name # t2/a1 10 10 inf 10 100 # t1/t3/a2 10 10 inf 10 100 self.assertEqual(df.ix['-', 't2/a1']['cpu'], 10) self.assertEqual(df.ix['-', 't1/t3/a2']['cpu'], 10)
def test_allocations(self): """Tests allocations report.""" report = reports.allocations(self.cell) pd.util.testing.assert_frame_equal( report, pd.DataFrame( [['_default', 't1/t11/a1', 10, 10, 10, 100, 0, 0, np.inf], ['part', 't2/a2', 10, 10, 10, 100, 0, 3, np.inf]], columns=[ 'partition', 'name', 'mem', 'cpu', 'disk', 'rank', 'rank_adj', 'traits', 'max_util' ]).sort_values(by=['partition', 'name']))
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 allocs(): """View allocation report""" cell_master = make_readonly_master(ctx['run_scheduler']) allocs = reports.allocations(cell_master.cell, cell_master.trait_codes) _print(allocs)
def allocs(): """View allocation report""" cell_master = _load() allocs = reports.allocations(cell_master.cell) _print_frame(allocs)
def allocs(): """View allocation report""" cell_master = make_readonly_master(ctx['run_scheduler']) allocs = reports.allocations(cell_master.cell) _print(allocs, allocs_formatter)