op5util 0.1.2 → 0.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/bin/op5util +6 -3
- data/lib/op5util/check_auth.rb +9 -0
- data/lib/op5util/version.rb +1 -1
- data/pkg/op5util-0.1.2.gem +0 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66a61ce3bc99e6e4d91278aefc1c6d3f5f9c4fd2
|
4
|
+
data.tar.gz: ba3e0fd30da81840f892b86f3244337a1c74ae6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 971e2e9b7b31ec5df7b079ed2da7b67c0783d7b21cf916b6d42df074f3d4a0bb08d2f7990b9373745a4543f251424e42fe82c020dbe3ccad374509142649b7cc
|
7
|
+
data.tar.gz: 27bd5cf0ba4dd63fac584f02c4e92c16b91a2465a14cc77a29ae64d73297a0d185510d4e02f78b7120b32c0af509421432cfffc994438462a24159163f15ea1b
|
data/Gemfile.lock
CHANGED
data/bin/op5util
CHANGED
@@ -9,7 +9,7 @@ include GLI::App
|
|
9
9
|
|
10
10
|
program_desc 'A small utility to perform common Op5 administration tasks from the command line'
|
11
11
|
program_long_desc '
|
12
|
-
About authentication, if you supply username/password as command-line flags they will be used first. If username/password options isn\'t supplied on the command-line, the environment variables OP5USER and OP5PASS will be used. If there are no environment variables present, the file ~/.op5pass (or --authfile
|
12
|
+
About authentication, if you supply username/password as command-line flags they will be used first. If username/password options isn\'t supplied on the command-line, the environment variables OP5USER and OP5PASS will be used. If there are no environment variables present, the file ~/.op5pass (or --authfile=, or environment OP5AUTHFILE) will be read. The file format is a single line with username and password separated by a : (colon). The supplied credentials shoud be an account with administrative privileges.
|
13
13
|
|
14
14
|
This application uses the REST-api described at https://your.op5.sever/api/help. Although TLS/SSL is used, no verification of the certificate is done as most Op5-servers have a self-signed certificate.'
|
15
15
|
|
@@ -32,7 +32,7 @@ desc 'Hostname or IP-address of the Op5 monitor server, if not supplied the envi
|
|
32
32
|
arg_name 'monitor'
|
33
33
|
flag [:m, :monitor]
|
34
34
|
|
35
|
-
desc 'Authfile containing "username:password" used to authenticate with Op5 server'
|
35
|
+
desc 'Authfile containing "username:password" used to authenticate with Op5 server, enviromnent variable OP5AUTHFILE will override the default value'
|
36
36
|
default_value '~/.op5pass'
|
37
37
|
arg_name 'authfile'
|
38
38
|
flag [:f, :authfile]
|
@@ -157,8 +157,11 @@ command :hostgroups do |c|
|
|
157
157
|
end
|
158
158
|
|
159
159
|
pre do |global, _command, _options, _args|
|
160
|
+
global[:authfile] = ENV['OP5AUTHFILE'] if !ENV['OP5AUTHFILE'].nil? && (global[:authfile] == '~/.op5pass')
|
160
161
|
Op5util.check_auth(global) ? true : false
|
161
162
|
if global[:monitor].nil? && ENV['MONITOR'].nil?
|
163
|
+
puts 'Hostname of Op5 server is required, Use -m/--monitor=op5.server.com or environment variable MONITOR'
|
164
|
+
raise Op5util::NoMonitorServerError
|
162
165
|
false
|
163
166
|
else
|
164
167
|
global[:monitor] = ENV['MONITOR'] if global['monitor'].nil?
|
@@ -174,7 +177,7 @@ on_error do |exception|
|
|
174
177
|
# return false to skip default error handling
|
175
178
|
# TODO: Catch error and print an apropriate message
|
176
179
|
puts "Error, #{exception}"
|
177
|
-
|
180
|
+
true
|
178
181
|
end
|
179
182
|
|
180
183
|
exit run(ARGV)
|
data/lib/op5util/check_auth.rb
CHANGED
@@ -8,6 +8,9 @@
|
|
8
8
|
# Toplevel documentation
|
9
9
|
module Op5util
|
10
10
|
class NoAuthMethodError < StandardError; end
|
11
|
+
class UnacceptableAuthFilePermission < StandardError; end
|
12
|
+
class NoMonitorServerError < ArgumentError; end
|
13
|
+
|
11
14
|
def check_authfile(file)
|
12
15
|
authline = File.open(File.expand_path(file)).readline.chomp
|
13
16
|
rescue StandardError
|
@@ -18,6 +21,11 @@ module Op5util
|
|
18
21
|
end
|
19
22
|
|
20
23
|
def check_auth(global_opts)
|
24
|
+
authfile_path = File.expand_path(global_opts[:authfile])
|
25
|
+
if File.exist?(authfile_path) && File.stat(authfile_path).mode.to_s(8)[-2, 2] != '00'
|
26
|
+
puts "Authfile must not be readable by other than owner, run \"chmod 400 #{global_opts[:authfile]}\" to set better permissions"
|
27
|
+
raise UnacceptableAuthFilePermission
|
28
|
+
end
|
21
29
|
if !global_opts[:username].nil? && !global_opts[:password].nil?
|
22
30
|
true
|
23
31
|
elsif !ENV['OP5USER'].nil? && !ENV['OP5PASS'].nil?
|
@@ -28,6 +36,7 @@ module Op5util
|
|
28
36
|
(global_opts[:username], global_opts[:password]) = check_authfile(global_opts[:authfile])
|
29
37
|
global_opts[:username].nil? ? false : true
|
30
38
|
else
|
39
|
+
puts 'No method of authentication with Op5-Server given'
|
31
40
|
raise NoAuthMethodError
|
32
41
|
end
|
33
42
|
end
|
data/lib/op5util/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: op5util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niklas Paulsson
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- pkg/op5util-0.0.9.gem
|
147
147
|
- pkg/op5util-0.1.0.gem
|
148
148
|
- pkg/op5util-0.1.1.gem
|
149
|
+
- pkg/op5util-0.1.2.gem
|
149
150
|
- screenshots/host_op5.png
|
150
151
|
- screenshots/host_op5_listview.png
|
151
152
|
- screenshots/usecase1.png
|