def execute(self, opts):
    token = _exit_on_file_read_failure(os.path.join(opts.config_path, 'localtoken')).rstrip()
    rest = ClusterManager(('http://127.0.0.1:' + opts.port), '@localtoken', token)
    check_cluster_initialized(rest)
    check_versions(rest)
    if ((opts.new_password is not None) and opts.regenerate):
        _exit_if_errors(['Cannot specify both --new-password and --regenerate at the same time'])
    elif (opts.new_password is not None):
        (_, errors) = rest.set_admin_password(opts.new_password)
        _exit_if_errors(errors)
        _success('Administrator password changed')
    elif opts.regenerate:
        (result, errors) = rest.regenerate_admin_password()
        _exit_if_errors(errors)
        print(result['password'])
    else:
        _exit_if_errors(['No parameters specified'])
def execute(self, opts):
    token = _exit_on_file_read_failure(os.path.join(opts.config_path, 'localtoken')).rstrip()
    rest = ClusterManager(('http://127.0.0.1:' + opts.port), '@localtoken', token)
    check_cluster_initialized(rest)
    check_versions(rest)
    if ((opts.new_password is not None) and opts.regenerate):
        _exit_if_errors(['Cannot specify both --new-password and --regenerate at the same time'])
    elif (opts.new_password is not None):
        (_, errors) = rest.set_admin_password(opts.new_password)
        _exit_if_errors(errors)
        _success('Administrator password changed')
    elif opts.regenerate:
        (result, errors) = rest.regenerate_admin_password()
        _exit_if_errors(errors)
        print(result['password'])
    else:
        _exit_if_errors(['No parameters specified'])