onering-client 0.0.73 → 0.0.74

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.
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby -W0
1
+ #!/usr/bin/env ruby
2
2
  require 'trollop'
3
3
  require 'onering'
4
4
  require 'hashlib'
@@ -8,7 +8,7 @@ require 'pp'
8
8
  plugins = Onering::CLI.submodules.collect{|i| i.name.split('::').last.downcase }
9
9
  global = Trollop::options do
10
10
  banner <<-EOS
11
- onering command line client utility
11
+ onering command line client utility - version #{Onering::CLI::VERSION}
12
12
 
13
13
  Usage:
14
14
  onering [global] [plugin] [subcommand] [options]
@@ -16,13 +16,14 @@ Usage:
16
16
  where [global] options are:
17
17
  EOS
18
18
 
19
- opt :url, "The URL of the Onering server to connect to", :short => '-s', :type => :string
20
- opt :path, "The base path to prepend to all requests (default: /api)", :type => :string
21
- opt :param, "Additional query string parameters to include with the request in the format FIELD=VALUE. Can be specified multiple times.", :short => '-p', :type => :string, :multi => true
22
- opt :format, "The output format for return values (i.e.: json, yaml, text)", :default => 'text', :short => '-t', :type => :string
23
- opt :sslkey, "Location of the SSL client key to use for authentication", :short => '-c', :type => :string
24
- opt :apikey, "The API token to use for authentication", :short => '-k', :type => :string
25
- opt :quiet, "Suppress standard output", :short => '-q'
19
+ opt :url, "The URL of the Onering server to connect to", :short => '-s', :type => :string
20
+ opt :path, "The base path to prepend to all requests (default: /api)", :type => :string
21
+ opt :source, "Specify the source IP address to use (i.e. which network interface the request should originate from)", :short => '-I', :type => :string
22
+ opt :param, "Additional query string parameters to include with the request in the format FIELD=VALUE. Can be specified multiple times.", :short => '-p', :type => :string, :multi => true
23
+ opt :format, "The output format for return values (i.e.: json, yaml, text)", :default => 'text', :short => '-t', :type => :string
24
+ opt :sslkey, "Location of the SSL client key to use for authentication", :short => '-c', :type => :string
25
+ opt :apikey, "The API token to use for authentication", :short => '-k', :type => :string
26
+ opt :quiet, "Suppress standard output", :short => '-q'
26
27
 
27
28
  stop_on plugins
28
29
  end
@@ -6,6 +6,7 @@ require 'openssl'
6
6
  #
7
7
  module OpenSSL
8
8
  module SSL
9
+ remove_const :VERIFY_PEER
9
10
  VERIFY_PEER = VERIFY_NONE
10
11
  end
11
12
  end
@@ -59,6 +60,36 @@ module Onering
59
60
  # load and merge all config file sources
60
61
  _load_config(@_connection_options[:configfile], @_connection_options.get(:config, {}))
61
62
 
63
+ # source interface specified
64
+ # !! HAX !! HAX !! HAX !! HAX !! HAX !! HAX !! HAX !! HAX !! HAX !! HAX !!
65
+ # Due to certain versions of Ruby's Net::HTTP not allowing you explicitly
66
+ # specify the source IP/interface to use, this horrific monkey patch is
67
+ # necessary, if not right.
68
+ #
69
+ # If at least some of your code doesn't make you feel bottomless shame
70
+ # then you aren't coding hard enough.
71
+ #
72
+ if options.get('config.source').is_a?(String)
73
+ if options.get('config.source') =~ /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/
74
+ # insert firing pin into the hack
75
+ TCPSocket.instance_eval do
76
+ (class << self; self; end).instance_eval do
77
+ alias_method :_stock_open, :open
78
+ attr_writer :_hack_local_ip
79
+
80
+ define_method(:open) do |conn_address, conn_port|
81
+ _stock_open(conn_address, conn_port, @_hack_local_ip)
82
+ end
83
+ end
84
+ end
85
+
86
+ # arm the hack
87
+ TCPSocket._hack_local_ip = options.get('config.source')
88
+ else
89
+ raise "Invalid source IP address #{options.get('config.source')}"
90
+ end
91
+ end
92
+
62
93
  # set API connectivity details
63
94
  Onering::API.base_uri @_config.get(:url, DEFAULT_BASE)
64
95
 
@@ -13,6 +13,7 @@ module Onering
13
13
  'config' => {
14
14
  'url' => cliargs[:url],
15
15
  'path' => cliargs[:path],
16
+ 'source' => cliargs[:source],
16
17
  'params' => Hash[(cliargs[:param] || []).collect{|i| i.split('=',2) }],
17
18
  'authentication' => {
18
19
  'type' => (cliargs[:apikey_given] ? :token : nil),
@@ -0,0 +1,5 @@
1
+ module Onering
2
+ module CLI
3
+ VERSION = "0.0.74"
4
+ end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onering-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.73
4
+ version: 0.0.74
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: facter
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &20974000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: '1.6'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: '1.6'
24
+ version_requirements: *20974000
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: deep_merge
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &20973520 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,15 +32,10 @@ dependencies:
37
32
  version: '0'
38
33
  type: :runtime
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
35
+ version_requirements: *20973520
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: addressable
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &20973020 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ! '>='
@@ -53,15 +43,10 @@ dependencies:
53
43
  version: '0'
54
44
  type: :runtime
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
46
+ version_requirements: *20973020
62
47
  - !ruby/object:Gem::Dependency
63
48
  name: httparty
64
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &20972560 !ruby/object:Gem::Requirement
65
50
  none: false
66
51
  requirements:
67
52
  - - ! '>='
@@ -69,15 +54,10 @@ dependencies:
69
54
  version: '0'
70
55
  type: :runtime
71
56
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
57
+ version_requirements: *20972560
78
58
  - !ruby/object:Gem::Dependency
79
59
  name: hashlib
80
- requirement: !ruby/object:Gem::Requirement
60
+ requirement: &20972100 !ruby/object:Gem::Requirement
81
61
  none: false
82
62
  requirements:
83
63
  - - ! '>='
@@ -85,15 +65,10 @@ dependencies:
85
65
  version: 0.0.19
86
66
  type: :runtime
87
67
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: 0.0.19
68
+ version_requirements: *20972100
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: multi_json
96
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &20971620 !ruby/object:Gem::Requirement
97
72
  none: false
98
73
  requirements:
99
74
  - - ! '>='
@@ -101,15 +76,10 @@ dependencies:
101
76
  version: '0'
102
77
  type: :runtime
103
78
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
79
+ version_requirements: *20971620
110
80
  - !ruby/object:Gem::Dependency
111
81
  name: rainbow
112
- requirement: !ruby/object:Gem::Requirement
82
+ requirement: &20971120 !ruby/object:Gem::Requirement
113
83
  none: false
114
84
  requirements:
115
85
  - - ! '>='
@@ -117,15 +87,10 @@ dependencies:
117
87
  version: '0'
118
88
  type: :runtime
119
89
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
90
+ version_requirements: *20971120
126
91
  - !ruby/object:Gem::Dependency
127
92
  name: trollop
128
- requirement: !ruby/object:Gem::Requirement
93
+ requirement: &20970660 !ruby/object:Gem::Requirement
129
94
  none: false
130
95
  requirements:
131
96
  - - ! '>='
@@ -133,12 +98,7 @@ dependencies:
133
98
  version: '0'
134
99
  type: :runtime
135
100
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
101
+ version_requirements: *20970660
142
102
  description: A Ruby wrapper for Onering
143
103
  email: ghetzel@outbrain.com
144
104
  executables:
@@ -147,19 +107,20 @@ extensions: []
147
107
  extra_rdoc_files: []
148
108
  files:
149
109
  - lib/onering.rb
150
- - lib/onering/util.rb
151
- - lib/onering/api.rb
152
110
  - lib/onering/cli.rb
153
- - lib/onering/cli/fact.rb
154
- - lib/onering/cli/call.rb
155
- - lib/onering/cli/config.rb
156
- - lib/onering/cli/devices.rb
157
- - lib/onering/cli/automation.rb
158
- - lib/onering/cli/reporter.rb
159
- - lib/onering/plugins/devices.rb
111
+ - lib/onering/api.rb
112
+ - lib/onering/util.rb
160
113
  - lib/onering/plugins/authentication.rb
161
- - lib/onering/plugins/automation.rb
162
114
  - lib/onering/plugins/reporter.rb
115
+ - lib/onering/plugins/devices.rb
116
+ - lib/onering/plugins/automation.rb
117
+ - lib/onering/cli/reporter.rb
118
+ - lib/onering/cli/version.rb
119
+ - lib/onering/cli/devices.rb
120
+ - lib/onering/cli/config.rb
121
+ - lib/onering/cli/automation.rb
122
+ - lib/onering/cli/fact.rb
123
+ - lib/onering/cli/call.rb
163
124
  - bin/onering
164
125
  homepage: https://github.com/outbrain/onering-ruby
165
126
  licenses: []
@@ -181,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
142
  version: '0'
182
143
  requirements: []
183
144
  rubyforge_project:
184
- rubygems_version: 1.8.23
145
+ rubygems_version: 1.8.11
185
146
  signing_key:
186
147
  specification_version: 3
187
148
  summary: Onering client API and utilities