def cmd_pods(args): if args.command == 'list': columnar = columns.Columnar( **columns_argparses.make_columnar_kwargs(args), stringifiers=pods.POD_LIST_STRINGIFIERS, ) for row in pods.cmd_list(): columnar.append(row) columnar.sort(lambda row: (row['name'], row['version'], row['id'])) columnar.output(sys.stdout) elif args.command == 'show': columnar = columns.Columnar( **columns_argparses.make_columnar_kwargs(args), stringifiers=pods.POD_SHOW_STRINGIFIERS, ) for row in pods.cmd_show(args.id): columnar.append(row) columnar.sort(lambda row: row['name']) columnar.output(sys.stdout) elif args.command == 'cat-config': pods.cmd_cat_config(args.id, sys.stdout.buffer) elif args.command == 'generate-id': pods.cmd_generate_id(sys.stdout) elif args.command == 'run': pods.cmd_run( pod_id=args.id or models.generate_pod_id(), config_path=args.config, debug=get_debug(), ) elif args.command == 'prepare': pods.cmd_prepare( pod_id=args.id or models.generate_pod_id(), config_path=args.config, ) elif args.command == 'run-prepared': pods.cmd_run_prepared(pod_id=args.id, debug=get_debug()) elif args.command == 'add-ref': pods.cmd_add_ref(pod_id=args.id, target_path=args.target) elif args.command == 'export-overlay': pods.cmd_export_overlay( pod_id=args.id, output_path=args.output, filter_patterns=args.filter or (), debug=get_debug(), ) elif args.command == 'remove': pods.cmd_remove(args.id) elif args.command == 'cleanup': pods.cmd_cleanup(**bases.make_grace_period_kwargs(args)) else: ASSERT.unreachable('unknown pod command: {}', args.command) return 0
def cmd_xars(args): if args.command == 'install': xars.cmd_install( **images.make_select_image_kwargs(args), xar_name=args.name, exec_relpath=args.exec, ) elif args.command == 'list': columnar = columns.Columnar( **columns_argparses.make_columnar_kwargs(args), stringifiers=xars.XAR_LIST_STRINGIFIERS, ) for row in xars.cmd_list(): columnar.append(row) columnar.sort( lambda row: (row['xar'], row['name'], row['version'], row['id']) ) columnar.output(sys.stdout) elif args.command == 'exec': xars.cmd_exec(args.name, args.args) elif args.command == 'uninstall': xars.cmd_uninstall(args.name) elif args.command == 'cleanup': xars.cmd_cleanup() else: ASSERT.unreachable('unknown xar command: {}', args.command) return 0
def cmd_list(args): columnar = columns.Columnar( **columns_argparses.make_columnar_kwargs(args), stringifiers=_XAR_LIST_STRINGIFIERS, ) with xar_ops_dirs.make_ops_dirs().listing_ops_dirs() as active_ops_dirs: for ops_dir in active_ops_dirs: columnar.append({ 'label': ops_dir.label, 'version': ops_dir.version, 'zipapp': ops_dir.metadata.is_zipapp(), }) columnar.sort(lambda row: (row['label'], row['version'])) columnar.output(sys.stdout) return 0
def cmd_list_assignments(args): columnar = columns.Columnar( **columns_argparses.make_columnar_kwargs(args), stringifiers=_ASSIGNMENT_LIST_STRINGIFIERS, ) for token_name, assignments in ( tokens.make_tokens_database().get().assignments.items()): for assignment in assignments: columnar.append({ 'token-name': token_name, 'pod-id': assignment.pod_id, 'name': assignment.name, 'value': assignment.value, }) columnar.sort(lambda row: (row['token-name'], row['pod-id'], row['name'], row['value'])) columnar.output(sys.stdout) return 0
def cmd_images(args): if args.command == 'build-base': builders.cmd_build_base_image( args.name, args.version, args.output, args.prune_stash_path ) elif args.command == 'prepare-base-rootfs': builders.cmd_prepare_base_rootfs(args.path) elif args.command == 'setup-base-rootfs': builders.cmd_setup_base_rootfs(args.path, args.prune_stash_path) elif args.command == 'build': images.cmd_build_image( args.name, args.version, args.rootfs, args.output ) elif args.command == 'import': images.cmd_import(args.path, tag=args.tag) elif args.command == 'list': columnar = columns.Columnar( **columns_argparses.make_columnar_kwargs(args), stringifiers=images.IMAGE_LIST_STRINGIFIERS, ) for row in images.cmd_list(): columnar.append(row) columnar.sort(lambda row: (row['name'], row['version'], row['id'])) columnar.output(sys.stdout) elif args.command == 'tag': images.cmd_tag( **images.make_select_image_kwargs(args), new_tag=args.new_tag, ) elif args.command == 'remove-tag': images.cmd_remove_tag(args.tag) elif args.command == 'remove': images.cmd_remove( **images.make_select_image_kwargs(args), skip_active=args.skip_active, ) elif args.command == 'cleanup': images.cmd_cleanup(**bases.make_grace_period_kwargs(args)) else: ASSERT.unreachable('unknown image command: {}', args.command) return 0
def cmd_list(args): columnar = columns.Columnar( **columns_argparses.make_columnar_kwargs(args), stringifiers=_POD_LIST_STRINGIFIERS, ) with pod_ops_dirs.make_ops_dirs().listing_ops_dirs() as active_ops_dirs: for ops_dir in active_ops_dirs: for config in ops_dir.metadata.systemd_unit_configs: columnar.append({ 'label': ops_dir.label, 'version': ops_dir.version, 'id': config.pod_id, 'name': config.name, 'unit': config.unit_name, 'auto-start': config.auto_start, 'auto-stop': config.auto_stop, 'enabled': systemds.is_enabled(config), 'active': systemds.is_active(config), }) columnar.sort(lambda row: (row['label'], row['version'], row['name'])) columnar.output(sys.stdout) return 0
def cmd_list_definitions(args): columnar = columns.Columnar( **columns_argparses.make_columnar_kwargs(args), stringifiers=_DEFINITION_LIST_STRINGIFIERS, ) for token_name, definition in ( tokens.make_tokens_database().get().definitions.items()): if definition.kind == 'range': columnar.append({ 'token-name': token_name, 'range': definition.args, 'values': (), }) else: ASSERT.equal(definition.kind, 'values') columnar.append({ 'token-name': token_name, 'range': (), 'values': definition.args, }) columnar.sort(lambda row: row['token-name']) columnar.output(sys.stdout) return 0
def cmd_list(args): columnar = columns.Columnar(**columns_argparses.make_columnar_kwargs(args)) for name, value in envs.load().items(): columnar.append({'name': name, 'value': value}) columnar.output(sys.stdout) return 0