canzea 0.1.60 → 0.1.61
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.
- checksums.yaml +4 -4
- data/lib/canzea/version.rb +1 -1
- data/lib/canzea.rb +27 -1
- data/lib/ssh-base-cmd-class.rb +41 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e43ec6fb5b900370eee107efc7c63a3df04d68ad
|
4
|
+
data.tar.gz: 669ff02f30f31302e0e26d21ce27140d2c13bcb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6659a1662fe46eee49a4eaafd7724161aea3d9ffe466b6fc1c86e91881f62f597eff4fcd202e3ff3500ab9b865932301cb3f2651d8f1bf1455a51b8c3d1606ae
|
7
|
+
data.tar.gz: b42c8e053c1cd7c2b63d5b8dda0f13e8803e1e04d55b9366ecadab764c163e3372c0f1674b3e4aaf9b31b7658a3e31f3c7eb9ef92a962a9e7ac3bdc49d800d33
|
data/lib/canzea/version.rb
CHANGED
data/lib/canzea.rb
CHANGED
@@ -41,6 +41,9 @@ module Canzea
|
|
41
41
|
# flag nil, :run, 'Run a step'
|
42
42
|
# flag nil, :helper, 'Execute a helper'
|
43
43
|
flag nil, :remote, 'Remote execution'
|
44
|
+
flag nil, :get, 'Get a file from the remote server'
|
45
|
+
flag nil, :put, 'Put a file onto the remote server'
|
46
|
+
flag nil, :encrypt, 'Encrypt'
|
44
47
|
flag nil, :init, 'Remote init execution'
|
45
48
|
# flag nil, :enable, 'Enable the service'
|
46
49
|
flag nil, :test, 'Run as a test'
|
@@ -51,9 +54,10 @@ module Canzea
|
|
51
54
|
|
52
55
|
option nil, :lifecycle, 'Lifecycle action [install, configure, upgrade, uninstall]', argument: :required
|
53
56
|
|
54
|
-
option nil, :util, "Utility action [gen-user, gen-cert]", argument: :required
|
57
|
+
option nil, :util, "Utility action [gen-user, gen-cert, add-env, add-env-secret, prepare-plan, apply-config]", argument: :required
|
55
58
|
option nil, :catalogTag, 'Specific tag of the catalog', argument: :required
|
56
59
|
option nil, :gitRoot, 'Git root', argument: :required
|
60
|
+
|
57
61
|
option nil, :role, 'Role', argument: :required
|
58
62
|
option nil, :solution, 'Solution', argument: :required
|
59
63
|
option nil, :task, 'Task', argument: :required
|
@@ -124,6 +128,28 @@ module Canzea
|
|
124
128
|
end
|
125
129
|
end
|
126
130
|
|
131
|
+
if (opts[:get] || opts[:put])
|
132
|
+
publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{opts[:serverBase]}-#{opts[:serverNumber]}.json")
|
133
|
+
if (opts[:get])
|
134
|
+
remote = RemoteCall.new
|
135
|
+
remote.get publicIp, opts[:privateKey], args[0], args[1]
|
136
|
+
end
|
137
|
+
if (opts[:put])
|
138
|
+
remote = RemoteCall.new
|
139
|
+
remote.put publicIp, opts[:privateKey], args[0], args[1]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
if (opts[:encrypt])
|
144
|
+
remote = RemoteCall.new
|
145
|
+
remote.encrypt args[0]
|
146
|
+
end
|
147
|
+
|
148
|
+
if (opts[:decrypt])
|
149
|
+
remote = RemoteCall.new
|
150
|
+
remote.decrypt args[0] opts[:privateKey]
|
151
|
+
end
|
152
|
+
|
127
153
|
if (opts[:lifecycle])
|
128
154
|
|
129
155
|
lifecycle = opts[:lifecycle]
|
data/lib/ssh-base-cmd-class.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'net/ssh'
|
4
4
|
require 'net/sftp'
|
5
5
|
require 'json'
|
6
|
+
require 'openssl'
|
7
|
+
require 'base64'
|
6
8
|
|
7
9
|
class RemoteCall
|
8
10
|
def exec (hostname, privateKey, cmd)
|
@@ -39,4 +41,42 @@ class RemoteCall
|
|
39
41
|
chan.wait
|
40
42
|
end
|
41
43
|
end
|
42
|
-
|
44
|
+
|
45
|
+
def encrypt (contents)
|
46
|
+
puts "Encrypting #{contents}"
|
47
|
+
pubkey_pem = File.read 'root_id_rsa.pem.pub'
|
48
|
+
key = OpenSSL::PKey::RSA.new pubkey_pem
|
49
|
+
output = Base64.encode64 key.public_encrypt contents
|
50
|
+
puts output
|
51
|
+
end
|
52
|
+
|
53
|
+
def decrypt (contents, privateKey)
|
54
|
+
puts "Decrypting #{contents}"
|
55
|
+
privkey_pem = File.read privateKey
|
56
|
+
key = OpenSSL::PKey::RSA.new privkey_pem
|
57
|
+
output = key.private_decrypt Base64.decode64 contents
|
58
|
+
puts output
|
59
|
+
end
|
60
|
+
|
61
|
+
# Secure copy - use the public key to encrypt the contents before sent across
|
62
|
+
#
|
63
|
+
def put (hostname, privateKey, localFile, remoteFile = nil)
|
64
|
+
|
65
|
+
@username = "root"
|
66
|
+
|
67
|
+
puts "Uploading #{localFile} to #{remoteFile}"
|
68
|
+
Net::SSH.start(hostname, @username, :paranoid => false, :keys => [privateKey]) do |ssh|
|
69
|
+
ssh.sftp.upload!(localFile, remoteFile)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def get (hostname, privateKey, remoteFile, localFile = nil)
|
74
|
+
|
75
|
+
@username = "root"
|
76
|
+
|
77
|
+
Net::SSH.start(hostname, @username, :paranoid => false, :keys => [privateKey]) do |ssh|
|
78
|
+
ssh.sftp.download!(remoteFile, localFile)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canzea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.61
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Canzea Technologies
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|