egi-fedcloud-cloudhound 0.0.2 → 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4e3b3c827061e35ca49b4ea566f0fa3264b4acd
|
4
|
+
data.tar.gz: 033094880617f0c90a25feaa5c4042c862d416a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37529d8dcd8fd6c4824ca091db0f959ae8212cc0a20058bc2c62f792db530cbf9b96f1b3c667228a525055466d35f0ab6fdd177e1681e32105f2e3bcfbe1e83b
|
7
|
+
data.tar.gz: 9d4e419443d9e6a20210332a7baa4da3fd728e1c021ddb76627d2adaae7e75aa64f410424d18f3730c684103fdff6394c06990f8345734b2a604a8109ce9f1e4
|
data/bin/egi-fedcloud-cloudhound
CHANGED
@@ -23,6 +23,8 @@ class EgiFedcloudCloudhound < Thor
|
|
23
23
|
include Thor::Actions
|
24
24
|
|
25
25
|
desc "all", "Prints information for all available cloud sites"
|
26
|
+
method_option :format, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.format,
|
27
|
+
:enum => Egi::Fedcloud::Cloudhound::Formatter::FORMATS, :aliases => '-o', :desc => 'Output formatting'
|
26
28
|
method_option :credentials, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.credentials,
|
27
29
|
:aliases => '-c', :desc => 'PEM file with a personal certificate and private key'
|
28
30
|
method_option :password, :type => :string, :default => nil,
|
@@ -38,7 +40,8 @@ class EgiFedcloudCloudhound < Thor
|
|
38
40
|
def all
|
39
41
|
init_log options[:debug]
|
40
42
|
|
41
|
-
$stdout.puts Egi::Fedcloud::Cloudhound::Formatter.
|
43
|
+
$stdout.puts Egi::Fedcloud::Cloudhound::Formatter.send(
|
44
|
+
"as_#{options[:format]}",
|
42
45
|
Egi::Fedcloud::Cloudhound::Extractor.find_all(
|
43
46
|
options
|
44
47
|
)
|
@@ -46,6 +49,8 @@ class EgiFedcloudCloudhound < Thor
|
|
46
49
|
end
|
47
50
|
|
48
51
|
desc "ip IP_ADDRESS", "Prints information based on the provided IP address or IP address range"
|
52
|
+
method_option :format, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.format,
|
53
|
+
:enum => Egi::Fedcloud::Cloudhound::Formatter::FORMATS, :aliases => '-o', :desc => 'Output formatting'
|
49
54
|
method_option :credentials, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.credentials,
|
50
55
|
:aliases => '-c', :desc => 'PEM file with a personal certificate and private key'
|
51
56
|
method_option :password, :type => :string, :default => nil,
|
@@ -61,7 +66,8 @@ class EgiFedcloudCloudhound < Thor
|
|
61
66
|
def ip(ip_address)
|
62
67
|
init_log options[:debug]
|
63
68
|
|
64
|
-
$stdout.puts Egi::Fedcloud::Cloudhound::Formatter.
|
69
|
+
$stdout.puts Egi::Fedcloud::Cloudhound::Formatter.send(
|
70
|
+
"as_#{options[:format]}",
|
65
71
|
Egi::Fedcloud::Cloudhound::Extractor.find_by_ip(
|
66
72
|
ip_address,
|
67
73
|
options
|
@@ -70,6 +76,8 @@ class EgiFedcloudCloudhound < Thor
|
|
70
76
|
end
|
71
77
|
|
72
78
|
desc "appuri URI", "Prints information based on the provided Appliance MPURI"
|
79
|
+
method_option :format, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.format,
|
80
|
+
:enum => Egi::Fedcloud::Cloudhound::Formatter::FORMATS, :aliases => '-o', :desc => 'Output formatting'
|
73
81
|
method_option :credentials, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.credentials,
|
74
82
|
:aliases => '-c', :desc => 'PEM file with a personal certificate and private key'
|
75
83
|
method_option :password, :type => :string, :default => nil,
|
@@ -85,7 +93,8 @@ class EgiFedcloudCloudhound < Thor
|
|
85
93
|
def appuri(uri)
|
86
94
|
init_log options[:debug]
|
87
95
|
|
88
|
-
$stdout.puts Egi::Fedcloud::Cloudhound::Formatter.
|
96
|
+
$stdout.puts Egi::Fedcloud::Cloudhound::Formatter.send(
|
97
|
+
"as_#{options[:format]}",
|
89
98
|
Egi::Fedcloud::Cloudhound::Extractor.find_by_appuri(
|
90
99
|
uri,
|
91
100
|
options
|
@@ -107,7 +116,7 @@ class EgiFedcloudCloudhound < Thor
|
|
107
116
|
# @return [Egi::Fedcloud::Cloudhound::Log] logger instance for additional configuration
|
108
117
|
def init_log(debug = false)
|
109
118
|
logger = Egi::Fedcloud::Cloudhound::Log.new(STDERR)
|
110
|
-
logger.level = debug ? Egi::Fedcloud::Cloudhound::Log::DEBUG : Egi::Fedcloud::Cloudhound::Log::
|
119
|
+
logger.level = debug ? Egi::Fedcloud::Cloudhound::Log::DEBUG : Egi::Fedcloud::Cloudhound::Log::WARN
|
111
120
|
logger
|
112
121
|
end
|
113
122
|
end
|
data/config/settings.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
---
|
2
2
|
production:
|
3
|
+
format: table
|
3
4
|
credentials: "<%= ENV['HOME'] %>/.globus/usercred.pem"
|
4
5
|
ca_path: '/etc/grid-security/certificates'
|
5
6
|
gocdb_base_url: 'https://goc.egi.eu'
|
@@ -7,6 +8,7 @@ production:
|
|
7
8
|
debug: false
|
8
9
|
|
9
10
|
development:
|
11
|
+
format: table
|
10
12
|
credentials: "<%= ENV['HOME'] %>/.globus/usercred.pem"
|
11
13
|
ca_path: '/etc/grid-security/certificates'
|
12
14
|
gocdb_base_url: 'https://goc.egi.eu'
|
@@ -14,6 +16,7 @@ development:
|
|
14
16
|
debug: true
|
15
17
|
|
16
18
|
test:
|
19
|
+
format: table
|
17
20
|
credentials: "<%= ENV['HOME'] %>/.globus/testcred.pem"
|
18
21
|
ca_path: '/etc/grid-security/certificates'
|
19
22
|
gocdb_base_url: 'http://localhost/goc'
|
@@ -3,10 +3,14 @@ require 'terminal-table'
|
|
3
3
|
#
|
4
4
|
class Egi::Fedcloud::Cloudhound::Formatter
|
5
5
|
|
6
|
+
FORMATS = %w(table json plain).freeze
|
7
|
+
|
6
8
|
class << self
|
7
9
|
#
|
8
10
|
def as_table(data = [])
|
9
11
|
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Transforming #{data.inspect} into a table"
|
12
|
+
|
13
|
+
data ||= []
|
10
14
|
table = Terminal::Table.new
|
11
15
|
|
12
16
|
table.add_row [' >>> Site Name <<< ', ' >>> NGI Name <<< ', ' >>> CSIRT Contact(s) <<< ']
|
@@ -21,7 +25,26 @@ class Egi::Fedcloud::Cloudhound::Formatter
|
|
21
25
|
|
22
26
|
#
|
23
27
|
def as_json(data = [])
|
24
|
-
data
|
28
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Transforming #{data.inspect} into a JSON document"
|
29
|
+
return '{}' if data.blank?
|
30
|
+
|
31
|
+
JSON.generate(data)
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
def as_plain(data = [])
|
36
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Transforming #{data.inspect} into plain text"
|
37
|
+
return '' if data.blank?
|
38
|
+
|
39
|
+
plain = []
|
40
|
+
data.each do |site|
|
41
|
+
Egi::Fedcloud::Cloudhound::Log.warn "[#{self}] #{site[:name]} doesn't " \
|
42
|
+
"have a CSIRT e-mail!" if site[:csirt].blank?
|
43
|
+
next if site[:csirt].blank?
|
44
|
+
plain << "#{site[:name]} <#{site[:csirt]}>"
|
45
|
+
end
|
46
|
+
|
47
|
+
plain.join ', '
|
25
48
|
end
|
26
49
|
end
|
27
50
|
|
@@ -16,7 +16,7 @@ class Egi::Fedcloud::Cloudhound::GocdbSite
|
|
16
16
|
@ngi = self.class.extract_text(element.locate('ROC'))
|
17
17
|
|
18
18
|
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Extracting IP ranges for site #{@name}"
|
19
|
-
@ip_ranges = self.class.extract_ranges(self.class.extract_text(element.locate('SITE_IP')))
|
19
|
+
@ip_ranges = self.class.extract_ranges(self.class.extract_text(element.locate('SITE_IP')), @name)
|
20
20
|
end
|
21
21
|
|
22
22
|
#
|
@@ -44,7 +44,7 @@ class Egi::Fedcloud::Cloudhound::GocdbSite
|
|
44
44
|
|
45
45
|
class << self
|
46
46
|
#
|
47
|
-
def extract_ranges(text_ranges)
|
47
|
+
def extract_ranges(text_ranges, site_name)
|
48
48
|
ranges = text_ranges.split(/[,;]/).reject { |el| el.blank? || !el.include?('/') || INVALID_RANGES.include?(el) }
|
49
49
|
|
50
50
|
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] -- Ranges: #{ranges.inspect}"
|
@@ -52,7 +52,8 @@ class Egi::Fedcloud::Cloudhound::GocdbSite
|
|
52
52
|
begin
|
53
53
|
IPAddr.new(range)
|
54
54
|
rescue
|
55
|
-
Egi::Fedcloud::Cloudhound::Log.warn "[#{self}]
|
55
|
+
Egi::Fedcloud::Cloudhound::Log.warn "[#{self}] Invalid IP range #{range.inspect} " \
|
56
|
+
"for site #{site_name}"
|
56
57
|
nil
|
57
58
|
end
|
58
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egi-fedcloud-cloudhound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Parak
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
272
|
version: '0'
|
273
273
|
requirements: []
|
274
274
|
rubyforge_project:
|
275
|
-
rubygems_version: 2.
|
275
|
+
rubygems_version: 2.4.4
|
276
276
|
signing_key:
|
277
277
|
specification_version: 4
|
278
278
|
summary: A proof-of-concept utility for locating cloud sites and corresponding CSIRT/CERT
|