def do_stack_preview(hc, args): """Preview the stack.""" tpl_files, template = template_utils.get_template_contents( args.template_file, args.template_url, args.template_object, hc.http_client.raw_request ) env_files, env = template_utils.process_multiple_environments_and_files(env_paths=args.environment_file) fields = { "stack_name": args.name, "disable_rollback": not (args.enable_rollback), "timeout_mins": args.timeout, "parameters": utils.format_parameters(args.parameters), "template": template, "files": dict(list(tpl_files.items()) + list(env_files.items())), "environment": env, } stack = hc.stacks.preview(**fields) formatters = { "description": utils.text_wrap_formatter, "template_description": utils.text_wrap_formatter, "stack_status_reason": utils.text_wrap_formatter, "parameters": utils.json_formatter, "outputs": utils.json_formatter, "resources": utils.json_formatter, "links": utils.link_formatter, } utils.print_dict(stack.to_dict(), formatters=formatters)
def do_stack_preview(hc, args): '''Preview the stack.''' tpl_files, template = template_utils.get_template_contents( args.template_file, args.template_url, args.template_object, hc.http_client.raw_request) env_files, env = template_utils.process_environment_and_files( env_path=args.environment_file) fields = { 'stack_name': args.name, 'parameters': utils.format_parameters(args.parameters), 'template': template, 'files': dict(list(tpl_files.items()) + list(env_files.items())), 'environment': env } stack = hc.stacks.preview(**fields) formatters = { 'description': utils.text_wrap_formatter, 'template_description': utils.text_wrap_formatter, 'stack_status_reason': utils.text_wrap_formatter, 'parameters': utils.json_formatter, 'outputs': utils.json_formatter, 'resources': utils.json_formatter, 'links': utils.link_formatter, } utils.print_dict(stack.to_dict(), formatters=formatters)
def do_stack_preview(hc, args): '''Preview the stack.''' tpl_files, template = template_utils.get_template_contents( args.template_file, args.template_url, args.template_object, hc.http_client.raw_request) env_files, env = template_utils.process_multiple_environments_and_files( env_paths=args.environment_file) fields = { 'stack_name': args.name, 'disable_rollback': not (args.enable_rollback), 'timeout_mins': args.timeout, 'parameters': utils.format_parameters(args.parameters), 'template': template, 'files': dict(list(tpl_files.items()) + list(env_files.items())), 'environment': env } stack = hc.stacks.preview(**fields) formatters = { 'description': utils.text_wrap_formatter, 'template_description': utils.text_wrap_formatter, 'stack_status_reason': utils.text_wrap_formatter, 'parameters': utils.json_formatter, 'outputs': utils.json_formatter, 'resources': utils.json_formatter, 'links': utils.link_formatter, } utils.print_dict(stack.to_dict(), formatters=formatters)
def do_stack_preview(hc, args): '''Preview the stack.''' tpl_files, template = template_utils.get_template_contents( args.template_file, args.template_url, args.template_object, _authenticated_fetcher(hc)) env_files, env = template_utils.process_multiple_environments_and_files( env_paths=args.environment_file) fields = { 'stack_name': args.name, 'disable_rollback': not(args.enable_rollback), 'timeout_mins': args.timeout, 'parameters': utils.format_all_parameters(args.parameters, args.parameter_file, args.template_file, args.template_url), 'template': template, 'files': dict(list(tpl_files.items()) + list(env_files.items())), 'environment': env } stack = hc.stacks.preview(**fields) formatters = { 'description': utils.text_wrap_formatter, 'template_description': utils.text_wrap_formatter, 'stack_status_reason': utils.text_wrap_formatter, 'parameters': utils.json_formatter, 'outputs': utils.json_formatter, 'resources': utils.json_formatter, 'links': utils.link_formatter, } utils.print_dict(stack.to_dict(), formatters=formatters)
def do_build_info(hc, args): '''Retrieve build information.''' result = hc.build_info.build_info() formatters = { 'api': utils.json_formatter, 'engine': utils.json_formatter, } utils.print_dict(result, formatters=formatters)
def do_resource_show(hc, args): """Describe the resource.""" fields = {"stack_id": args.id, "resource_name": args.resource} try: resource = hc.resources.get(**fields) except exc.HTTPNotFound: raise exc.CommandError("Stack or resource not found: %s %s" % (args.id, args.resource)) else: formatters = {"links": utils.link_formatter, "required_by": utils.newline_list_formatter} utils.print_dict(resource.to_dict(), formatters=formatters)
def do_event_show(hc, args): """Describe the event.""" fields = {"stack_id": args.id, "resource_name": args.resource, "event_id": args.event} try: event = hc.events.get(**fields) except exc.HTTPNotFound as ex: # it could be the stack/resource/or event that is not found # just use the message that the server sent us. raise exc.CommandError(str(ex)) else: formatters = {"links": utils.link_formatter, "resource_properties": utils.json_formatter} utils.print_dict(event.to_dict(), formatters=formatters)
def do_resource_metadata(hc, args): '''List resource metadata''' fields = {'stack_id': args.id, 'resource_name': args.resource} try: resource = hc.resources.metadata(**fields) except exc.HTTPNotFound: raise exc.CommandError('Stack or resource not found: %s %s' % (args.id, args.resource)) else: formatters = {} utils.print_dict(resource.to_dict(), formatters=formatters)
def do_resource_show(hc, args): '''Describe the resource.''' fields = {'stack_id': args.id, 'resource_name': args.resource} try: resource = hc.resources.get(**fields) except exc.HTTPNotFound: raise exc.CommandError('Stack or resource not found: %s %s' % (args.id, args.resource)) else: formatters = { 'links': utils.link_formatter, 'required_by': utils.newline_list_formatter } utils.print_dict(resource.to_dict(), formatters=formatters)
def do_event_show(hc, args): '''Describe the event.''' fields = {'stack_id': args.id, 'resource_name': args.resource, 'event_id': args.event} try: event = hc.events.get(**fields) except exc.HTTPNotFound: raise exc.CommandError('Stack not found: %s' % args.id) else: formatters = { 'links': utils.link_formatter, 'resource_properties': utils.json_formatter } utils.print_dict(event.to_dict(), formatters=formatters)
def do_resource_show(hc, args): '''Describe the resource''' fields = {'stack_id': args.id, 'resource_name': args.resource} try: resource = hc.resources.get(**fields) except exc.HTTPNotFound: raise exc.CommandError('Stack or resource not found: %s %s' % (args.id, args.resource)) else: link_format = lambda links: '\n'.join([l['href'] for l in links]) json_format = lambda js: json.dumps(js, indent=2) formatters = { 'links': link_format } utils.print_dict(resource.to_dict(), formatters=formatters)
def do_stack_show(hc, args): """Describe the stack.""" fields = {"stack_id": args.id} try: stack = hc.stacks.get(**fields) except exc.HTTPNotFound: raise exc.CommandError("Stack not found: %s" % args.id) else: formatters = { "description": utils.text_wrap_formatter, "template_description": utils.text_wrap_formatter, "stack_status_reason": utils.text_wrap_formatter, "parameters": utils.json_formatter, "outputs": utils.json_formatter, "links": utils.link_formatter, } utils.print_dict(stack.to_dict(), formatters=formatters)
def do_stack_show(hc, args): '''Describe the stack.''' fields = {'stack_id': args.id} try: stack = hc.stacks.get(**fields) except exc.HTTPNotFound: raise exc.CommandError('Stack not found: %s' % args.id) else: formatters = { 'description': utils.text_wrap_formatter, 'template_description': utils.text_wrap_formatter, 'stack_status_reason': utils.text_wrap_formatter, 'parameters': utils.json_formatter, 'outputs': utils.json_formatter, 'links': utils.link_formatter } utils.print_dict(stack.to_dict(), formatters=formatters)
def do_event_show(hc, args): '''Describe the event''' fields = {'stack_id': args.id, 'resource_name': args.resource, 'event_id': args.event} try: event = hc.events.get(**fields) except exc.HTTPNotFound: raise exc.CommandError('Stack not found: %s' % args.id) else: link_format = lambda links: '\n'.join([l['href'] for l in links]) json_format = lambda js: json.dumps(js, indent=2) formatters = { 'links': link_format, 'resource_properties': json_format } utils.print_dict(event.to_dict(), formatters=formatters)
def do_event_show(hc, args): '''Describe the event.''' fields = {'stack_id': args.id, 'resource_name': args.resource, 'event_id': args.event} try: event = hc.events.get(**fields) except exc.HTTPNotFound as ex: # it could be the stack/resource/or event that is not found # just use the message that the server sent us. raise exc.CommandError(str(ex)) else: formatters = { 'links': utils.link_formatter, 'resource_properties': utils.json_formatter } utils.print_dict(event.to_dict(), formatters=formatters)
def do_describe(hc, args): '''Describe the stack''' fields = {'stack_id': args.id} try: stack = hc.stacks.get(**fields) except exc.HTTPNotFound: raise exc.CommandError('Stack not found: %s' % args.id) else: text_wrap = lambda d: '\n'.join(textwrap.wrap(d, 55)) link_format = lambda links: '\n'.join([l['href'] for l in links]) json_format = lambda js: json.dumps(js, indent=2) formatters = { 'description': text_wrap, 'template_description': text_wrap, 'stack_status_reason': text_wrap, 'parameters': json_format, 'outputs': json_format, 'links': link_format } utils.print_dict(stack.to_dict(), formatters=formatters)
def do_build_info(hc, args): """Retrieve build information.""" result = hc.build_info.build_info() formatters = {"api": utils.json_formatter, "engine": utils.json_formatter} utils.print_dict(result, formatters=formatters)