ey_cloud_server 1.4.28 → 1.4.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ .DS_Store
2
+ pkg
3
+ vendor/gems/ruby/1.8/*
4
+ vendor/gems/environment.rb
5
+ !vendor/gems/ruby/1.8/cache
6
+ gbin
7
+ coverage
8
+ spec/config.yml
9
+ tmp
10
+ .bundle
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.8.7
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ source 'http://rubygems.org/'
2
+ source 'http://geminst:hoa3laml@rubygems.engineyard.com/'
3
+
4
+ gemspec
5
+
6
+ ## Group Dependencies
7
+
8
+ group :test do
9
+ gem 'rspec'
10
+ gem 'randexp'
11
+ gem 'cucumber'
12
+ gem 'rcov'
13
+ gem 'fakeweb', '1.2.6.ninjas'
14
+ gem 'fakefs', '=0.0.1.ninjas'
15
+ gem 'dbi'
16
+ gem 'dbd-mysql'
17
+ gem 'ruby-debug', :platforms => :mri
18
+ end
19
+
20
+ group :development do
21
+ gem 'rake'
22
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,124 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ey_cloud_server (1.4.29.pre)
5
+ ey_enzyme
6
+ ey_instance_api_client (~> 0.1.5)
7
+ fog (~> 1.1.2)
8
+ json (~> 1.6.4)
9
+ open4 (~> 1.3.0)
10
+
11
+ GEM
12
+ remote: http://rubygems.org/
13
+ remote: http://geminst:hoa3laml@rubygems.engineyard.com/
14
+ specs:
15
+ builder (3.0.0)
16
+ chef (0.6.0.2)
17
+ erubis
18
+ extlib
19
+ json
20
+ ohai
21
+ ruby-openid
22
+ stomp
23
+ chef-deploy (0.2.5)
24
+ columnize (0.3.6)
25
+ cucumber (1.1.4)
26
+ builder (>= 2.1.2)
27
+ diff-lcs (>= 1.1.2)
28
+ gherkin (~> 2.7.1)
29
+ json (>= 1.4.6)
30
+ term-ansicolor (>= 1.0.6)
31
+ dbd-mysql (0.4.4)
32
+ dbi (>= 0.4.0)
33
+ mysql
34
+ dbi (0.4.5)
35
+ deprecated (= 2.0.1)
36
+ deprecated (2.0.1)
37
+ diff-lcs (1.1.3)
38
+ erubis (2.7.0)
39
+ excon (0.9.4)
40
+ extlib (0.9.15)
41
+ ey_enzyme (0.9.44)
42
+ chef (= 0.6.0.2)
43
+ chef-deploy (= 0.2.5)
44
+ json
45
+ rest-client (~> 1.6.1)
46
+ ey_instance_api_client (0.1.5)
47
+ json
48
+ rest-client
49
+ fakefs (0.0.1.ninjas)
50
+ fakeweb (1.2.6.ninjas)
51
+ fog (1.1.2)
52
+ builder
53
+ excon (~> 0.9.0)
54
+ formatador (~> 0.2.0)
55
+ mime-types
56
+ multi_json (~> 1.0.3)
57
+ net-scp (~> 1.0.4)
58
+ net-ssh (>= 2.1.3)
59
+ nokogiri (~> 1.5.0)
60
+ ruby-hmac
61
+ formatador (0.2.1)
62
+ gherkin (2.7.1)
63
+ json (>= 1.4.6)
64
+ json (1.6.4)
65
+ linecache (0.46)
66
+ rbx-require-relative (> 0.0.4)
67
+ mime-types (1.17.2)
68
+ mixlib-cli (1.2.2)
69
+ mixlib-config (1.1.2)
70
+ mixlib-log (1.3.0)
71
+ multi_json (1.0.4)
72
+ mysql (2.8.1)
73
+ net-scp (1.0.4)
74
+ net-ssh (>= 1.99.1)
75
+ net-ssh (2.2.1)
76
+ nokogiri (1.5.0)
77
+ ohai (0.6.10)
78
+ mixlib-cli
79
+ mixlib-config
80
+ mixlib-log
81
+ systemu (~> 2.2.0)
82
+ yajl-ruby
83
+ open4 (1.3.0)
84
+ rake (0.9.2.2)
85
+ randexp (0.1.6)
86
+ rbx-require-relative (0.0.5)
87
+ rcov (0.9.11)
88
+ rest-client (1.6.7)
89
+ mime-types (>= 1.16)
90
+ rspec (2.7.0)
91
+ rspec-core (~> 2.7.0)
92
+ rspec-expectations (~> 2.7.0)
93
+ rspec-mocks (~> 2.7.0)
94
+ rspec-core (2.7.1)
95
+ rspec-expectations (2.7.0)
96
+ diff-lcs (~> 1.1.2)
97
+ rspec-mocks (2.7.0)
98
+ ruby-debug (0.10.4)
99
+ columnize (>= 0.1)
100
+ ruby-debug-base (~> 0.10.4.0)
101
+ ruby-debug-base (0.10.4)
102
+ linecache (>= 0.3)
103
+ ruby-hmac (0.4.0)
104
+ ruby-openid (2.1.8)
105
+ stomp (1.2.0)
106
+ systemu (2.2.0)
107
+ term-ansicolor (1.0.7)
108
+ yajl-ruby (1.1.0)
109
+
110
+ PLATFORMS
111
+ ruby
112
+
113
+ DEPENDENCIES
114
+ cucumber
115
+ dbd-mysql
116
+ dbi
117
+ ey_cloud_server!
118
+ fakefs (= 0.0.1.ninjas)
119
+ fakeweb (= 1.2.6.ninjas)
120
+ rake
121
+ randexp
122
+ rcov
123
+ rspec
124
+ ruby-debug
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Engine Yard Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,46 @@
1
+ == ey
2
+
3
+ AKA Ey Instance Tools
4
+
5
+ = Development
6
+
7
+ Requirements:
8
+
9
+ bundler
10
+ gnupg
11
+ postgres and mysql servers
12
+
13
+ Then bundle everything up:
14
+
15
+ bundle
16
+
17
+ Configure your system:
18
+
19
+ cp spec/config-example.yml spec/config.yml
20
+
21
+ edit the database users
22
+ add amazon credentials to use for uploading test backups to S3
23
+
24
+ == Testing
25
+
26
+ To run the specs:
27
+
28
+ bundle exec rake
29
+
30
+ To run a specifc spec:
31
+
32
+ bundle exec spec -f spec/ey_backup/cli_spec.rb
33
+
34
+ Running the bin files are easy too:
35
+
36
+ bin/ey-recipes
37
+
38
+ == Releasing
39
+
40
+ ey-gem release
41
+
42
+ Bump the cloud_cookbooks version in dracul/resin:
43
+
44
+ cd ../dracul
45
+ edit lib/dracul.rb and bump the versions in the ey resin config
46
+ follow the instructions in the dracul readme from here to release a new dracul
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ Bundler.setup(:runtime, :test)
2
+
3
+ $:.unshift File.dirname(__FILE__) + '/lib'
4
+ require File.dirname(__FILE__) + '/lib/ey-flex'
5
+
6
+ require 'rspec/core/rake_task'
7
+ desc "Run unit specifications"
8
+ RSpec::Core::RakeTask.new do |t|
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ t.rspec_opts = %w(-fs --color --backtrace)
11
+ end
12
+
13
+ require 'cucumber/rake/task'
14
+ Cucumber::Rake::Task.new do |t|
15
+ t.cucumber_opts = %w{--format pretty}
16
+ end
17
+
18
+ desc "Run unit specifications"
19
+ task :default => [:spec, :cucumber]
data/TODO ADDED
@@ -0,0 +1,4 @@
1
+ TODO:
2
+ Fix LICENSE with your name
3
+ Fix Rakefile with your name and contact info
4
+ Add your code to lib/<%= name %>.rb
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/ey_cloud_server/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["EngineYard"]
6
+ gem.email = ["engineering@engineyard.com"]
7
+ gem.description = %q{}
8
+ gem.summary = %q{Server side components for Engine Yard's cloud}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "ey_cloud_server"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = EY::CloudServer::VERSION
17
+
18
+ gem.add_runtime_dependency 'json', '~> 1.6.4'
19
+ gem.add_runtime_dependency 'open4', "~> 1.3.0"
20
+
21
+ gem.add_runtime_dependency 'fog', '~> 1.1.2'
22
+ gem.add_runtime_dependency "ey_enzyme"
23
+
24
+ gem.add_runtime_dependency "ey_instance_api_client", "~> 0.1.5"
25
+ end
@@ -0,0 +1,12 @@
1
+ Feature:
2
+ Scenario: a single database
3
+ Given there is a mysql database (first)
4
+ And backups for mysql are run
5
+ When backup "0" for the "first" database is downloaded
6
+ Then there is a backup file for the "first" database
7
+
8
+ Scenario: no database backup
9
+ Given there is a mysql database (first)
10
+ When backup "0" for the "first" database is downloaded
11
+ Then there is no backup file for the "first" database
12
+ And stderr contains "No backup found for database"
@@ -0,0 +1,12 @@
1
+ Feature:
2
+ Scenario: no backups run
3
+ Given there is a postgresql database (first)
4
+ When listing the backups for the "first" postgresql database
5
+ Then the output contains "0 backup(s) found"
6
+
7
+ Scenario: a single backup run
8
+ Given there is a postgresql database (first)
9
+ And backups for postgresql are run
10
+ When listing the backups for the "first" postgresql database
11
+ Then the output contains "1 backup(s) found"
12
+ And the output contains "0:%s" substituting the "first" postgresql database
@@ -0,0 +1,12 @@
1
+ Feature:
2
+ Scenario: no backup
3
+ Given there is a postgresql database (first)
4
+ When backup "0" for the "first" database is restored
5
+ Then stderr contains "No backup found for database"
6
+
7
+ Scenario: with a backup
8
+ Given there is a postgresql database (first)
9
+ And backups for postgresql are run
10
+ And the "first" database is dropped
11
+ When backup "0" for the "first" database is restored
12
+ Then the "first" postgresql database exists
@@ -0,0 +1,61 @@
1
+ Given \
2
+ /^backups for mysql are run$/ do
3
+ capturing_stdio do
4
+ EY::Backup.logger = EY::Backup::Logger.new
5
+ EY::Backup.run([ "-c", backup_config_file ])
6
+ end
7
+ end
8
+
9
+ Given \
10
+ /^backups for postgresql are run$/ do
11
+ capturing_stdio do
12
+ EY::Backup.logger = EY::Backup::Logger.new
13
+ EY::Backup.run(["-e", "postgresql", "-c", backup_config_file ])
14
+ end
15
+ end
16
+
17
+ When \
18
+ /^backup "([^\"]*)" for the "([^\"]*)" database is downloaded$/ do |index,db_key|
19
+ db_name = created_mysql_dbs[db_key]
20
+ capturing_stdio do
21
+ EY::Backup.logger = EY::Backup::Logger.new
22
+ EY::Backup.run(["-d", "#{index}:#{db_name}", "-c", backup_config_file ])
23
+ end
24
+ end
25
+
26
+ When \
27
+ /^backup "([^\"]*)" for the "([^\"]*)" database is restored$/ do |index,db_key|
28
+ db_name = created_postgresql_dbs[db_key]
29
+ capturing_stdio do
30
+ EY::Backup.logger = EY::Backup::Logger.new
31
+ EY::Backup.run(["-e", "postgresql", "-r", "#{index}:#{db_name}", "-c", backup_config_file ])
32
+ end
33
+ end
34
+
35
+ When \
36
+ /^listing the backups for the "([^\"]*)" postgresql database$/ do |db_key|
37
+ db_name = created_postgresql_dbs[db_key]
38
+ capturing_stdio do
39
+ EY::Backup.logger = EY::Backup::Logger.new
40
+ EY::Backup.run(["-e", "postgresql", "-l", db_name, "-c", backup_config_file ])
41
+ end
42
+ end
43
+
44
+ Then \
45
+ /^the output contains "([^\"]*)" substituting the "([^\"]*)" postgresql database$/ do |text,db_key|
46
+ db_name = created_postgresql_dbs[db_key]
47
+ last_stdout.should include(text % db_name)
48
+ end
49
+
50
+ Then \
51
+ /^there is a backup file for the "([^\"]*)" database$/ do |db_key|
52
+ db_name = created_mysql_dbs[db_key]
53
+ Dir.glob("#{EY::Backup.tmp_dir}/#{db_name}.*").should have(1).entries
54
+ Dir.glob("#{EY::Backup.tmp_dir}/#{db_name}.*").each{ |f| FileUtils.rm(f) }
55
+ end
56
+
57
+ Then \
58
+ /^there is no backup file for the "([^\"]*)" database$/ do |db_key|
59
+ db_name = created_mysql_dbs[db_key]
60
+ Dir.glob("#{db_name}.*").should have(0).entries
61
+ end
@@ -0,0 +1,9 @@
1
+ Then \
2
+ /^the output contains "([^\"]*)"$/ do |text|
3
+ last_stdout.should include(text)
4
+ end
5
+
6
+ Then \
7
+ /^stderr contains "([^\"]*)"$/ do |text|
8
+ last_stderr.should include(text)
9
+ end
@@ -0,0 +1,4 @@
1
+ Given \
2
+ /^there is a mysql database \(([^\)]*)\)$/ do |db_key|
3
+ create_mysql_database(db_key)
4
+ end
@@ -0,0 +1,15 @@
1
+ Given \
2
+ /^there is a postgresql database \(([^\)]*)\)$/ do |db_key|
3
+ create_postgresql_database(db_key)
4
+ end
5
+
6
+ Then \
7
+ /^the "([^\"]*)" postgresql database exists$/ do |db_key|
8
+ db_name = created_postgresql_dbs[db_key]
9
+ check_postgresql_database(db_name)
10
+ end
11
+
12
+ Given \
13
+ /^the "([^\"]*)" database is dropped$/ do |db_key|
14
+ drop_postgresql_database(db_key)
15
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + "/../../lib/ey-flex"
2
+ require File.dirname(__FILE__) + "/../../lib/ey_backup"
3
+ require 'fakeweb'
4
+ require 'fakefs/safe'
5
+ require 'randexp'
6
+
7
+ require File.dirname(__FILE__) + '/../../spec/fakefs_hax'
8
+ require File.dirname(__FILE__) + '/../../spec/helpers'
9
+
10
+ FakeWeb.allow_net_connect = false # if it's not here, it doesn't exist
11
+ Randexp::Dictionary.words
12
+ Fog.mock!
13
+
14
+ Fog.mock!
15
+
16
+ World(Helpers)
17
+
18
+ Before do
19
+ run_before
20
+ end
21
+
22
+ After do
23
+ run_after
24
+ end
@@ -55,14 +55,14 @@ module EY
55
55
  end
56
56
  @result.to_json
57
57
  end
58
-
58
+
59
59
  def check_mysql
60
60
  check_process('mysqld')
61
61
  DBI.connect("DBI:Mysql:mysql:#{@dna['db_host']}", 'root', @dna['users'].first['password'])
62
62
  rescue DBI::DatabaseError => e
63
63
  @result['mysqld'] = 'down'
64
64
  end
65
-
65
+
66
66
  def check_process(name)
67
67
  return if name == ''
68
68
  pids = `pgrep #{name}`.split("\n")
data/lib/ey-flex.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  require 'json'
2
- require 'aws/s3'
3
2
  require 'date'
4
3
  require 'digest'
5
4
  require 'net/http'
6
5
  require 'fileutils'
7
6
  require 'json/ext'
8
- require 'right_aws'
9
7
  require 'open-uri'
10
8
  require 'rest_client'
11
9
  require 'dbi'
@@ -49,5 +47,4 @@ require lib_dir + '/big-brother'
49
47
  require lib_dir + '/bucket_minder'
50
48
  require lib_dir + '/ey-api'
51
49
  require lib_dir + '/snapshot_minder'
52
- require lib_dir + '/ec2'
53
50
  require lib_dir + '/../ey_cloud_server/version'
data/lib/ey_backup/cli.rb CHANGED
@@ -61,7 +61,7 @@ module EY
61
61
  options[:db] = db
62
62
  end
63
63
 
64
- opts.on("-e", "--engine DATABASE_ENGINE", "The database engine. ex: mysql, postgres, mongodb.") do |engine|
64
+ opts.on("-e", "--engine DATABASE_ENGINE", "The database engine. ex: mysql, postgres.") do |engine|
65
65
  options[:engine] = engine
66
66
  end
67
67
 
@@ -6,7 +6,7 @@ module EY
6
6
  def dump(database_name, basename)
7
7
  file = basename + '.dump'
8
8
 
9
- command = "PGPASSWORD='#{password}' pg_dump -h #{host} --format=c --no-owner --no-privileges -Upostgres #{database_name}"
9
+ command = "PGPASSWORD='#{password}' pg_dump -h #{host} --format=c --no-owner --no-privileges -U#{username} #{database_name}"
10
10
 
11
11
  if gpg?
12
12
  command << " | " << GPGEncryptor.command_for(key_id)
@@ -33,7 +33,7 @@ module EY
33
33
  raise "Cannot load a GPG backup"
34
34
  end
35
35
 
36
- command << " | PGPASSWORD='#{password}' pg_restore -h #{host} --format=c --ignore-version -Upostgres -d #{database_name}"
36
+ command << " | PGPASSWORD='#{password}' pg_restore -h #{host} --format=c --ignore-version -U#{username} -d #{database_name}"
37
37
 
38
38
  run(command)
39
39
  end
data/lib/ey_backup.rb CHANGED
@@ -126,7 +126,6 @@ require lib_dir + '/backend'
126
126
 
127
127
  require lib_dir + '/engines/mysql_engine'
128
128
  require lib_dir + '/engines/postgresql_engine'
129
- require lib_dir + '/engines/mongodb_engine'
130
129
 
131
130
  require lib_dir + '/processors/gzipper'
132
131
  require lib_dir + '/processors/splitter'
@@ -1,3 +1,5 @@
1
- module EY::CloudServer
2
- VERSION = '1.4.28'
1
+ module EY
2
+ module CloudServer
3
+ VERSION = '1.4.29'
4
+ end
3
5
  end
data/script/ci ADDED
@@ -0,0 +1,31 @@
1
+ #! /bin/sh
2
+
3
+ set -x
4
+ set -e # exits on any non 0 exit code
5
+
6
+ # TODO: WHY?
7
+
8
+ sudo cp -pr /root/.gnupg $HOME/
9
+ sudo chown -R deploy:deploy $HOME/.gnupg/
10
+
11
+ cp spec/config-example.yml spec/config.yml
12
+
13
+ sed -i "s/^mysql_host: *.*$/mysql_host: $DB_HOST/g" spec/config.yml
14
+ sed -i "s/^mysql_user: *.*$/mysql_user: root/g" spec/config.yml
15
+ sed -i "s/^mysql_password: *.*$/mysql_password: $DB_PASS/g" spec/config.yml
16
+
17
+ sed -i "s/^postgresql_host: *.*$/postgresql_host: $DB_HOST/g" spec/config.yml
18
+ sed -i "s/^postgresql_user: *.*$/postgresql_user: $USER/g" spec/config.yml
19
+ sed -i "s/^postgresql_password: *.*$/postgresql_password: $DB_PASS/g" spec/config.yml
20
+
21
+ # Get the real aws keys; first remove what we have
22
+ grep -v aws_ spec/config.yml >spec/config.yml.tmp
23
+ mv spec/config.yml.tmp spec/config.yml
24
+ sudo grep -i aws_secret_key /etc/chef/dna.json | tail -n 1 | sed -e 's/,* *$//' -e 's/^ *//' >>spec/config.yml
25
+ sudo grep -i aws_secret_id /etc/chef/dna.json | tail -n 1 | sed -e 's/,* *$//' -e 's/^ *//' >>spec/config.yml
26
+
27
+ echo "CONFIG FILE: "
28
+ cat spec/config.yml
29
+
30
+ bundle install --deployment &> bundle.log
31
+ bundle exec rake --trace
@@ -7,8 +7,5 @@ mysql_host: localhost
7
7
  postgresql_user: root
8
8
  postgresql_password:
9
9
  postgresql_host: localhost
10
- mongodb_user: root
11
- mongodb_passwd:
12
- mongodb_host: localhost
13
10
  aws_secret_id: 'abcd123.id'
14
11
  aws_secret_key: 'abcd123.key'
@@ -12,7 +12,7 @@ describe "Postgres Backups" do
12
12
 
13
13
  EY::Backup.run(["-c", backup_config_file, "-l", @db_name, "-e", "postgresql"])
14
14
 
15
- stdout.should match(/0:#{@db_name}.*\.dump.gz$/)
15
+ stdout.should match(/0:#{@db_name}.*\.dump$/)
16
16
  end
17
17
 
18
18
  it "makes a split backup" do