def get_password(max_password_prompts=3): """Read password from TTY.""" verify = strutils.bool_from_string(env("OS_VERIFY_PASSWORD")) pw = None if hasattr(sys.stdin, "isatty") and sys.stdin.isatty(): # Check for Ctrl-D try: for __ in moves.range(max_password_prompts): pw1 = getpass.getpass("OS Password: "******"Please verify: ") else: pw2 = pw1 if pw1 == pw2 and pw1: pw = pw1 break except EOFError: pass return pw
def do_stack_update(hc, args): '''Update 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_id': args.id, 'parameters': utils.format_parameters(args.parameters), 'existing': args.existing, 'template': template, 'files': dict(list(tpl_files.items()) + list(env_files.items())), 'environment': env } if args.timeout: fields['timeout_mins'] = args.timeout if args.clear_parameter: fields['clear_parameters'] = list(args.clear_parameter) if args.rollback is not None: try: rollback = strutils.bool_from_string(args.rollback, strict=True) except ValueError as ex: raise exc.CommandError(six.text_type(ex)) else: fields['disable_rollback'] = not(rollback) # TODO(pshchelo): remove the following 'else' clause after deprecation # period of --enable-rollback switch and assign -r shortcut to --rollback else: if args.enable_rollback: fields['disable_rollback'] = False hc.stacks.update(**fields) do_stack_list(hc)
def do_stack_update(hc, args): '''Update 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_id': args.id, 'parameters': utils.format_parameters(args.parameters), 'existing': args.existing, 'template': template, 'files': dict(list(tpl_files.items()) + list(env_files.items())), 'environment': env } if args.timeout: fields['timeout_mins'] = args.timeout if args.clear_parameter: fields['clear_parameters'] = list(args.clear_parameter) if args.rollback is not None: try: rollback = strutils.bool_from_string(args.rollback, strict=True) except ValueError as ex: raise exc.CommandError(six.text_type(ex)) else: fields['disable_rollback'] = not (rollback) # TODO(pshchelo): remove the following 'else' clause after deprecation # period of --enable-rollback switch and assign -r shortcut to --rollback else: if args.enable_rollback: fields['disable_rollback'] = False hc.stacks.update(**fields) do_stack_list(hc)