Module: RDSBackup
- Defined in:
- lib/rds_backup_service/rds_backup_service.rb,
lib/rds_backup_service/config.rb,
lib/rds_backup_service/service.rb,
lib/rds_backup_service/version.rb,
lib/rds_backup_service/model/email.rb,
lib/rds_backup_service/model/backup_job.rb,
lib/rds_backup_service/model/delayed_job.rb
Overview
The top-level project module. Contains some static helper methods.
Defined Under Namespace
Modules: Config Classes: DelayedJob, Email, Job, Service
Constant Summary collapse
- VERSION =
The version of this Gem / Library.
"0.0.4"
- API_VERSION =
This library’s version of the REST API.
"1"
- PROJECT_DIR =
File.(File.join(File.dirname(__FILE__), '..', '..'))
Class Method Summary collapse
- .default_logger(output = nil) ⇒ Object
-
.ec2 ⇒ Object
Returns a new connection to the AWS EC2 service (Fog::Compute::AWS).
-
.get_rds(rds_id) ⇒ Fog::AWS::RDS::Server
Returns a Fog RDS entity for a given an RDS ID.
-
.rds_accounts ⇒ Object
Loads account information, and returns only those entries that repesent RDS accounts.
-
.read_accounts(account_file = ENV['RDS_ACCOUNTS_FILE']) ⇒ Hash
Loads account information defined in config/accounts.yml, or ENV.
-
.root ⇒ String
Defines the root URI path of the web service.
-
.s3 ⇒ Object
Returns a new connection to the AWS S3 service (Fog::Storage::AWS).
-
.settings(settings_file = ) ⇒ Object
Returns the configuration Hash read from config/s3_account.yml or ENV.
Class Method Details
.default_logger(output = nil) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/rds_backup_service/rds_backup_service.rb', line 58 def self.default_logger(output = nil) logger = ::Logger.new(output) logger.sev_threshold = Logger::INFO logger.formatter = proc {|lvl, time, prog, msg| "#{lvl}: #{msg}\n"} logger end |
.ec2 ⇒ Object
Returns a new connection to the AWS EC2 service (Fog::Compute::AWS)
26 27 28 29 30 |
# File 'lib/rds_backup_service/rds_backup_service.rb', line 26 def self.ec2 accts = RDSBackup.read_accounts.select{|id,acc| acc[:service] == 'Compute'} raise "At least one S3 account must be defined" if accts.empty? Fog::Compute::AWS.new(accts.first[1][:credentials]) end |
.get_rds(rds_id) ⇒ Fog::AWS::RDS::Server
Returns a Fog RDS entity for a given an RDS ID. Polls all accounts. The account name is attached to the result as ‘tracker_account’.
69 70 71 72 73 |
# File 'lib/rds_backup_service/rds_backup_service.rb', line 69 def self.get_rds(rds_id) require 'fog_tracker' ::FogTracker::Tracker.new(RDSBackup.rds_accounts).update. select{|rds| rds.identity == rds_id}.first end |
.rds_accounts ⇒ Object
Loads account information, and returns only those entries that repesent RDS accounts.
21 22 23 |
# File 'lib/rds_backup_service/rds_backup_service.rb', line 21 def self.rds_accounts RDSBackup.read_accounts.select{|id,acc| acc[:service] == 'RDS'} end |
.read_accounts(account_file = ENV['RDS_ACCOUNTS_FILE']) ⇒ Hash
Loads account information defined in config/accounts.yml, or ENV. The keys in each account Hash are converted to Symbols.
14 15 16 17 |
# File 'lib/rds_backup_service/rds_backup_service.rb', line 14 def self.read_accounts(account_file = ENV['RDS_ACCOUNTS_FILE']) YAML::load(File.read(account_file || "./config/accounts.yml")). inject({}) {|a,b| a[b[0]] = b[1].symbolize_keys ; a } end |
.root ⇒ String
Defines the root URI path of the web service.
54 55 56 |
# File 'lib/rds_backup_service/rds_backup_service.rb', line 54 def self.root "/api/v#{RDSBackup::API_VERSION}" end |
.s3 ⇒ Object
Returns a new connection to the AWS S3 service (Fog::Storage::AWS)
33 34 35 36 37 |
# File 'lib/rds_backup_service/rds_backup_service.rb', line 33 def self.s3 accts = RDSBackup.read_accounts.select{|id,acc| acc[:service] == 'Storage'} raise "At least one S3 account must be defined" if accts.empty? Fog::Storage::AWS.new(accts.first[1][:credentials]) end |
.settings(settings_file = ) ⇒ Object
Returns the configuration Hash read from config/s3_account.yml or ENV.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rds_backup_service/rds_backup_service.rb', line 41 def self.settings(settings_file = ENV['RDS_SETTINGS_FILE']) { # here are some defaults 'rds_security_group' => 'rds-backup-service', 'ec2_security_group' => 'rds-backup-service', 'tmp_dir' => Dir.tmpdir, 'email_from' => 'rdsbackups@localhost', 'email_tls' => 'false', }.merge(YAML::load( File.read(settings_file || "./config/settings.yml"))) end |