proboscis_cli 0.0.1 → 0.0.3

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
  SHA1:
3
- metadata.gz: 5e3b6f2f18f6f9665c39527fcf3506b71313fe57
4
- data.tar.gz: c2247b2671caac429aed7efb01bcffc0b063b7d6
3
+ metadata.gz: 68887540f97851fe83c8058dc3b0e4c0a6133c54
4
+ data.tar.gz: 169d78d95aaa119595799910cf71fe8e3c98861e
5
5
  SHA512:
6
- metadata.gz: 04dd7bd6846b352f7c889315ae8e7f6c3788b00268a680d2a402aefeb71294cb8806a2627fbf3f5273c3941cc7031b67e59bcc1f2f97d4a49577d59fdf9f1390
7
- data.tar.gz: 764138989c723e0fec2aa2c48c11a1f2e6a89654171c1ca231ad4c5703e344e1e364b819563ccace874f0294e8f8effbe32bb3b2aebed42425b06e8c6648f27e
6
+ metadata.gz: 4640c861d6c7326ebff498a81d93b4c68813246dbb94f18f34bc3332f88d9918a8cc6d757992a168138fa5671be1cb7380f9750a39199fd67fb5946ec335cedf
7
+ data.tar.gz: b2a2945c1f4aaf86085d69c4f6772887d955da46352dd06e0a0c73e55f5727cb0bc134f165d3bb136fc6d166b6a8fa434e0732bff9fed9262a6757c4f372a25d
data/bin/proboscis CHANGED
@@ -1,18 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'proboscis_cli'
3
3
 
4
- if(ARGV.empty? || ARGV.size != 3)
5
- puts "Usage proboscis <qa|prod> <subdomain> <server|worker>"
4
+ if(ARGV.empty? || ARGV.size != 4)
5
+ puts "Usage proboscis <qa|prod> <subdomain> <server|worker> <b|i>"
6
6
  exit
7
7
  end
8
8
 
9
9
  environment = ARGV[0].downcase
10
10
  subdomain = ARGV[1].downcase
11
11
  target = ARGV[2].downcase
12
+ type = ARGV[3].downcase
12
13
 
13
- if((%w(qa prod).select {|e| e == environment}).empty? || (%w(server worker).select {|e| e == target}).empty?)
14
- puts "Usage proboscis <qa|prod> <subdomain> <server|worker>"
14
+ if((%w(qa prod).select {|e| e == environment}).empty? ||
15
+ (%w(server worker).select {|e| e == target}).empty? ||
16
+ (%w(b i).select {|e| e == type}).empty?)
17
+ puts "Usage proboscis <qa|prod> <subdomain> <server|worker> <b|i>"
15
18
  exit
16
19
  end
17
20
 
18
- Proboscis.connect(environment, subdomain, target)
21
+ Proboscis.connect(environment, subdomain, target, type)
@@ -1,3 +1,3 @@
1
1
  module ProboscisCli
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/proboscis_cli.rb CHANGED
@@ -4,7 +4,6 @@ require 'json'
4
4
  require "base64"
5
5
 
6
6
  class Proboscis
7
-
8
7
  def self.host(environment)
9
8
  ENV["proboscis_#{environment}"]
10
9
  end
@@ -12,48 +11,29 @@ class Proboscis
12
11
  def self.param(environment, lookup)
13
12
  ENV["proboscis_#{environment}_#{lookup}"]
14
13
  end
15
-
16
- def self.connect(environment, subdomain, target)
14
+
15
+ def self.connect(environment, subdomain, target, type)
16
+ type = type == 'b' ? 'BUSY_BEE' : 'INSTANT_HONEY'
17
17
  self.login environment
18
- self.client_list environment
19
- client_id = @client_list.select {|c| c["domain"] == subdomain}
20
- if client_id.empty?
21
- puts "Unable to find client with subdomain #{subdomain}"
22
- exit -1
23
- end
24
- self.client environment, client_id.first
25
- if(!@infra_info["#{target.upcase}_IP"])
26
- puts "Unable to find target #{target.upcase}_IP in #{@infra_info}. Is the machine up?"
18
+ self.client environment, subdomain, type
19
+ if(!@ipAddress)
20
+ puts "Unable to find target #{@ipAddress}. Is the machine up?"
27
21
  exit -1
28
22
  end
29
- ip = @infra_info["#{target.upcase}_IP"]
30
23
  user = ENV["proboscis_#{environment}_target_user"] || "root"
31
24
  port = ENV["proboscis_#{environment}_target_port"] || "22"
32
- puts "Executing ssh #{user}@#{ip} -p #{port}"
33
- system "ssh #{user}@#{ip} -p #{port}"
34
- end
35
-
36
- def self.client(environment, client_id)
37
- response = HTTParty.get("#{self.host(environment)}/api/api/clients/#{client_id["id"]}/products", headers: {"X-Authorization" => @auth_code})
38
- if response.code != 200
39
- puts "Unable to fetch details of client with id #{client_id}"
40
- exit -1
41
- end
42
- infra_info = JSON::parse(response.body)
43
- if infra_info.empty?
44
- puts "No Products Mapped!"
45
- exit -1
46
- end
47
- @infra_info = JSON::parse(infra_info.first["infrastructureInfo"])
25
+ puts "Executing ssh #{user}@#{@ipAddress} -p #{port}"
26
+ system "ssh #{user}@#{@ipAddress} -p #{port}"
48
27
  end
49
28
 
50
- def self.client_list(environment)
51
- response = HTTParty.get("#{self.host(environment)}/api/api/clients", headers: {"X-Authorization" => @auth_code})
29
+ def self.client(environment, subdomain, type)
30
+ response = HTTParty.get("#{self.host(environment)}/api/api/hives/#{subdomain}/#{type}", headers: {"X-Authorization" => @auth_code})
52
31
  if response.code != 200
53
- puts "Unable to get the client list.."
32
+ puts "Unable to fetch details for domain #{subdomain}"
54
33
  exit -1
55
34
  end
56
- @client_list = JSON::parse(response.body)["content"]
35
+ hive = JSON::parse(response.body)
36
+ @ipAddress = hive["ip_address"]
57
37
  end
58
38
 
59
39
  def self.login(environment)
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'proboscis_cli'
3
- s.version = '0.0.1'
4
- s.date = '2017-11-13'
3
+ s.version = '0.0.3'
4
+ s.date = '2017-12-18'
5
5
  s.summary = "A cli client for proboscis"
6
6
  s.description = "A cli client for proboscis"
7
- s.authors = ["Simon Roy"]
7
+ s.authors = ["Simon Roy", "Arvind"]
8
8
  s.email = 'simon@delium.co'
9
9
  s.homepage =
10
10
  'http://rubygems.org/gems/proboscis_cli'
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proboscis_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Roy
8
+ - Arvind
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-11-13 00:00:00.000000000 Z
12
+ date: 2017-12-18 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  version: '0'
89
90
  requirements: []
90
91
  rubyforge_project:
91
- rubygems_version: 2.6.13
92
+ rubygems_version: 2.6.11
92
93
  signing_key:
93
94
  specification_version: 4
94
95
  summary: A cli client for proboscis