def allocs(ctx, match, partition): """View allocations report.""" report = fetch_report( ctx.obj.get('api'), 'allocations', match, partition ) report = report.loc[ ~report.name.str.startswith('_default/') ].reset_index(drop=True) print_report(report)
def explain(instance): """Explain why an instance is pending.""" api_urls = context.GLOBAL.cell_api() path = '/scheduler/explain/{}'.format(urllib.parse.quote(instance)) try: response = restclient.get(api_urls, path).json() except restclient.AlreadyExistsError: cli.out('Instance {} is running.'.format(instance)) else: report = pd.DataFrame(response['data'], columns=response['columns']) print_report(report)
def apps(ctx, match, partition, full): """View apps report.""" report = fetch_report(ctx.obj.get('api'), 'apps', match, partition) # Replace integer N/As for col in ['identity', 'expires', 'lease', 'data_retention']: report.loc[report[col] == -1, col] = '' # Convert to datetimes for col in ['expires']: report[col] = pd.to_datetime(report[col], unit='s') # Convert to timedeltas for col in ['lease', 'data_retention']: report[col] = pd.to_timedelta(report[col], unit='s') report = report.fillna('') if not full: report = report[[ 'instance', 'allocation', 'partition', 'server', 'mem', 'cpu', 'disk' ]] print_report(report)
def servers(ctx, match, partition): """View servers report.""" report = fetch_report(ctx.obj.get('api'), 'servers', match, partition) report['valid_until'] = pd.to_datetime(report['valid_until'], unit='s') print_report(report)