proboscis_cli 0.0.3 → 0.0.4
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/proboscis_cli/version.rb +1 -1
- data/lib/proboscis_cli.rb +65 -16
- data/proboscis_cli.gemspec +2 -2
- 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: 7de9c6ea2978ddcbaf60321bc4def451904337df
|
4
|
+
data.tar.gz: f371d52272b495686e624210c84f4a3679d844db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c97aefc8adf5dd97c2944522d733ab1fe2276a81928eb4e9d17390449bee72b19332715993d2694a880e15bcace13a7f7abbfe74aa3a00cddcf49c6090d923
|
7
|
+
data.tar.gz: 0217d69975eacb0755b00690bbba0abe0fa9797bb8062898c844e810a4471f5037139b41a9f8f0814836eb0a337b7b0dac49da7ca6bcb0e85a84f6b6294a2313
|
data/lib/proboscis_cli.rb
CHANGED
@@ -3,6 +3,59 @@ require 'httparty'
|
|
3
3
|
require 'json'
|
4
4
|
require "base64"
|
5
5
|
|
6
|
+
class Server
|
7
|
+
def self.ip(auth_code, host, environment, subdomain, type)
|
8
|
+
response = HTTParty.get("#{host}/api/api/hives/#{subdomain}/#{type}", headers: {"X-Authorization" => auth_code})
|
9
|
+
if response.code != 200
|
10
|
+
puts "Unable to fetch details for domain #{subdomain}"
|
11
|
+
exit -1
|
12
|
+
end
|
13
|
+
hive = JSON::parse(response.body)
|
14
|
+
@ipAddress = hive["ip_address"]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Worker
|
19
|
+
def self.ip(auth_code, host, environment, subdomain, type)
|
20
|
+
@auth_code = auth_code
|
21
|
+
@host = host
|
22
|
+
self.client_list environment
|
23
|
+
client_id = @client_list.select {|c| c["domain"] == subdomain}
|
24
|
+
if client_id.empty?
|
25
|
+
puts "Unable to find client with subdomain #{subdomain}"
|
26
|
+
exit -1
|
27
|
+
end
|
28
|
+
self.client environment, client_id.first
|
29
|
+
if(!@infra_info["WORKER_IP"])
|
30
|
+
puts "Unable to find target WORKER_IP in #{@infra_info}. Is the machine up?"
|
31
|
+
end
|
32
|
+
@infra_info["WORKER_IP"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.client_list(environment)
|
36
|
+
response = HTTParty.get("#{@host}/api/api/clients", headers: {"X-Authorization" => @auth_code})
|
37
|
+
if response.code != 200
|
38
|
+
puts "Unable to get the client list.."
|
39
|
+
exit -1
|
40
|
+
end
|
41
|
+
@client_list = JSON::parse(response.body)["content"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.client(environment, client_id)
|
45
|
+
response = HTTParty.get("#{@host}/api/api/clients/#{client_id["id"]}/products", headers: {"X-Authorization" => @auth_code})
|
46
|
+
if response.code != 200
|
47
|
+
puts "Unable to fetch details of client with id #{client_id}"
|
48
|
+
exit -1
|
49
|
+
end
|
50
|
+
infra_info = JSON::parse(response.body)
|
51
|
+
if infra_info.empty?
|
52
|
+
puts "No Products Mapped!"
|
53
|
+
exit -1
|
54
|
+
end
|
55
|
+
@infra_info = JSON::parse(infra_info.first["infrastructureInfo"])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
6
59
|
class Proboscis
|
7
60
|
def self.host(environment)
|
8
61
|
ENV["proboscis_#{environment}"]
|
@@ -14,34 +67,30 @@ class Proboscis
|
|
14
67
|
|
15
68
|
def self.connect(environment, subdomain, target, type)
|
16
69
|
type = type == 'b' ? 'BUSY_BEE' : 'INSTANT_HONEY'
|
70
|
+
@host = self.host(environment)
|
17
71
|
self.login environment
|
18
|
-
self.
|
19
|
-
if(
|
20
|
-
puts "Unable to find target #{
|
72
|
+
ip = self.get_ip environment, subdomain, type, target
|
73
|
+
if(!ip)
|
74
|
+
puts "Unable to find target #{ip}. Is the machine up?"
|
21
75
|
exit -1
|
22
76
|
end
|
23
77
|
user = ENV["proboscis_#{environment}_target_user"] || "root"
|
24
78
|
port = ENV["proboscis_#{environment}_target_port"] || "22"
|
25
|
-
puts "Executing ssh #{user}@#{
|
26
|
-
system "ssh #{user}@#{
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.client(environment, subdomain, type)
|
30
|
-
response = HTTParty.get("#{self.host(environment)}/api/api/hives/#{subdomain}/#{type}", headers: {"X-Authorization" => @auth_code})
|
31
|
-
if response.code != 200
|
32
|
-
puts "Unable to fetch details for domain #{subdomain}"
|
33
|
-
exit -1
|
34
|
-
end
|
35
|
-
hive = JSON::parse(response.body)
|
36
|
-
@ipAddress = hive["ip_address"]
|
79
|
+
puts "Executing ssh #{user}@#{ip} -p #{port}"
|
80
|
+
system "ssh #{user}@#{ip} -p #{port}"
|
37
81
|
end
|
38
82
|
|
39
83
|
def self.login(environment)
|
40
|
-
response = HTTParty.post("#{
|
84
|
+
response = HTTParty.post("#{@host}/api/login", body: {phoneNumber: self.param(environment, 'user'), password: self.param(environment, 'pass')}.to_json, headers: { 'Content-Type' => 'application/json' })
|
41
85
|
if response.code != 200
|
42
86
|
puts "Unable to login to proboscis.."
|
43
87
|
exit -1
|
44
88
|
end
|
45
89
|
@auth_code = Base64.strict_encode64(JSON::parse(response.body)["accessToken"])
|
46
90
|
end
|
91
|
+
|
92
|
+
def self.get_ip(environment, subdomain, type, target)
|
93
|
+
machine = target.downcase == 'server' ? Server : Worker
|
94
|
+
machine.ip @auth_code, @host, environment, subdomain, type
|
95
|
+
end
|
47
96
|
end
|
data/proboscis_cli.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'proboscis_cli'
|
3
|
-
s.version = '0.0.
|
4
|
-
s.date = '2017-12-
|
3
|
+
s.version = '0.0.4'
|
4
|
+
s.date = '2017-12-24'
|
5
5
|
s.summary = "A cli client for proboscis"
|
6
6
|
s.description = "A cli client for proboscis"
|
7
7
|
s.authors = ["Simon Roy", "Arvind"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proboscis_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Roy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-12-
|
12
|
+
date: 2017-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|