module ManageIQ::ApplianceConsole::AuthUtilities

Constants

HTTPD_CONFIG_DIRECTORY

Public Instance Methods

configure_auth_settings(args) click to toggle source
# File lib/manageiq/appliance_console/auth_utilities.rb, line 69
def configure_auth_settings(args)
  Utilities.rake_run("evm:settings:set", args.collect { |key, val| "/authentication/#{key}=#{val}" })
end
configure_auth_settings_database() click to toggle source

Appliance Settings

# File lib/manageiq/appliance_console/auth_utilities.rb, line 59
def configure_auth_settings_database
  say("Setting Appliance Authentication Settings to Database ...")
  configure_auth_settings(:mode          => "database",
                          :httpd_role    => false,
                          :saml_enabled  => false,
                          :oidc_enabled  => false,
                          :sso_enabled   => false,
                          :provider_type => "none")
end
copy_template(dir, file, template_parameters = nil) click to toggle source
# File lib/manageiq/appliance_console/auth_utilities.rb, line 34
def copy_template(dir, file, template_parameters = nil)
  src_path = template_directory.join(relative_from_root(dir), file)
  dest_path = dir.join(file)
  dest_path = dest_path.sub_ext('') if src_path.extname == ".erb"
  debug_msg("Copying template #{src_path} to #{dest_path} ...")
  if src_path.extname == ".erb"
    raise ArgumentError, "Must specify template parameters for ERB files" if template_parameters.nil?

    template = ERB.new(File.read(src_path), nil, '-')
    File.write(dest_path, template.result_with_hash(template_parameters))
  else
    FileUtils.cp(src_path, dest_path)
  end
end
debug_msg(msg) click to toggle source

Logging

# File lib/manageiq/appliance_console/auth_utilities.rb, line 75
def debug_msg(msg)
  say(msg) if options[:verbose]
end
log_command_error(err) click to toggle source
# File lib/manageiq/appliance_console/auth_utilities.rb, line 79
def log_command_error(err)
  say(err.result.output)
  say(err.result.error)
  say("")
end
path_is_file?(path) click to toggle source
# File lib/manageiq/appliance_console/auth_utilities.rb, line 17
def path_is_file?(path)
  path.present? && !path_is_url?(path)
end
path_is_url?(path) click to toggle source
# File lib/manageiq/appliance_console/auth_utilities.rb, line 21
def path_is_url?(path)
  path =~ /\A#{URI.regexp(["http", "https"])}\z/x
end
relative_from_root(path) click to toggle source
# File lib/manageiq/appliance_console/auth_utilities.rb, line 53
def relative_from_root(path)
  path.absolute? ? path.relative_path_from(Pathname.new("/")) : path
end
remove_file(path) click to toggle source

File Management

# File lib/manageiq/appliance_console/auth_utilities.rb, line 27
def remove_file(path)
  if path.exist?
    debug_msg("Removing #{path} ...")
    path.delete
  end
end
restart_httpd() click to toggle source
# File lib/manageiq/appliance_console/auth_utilities.rb, line 9
def restart_httpd
  httpd_service = LinuxAdmin::Service.new("httpd")
  if httpd_service.running?
    say("Restarting httpd ...")
    httpd_service.restart
  end
end
template_directory() click to toggle source
# File lib/manageiq/appliance_console/auth_utilities.rb, line 49
def template_directory
  @template_directory ||= Pathname.new(ENV.fetch("APPLIANCE_TEMPLATE_DIRECTORY"))
end