def default_url_options
options = {}
- if Rails.configuration.Services["Controller"]["ExternalURL"] != ""
- exturl = URI.parse(Rails.configuration.Services["Controller"]["ExternalURL"])
+ if Rails.configuration.Services.Controller.ExternalURL != ""
+ exturl = URI.parse(Rails.configuration.Services.Controller.ExternalURL)
options[:host] = exturl.host
options[:port] = exturl.port
options[:protocol] = exturl.scheme
limit_query.each do |record|
new_limit += 1
read_total += record.read_length.to_i
- if read_total >= Rails.configuration.API["MaxIndexDatabaseRead"]
+ if read_total >= Rails.configuration.API.MaxIndexDatabaseRead
new_limit -= 1 if new_limit > 1
@limit = new_limit
break
end
def disable_api_methods
- if Rails.configuration.API["DisabledAPIs"].
- include?(controller_name + "." + action_name)
+ if Rails.configuration.API.DisabledAPIs.include?(controller_name + "." + action_name)
send_error("Disabled", status: 404)
end
end
table_names = Hash[klasses.collect { |k| [k, k.table_name] }]
- disabled_methods = Rails.configuration.API["DisabledAPIs"]
+ disabled_methods = Rails.configuration.API.DisabledAPIs
avail_klasses = table_names.select{|k, t| !disabled_methods.include?(t+'.index')}
klasses = avail_klasses.keys
title: "Arvados API",
description: "The API to interact with Arvados.",
documentationLink: "http://doc.arvados.org/api/index.html",
- defaultCollectionReplication: Rails.configuration.Collections["DefaultReplication"],
+ defaultCollectionReplication: Rails.configuration.Collections.DefaultReplication,
protocol: "rest",
baseUrl: root_url + "arvados/v1/",
basePath: "/arvados/v1/",
servicePath: "arvados/v1/",
batchPath: "batch",
uuidPrefix: Rails.configuration.ClusterID,
- defaultTrashLifetime: Rails.configuration.Collections["DefaultTrashLifetime"],
- blobSignatureTtl: Rails.configuration.Collections["BlobSigningTTL"],
- maxRequestSize: Rails.configuration.API["MaxRequestSize"],
- maxItemsPerResponse: Rails.configuration.API["MaxItemsPerResponse"],
- dockerImageFormats: Rails.configuration.Containers["SupportedDockerImageFormats"],
- crunchLogBytesPerEvent: Rails.configuration.Containers["Logging"]["LogBytesPerEvent"],
- crunchLogSecondsBetweenEvents: Rails.configuration.Containers["Logging"]["LogSecondsBetweenEvents"],
- crunchLogThrottlePeriod: Rails.configuration.Containers["Logging"]["LogThrottlePeriod"],
- crunchLogThrottleBytes: Rails.configuration.Containers["Logging"]["LogThrottleBytes"],
- crunchLogThrottleLines: Rails.configuration.Containers["Logging"]["LogThrottleLines"],
- crunchLimitLogBytesPerJob: Rails.configuration.Containers["Logging"]["LimitLogBytesPerJob"],
- crunchLogPartialLineThrottlePeriod: Rails.configuration.Containers["Logging"]["LogPartialLineThrottlePeriod"],
- crunchLogUpdatePeriod: Rails.configuration.Containers["Logging"]["LogUpdatePeriod"],
- crunchLogUpdateSize: Rails.configuration.Containers["Logging"]["LogUpdateSize"],
+ defaultTrashLifetime: Rails.configuration.Collections.DefaultTrashLifetime,
+ blobSignatureTtl: Rails.configuration.Collections.BlobSigningTTL,
+ maxRequestSize: Rails.configuration.API.MaxRequestSize,
+ maxItemsPerResponse: Rails.configuration.API.MaxItemsPerResponse,
+ dockerImageFormats: Rails.configuration.Containers.SupportedDockerImageFormats,
+ crunchLogBytesPerEvent: Rails.configuration.Containers.Logging.LogBytesPerEvent,
+ crunchLogSecondsBetweenEvents: Rails.configuration.Containers.Logging.LogSecondsBetweenEvents,
+ crunchLogThrottlePeriod: Rails.configuration.Containers.Logging.LogThrottlePeriod,
+ crunchLogThrottleBytes: Rails.configuration.Containers.Logging.LogThrottleBytes,
+ crunchLogThrottleLines: Rails.configuration.Containers.Logging.LogThrottleLines,
+ crunchLimitLogBytesPerJob: Rails.configuration.Containers.Logging.LimitLogBytesPerJob,
+ crunchLogPartialLineThrottlePeriod: Rails.configuration.Containers.Logging.LogPartialLineThrottlePeriod,
+ crunchLogUpdatePeriod: Rails.configuration.Containers.Logging.LogUpdatePeriod,
+ crunchLogUpdateSize: Rails.configuration.Containers.Logging.LogUpdateSize,
remoteHosts: remoteHosts,
- remoteHostsViaDNS: Rails.configuration.RemoteClusters["*"]["Proxy"],
- websocketUrl: Rails.configuration.Services["Websocket"]["ExternalURL"].to_s,
- workbenchUrl: Rails.configuration.Services["Workbench1"]["ExternalURL"].to_s,
- keepWebServiceUrl: Rails.configuration.Services["WebDAV"]["ExternalURL"].to_s,
- gitUrl: Rails.configuration.Services["GitHTTP"]["ExternalURL"].to_s,
+ remoteHostsViaDNS: Rails.configuration.RemoteClusters["*"].Proxy,
+ websocketUrl: Rails.configuration.Services.Websocket.ExternalURL.to_s,
+ workbenchUrl: Rails.configuration.Services.Workbench1.ExternalURL.to_s,
+ keepWebServiceUrl: Rails.configuration.Services.WebDAV.ExternalURL.to_s,
+ gitUrl: Rails.configuration.Services.GitHTTP.ExternalURL.to_s,
parameters: {
alt: {
type: "string",
end
end
end
- Rails.configuration.API["DisabledAPIs"].each do |method|
+ Rails.configuration.API.DisabledAPIs.each do |method|
ctrl, action = method.split('.', 2)
discovery[:resources][ctrl][:methods].delete(action.to_sym)
end
def home
respond_to do |f|
f.html do
- if !Rails.configuration.Services["Workbench1"]["ExternalURL"].to_s.empty?
- redirect_to Rails.configuration.Services["Workbench1"]["ExternalURL"]
+ if !Rails.configuration.Services.Workbench1.ExternalURL.to_s.empty?
+ redirect_to Rails.configuration.Services.Workbench1.ExternalURL
else
render_not_found "Oops, this is an API endpoint. You probably want to point your browser to an Arvados Workbench site instead."
end
:first_name => omniauth['info']['first_name'],
:last_name => omniauth['info']['last_name'],
:identity_url => omniauth['info']['identity_url'],
- :is_active => Rails.configuration.Users["NewUsersAreActive"],
+ :is_active => Rails.configuration.Users.NewUsersAreActive,
:owner_uuid => system_user_uuid)
if omniauth['info']['username']
user.set_initial_username(requested: omniauth['info']['username'])
flash[:notice] = 'You have logged off'
return_to = params[:return_to] || root_url
- redirect_to "#{Rails.configuration.Services["SSO"]["ExternalURL"]}/users/sign_out?redirect_uri=#{CGI.escape return_to}"
+ redirect_to "#{Rails.configuration.Services.SSO.ExternalURL}/users/sign_out?redirect_uri=#{CGI.escape return_to}"
end
# login - Just bounce to /auth/joshid. The only purpose of this function is
class AdminNotifier < ActionMailer::Base
include AbstractController::Callbacks
- default from: Rails.configuration.Users["AdminNotifierEmailFrom"]
+ default from: Rails.configuration.Users.AdminNotifierEmailFrom
def new_user(user)
@user = user
- if not Rails.configuration.Users["NewUserNotificationRecipients"].empty? then
- @recipients = Rails.configuration.Users["NewUserNotificationRecipients"]
+ if not Rails.configuration.Users.NewUserNotificationRecipients.empty? then
+ @recipients = Rails.configuration.Users.NewUserNotificationRecipients
logger.info "Sending mail to #{@recipients} about new user #{@user.uuid} (#{@user.full_name} <#{@user.email}>)"
add_to_subject = ''
- if Rails.configuration.Users["AutoSetupNewUsers"]
+ if Rails.configuration.Users.AutoSetupNewUsers
add_to_subject = @user.is_invited ? ' and setup' : ', but not setup'
end
mail(to: @recipients,
- subject: "#{Rails.configuration.Users["EmailSubjectPrefix"]}New user created#{add_to_subject} notification"
+ subject: "#{Rails.configuration.Users.EmailSubjectPrefix}New user created#{add_to_subject} notification"
)
end
end
def new_inactive_user(user)
@user = user
- if not Rails.configuration.Users["NewInactiveUserNotificationRecipients"].empty? then
- @recipients = Rails.configuration.Users["NewInactiveUserNotificationRecipients"]
+ if not Rails.configuration.Users.NewInactiveUserNotificationRecipients.empty? then
+ @recipients = Rails.configuration.Users.NewInactiveUserNotificationRecipients
logger.info "Sending mail to #{@recipients} about new user #{@user.uuid} (#{@user.full_name} <#{@user.email}>)"
mail(to: @recipients,
- subject: "#{Rails.configuration.Users["EmailSubjectPrefix"]}New inactive user notification"
+ subject: "#{Rails.configuration.Users.EmailSubjectPrefix}New inactive user notification"
)
end
end
# SPDX-License-Identifier: AGPL-3.0
class ProfileNotifier < ActionMailer::Base
- default from: Rails.configuration.Users["AdminNotifierEmailFrom"]
+ default from: Rails.configuration.Users.AdminNotifierEmailFrom
def profile_created(user, address)
@user = user
class UserNotifier < ActionMailer::Base
include AbstractController::Callbacks
- default from: Rails.configuration.Users["UserNotifierEmailFrom"]
+ default from: Rails.configuration.Users.UserNotifierEmailFrom
def account_is_setup(user)
@user = user
# [re]validate it.
begin
clnt = HTTPClient.new
- if Rails.configuration.TLS["Insecure"]
+ if Rails.configuration.TLS.Insecure
clnt.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
else
# Use system CA certificates
end
end
- if Rails.configuration.Users["NewUsersAreActive"] ||
+ if Rails.configuration.Users.NewUsersAreActive ||
Rails.configuration.RemoteClusters[remote_user['uuid'][0..4]].andand["ActivateUsers"]
# Update is_active to whatever it is at the remote end
user.is_active = remote_user['is_active']
end
def logged_attributes
- attributes.except(*Rails.configuration.AuditLogs["UnloggedAttributes"])
+ attributes.except(*Rails.configuration.AuditLogs.UnloggedAttributes)
end
def self.full_text_searchable_columns
end
def is_audit_logging_enabled?
- return !(Rails.configuration.AuditLogs["MaxAge"].to_i == 0 &&
- Rails.configuration.AuditLogs["MaxDeleteBatch"].to_i > 0)
+ return !(Rails.configuration.AuditLogs.MaxAge.to_i == 0 &&
+ Rails.configuration.AuditLogs.MaxDeleteBatch.to_i > 0)
end
def log_start_state
timestamp = opts[:expire]
else
timestamp = db_current_time.to_i +
- (opts[:ttl] || Rails.configuration.Collections["BlobSigningTTL"])
+ (opts[:ttl] || Rails.configuration.Collections.BlobSigningTTL)
end
timestamp_hex = timestamp.to_s(16)
# => "53163cb4"
- blob_signature_ttl = Rails.configuration.Collections["BlobSigningTTL"].to_s(16)
+ blob_signature_ttl = Rails.configuration.Collections.BlobSigningTTL.to_s(16)
# Generate a signature.
signature =
- generate_signature((opts[:key] or Rails.configuration.Collections["BlobSigningKey"]),
+ generate_signature((opts[:key] or Rails.configuration.Collections.BlobSigningKey),
blob_hash, opts[:api_token], timestamp_hex, blob_signature_ttl)
blob_locator + '+A' + signature + '@' + timestamp_hex
if timestamp.to_i(16) < (opts[:now] or db_current_time.to_i)
raise Blob::InvalidSignatureError.new 'Signature expiry time has passed.'
end
- blob_signature_ttl = Rails.configuration.Collections["BlobSigningTTL"].to_s(16)
+ blob_signature_ttl = Rails.configuration.Collections.BlobSigningTTL.to_s(16)
my_signature =
- generate_signature((opts[:key] or Rails.configuration.Collections["BlobSigningKey"]),
+ generate_signature((opts[:key] or Rails.configuration.Collections.BlobSigningKey),
blob_hash, opts[:api_token], timestamp, blob_signature_ttl)
if my_signature != given_signature
# Signature provided, but verify_signature did not like it.
logger.warn "Invalid signature on locator #{tok}"
raise ArvadosModel::PermissionDeniedError
- elsif !Rails.configuration.Collections["BlobSigning"]
+ elsif !Rails.configuration.Collections.BlobSigning
# No signature provided, but we are running in insecure mode.
logger.debug "Missing signature on locator #{tok} ignored"
elsif Blob.new(tok).empty?
end
def should_preserve_version?
- return false unless (Rails.configuration.Collections["CollectionVersioning"] && versionable_updates?(self.changes.keys))
+ return false unless (Rails.configuration.Collections.CollectionVersioning && versionable_updates?(self.changes.keys))
- idle_threshold = Rails.configuration.Collections["PreserveVersionIfIdle"]
+ idle_threshold = Rails.configuration.Collections.PreserveVersionIfIdle
if !self.preserve_version_was &&
(idle_threshold < 0 ||
(idle_threshold > 0 && self.modified_at_was > db_current_time-idle_threshold.seconds))
return manifest_text
else
token = Thread.current[:token]
- exp = [db_current_time.to_i + Rails.configuration.Collections["BlobSigningTTL"],
+ exp = [db_current_time.to_i + Rails.configuration.Collections.BlobSigningTTL,
trash_at].compact.map(&:to_i).min
self.class.sign_manifest manifest_text, token, exp
end
def self.sign_manifest manifest, token, exp=nil
if exp.nil?
- exp = db_current_time.to_i + Rails.configuration.Collections["BlobSigningTTL"]
+ exp = db_current_time.to_i + Rails.configuration.Collections.BlobSigningTTL
end
signing_opts = {
api_token: token,
#
# If filter_compatible_format is true (the default), only return image
# collections which are support by the installation as indicated by
- # Rails.configuration.Containers["SupportedDockerImageFormats"]. Will follow
+ # Rails.configuration.Containers.SupportedDockerImageFormats. Will follow
# 'docker_image_migration' links if search_term resolves to an incompatible
# image, but an equivalent compatible image is available.
def self.find_all_for_docker_image(search_term, search_tag=nil, readers=nil, filter_compatible_format: true)
joins("JOIN collections ON links.head_uuid = collections.uuid").
order("links.created_at DESC")
- docker_image_formats = Rails.configuration.Containers["SupportedDockerImageFormats"]
+ docker_image_formats = Rails.configuration.Containers.SupportedDockerImageFormats
if (docker_image_formats.include? 'v1' and
docker_image_formats.include? 'v2') or filter_compatible_format == false
unless src_gitdir
raise ArgumentError.new "no local repository for #{repo_name}"
end
- dst_gitdir = Rails.configuration.Containers["JobsAPI"]["GitInternalDir"]
+ dst_gitdir = Rails.configuration.Containers.JobsAPI.GitInternalDir
begin
commit_in_dst = must_git(dst_gitdir, "log -n1 --format=%H #{sha1.shellescape}^{commit}").strip
protected
def ask_git_whether_is
- @gitdirbase = Rails.configuration.Git["Repositories"]
+ @gitdirbase = Rails.configuration.Git.Repositories
self.is = nil
Dir.foreach @gitdirbase do |repo|
next if repo.match(/^\./)
rc = {}
defaults = {
'keep_cache_ram' =>
- Rails.configuration.Containers["DefaultKeepCacheRAM"],
+ Rails.configuration.Containers.DefaultKeepCacheRAM,
}
defaults.merge(runtime_constraints).each do |k, v|
if v.is_a? Array
transaction do
reload(lock: 'FOR UPDATE')
check_unlock_fail
- if self.lock_count < Rails.configuration.Containers["MaxDispatchAttempts"]
+ if self.lock_count < Rails.configuration.Containers.MaxDispatchAttempts
update_attributes!(state: Queued)
else
update_attributes!(state: Cancelled,
self.mounts ||= {}
self.secret_mounts ||= {}
self.cwd ||= "."
- self.container_count_max ||= Rails.configuration.Containers["MaxComputeVMs"]
+ self.container_count_max ||= Rails.configuration.Containers.MaxComputeVMs
self.scheduling_parameters ||= {}
self.output_ttl ||= 0
self.priority ||= 0
if self.state == Committed
# If preemptible instances (eg: AWS Spot Instances) are allowed,
# ask them on child containers by default.
- if Rails.configuration.Containers["UsePreemptibleInstances"] and !c.nil? and
+ if Rails.configuration.Containers.UsePreemptibleInstances and !c.nil? and
self.scheduling_parameters['preemptible'].nil?
self.scheduling_parameters['preemptible'] = true
end
scheduling_parameters['partitions'].size)
errors.add :scheduling_parameters, "partitions must be an array of strings"
end
- if !Rails.configuration.Containers["UsePreemptibleInstances"] and scheduling_parameters['preemptible']
+ if !Rails.configuration.Containers.UsePreemptibleInstances and scheduling_parameters['preemptible']
errors.add :scheduling_parameters, "preemptible instances are not allowed"
end
if scheduling_parameters.include? 'max_run_time' and
log_reuse_info { "job #{j.uuid} has nil output" }
elsif j.log.nil?
log_reuse_info { "job #{j.uuid} has nil log" }
- elsif Rails.configuration.Containers["JobsAPI"]["ReuseJobIfOutputsDiffer"]
+ elsif Rails.configuration.Containers.JobsAPI.ReuseJobIfOutputsDiffer
if !Collection.readable_by(current_user).find_by_portable_data_hash(j.output)
# Ignore: keep looking for an incomplete job or one whose
# output is readable.
end
def find_docker_image_locator
- if runtime_constraints.is_a? Hash and Rails.configuration.Containers["JobsAPI"]["DefaultDockerImage"] != ""
+ if runtime_constraints.is_a? Hash and Rails.configuration.Containers.JobsAPI.DefaultDockerImage != ""
runtime_constraints['docker_image'] ||=
- Rails.configuration.Containers["JobsAPI"]["DefaultDockerImage"]
+ Rails.configuration.Containers.JobsAPI.DefaultDockerImage
end
resolve_runtime_constraint("docker_image",
def trigger_crunch_dispatch_if_cancelled
if @need_crunch_dispatch_trigger
- File.open(Rails.configuration.Containers["JobsAPI"]["CrunchRefreshTrigger"], 'wb') do
+ File.open(Rails.configuration.Containers.JobsAPI.CrunchRefreshTrigger, 'wb') do
# That's all, just create/touch a file for crunch-job to see.
end
end
api_accessible :superuser, :extend => :user do |t|
t.add :first_ping_at
t.add :info
- t.add lambda { |x| Rails.configuration.Containers["SLURM"]["Managed"]["ComputeNodeNameservers"] }, :as => :nameservers
+ t.add lambda { |x| Rails.configuration.Containers.SLURM.Managed.ComputeNodeNameservers }, :as => :nameservers
end
after_initialize do
end
def domain
- super || Rails.configuration.Containers["SLURM"]["Managed"]["ComputeNodeDomain"]
+ super || Rails.configuration.Containers.SLURM.Managed.ComputeNodeDomain
end
def api_job_uuid
protected
def assign_hostname
- if self.hostname.nil? and Rails.configuration.Containers["SLURM"]["Managed"]["AssignNodeHostname"]
+ if self.hostname.nil? and Rails.configuration.Containers.SLURM.Managed.AssignNodeHostname
self.hostname = self.class.hostname_for_slot(self.slot_number)
end
end
# query label:
'Node.available_slot_number',
# [col_id, val] for $1 vars:
- [[nil, Rails.configuration.Containers["MaxComputeVMs"]]],
+ [[nil, Rails.configuration.Containers.MaxComputeVMs]],
).rows.first.andand.first
end
ptr_domain: ptr_domain,
}
- if (!Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"].to_s.empty? and
- !Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfTemplate"].to_s.empty?)
+ if (!Rails.configuration.Containers.SLURM.Managed.DNSServerConfDir.to_s.empty? and
+ !Rails.configuration.Containers.SLURM.Managed.DNSServerConfTemplate.to_s.empty?)
tmpfile = nil
begin
begin
- template = IO.read(Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfTemplate"])
+ template = IO.read(Rails.configuration.Containers.SLURM.Managed.DNSServerConfTemplate)
rescue IOError, SystemCallError => e
- logger.error "Reading #{Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfTemplate"]}: #{e.message}"
+ logger.error "Reading #{Rails.configuration.Containers.SLURM.Managed.DNSServerConfTemplate}: #{e.message}"
raise
end
- hostfile = File.join Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"], "#{hostname}.conf"
+ hostfile = File.join Rails.configuration.Containers.SLURM.Managed.DNSServerConfDir, "#{hostname}.conf"
Tempfile.open(["#{hostname}-", ".conf.tmp"],
- Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"]) do |f|
+ Rails.configuration.Containers.SLURM.Managed.DNSServerConfDir) do |f|
tmpfile = f.path
f.puts template % template_vars
end
end
end
- if !Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerUpdateCommand"].empty?
- cmd = Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerUpdateCommand"] % template_vars
+ if !Rails.configuration.Containers.SLURM.Managed.DNSServerUpdateCommand.empty?
+ cmd = Rails.configuration.Containers.SLURM.Managed.DNSServerUpdateCommand % template_vars
if not system cmd
logger.error "dns_server_update_command #{cmd.inspect} failed: #{$?}"
ok = false
end
end
- if (!Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"].to_s.empty? and
- !Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerReloadCommand"].to_s.empty?)
- restartfile = File.join(Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"], 'restart.txt')
+ if (!Rails.configuration.Containers.SLURM.Managed.DNSServerConfDir.to_s.empty? and
+ !Rails.configuration.Containers.SLURM.Managed.DNSServerReloadCommand.to_s.empty?)
+ restartfile = File.join(Rails.configuration.Containers.SLURM.Managed.DNSServerConfDir, 'restart.txt')
begin
File.open(restartfile, 'w') do |f|
# Typically, this is used to trigger a dns server restart
- f.puts Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerReloadCommand"]
+ f.puts Rails.configuration.Containers.SLURM.Managed.DNSServerReloadCommand
end
rescue IOError, SystemCallError => e
logger.error "Unable to write #{restartfile}: #{e.message}"
end
def self.hostname_for_slot(slot_number)
- config = Rails.configuration.Containers["SLURM"]["Managed"]["AssignNodeHostname"]
+ config = Rails.configuration.Containers.SLURM.Managed.AssignNodeHostname
return nil if !config
# At startup, make sure all DNS entries exist. Otherwise, slurmctld
# will refuse to start.
- if (!Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"].to_s.empty? and
- !Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfTemplate"].to_s.empty? and
- !Rails.configuration.Containers["SLURM"]["Managed"]["AssignNodeHostname"].empty?)
+ if (!Rails.configuration.Containers.SLURM.Managed.DNSServerConfDir.to_s.empty? and
+ !Rails.configuration.Containers.SLURM.Managed.DNSServerConfTemplate.to_s.empty? and
+ !Rails.configuration.Containers.SLURM.Managed.AssignNodeHostname.empty?)
- (0..Rails.configuration.Containers["MaxComputeVMs"]-1).each do |slot_number|
+ (0..Rails.configuration.Containers.MaxComputeVMs-1).each do |slot_number|
hostname = hostname_for_slot(slot_number)
- hostfile = File.join Rails.configuration.Containers["SLURM"]["Managed"]["DNSServerConfDir"], "#{hostname}.conf"
+ hostfile = File.join Rails.configuration.Containers.SLURM.Managed.DNSServerConfDir, "#{hostname}.conf"
if !File.exist? hostfile
n = Node.where(:slot_number => slot_number).first
if n.nil? or n.ip_address.nil?
# prefers bare repositories over checkouts.
[["%s.git"], ["%s", ".git"]].each do |repo_base, *join_args|
[:uuid, :name].each do |path_attr|
- git_dir = File.join(Rails.configuration.Git["Repositories"],
+ git_dir = File.join(Rails.configuration.Git.Repositories,
repo_base % send(path_attr), *join_args)
return git_dir if File.exist?(git_dir)
end
end
def ssh_clone_url
- _clone_url Rails.configuration.Services["GitSSH"].andand["ExternalURL"], 'ssh://git@git.%s.arvadosapi.com'
+ _clone_url Rails.configuration.Services.GitSSH.andand.ExternalURL, 'ssh://git@git.%s.arvadosapi.com'
end
def https_clone_url
- _clone_url Rails.configuration.Services["GitHTTP"].andand["ExternalURL"], 'https://git.%s.arvadosapi.com/'
+ _clone_url Rails.configuration.Services.GitHTTP.andand.ExternalURL, 'https://git.%s.arvadosapi.com/'
end
def _clone_url config_var, default_base_fmt
after_create :add_system_group_permission_link
after_create :invalidate_permissions_cache
after_create :auto_setup_new_user, :if => Proc.new { |user|
- Rails.configuration.Users["AutoSetupNewUsers"] and
+ Rails.configuration.Users.AutoSetupNewUsers and
(user.uuid != system_user_uuid) and
(user.uuid != anonymous_user_uuid)
}
def is_invited
!!(self.is_active ||
- Rails.configuration.Users["NewUsersAreActive"] ||
+ Rails.configuration.Users.NewUsersAreActive ||
self.groups_i_can(:read).select { |x| x.match(/-f+$/) }.first)
end
current_user.andand.is_admin or
(self == current_user &&
self.redirect_to_user_uuid.nil? &&
- self.is_active == Rails.configuration.Users["NewUsersAreActive"])
+ self.is_active == Rails.configuration.Users.NewUsersAreActive)
end
def check_auto_admin
return if self.uuid.end_with?('anonymouspublic')
if (User.where("email = ?",self.email).where(:is_admin => true).count == 0 and
- !Rails.configuration.Users["AutoAdminUserWithEmail"].empty? and self.email == Rails.configuration.Users["AutoAdminUserWithEmail"]) or
+ !Rails.configuration.Users.AutoAdminUserWithEmail.empty? and self.email == Rails.configuration.Users["AutoAdminUserWithEmail"]) or
(User.where("uuid not like '%-000000000000000'").where(:is_admin => true).count == 0 and
- Rails.configuration.Users["AutoAdminFirstUser"])
+ Rails.configuration.Users.AutoAdminFirstUser)
self.is_admin = true
self.is_active = true
end
quoted_name = self.class.connection.quote_string(basename)
next_username = basename
next_suffix = 1
- while Rails.configuration.Users["AutoSetupUsernameBlacklist"].include?(next_username)
+ while Rails.configuration.Users.AutoSetupUsernameBlacklist.include?(next_username)
next_suffix += 1
next_username = "%s%i" % [basename, next_suffix]
end
def auto_setup_new_user
setup(openid_prefix: Rails.configuration.default_openid_prefix)
if username
- create_vm_login_permission_link(Rails.configuration.Users["AutoSetupNewUsersWithVmUUID"],
+ create_vm_login_permission_link(Rails.configuration.Users.AutoSetupNewUsersWithVmUUID,
username)
repo_name = "#{username}/#{username}"
- if Rails.configuration.Users["AutoSetupNewUsersWithRepository"] and
+ if Rails.configuration.Users.AutoSetupNewUsersWithRepository and
Repository.where(name: repo_name).first.nil?
repo = Repository.create!(name: repo_name, owner_uuid: uuid)
Link.create!(tail_uuid: uuid, head_uuid: repo.uuid,
def send_profile_created_notification
if self.prefs_changed?
if self.prefs_was.andand.empty? || !self.prefs_was.andand['profile']
- profile_notification_address = Rails.configuration.Users["UserProfileNotificationAddress"]
+ profile_notification_address = Rails.configuration.Users.UserProfileNotificationAddress
ProfileNotifier.profile_created(self, profile_notification_address).deliver_now if profile_notification_address
end
end
<%= @user.full_name %> <<%= @user.email %>>
-<% if Rails.configuration.Services["Workbench1"]["ExternalURL"] -%>
+<% if Rails.configuration.Services.Workbench1.ExternalURL -%>
Please see workbench for more information:
- <%= Rails.configuration.Services["Workbench1"]["ExternalURL"] %>
+ <%= Rails.configuration.Services.Workbench1.ExternalURL %>
<% end -%>
Thanks,
<%
add_to_message = ''
- if Rails.configuration.Users["AutoSetupNewUsers"]
+ if Rails.configuration.Users.AutoSetupNewUsers
add_to_message = @user.is_invited ? ' and setup' : ', but not setup'
end
%>
This user is <%= @user.is_active ? '' : 'NOT ' %>active.
-<% if Rails.configuration.Services["Workbench1"]["ExternalURL"] -%>
+<% if Rails.configuration.Services.Workbench1.ExternalURL -%>
Please see workbench for more information:
- <%= Rails.configuration.Services["Workbench1"]["ExternalURL"] %>
+ <%= Rails.configuration.Services.Workbench1.ExternalURL %>
<% end -%>
Thanks,
Hi there,
<% end -%>
-Your Arvados shell account has been set up. Please visit the virtual machines page <% if Rails.configuration.Services["Workbench1"]["ExternalURL"] %>at
+Your Arvados shell account has been set up. Please visit the virtual machines page <% if Rails.configuration.Services.Workbench1.ExternalURL %>at
- <%= Rails.configuration.Services["Workbench1"]["ExternalURL"] %><%= "/" if !Rails.configuration.Services["Workbench1"]["ExternalURL"].to_s.end_with?("/") %>users/<%= @user.uuid%>/virtual_machines <% else %><% end %>
+ <%= Rails.configuration.Services.Workbench1.ExternalURL %><%= "/" if !Rails.configuration.Services.Workbench1.ExternalURL.to_s.end_with?("/") %>users/<%= @user.uuid%>/virtual_machines <% else %><% end %>
for connection instructions.
('20190214214814'),
('20190322174136');
+
end
def self.tidy_in_background
- max_age = Rails.configuration.AuditLogs["MaxAge"]
- max_batch = Rails.configuration.AuditLogs["MaxDeleteBatch"]
+ max_age = Rails.configuration.AuditLogs.MaxAge
+ max_batch = Rails.configuration.AuditLogs.MaxDeleteBatch
return if max_age <= 0 || max_batch <= 0
exp = (max_age/14).seconds
@cgroup_root = ENV['CRUNCH_CGROUP_ROOT']
@srun_sync_timeout = ENV['CRUNCH_SRUN_SYNC_TIMEOUT']
- @arvados_internal = Rails.configuration.Containers["JobsAPI"]["GitInternalDir"]
+ @arvados_internal = Rails.configuration.Containers.JobsAPI.GitInternalDir
if not File.exist? @arvados_internal
$stderr.puts `mkdir -p #{@arvados_internal.shellescape} && git init --bare #{@arvados_internal.shellescape}`
raise "No internal git repository available" unless ($? == 0)
end
- @repo_root = Rails.configuration.Git["Repositories"]
+ @repo_root = Rails.configuration.Git.Repositories
@arvados_repo_path = Repository.where(name: "arvados").first.server_path
@authorizations = {}
@did_recently = {}
end
def update_node_status
- return unless Rails.configuration.Containers["JobsAPI"]["CrunchJobWrapper"].to_s.match(/^slurm/)
+ return unless Rails.configuration.Containers.JobsAPI.CrunchJobWrapper.to_s.match(/^slurm/)
slurm_status.each_pair do |hostname, slurmdata|
next if @node_state[hostname] == slurmdata
begin
next if @running[job.uuid]
cmd_args = nil
- case Rails.configuration.Containers["JobsAPI"]["CrunchJobWrapper"]
+ case Rails.configuration.Containers.JobsAPI.CrunchJobWrapper
when "none"
if @running.size > 0
# Don't run more than one at a time.
"--job-name=#{job.uuid}",
"--nodelist=#{nodelist.join(',')}"]
else
- raise "Unknown crunch_job_wrapper: #{Rails.configuration.Containers["JobsAPI"]["CrunchJobWrapper"]}"
+ raise "Unknown crunch_job_wrapper: #{Rails.configuration.Containers.JobsAPI.CrunchJobWrapper}"
end
cmd_args = sudo_preface + cmd_args
bytes_logged: 0,
events_logged: 0,
log_throttle_is_open: true,
- log_throttle_reset_time: Time.now + Rails.configuration.Containers["Logging"]["LogThrottlePeriod"],
+ log_throttle_reset_time: Time.now + Rails.configuration.Containers.Logging.LogThrottlePeriod,
log_throttle_bytes_so_far: 0,
log_throttle_lines_so_far: 0,
log_throttle_bytes_skipped: 0,
matches = line.match(/^\S+ \S+ \d+ \d+ stderr (.*)/)
if matches and matches[1] and matches[1].start_with?('[...]') and matches[1].end_with?('[...]')
partial_line = true
- if Time.now > running_job[:log_throttle_partial_line_last_at] + Rails.configuration.Containers["Logging"]["LogPartialLineThrottlePeriod"]
+ if Time.now > running_job[:log_throttle_partial_line_last_at] + Rails.configuration.Containers.Logging.LogPartialLineThrottlePeriod
running_job[:log_throttle_partial_line_last_at] = Time.now
else
skip_counts = true
end
if (running_job[:bytes_logged] >
- Rails.configuration.Containers["Logging"]["LimitLogBytesPerJob"])
- message = "Exceeded log limit #{Rails.configuration.Containers["Logging"]["LimitLogBytesPerJob"]} bytes (LimitLogBytesPerJob). Log will be truncated."
+ Rails.configuration.Containers.Logging.LimitLogBytesPerJob)
+ message = "Exceeded log limit #{Rails.configuration.Containers.Logging.LimitLogBytesPerJob} bytes (LimitLogBytesPerJob). Log will be truncated."
running_job[:log_throttle_reset_time] = Time.now + 100.years
running_job[:log_throttle_is_open] = false
elsif (running_job[:log_throttle_bytes_so_far] >
- Rails.configuration.Containers["Logging"]["LogThrottleBytes"])
+ Rails.configuration.Containers.Logging.LogThrottleBytes)
remaining_time = running_job[:log_throttle_reset_time] - Time.now
- message = "Exceeded rate #{Rails.configuration.Containers["Logging"]["LogThrottleBytes"]} bytes per #{Rails.configuration.Containers["Logging"]["LogThrottlePeriod"]} seconds (LogThrottleBytes). Logging will be silenced for the next #{remaining_time.round} seconds."
+ message = "Exceeded rate #{Rails.configuration.Containers.Logging.LogThrottleBytes} bytes per #{Rails.configuration.Containers.Logging.LogThrottlePeriod} seconds (LogThrottleBytes). Logging will be silenced for the next #{remaining_time.round} seconds."
running_job[:log_throttle_is_open] = false
elsif (running_job[:log_throttle_lines_so_far] >
- Rails.configuration.Containers["Logging"]["LogThrottleLines"])
+ Rails.configuration.Containers.Logging.LogThrottleLines)
remaining_time = running_job[:log_throttle_reset_time] - Time.now
- message = "Exceeded rate #{Rails.configuration.Containers["Logging"]["LogThrottleLines"]} lines per #{Rails.configuration.Containers["Logging"]["LogThrottlePeriod"]} seconds (LogThrottleLines), logging will be silenced for the next #{remaining_time.round} seconds."
+ message = "Exceeded rate #{Rails.configuration.Containers.Logging.LogThrottleLines} lines per #{Rails.configuration.Containers.Logging.LogThrottlePeriod} seconds (LogThrottleLines), logging will be silenced for the next #{remaining_time.round} seconds."
running_job[:log_throttle_is_open] = false
elsif partial_line and running_job[:log_throttle_first_partial_line]
running_job[:log_throttle_first_partial_line] = false
- message = "Rate-limiting partial segments of long lines to one every #{Rails.configuration.Containers["Logging"]["LogPartialLineThrottlePeriod"]} seconds."
+ message = "Rate-limiting partial segments of long lines to one every #{Rails.configuration.Containers.Logging.LogPartialLineThrottlePeriod} seconds."
end
end
j[:stderr_buf_to_flush] << "#{LogTime.now} #{message}\n"
end
- j[:log_throttle_reset_time] = now + Rails.configuration.Containers["Logging"]["LogThrottlePeriod"]
+ j[:log_throttle_reset_time] = now + Rails.configuration.Containers.Logging.LogThrottlePeriod
j[:log_throttle_bytes_so_far] = 0
j[:log_throttle_lines_so_far] = 0
j[:log_throttle_bytes_skipped] = 0
bufend = ''
streambuf.each_line do |line|
if not line.end_with? $/
- if line.size > Rails.configuration.Containers["Logging"]["LogThrottleBytes"]
+ if line.size > Rails.configuration.Containers.Logging.LogThrottleBytes
# Without a limit here, we'll use 2x an arbitrary amount
# of memory, and waste a lot of time copying strings
# around, all without providing any feedback to anyone
# This is how crunch-job child procs know where the "refresh"
# trigger file is
- ENV["CRUNCH_REFRESH_TRIGGER"] = Rails.configuration.Containers["JobsAPI"]["CrunchRefreshTrigger"]
+ ENV["CRUNCH_REFRESH_TRIGGER"] = Rails.configuration.Containers.JobsAPI.CrunchRefreshTrigger
# If salloc can't allocate resources immediately, make it use our
# temporary failure exit code. This ensures crunch-dispatch won't
end
def sudo_preface
- return [] if not Rails.configuration.Containers["JobsAPI"]["CrunchJobUser"]
+ return [] if not Rails.configuration.Containers.JobsAPI.CrunchJobUser
["sudo", "-E", "-u",
- Rails.configuration.Containers["JobsAPI"]["CrunchJobUser"],
+ Rails.configuration.Containers.JobsAPI.CrunchJobUser,
"LD_LIBRARY_PATH=#{ENV['LD_LIBRARY_PATH']}",
"PATH=#{ENV['PATH']}",
"PERLLIB=#{ENV['PERLLIB']}",
# Send out to log event if buffer size exceeds the bytes per event or if
# it has been at least crunch_log_seconds_between_events seconds since
# the last flush.
- if running_job[:stderr_buf_to_flush].size > Rails.configuration.Containers["Logging"]["LogBytesPerEvent"] or
- (Time.now - running_job[:stderr_flushed_at]) >= Rails.configuration.Containers["Logging"]["LogSecondsBetweenEvents"]
+ if running_job[:stderr_buf_to_flush].size > Rails.configuration.Containers.Logging.LogBytesPerEvent or
+ (Time.now - running_job[:stderr_flushed_at]) >= Rails.configuration.Containers.Logging.LogSecondsBetweenEvents
begin
log = Log.new(object_uuid: running_job[:job].uuid,
event_type: 'stderr',
# An array of job_uuids in squeue
def squeue_jobs
- if Rails.configuration.Containers["JobsAPI"]["CrunchJobWrapper"] == "slurm_immediate"
+ if Rails.configuration.Containers.JobsAPI.CrunchJobWrapper == "slurm_immediate"
p = IO.popen(['squeue', '-a', '-h', '-o', '%j'])
begin
p.readlines.map {|line| line.strip}
"job_tasks.show"]
def check_enable_legacy_jobs_api
- if Rails.configuration.Containers["JobsAPI"]["Enable"] == "false" ||
- (Rails.configuration.Containers["JobsAPI"]["Enable"] == "auto" &&
+ if Rails.configuration.Containers.JobsAPI.Enable == "false" ||
+ (Rails.configuration.Containers.JobsAPI.Enable == "auto" &&
Job.count == 0)
- Rails.configuration.API["DisabledAPIs"] += Disable_jobs_api_method_list
+ Rails.configuration.API.DisabledAPIs += Disable_jobs_api_method_list
end
end
options.client_options[:site] = options[:custom_provider_url]
options.client_options[:authorize_url] = "#{options[:custom_provider_url]}/auth/josh_id/authorize"
options.client_options[:access_token_url] = "#{options[:custom_provider_url]}/auth/josh_id/access_token"
- if Rails.configuration.TLS["Insecure"]
+ if Rails.configuration.TLS.Insecure
options.client_options[:ssl] = {verify_mode: OpenSSL::SSL::VERIFY_NONE}
end
::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options))
raise ArgumentError.new("Invalid value for limit parameter")
end
@limit = [params[:limit].to_i,
- Rails.configuration.API["MaxItemsPerResponse"]].min
+ Rails.configuration.API.MaxItemsPerResponse].min
else
@limit = DEFAULT_LIMIT
end
# doing expensive things like database queries, and we want to skip
# those when logging is disabled.
def log_reuse_info(candidates=nil)
- if Rails.configuration.Containers["LogReuseDecisions"]
+ if Rails.configuration.Containers.LogReuseDecisions
msg = yield
if !candidates.nil?
msg = "have #{candidates.count} candidates " + msg
end
def refresh_permission_view(async=false)
- if async and Rails.configuration.API["AsyncPermissionsUpdateInterval"] > 0
- exp = Rails.configuration.API["AsyncPermissionsUpdateInterval"].seconds
+ if async and Rails.configuration.API.AsyncPermissionsUpdateInterval > 0
+ exp = Rails.configuration.API.AsyncPermissionsUpdateInterval.seconds
need = false
Rails.cache.fetch('AsyncRefreshPermissionView', expires_in: exp) do
need = true
end
def self.sweep_if_stale
- return if Rails.configuration.Collections["TrashSweepInterval"] <= 0
- exp = Rails.configuration.Collections["TrashSweepInterval"].seconds
+ return if Rails.configuration.Collections.TrashSweepInterval <= 0
+ exp = Rails.configuration.Collections.TrashSweepInterval.seconds
need = false
Rails.cache.fetch('SweepTrashedObjects', expires_in: exp) do
need = true
end
end
# default_trash_lifetime cannot be less than 24 hours
- if Rails.configuration.Collections["DefaultTrashLifetime"] < 86400 then
- raise "default_trash_lifetime is %d, must be at least 86400" % Rails.configuration.Collections["DefaultTrashLifetime"]
+ if Rails.configuration.Collections.DefaultTrashLifetime < 86400 then
+ raise "default_trash_lifetime is %d, must be at least 86400" % Rails.configuration.Collections.DefaultTrashLifetime
end
end
end
desc "Remove old container log entries from the logs table"
task delete_old_container_logs: :environment do
- delete_sql = "DELETE FROM logs WHERE id in (SELECT logs.id FROM logs JOIN containers ON logs.object_uuid = containers.uuid WHERE event_type IN ('stdout', 'stderr', 'arv-mount', 'crunch-run', 'crunchstat') AND containers.log IS NOT NULL AND clock_timestamp() - containers.finished_at > interval '#{Rails.configuration.Containers["Logging"]["MaxAge"]} seconds')"
+ delete_sql = "DELETE FROM logs WHERE id in (SELECT logs.id FROM logs JOIN containers ON logs.object_uuid = containers.uuid WHERE event_type IN ('stdout', 'stderr', 'arv-mount', 'crunch-run', 'crunchstat') AND containers.log IS NOT NULL AND clock_timestamp() - containers.finished_at > interval '#{Rails.configuration.Containers.Logging.MaxAge} seconds')"
ActiveRecord::Base.connection.execute(delete_sql)
end
namespace :db do
desc "Remove old job stderr entries from the logs table"
task delete_old_job_logs: :environment do
- delete_sql = "DELETE FROM logs WHERE id in (SELECT logs.id FROM logs JOIN jobs ON logs.object_uuid = jobs.uuid WHERE event_type = 'stderr' AND jobs.log IS NOT NULL AND clock_timestamp() - jobs.finished_at > interval '#{Rails.configuration.Containers["Logging"]["MaxAge"]} seconds')"
+ delete_sql = "DELETE FROM logs WHERE id in (SELECT logs.id FROM logs JOIN jobs ON logs.object_uuid = jobs.uuid WHERE event_type = 'stderr' AND jobs.log IS NOT NULL AND clock_timestamp() - jobs.finished_at > interval '#{Rails.configuration.Containers.Logging.MaxAge} seconds')"
ActiveRecord::Base.connection.execute(delete_sql)
end
if trash_at.nil?
self.delete_at = nil
else
- self.delete_at = trash_at + Rails.configuration.Collections["DefaultTrashLifetime"].seconds
+ self.delete_at = trash_at + Rails.configuration.Collections.DefaultTrashLifetime.seconds
end
elsif !trash_at || !delete_at || trash_at > delete_at
# Not trash, or bogus arguments? Just validate in
earliest_delete = [
@validation_timestamp,
trash_at_was,
- ].compact.min + Rails.configuration.Collections["BlobSigningTTL"].seconds
+ ].compact.min + Rails.configuration.Collections.BlobSigningTTL.seconds
# The previous value of delete_at is also an upper bound on the
# longest-lived permission token. For example, if TTL=14,
@object.update_attributes!(trash_at: db_current_time)
end
earliest_delete = (@object.trash_at +
- Rails.configuration.Collections["BlobSigningTTL"].seconds)
+ Rails.configuration.Collections.BlobSigningTTL.seconds)
if @object.delete_at > earliest_delete
@object.update_attributes!(delete_at: earliest_delete)
end