pvcglue 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5317c0a638c5ddacd0a3ee767d7754caa2c04848
4
- data.tar.gz: 7342a1125dcc1b35fcbb969043455bc8a99c734c
3
+ metadata.gz: 9582fa0791b38da8006bf4672032b35d97bfa11b
4
+ data.tar.gz: 3facc6e4e1c64d0baec87d6cc24503958a67f812
5
5
  SHA512:
6
- metadata.gz: eac0304984a7caa026023d250da35441a8b95aa3e4755d9c5efc12175b8cee108f1ef5e96af81b4654028905f535f8ce99e72bd0695bf7fdf307a60f788c2838
7
- data.tar.gz: a9e4d18207fe3eb2a920125ab4e2df1bf6174957b1f06b874096d62ae7b8d786798b0f17dd9851d2c21847b627d83cb65f068c06a2908d809dddbf6045d25e54
6
+ metadata.gz: bc1af302e92fc29daa6bde7a2ac3ab30ee1becf137c055f1b116746d90036303e9c0050124eef04a42bede3fde155f9ab59ae26251696be8e071b45e2bd28ea8
7
+ data.tar.gz: 03fee3e424a4c4fe9ab2b5fdaf62b4431ed00b9b5ff231bf69d2763fa86c5570639806c7e2a27cbe5bea78e3dd412091881b283b6c378f8b0ea26b773d04c7bc
data/README.md CHANGED
@@ -158,7 +158,7 @@ Add these lines to your application's Gemfile. `dotenv-rails` must be listed fi
158
158
 
159
159
  Then add these lines to your application's Gemfile, whereever you like (usually at the end):
160
160
 
161
- gem 'pvcglue', "~> 0.1.15", :group => :development
161
+ gem 'pvcglue', "~> 0.1.18", :group => :development
162
162
  gem 'pvcglue_dbutils', "~> 0.5.3"
163
163
 
164
164
  And then execute:
data/lib/pvcglue.rb CHANGED
@@ -35,6 +35,16 @@ module Pvcglue
35
35
  data
36
36
  end
37
37
 
38
+ def self.run_remote(host, port, user, cmd)
39
+ cmd = "ssh -p #{port} #{user}@#{host} '#{cmd}'"
40
+ # puts "Running `#{cmd}`"
41
+
42
+ unless system cmd
43
+ raise(Thor::Error, "Error: #{$?}")
44
+ end
45
+ true
46
+ end
47
+
38
48
  class Version
39
49
  def self.version
40
50
  VERSION
data/lib/pvcglue/db.rb CHANGED
@@ -15,7 +15,7 @@ module Pvcglue
15
15
  pg_restore(self.class.remote, file_name)
16
16
  end
17
17
 
18
- desc "pull", "Pull copy of database from remote stage. Pass -f to exclude tables defined in the configutation file. If no tables are specified in the `excluded_db_tables` option, 'versions' will be used by default."
18
+ desc "pull", "Pull copy of database from remote stage. Pass -f to exclude tables defined in the configuration file. If no tables are specified in the `excluded_db_tables` option, 'versions' will be used by default."
19
19
  method_option :fast, :type => :boolean, :aliases => "-f"
20
20
  def pull(file_name = nil)
21
21
  raise(Thor::Error, "Stage required.") if Pvcglue.cloud.stage_name.nil?
@@ -25,14 +25,14 @@ module Pvcglue
25
25
  desc "dump", "dump"
26
26
 
27
27
  def dump(file_name = nil)
28
- raise(Thor::Error, "Stage should not be set for this command.") unless Pvcglue.cloud.stage_name.nil?
28
+ raise(Thor::Error, "Stage should not be set for this command. (Use 'pull' for remote databases.)") unless Pvcglue.cloud.stage_name.nil?
29
29
  pg_dump(self.class.local, file_name)
30
30
  end
31
31
 
32
32
  desc "restore", "restore"
33
33
 
34
34
  def restore(file_name = nil)
35
- raise(Thor::Error, "Stage should not be set for this command.") unless Pvcglue.cloud.stage_name.nil?
35
+ raise(Thor::Error, "Stage should not be set for this command. (Use 'push' for remote databases.)") unless Pvcglue.cloud.stage_name.nil?
36
36
  pg_restore(self.class.local, file_name)
37
37
  end
38
38
 
@@ -101,7 +101,7 @@ module Pvcglue
101
101
  def self.file_helper(file_name)
102
102
  # TODO: make it more helpful ;)
103
103
  stage = Pvcglue.cloud.stage_name || "dev"
104
- file_name = "#{Pvcglue.configuration.application_name}_#{stage}_#{Time.now.strftime("%Y-%m-%d")}.dump" unless file_name
104
+ file_name = "#{Pvcglue.configuration.application_name}_#{stage}_#{Time.now.strftime("%Y-%m-%d-%H%M")}.dump" unless file_name
105
105
  # "#{File.dirname(file_name)}/#{File.basename(file_name, '.*')}.dump"
106
106
  file_name
107
107
  end
@@ -118,26 +118,42 @@ module Pvcglue
118
118
 
119
119
  def destroy_prod?
120
120
  say("Are you *REALLY* sure you want to DESTROY the PRODUCTION database?")
121
- input = ask("Type 'destroy production' if you are:")
122
- raise(Thor::Error, "Ain't gonna do it.") if input.downcase != "destroy production"
123
- puts "ok, going through with the it..."
121
+ input = ask("Type 'destroy #{source.database}' if you are:")
122
+ raise(Thor::Error, "Ain't gonna do it.") if input.downcase != "destroy #{source.database}"
123
+ puts "ok, going through with the it... (I sure hope you know what you are doing, Keith!)"
124
124
  end
125
125
 
126
126
 
127
- def pg_dump(source, file_name, fast)
128
- cmd = "pg_dump -Fc --no-acl --no-owner -h #{source.host} -p #{source.port}"
129
- cmd += " -U #{source.username}" if source.username
127
+ def pg_dump(db, file_name, fast)
128
+ host = Pvcglue.cloud.nodes_in_stage('db')['db']['public_ip']
129
+ port = Pvcglue.cloud.port_in_context(:shell)
130
+ user = 'deploy'
131
+ file_name = self.class.file_helper(file_name)
132
+
133
+ cmd = "pg_dump -Fc --no-acl --no-owner -h #{db.host} -p #{db.port}"
134
+ cmd += " -U #{db.username}" if db.username
130
135
  if fast
131
136
  Pvcglue.cloud.exclude_tables.each do |table|
132
137
  cmd += " --exclude-table=#{table}"
133
138
  end
134
139
  end
135
- cmd += " #{source.database} -v -f #{self.class.file_helper(file_name)}"
140
+ cmd += " #{db.database} -v -f #{file_name}"
141
+
136
142
  puts cmd
137
- unless system({"PGPASSWORD" => source.password}, cmd)
143
+ unless Pvcglue.run_remote(host, port, user, " PGPASSWORD=#{db.password} #{cmd}")
138
144
  puts "ERROR:"
139
145
  puts $?.inspect
146
+ raise(Thor::Error, "Error: #{$?}")
140
147
  end
148
+
149
+ cmd = %{scp -P #{port} #{user}@#{host}:#{file_name} #{self.class.file_helper(file_name)}}
150
+ puts "Running `#{cmd}`"
151
+
152
+ unless system cmd
153
+ raise(Thor::Error, "Error: #{$?}")
154
+ end
155
+
156
+
141
157
  end
142
158
 
143
159
  def pg_destroy(dest)
@@ -1,3 +1,3 @@
1
1
  module Pvcglue
2
- VERSION = "0.1.17"
2
+ VERSION = "0.1.18"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pvcglue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Lyric
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler