mongolly 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,7 +23,7 @@ module Mongolly
23
23
  db = Mongo::Connection.new( @db_config["host"], @db_config["port"] )
24
24
  db['admin'].authenticate( @db_config["user"], @db_config["pass"] )
25
25
 
26
- SnapshotManager.take_snapshots( db, @config["aws_access_key_id"], @config["aws_secret_asccess_key"], @db_config["volumes"] )
26
+ SnapshotManager.take_snapshots( db, @config["aws_access_key_id"], @config["aws_secret_access_key"], @db_config["region"], @db_config["volumes"] )
27
27
  end
28
28
 
29
29
  desc "clean", "removes snapshots older than the given data"
@@ -34,7 +34,7 @@ module Mongolly
34
34
 
35
35
  puts " ** Cleaning snapshots older than #{max_age}"
36
36
 
37
- ec2 = AWS::EC2.new(access_key_id: @config["aws_access_key_id"], secret_access_key: @config["aws_secret_asccess_key"])
37
+ ec2 = AWS::EC2.new(access_key_id: @config["aws_access_key_id"], secret_access_key: @config["aws_secret_access_key"]).regions[@db_config["region"]]
38
38
  ec2.snapshots.with_owner(:self).each do |snapshot|
39
39
  unless snapshot.tags[:created_at].nil? || snapshot.tags[:backup_key].nil?
40
40
  if Time.parse(snapshot.tags[:created_at]) < max_age
@@ -56,11 +56,12 @@ module Mongolly
56
56
  port: nil,
57
57
  user: nil,
58
58
  pass: nil,
59
+ region: nil,
59
60
  volumes: [nil]
60
61
  }
61
62
  },
62
63
  aws_access_key_id: nil,
63
- aws_secret_asccess_key: nil,
64
+ aws_secret_access_key: nil,
64
65
  }
65
66
 
66
67
  File.open( CONFIG_PATH, "w" ) do |f|
@@ -108,7 +109,7 @@ module Mongolly
108
109
  end
109
110
 
110
111
  def valid_config?
111
- %w(aws_access_key_id aws_secret_asccess_key).each do |arg|
112
+ %w(aws_access_key_id aws_secret_access_key).each do |arg|
112
113
  raise ArgumentError.new("#{arg} cannot be empty") if @config[arg].to_s.strip.empty?
113
114
  end
114
115
  return true
@@ -2,5 +2,4 @@ require "mongolly/version"
2
2
  require "mongolly/snapshot_manager"
3
3
 
4
4
  module Mongolly
5
- # Your code goes here...
6
5
  end
@@ -3,14 +3,23 @@ require 'aws-sdk'
3
3
  module Mongolly
4
4
  class SnapshotManager
5
5
 
6
- def self.take_snapshots(db, aws_key_id, aws_secret_key, volume_ids)
6
+ def self.take_snapshots(db, aws_key_id, aws_secret_key, region, volume_ids)
7
+ profile_levels = {}
8
+
7
9
  unless db.locked?
8
10
  puts " ** Locking Database"
11
+ db.database_names.each do |db_name|
12
+ level = db[db_name].profiling_level
13
+ if level != :off
14
+ profile_levels[db_name] = level
15
+ db[db_name].profiling_level = :off
16
+ end
17
+ end
9
18
  db.lock!
10
19
  end
11
20
 
12
21
  begin
13
- ec2 = AWS::EC2.new(access_key_id: aws_key_id, secret_access_key: aws_secret_key)
22
+ ec2 = AWS::EC2.new(access_key_id: aws_key_id, secret_access_key: aws_secret_key).regions[region]
14
23
  backup_key = (0...8).map{65.+(rand(25)).chr}.join
15
24
 
16
25
  puts " ** Starting Snapshot with key #{backup_key}"
@@ -28,6 +37,13 @@ module Mongolly
28
37
  if db.locked?
29
38
  puts " ** Unlocking Database"
30
39
  db.unlock!
40
+ db.database_names.each do |db_name|
41
+ level = profile_levels[db_name]
42
+ unless level.nil? || level == :off
43
+ puts " ** Setting #{db_name} profile level to #{level.to_s}"
44
+ db[db_name].profiling_level = level
45
+ end
46
+ end
31
47
  end
32
48
  end
33
49
  end
@@ -1,3 +1,3 @@
1
1
  module Mongolly
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongolly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  segments:
109
109
  - 0
110
- hash: -2926264446981327269
110
+ hash: 3409233611429320048
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  none: false
113
113
  requirements:
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: -2926264446981327269
119
+ hash: 3409233611429320048
120
120
  requirements: []
121
121
  rubyforge_project:
122
122
  rubygems_version: 1.8.24