egi-fedcloud-vmhound 0.0.1 → 0.0.2
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/bin/egi-fedcloud-vmhound +15 -6
- data/config/settings.yml +3 -0
- data/lib/egi/fedcloud/vmhound/connectors/dummy_connector.rb +2 -0
- data/lib/egi/fedcloud/vmhound/connectors/opennebula_connector.rb +31 -1
- data/lib/egi/fedcloud/vmhound/extractor.rb +1 -0
- data/lib/egi/fedcloud/vmhound/formatter.rb +17 -9
- data/lib/egi/fedcloud/vmhound/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 318e4b960de7c33ef26bdc80d47b2549e7990540
|
4
|
+
data.tar.gz: 6443cbdf45d2a17a90a73a5b7a0c0419a1641247
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb7997567ebd5f0c68f917ee1d3503581dec6aa2fc0776f900eab238ef4048710ba04db6937788f3fcc80afbd4abb97867e61e2df6725af93878cc1df3a41d35
|
7
|
+
data.tar.gz: 7fdda488d9ce49582c2b114b7b9280f37601749d74069e2a5af406cf70c5ac60c91f8a8ff3fa1be2c99871841210ee73ba7327c4a4bcab6bcb231269f7a454eb
|
data/bin/egi-fedcloud-vmhound
CHANGED
@@ -24,7 +24,7 @@ class EgiFedcloudVmhound < Thor
|
|
24
24
|
|
25
25
|
desc "ip IP_ADDRESS", "Prints information based on the provided IP address or IP address range"
|
26
26
|
method_option :cmf, :type => :string, :default => Egi::Fedcloud::Vmhound::Settings.cmf,
|
27
|
-
:aliases => '-c', :desc => 'Type of the underlying CMF'
|
27
|
+
:aliases => '-c', :desc => 'Type of the underlying CMF'
|
28
28
|
method_option :endpoint, :type => :string, :default => nil,
|
29
29
|
:aliases => '-e', :desc => 'Endpoint of the CMF'
|
30
30
|
method_option :username, :type => :string, :default => nil,
|
@@ -37,6 +37,8 @@ class EgiFedcloudVmhound < Thor
|
|
37
37
|
:aliases => '-x', :desc => 'Directory path to all trusted CA certificates'
|
38
38
|
method_option :insecure, :type => :boolean, :default => Egi::Fedcloud::Vmhound::Settings.insecure,
|
39
39
|
:aliases => '-k', :desc => 'Enable insecure mode for SSL (no peer validation)'
|
40
|
+
method_option :details, :type => :boolean, :default => Egi::Fedcloud::Vmhound::Settings.details,
|
41
|
+
:aliases => '-l', :desc => 'Enable wide tables with more details (off by default)'
|
40
42
|
method_option :debug, :type => :boolean, :default => Egi::Fedcloud::Vmhound::Settings.debug,
|
41
43
|
:aliases => '-d', :desc => 'Enable debugging'
|
42
44
|
def ip(ip_address)
|
@@ -46,13 +48,14 @@ class EgiFedcloudVmhound < Thor
|
|
46
48
|
Egi::Fedcloud::Vmhound::Extractor.find_by_ip(
|
47
49
|
ip_address,
|
48
50
|
options
|
49
|
-
)
|
51
|
+
),
|
52
|
+
options
|
50
53
|
)
|
51
54
|
end
|
52
55
|
|
53
56
|
desc "appuri URI", "Prints information based on the provided Appliance MPURI"
|
54
57
|
method_option :cmf, :type => :string, :default => Egi::Fedcloud::Vmhound::Settings.cmf,
|
55
|
-
:aliases => '-c', :desc => 'Type of the underlying CMF'
|
58
|
+
:aliases => '-c', :desc => 'Type of the underlying CMF'
|
56
59
|
method_option :endpoint, :type => :string, :default => nil,
|
57
60
|
:aliases => '-e', :desc => 'Endpoint of the CMF'
|
58
61
|
method_option :username, :type => :string, :default => nil,
|
@@ -65,6 +68,8 @@ class EgiFedcloudVmhound < Thor
|
|
65
68
|
:aliases => '-x', :desc => 'Directory path to all trusted CA certificates'
|
66
69
|
method_option :insecure, :type => :boolean, :default => Egi::Fedcloud::Vmhound::Settings.insecure,
|
67
70
|
:aliases => '-k', :desc => 'Enable insecure mode for SSL (no peer validation)'
|
71
|
+
method_option :details, :type => :boolean, :default => Egi::Fedcloud::Vmhound::Settings.details,
|
72
|
+
:aliases => '-l', :desc => 'Enable wide tables with more details (off by default)'
|
68
73
|
method_option :debug, :type => :boolean, :default => Egi::Fedcloud::Vmhound::Settings.debug,
|
69
74
|
:aliases => '-d', :desc => 'Enable debugging'
|
70
75
|
def appuri(uri)
|
@@ -74,13 +79,14 @@ class EgiFedcloudVmhound < Thor
|
|
74
79
|
Egi::Fedcloud::Vmhound::Extractor.find_by_appuri(
|
75
80
|
uri,
|
76
81
|
options
|
77
|
-
)
|
82
|
+
),
|
83
|
+
options
|
78
84
|
)
|
79
85
|
end
|
80
86
|
|
81
87
|
desc "user ID", "Prints information based on the provided user identifier"
|
82
88
|
method_option :cmf, :type => :string, :default => Egi::Fedcloud::Vmhound::Settings.cmf,
|
83
|
-
:aliases => '-c', :desc => 'Type of the underlying CMF'
|
89
|
+
:aliases => '-c', :desc => 'Type of the underlying CMF'
|
84
90
|
method_option :endpoint, :type => :string, :default => nil,
|
85
91
|
:aliases => '-e', :desc => 'Endpoint of the CMF'
|
86
92
|
method_option :username, :type => :string, :default => nil,
|
@@ -93,6 +99,8 @@ class EgiFedcloudVmhound < Thor
|
|
93
99
|
:aliases => '-x', :desc => 'Directory path to all trusted CA certificates'
|
94
100
|
method_option :insecure, :type => :boolean, :default => Egi::Fedcloud::Vmhound::Settings.insecure,
|
95
101
|
:aliases => '-k', :desc => 'Enable insecure mode for SSL (no peer validation)'
|
102
|
+
method_option :details, :type => :boolean, :default => Egi::Fedcloud::Vmhound::Settings.details,
|
103
|
+
:aliases => '-l', :desc => 'Enable wide tables with more details (off by default)'
|
96
104
|
method_option :debug, :type => :boolean, :default => Egi::Fedcloud::Vmhound::Settings.debug,
|
97
105
|
:aliases => '-d', :desc => 'Enable debugging'
|
98
106
|
def user(id)
|
@@ -102,7 +110,8 @@ class EgiFedcloudVmhound < Thor
|
|
102
110
|
Egi::Fedcloud::Vmhound::Extractor.find_by_user(
|
103
111
|
id,
|
104
112
|
options
|
105
|
-
)
|
113
|
+
),
|
114
|
+
options
|
106
115
|
)
|
107
116
|
end
|
108
117
|
|
data/config/settings.yml
CHANGED
@@ -3,16 +3,19 @@ production:
|
|
3
3
|
cmf: opennebula
|
4
4
|
ca_path: '/etc/grid-security/certificates'
|
5
5
|
insecure: false
|
6
|
+
details: false
|
6
7
|
debug: false
|
7
8
|
|
8
9
|
development:
|
9
10
|
cmf: opennebula
|
10
11
|
ca_path: '/etc/grid-security/certificates'
|
11
12
|
insecure: true
|
13
|
+
details: true
|
12
14
|
debug: true
|
13
15
|
|
14
16
|
test:
|
15
17
|
cmf: dummy
|
16
18
|
ca_path: '/etc/grid-security/certificates'
|
17
19
|
insecure: true
|
20
|
+
details: true
|
18
21
|
debug: true
|
@@ -7,6 +7,7 @@ class Egi::Fedcloud::Vmhound::Connectors::DummyConnector < Egi::Fedcloud::Vmhoun
|
|
7
7
|
#
|
8
8
|
# @return [Array<Hash>] List of instances, each represented as a hash
|
9
9
|
def active_instances
|
10
|
+
Egi::Fedcloud::Vmhound::Log.info "[#{self.class}] Retrieving active instances"
|
10
11
|
[]
|
11
12
|
end
|
12
13
|
|
@@ -15,6 +16,7 @@ class Egi::Fedcloud::Vmhound::Connectors::DummyConnector < Egi::Fedcloud::Vmhoun
|
|
15
16
|
#
|
16
17
|
# @return [Array<Hash>] List of instances, each represented as a hash
|
17
18
|
def running_instances
|
19
|
+
Egi::Fedcloud::Vmhound::Log.info "[#{self.class}] Retrieving running instances"
|
18
20
|
[]
|
19
21
|
end
|
20
22
|
|
@@ -13,8 +13,10 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
13
13
|
super
|
14
14
|
|
15
15
|
secret = if opts[:username] && opts[:password]
|
16
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Using provided plain credentials"
|
16
17
|
"#{opts[:username]}:#{opts[:password]}"
|
17
18
|
else
|
19
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Falling back to file and environment credentials"
|
18
20
|
opts[:auth_file] ? File.read(opts[:auth_file]) : nil
|
19
21
|
end
|
20
22
|
secret.strip! if secret
|
@@ -43,6 +45,7 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
43
45
|
#
|
44
46
|
# @return [Array<Hash>] List of instances, each represented as a hash
|
45
47
|
def active_instances
|
48
|
+
Egi::Fedcloud::Vmhound::Log.info "[#{self.class}] Retrieving active instances"
|
46
49
|
instances
|
47
50
|
end
|
48
51
|
|
@@ -51,6 +54,7 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
51
54
|
#
|
52
55
|
# @return [Array<Hash>] List of instances, each represented as a hash
|
53
56
|
def running_instances
|
57
|
+
Egi::Fedcloud::Vmhound::Log.info "[#{self.class}] Retrieving running instances"
|
54
58
|
instances ['ACTIVE']
|
55
59
|
end
|
56
60
|
|
@@ -62,6 +66,9 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
62
66
|
# @param reject_states [Array<String>] a list of states to be rejected
|
63
67
|
# @return [Array<Hash>] a list of instances matching given criteria
|
64
68
|
def instances(allow_states = nil, reject_states = nil)
|
69
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Retrieving instances: " \
|
70
|
+
"allow_states=#{allow_states.inspect} & " \
|
71
|
+
"reject_states=#{reject_states.inspect}"
|
65
72
|
return if allow_states && allow_states.empty?
|
66
73
|
reject_states ||= []
|
67
74
|
|
@@ -69,7 +76,12 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
69
76
|
|
70
77
|
vms = []
|
71
78
|
@vm_pool_ary.each do |vm|
|
72
|
-
|
79
|
+
if reject_states.include? vm.state_str
|
80
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Rejecting VM #{vm['ID']} " \
|
81
|
+
"-- #{vm.state_str}"
|
82
|
+
next
|
83
|
+
end
|
84
|
+
|
73
85
|
vms << canonical_instance(vm) if (allow_states.nil? || (allow_states && allow_states.include?(vm.state_str)))
|
74
86
|
end
|
75
87
|
|
@@ -84,17 +96,21 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
84
96
|
# @return [Array<OpenNebula::VirtualMachine>] a list of VM instances
|
85
97
|
def instances_batch_pool(vm_pool)
|
86
98
|
fail 'Pool object not provided!' unless vm_pool
|
99
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Iterating over the VM " \
|
100
|
+
"pool with batch size #{VM_POOL_BATCH_SIZE}"
|
87
101
|
|
88
102
|
batch_start = 0
|
89
103
|
batch_stop = VM_POOL_BATCH_SIZE - 1
|
90
104
|
vm_pool_ary = []
|
91
105
|
|
92
106
|
begin
|
107
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Getting #{batch_start} to #{batch_stop}"
|
93
108
|
check_retval vm_pool.info(
|
94
109
|
OpenNebula::VirtualMachinePool::INFO_ALL,
|
95
110
|
batch_start, batch_stop,
|
96
111
|
OpenNebula::VirtualMachinePool::INFO_NOT_DONE
|
97
112
|
)
|
113
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Got #{vm_pool.count.inspect} VMs from pool"
|
98
114
|
vm_pool_ary.concat vm_pool.to_a unless vm_pool.count < 1
|
99
115
|
|
100
116
|
batch_start = batch_stop + 1
|
@@ -110,6 +126,7 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
110
126
|
# @return [Array<Hash>] a list of images
|
111
127
|
def images
|
112
128
|
return @canonical_image_pool if @canonical_image_pool
|
129
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Retrieving all images"
|
113
130
|
check_retval @image_pool.info_all!
|
114
131
|
|
115
132
|
@canonical_image_pool = []
|
@@ -122,6 +139,7 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
122
139
|
# @param image_id [String,Integer] native image ID
|
123
140
|
# @return [Hash,NilClass] canonical image structure
|
124
141
|
def image_by_id(image_id)
|
142
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Picking image ID #{image_id.inspect} from pool"
|
125
143
|
images.select { |image| image[:id] == image_id.to_i }.first
|
126
144
|
end
|
127
145
|
|
@@ -130,6 +148,7 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
130
148
|
# @return [Array<Hash>] a list of users
|
131
149
|
def users
|
132
150
|
return @canonical_user_pool if @canonical_user_pool
|
151
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Retrieving all users"
|
133
152
|
check_retval @user_pool.info!
|
134
153
|
|
135
154
|
@canonical_user_pool = []
|
@@ -142,6 +161,7 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
142
161
|
# @param user_id [String,Integer] native user ID
|
143
162
|
# @return [Hash,NilClass] canonical user structure
|
144
163
|
def user_by_id(user_id)
|
164
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Picking user ID #{user_id.inspect} from pool"
|
145
165
|
users.select { |user| user[:id] == user_id.to_i }.first
|
146
166
|
end
|
147
167
|
|
@@ -175,6 +195,8 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
175
195
|
opennebula_instance.each('TEMPLATE/NIC') { |nic| ips << nic['IP'] }
|
176
196
|
ips.compact!
|
177
197
|
|
198
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Assigning IPs #{ips.inspect} " \
|
199
|
+
"to #{opennebula_instance['ID'].inspect}"
|
178
200
|
ips
|
179
201
|
end
|
180
202
|
|
@@ -191,6 +213,8 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
191
213
|
identifiers << opennebula_instance['ID'].to_s
|
192
214
|
identifiers.compact!
|
193
215
|
|
216
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Assigning instance IDs " \
|
217
|
+
"#{identifiers.inspect} to #{opennebula_instance['ID'].inspect}"
|
194
218
|
identifiers
|
195
219
|
end
|
196
220
|
|
@@ -205,6 +229,8 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
205
229
|
opennebula_instance.each('HISTORY_RECORDS/HISTORY') { |history| hosts << history['HOSTNAME'] }
|
206
230
|
hosts.compact!
|
207
231
|
|
232
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Assigning hosts #{hosts.inspect} " \
|
233
|
+
"to #{opennebula_instance['ID'].inspect}"
|
208
234
|
hosts.last
|
209
235
|
end
|
210
236
|
|
@@ -242,6 +268,8 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
242
268
|
identifiers << opennebula_image['ID'].to_s
|
243
269
|
identifiers.compact!
|
244
270
|
|
271
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Assigning IDs #{identifiers.inspect} " \
|
272
|
+
"to image #{opennebula_image['ID'].inspect}"
|
245
273
|
identifiers
|
246
274
|
end
|
247
275
|
|
@@ -277,6 +305,8 @@ class Egi::Fedcloud::Vmhound::Connectors::OpennebulaConnector < Egi::Fedcloud::V
|
|
277
305
|
identities.flatten!
|
278
306
|
identities.compact!
|
279
307
|
|
308
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self.class}] Assigning identities #{identities.inspect} " \
|
309
|
+
"to user #{opennebula_user['ID'].inspect}"
|
280
310
|
identities
|
281
311
|
end
|
282
312
|
|
@@ -12,6 +12,7 @@ class Egi::Fedcloud::Vmhound::Extractor
|
|
12
12
|
return if defined?(@@connector)
|
13
13
|
|
14
14
|
connector_name = "#{options[:cmf].camelize}Connector"
|
15
|
+
Egi::Fedcloud::Vmhound::Log.debug "[#{self}] Getting #{connector_name} for #{options[:cmf]}"
|
15
16
|
@@connector = Egi::Fedcloud::Vmhound::Connectors.const_get(connector_name).new(options)
|
16
17
|
|
17
18
|
connector_name
|
@@ -5,30 +5,38 @@ class Egi::Fedcloud::Vmhound::Formatter
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
#
|
8
|
-
def as_table(data)
|
8
|
+
def as_table(data, opts = {})
|
9
9
|
data ||= []
|
10
10
|
Egi::Fedcloud::Vmhound::Log.debug "[#{self}] Transforming #{data.inspect} into a table"
|
11
11
|
table = Terminal::Table.new
|
12
12
|
|
13
|
-
|
14
|
-
' >>> VM ID <<< ', ' >>>
|
15
|
-
' >>>
|
16
|
-
' >>> Contact <<< '
|
13
|
+
thead = [
|
14
|
+
' >>> VM ID <<< ', ' >>> Contact <<< ',
|
15
|
+
' >>> Location <<< ', ' >>> State <<< '
|
17
16
|
]
|
17
|
+
thead.concat [
|
18
|
+
' >>> Owner Identity <<< ', ' >>> Group <<< ', ' >>> IPs <<< '
|
19
|
+
] if opts[:details]
|
20
|
+
|
21
|
+
table.add_row thead
|
18
22
|
table.add_separator
|
19
23
|
data.each do |vm|
|
20
24
|
table.add_separator
|
21
|
-
|
22
|
-
vm[:id], vm[:owner][:
|
23
|
-
vm[:ips].join("\n"), vm[:host], vm[:state], vm[:owner][:email]
|
25
|
+
tbody = [
|
26
|
+
vm[:id], vm[:owner][:email], vm[:host], vm[:state]
|
24
27
|
]
|
28
|
+
tbody.concat [
|
29
|
+
vm[:owner][:identities].join("\n"),
|
30
|
+
vm[:group], vm[:ips].join("\n")
|
31
|
+
] if opts[:details]
|
32
|
+
table.add_row tbody
|
25
33
|
end
|
26
34
|
|
27
35
|
table
|
28
36
|
end
|
29
37
|
|
30
38
|
#
|
31
|
-
def as_json(data)
|
39
|
+
def as_json(data, opts = {})
|
32
40
|
data ||= []
|
33
41
|
data ? JSON.generate(data) : '{}'
|
34
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egi-fedcloud-vmhound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Parak
|
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
249
|
version: '0'
|
250
250
|
requirements: []
|
251
251
|
rubyforge_project:
|
252
|
-
rubygems_version: 2.
|
252
|
+
rubygems_version: 2.4.4
|
253
253
|
signing_key:
|
254
254
|
specification_version: 4
|
255
255
|
summary: A proof-of-concept utility for locating VM instances in EGI Federated Cloud
|