proboscis_cli 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4f632a964f736abf931e8d14dbf01313710bd1cd9cde5fb95055903ee93c0d1
4
- data.tar.gz: 82244db7f3fbaab6439ffa51f44cb9588de5598fec41ad4eac1ecd22b6280cc5
3
+ metadata.gz: 9b08e20f2e8f4a6771b7a8192a86a2083c169546137f1a0b069bdb4fb9bf6648
4
+ data.tar.gz: f63e3d0c12e1563317e2d4034172bc239b51d3f5690e6c72a9bacd45b4897b73
5
5
  SHA512:
6
- metadata.gz: a89bb59acdf1e03ad2cf10fe97336d6feaa6d393db29b43269fb95f22861fbb04e72ca3c81388ce6ea6f8ce0e55281c39d8bad2620ce1e4c64571536533a34ea
7
- data.tar.gz: af8c2f8f6517a8d69ffb6a8f1a88a4155704c0c3accf17b094d03a33e8d4d4eccc70c60e1aedfa0db2a29adf4b683767c36549e264f8335feb1296959a6ca273
6
+ metadata.gz: 9be97117c7a5d2d6efa5b6f00ab6dd2f9cc29c13e0e19e49fb5b8983a52bfa8ab49c5ae631cb5b2f72d8d77fa1b87575d417b58c4a71fe6a24eec0ff745d5265
7
+ data.tar.gz: 85ec027dbac647f5479cfc6b573d43b0a8fc1a0678fba499e9d32e52a175c6abe90cc7ce213883a76376a877a237da72dc464fe6317d95667bab1f02b1798114
data/README.md CHANGED
@@ -30,6 +30,8 @@ Or install it yourself as:
30
30
  $ export proboscis_qa_target_user=<target_ssh_user>
31
31
  $ export proboscis_prod_target_port=<target_ssh_port>
32
32
  $ export proboscis_prod_target_user=<target_ssh_user>
33
+ $ export araneae_qa_token=<araneae_token>
34
+ $ export araneae_prod_token=<araneae_token>
33
35
  ```
34
36
 
35
37
  ```bash
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'proboscis_cli'
3
3
 
4
- if(ARGV.empty? || ARGV.size != 4)
4
+ if(ARGV.empty? || ARGV.size > 5)
5
5
  puts "Usage proboscis <qa|prod> <subdomain> <server|worker> <b|i|c>"
6
6
  exit
7
7
  end
@@ -10,6 +10,10 @@ environment = ARGV[0].downcase
10
10
  subdomain = ARGV[1].downcase
11
11
  target = ARGV[2].downcase
12
12
  type = ARGV[3].downcase
13
+ subpath = 'araneae'
14
+ if not ARGV[4].nil?
15
+ subpath = ARGV[4].downcase
16
+ end
13
17
 
14
18
  if((%w(qa prod).select {|e| e == environment}).empty? ||
15
19
  (%w(server worker).select {|e| e == target}).empty? ||
@@ -18,4 +22,4 @@ if((%w(qa prod).select {|e| e == environment}).empty? ||
18
22
  exit
19
23
  end
20
24
 
21
- Proboscis.connect(environment, subdomain, target, type)
25
+ Proboscis.connect(environment, subdomain, target, type, subpath=subpath)
@@ -3,8 +3,14 @@ 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)
6
+ class Machine
7
+ def self.port(environment, type, subpath)
8
+ ENV["proboscis_#{environment}_target_port"] || "22"
9
+ end
10
+ end
11
+
12
+ class Server < Machine
13
+ def self.ip(auth_code, host, environment, subdomain, type, subpath)
8
14
  response = HTTParty.get("#{host}/api/api/hives/#{subdomain}/#{type}", headers: {"X-Authorization" => auth_code})
9
15
  if response.code != 200
10
16
  puts "Unable to fetch details for domain #{subdomain}"
@@ -15,8 +21,33 @@ class Server
15
21
  end
16
22
  end
17
23
 
18
- class Worker
19
- def self.ip(auth_code, host, environment, subdomain, type)
24
+ class CashServer < Server
25
+ def self.port(environment, type, subpath)
26
+ subpath == 'araneae' ? "1729" : "22"
27
+ end
28
+
29
+ def self.param(environment, lookup)
30
+ ENV["araneae_#{environment}_#{lookup}"]
31
+ end
32
+
33
+ def self.ip(auth_code, host, environment, subdomain, type, subpath)
34
+ super
35
+ if subpath == 'araneae'
36
+ return @ipAddress
37
+ end
38
+ res = HTTParty.get("http://#{@ipAddress}/admin/hosts", headers: {'X-Auth-Key': self.param(environment, 'token')})
39
+ if res.code != 200
40
+ puts "Failed to get subpath details. #{res.code}"
41
+ exit -1
42
+ end
43
+ subservers = JSON::parse(res.body)
44
+ @ipAddress = subservers.select {|s| s['name'] == subpath}[0]['host']
45
+ @ipAddress
46
+ end
47
+ end
48
+
49
+ class Worker < Machine
50
+ def self.ip(auth_code, host, environment, subdomain, type, subpath)
20
51
  @auth_code = auth_code
21
52
  @host = host
22
53
  self.client_list environment
@@ -26,6 +57,10 @@ class Worker
26
57
  exit -1
27
58
  end
28
59
  self.client environment, client_id.first
60
+ self.worker_ip subpath
61
+ end
62
+
63
+ def self.worker_ip(subpath)
29
64
  if(!@infra_info["WORKER_IP"])
30
65
  puts "Unable to find target WORKER_IP in #{@infra_info}. Is the machine up?"
31
66
  end
@@ -56,6 +91,16 @@ class Worker
56
91
  end
57
92
  end
58
93
 
94
+ class CashWorker < Worker
95
+ def self.worker_ip(subpath)
96
+ key = "#{subpath.gsub('_', '-')}_WORKER_IP"
97
+ if(!@infra_info[key])
98
+ puts "Unable to find target WORKER_IP in #{@infra_info}. Is the machine up?"
99
+ end
100
+ @infra_info[key]
101
+ end
102
+ end
103
+
59
104
  class Proboscis
60
105
  def self.host(environment)
61
106
  ENV["proboscis_#{environment}"]
@@ -65,21 +110,30 @@ class Proboscis
65
110
  ENV["proboscis_#{environment}_#{lookup}"]
66
111
  end
67
112
 
68
- def self.connect(environment, subdomain, target, type)
113
+ def self.connect(environment, subdomain, target, type, subpath='araneae')
69
114
  type = type == 'b' ? 'BUSY_BEE' : (type == 'i' ? 'INSTANT_HONEY' : 'CASH_REPLENISHMENT')
70
115
  @host = self.host(environment)
71
116
  self.login environment
72
- ip = self.get_ip environment, subdomain, type, target
117
+ machine = self.get_machine target, type
118
+ ip = machine.ip @auth_code, @host, environment, subdomain, type, subpath
73
119
  if(!ip)
74
120
  puts "Unable to find target #{ip}. Is the machine up?"
75
121
  exit -1
76
122
  end
77
123
  user = ENV["proboscis_#{environment}_target_user"] || "root"
78
- port = ENV["proboscis_#{environment}_target_port"] || "22"
124
+ port = machine.port environment, type, subpath
79
125
  puts "Executing ssh #{user}@#{ip} -p #{port}"
80
126
  system "ssh #{user}@#{ip} -p #{port}"
81
127
  end
82
128
 
129
+ def self.get_machine(target, type)
130
+ if type == 'c'
131
+ target == 'server' ? Server : Worker
132
+ else
133
+ target == 'server' ? CashServer : CashWorker
134
+ end
135
+ end
136
+
83
137
  def self.login(environment)
84
138
  response = HTTParty.post("#{@host}/api/login", body: {phoneNumber: self.param(environment, 'user'), password: self.param(environment, 'pass')}.to_json, headers: { 'Content-Type' => 'application/json' })
85
139
  if response.code != 200
@@ -88,9 +142,4 @@ class Proboscis
88
142
  end
89
143
  @auth_code = Base64.strict_encode64(JSON::parse(response.body)["accessToken"])
90
144
  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
96
145
  end
@@ -1,3 +1,3 @@
1
1
  module ProboscisCli
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'proboscis_cli'
3
- s.version = '0.0.7'
3
+ s.version = '0.0.8'
4
4
  s.date = '2018-04-10'
5
5
  s.summary = "A cli client for proboscis"
6
6
  s.description = "A cli client for proboscis"
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proboscis_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Roy
8
8
  - Arvind
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2018-04-10 00:00:00.000000000 Z
@@ -73,7 +73,7 @@ homepage: http://rubygems.org/gems/proboscis_cli
73
73
  licenses:
74
74
  - MIT
75
75
  metadata: {}
76
- post_install_message:
76
+ post_install_message:
77
77
  rdoc_options: []
78
78
  require_paths:
79
79
  - lib
@@ -88,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubygems_version: 3.0.1
92
- signing_key:
91
+ rubygems_version: 3.0.4
92
+ signing_key:
93
93
  specification_version: 4
94
94
  summary: A cli client for proboscis
95
95
  test_files: []