Page MenuHomeGRNET

No OneTemporary

File Metadata

Created
Sun, May 18, 9:00 AM
diff --git a/app/models/configuration_setting.rb b/app/models/configuration_setting.rb
index 2554fa6..c3215b7 100644
--- a/app/models/configuration_setting.rb
+++ b/app/models/configuration_setting.rb
@@ -1,112 +1,119 @@
# ConfigurationSetting class describes a model that keeps the current Bacula
# configuration.
#
# It has some hard coded settings as defaults.
# Archiving's admins can enter new settings concerning:
#
# * jobs
# * clients
#
# and override the default ones.
#
# ConfigurationSetting is supposed to have only one record in persisted in the database
# which will hold the altered configuration as a patch to the defaults.
# Admins can reset this change at any time.
class ConfigurationSetting < ActiveRecord::Base
establish_connection ARCHIVING_CONF
serialize :job, JSON
serialize :client, JSON
serialize :pool, JSON
JOB = {
storage: :File,
pool: Archiving.settings[:default_pool],
messages: :Standard,
priority: 10,
:'Write Bootstrap' => '"/var/lib/bacula/%c.bsr"'
}
CLIENT = {
catalog: 'MyCatalog',
file_retention: 60,
file_retention_period_type: 'days',
job_retention: 180,
job_retention_period_type: 'days',
autoprune: 'yes',
quota: Archiving.settings[:client_quota]
}
POOL = {
full: Archiving.settings[:default_pool],
differential: Archiving.settings[:default_pool],
incremental: Archiving.settings[:default_pool]
}
RETENTION_PERIODS = %w{seconds minutes hours days weeks months quarters years}
AUTOPRUNE_OPTIONS = ['yes', 'no']
# Fetches the current configuration for jobs.
#
# The current configuration is the last submitted record, patched to the default
# settings.
# If there is no record, the default settings are returned
#
# @return [Hash] with settings
def self.current_job_settings
(last || new).job.symbolize_keys.reverse_merge(JOB.dup)
end
# Fetches the current configuration for clients.
#
# The current configuration is the last submitted record, patched to the default
# settings.
# If there is no record, the default settings are returned
#
# @return [Hash] with settings
def self.current_client_settings
(last || new).client.symbolize_keys.reverse_merge(CLIENT.dup)
end
# Fetches the current configuration for pools.
#
# The current configuration is the last submitted record, patched to the default
# settings.
# If there is no record, the default settings are returned
#
# @return [Hash] with settings
def self.current_pool_settings
(last || new).pool.symbolize_keys.reverse_merge(POOL.dup)
end
+ # Fetches the provided client size quota
+ #
+ # @return [Integer] bytes space quota per client
+ def self.client_quota
+ current_client_settings[:quota]
+ end
+
# Fetches the record's configuration for jobs.
#
# The configuration is the record's configuration patched to the default
# settings.
#
# @return [Hash] with settings
def current_job_settings
job.symbolize_keys.reverse_merge(JOB.dup)
end
# Fetches the record's configuration for clients.
#
# The configuration is the record's configuration patched to the default
# settings.
#
# @return [Hash] with settings
def current_client_settings
client.symbolize_keys.reverse_merge(CLIENT.dup)
end
# Fetches the record's configuration for pools.
#
# The configuration is the record's configuration patched to the default
# settings.
#
# @return [Hash] with settings
def current_pool_settings
pool.symbolize_keys.reverse_merge(POOL.dup)
end
end
diff --git a/config/bacula.yml.sample b/config/bacula.yml.sample
index 5ed1109..f7ab735 100644
--- a/config/bacula.yml.sample
+++ b/config/bacula.yml.sample
@@ -1,7 +1,9 @@
development:
director: ser-baculas-dir
pool: Default
+ quota_checker: /etc/bacula/quota_checker
production:
director: bacula-dir-edet4-dir'
pool: Default
+ quota_checker: /etc/bacula/quota_checker
diff --git a/config/initializers/00_settings.rb b/config/initializers/00_settings.rb
index f4cd308..e213d1f 100644
--- a/config/initializers/00_settings.rb
+++ b/config/initializers/00_settings.rb
@@ -1,18 +1,18 @@
-Archiving.settings director_name: YAML.load_file(Rails.root.join('config', 'bacula.yml'))[Rails.env].
- symbolize_keys[:director]
-Archiving.settings default_pool: YAML.load_file(Rails.root.join('config', 'bacula.yml'))[Rails.env].
- symbolize_keys[:pool]
+bacula_yml = YAML.load_file(Rails.root.join('config', 'bacula.yml'))[Rails.env].symbolize_keys
+Archiving.settings director_name: bacula_yml[:director]
+Archiving.settings default_pool: bacula_yml[:pool]
+Archiving.settings quota_checker: bacula_yml[:quota_checker]
Archiving.settings vima_oauth_enabled: true
Archiving.settings institutional_authentication_enabled: true
Archiving.settings okeanos_authentication_enabled: false
Archiving.settings default_sender: 'admin@archiving.grnet.gr'
Archiving.settings admin_email: 'admin@archiving.grnet.gr'
Archiving.settings temp_db_retention: 3.days
Archiving.settings skip_host_fetch_time_period: 1.month
Archiving.settings mail_settings: YAML::load(File.open("#{Rails.root}/config/mailer.yml"))[Rails.env].symbolize_keys
Archiving.settings client_quota: 100.megabytes

Event Timeline