opennebula 5.10.5 → 5.12.0.1
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/lib/ActionManager.rb +1 -1
- data/lib/CommandManager.rb +13 -3
- data/lib/DriverExecHelper.rb +19 -18
- data/lib/OpenNebulaDriver.rb +38 -62
- data/lib/VirtualMachineDriver.rb +1 -1
- data/lib/cloud/CloudClient.rb +3 -3
- data/lib/opennebula.rb +2 -2
- data/lib/opennebula/acl.rb +1 -1
- data/lib/opennebula/acl_pool.rb +1 -1
- data/lib/opennebula/client.rb +1 -1
- data/lib/opennebula/cluster.rb +1 -1
- data/lib/opennebula/cluster_pool.rb +1 -1
- data/lib/opennebula/datastore.rb +1 -1
- data/lib/opennebula/datastore_pool.rb +1 -1
- data/lib/opennebula/document.rb +1 -1
- data/lib/opennebula/document_json.rb +1 -1
- data/lib/opennebula/document_pool.rb +2 -2
- data/lib/opennebula/document_pool_json.rb +1 -1
- data/lib/opennebula/error.rb +1 -1
- data/lib/opennebula/group.rb +1 -1
- data/lib/opennebula/group_pool.rb +1 -1
- data/lib/opennebula/hook.rb +1 -1
- data/lib/opennebula/hook_log.rb +1 -1
- data/lib/opennebula/hook_pool.rb +1 -1
- data/lib/opennebula/host.rb +13 -5
- data/lib/opennebula/host_pool.rb +11 -5
- data/lib/opennebula/image.rb +1 -1
- data/lib/opennebula/image_pool.rb +1 -1
- data/lib/opennebula/ldap_auth.rb +24 -19
- data/lib/opennebula/ldap_auth_spec.rb +1 -1
- data/lib/opennebula/marketplace.rb +1 -1
- data/lib/opennebula/marketplace_pool.rb +1 -1
- data/lib/opennebula/marketplaceapp.rb +4 -3
- data/lib/opennebula/marketplaceapp_pool.rb +1 -1
- data/lib/opennebula/oneflow_client.rb +24 -3
- data/lib/opennebula/pool.rb +4 -10
- data/lib/opennebula/pool_element.rb +9 -37
- data/lib/opennebula/security_group.rb +1 -1
- data/lib/opennebula/security_group_pool.rb +1 -1
- data/lib/opennebula/server_cipher_auth.rb +1 -1
- data/lib/opennebula/server_x509_auth.rb +1 -1
- data/lib/opennebula/ssh_auth.rb +1 -1
- data/lib/opennebula/system.rb +3 -3
- data/lib/opennebula/template.rb +1 -1
- data/lib/opennebula/template_pool.rb +1 -1
- data/lib/opennebula/user.rb +1 -1
- data/lib/opennebula/user_pool.rb +1 -1
- data/lib/opennebula/utils.rb +1 -1
- data/lib/opennebula/vdc.rb +1 -1
- data/lib/opennebula/vdc_pool.rb +1 -1
- data/lib/opennebula/virtual_machine.rb +8 -7
- data/lib/opennebula/virtual_machine_pool.rb +9 -7
- data/lib/opennebula/virtual_network.rb +9 -3
- data/lib/opennebula/virtual_network_pool.rb +1 -1
- data/lib/opennebula/virtual_router.rb +1 -1
- data/lib/opennebula/virtual_router_pool.rb +1 -1
- data/lib/opennebula/vm_group.rb +1 -1
- data/lib/opennebula/vm_group_pool.rb +1 -1
- data/lib/opennebula/vntemplate.rb +1 -1
- data/lib/opennebula/vntemplate_pool.rb +1 -1
- data/lib/opennebula/x509_auth.rb +1 -1
- data/lib/opennebula/xml_element.rb +1 -1
- data/lib/opennebula/xml_pool.rb +1 -1
- data/lib/opennebula/xml_utils.rb +1 -1
- data/lib/opennebula/zone.rb +1 -1
- data/lib/opennebula/zone_pool.rb +1 -1
- data/lib/vcenter_driver.rb +10 -3
- metadata +6 -6
data/lib/opennebula/document.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -52,7 +52,7 @@ module OpenNebula
|
|
|
52
52
|
#
|
|
53
53
|
# @param [OpenNebula::Client] client the xml-rpc client
|
|
54
54
|
# @param [Integer] user_id the filter flag, see
|
|
55
|
-
# http://opennebula.
|
|
55
|
+
# http://docs.opennebula.io/stable/integration/system_interfaces/api.html
|
|
56
56
|
#
|
|
57
57
|
# @return [DocumentPool] the new object
|
|
58
58
|
def initialize(client, user_id=-1)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/error.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/group.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/hook.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/hook_log.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/hook_pool.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/host.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -125,6 +125,14 @@ module OpenNebula
|
|
|
125
125
|
set_status("OFFLINE")
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
+
#Resets monitoring forcing an update
|
|
129
|
+
def forceupdate()
|
|
130
|
+
rc = offline
|
|
131
|
+
return rc if OpenNebula.is_error?(rc)
|
|
132
|
+
|
|
133
|
+
enable
|
|
134
|
+
end
|
|
135
|
+
|
|
128
136
|
def flush(action)
|
|
129
137
|
self.disable
|
|
130
138
|
|
|
@@ -134,7 +142,7 @@ module OpenNebula
|
|
|
134
142
|
rc = vm_pool.info
|
|
135
143
|
if OpenNebula.is_error?(rc)
|
|
136
144
|
puts rc.message
|
|
137
|
-
exit
|
|
145
|
+
exit(-1)
|
|
138
146
|
end
|
|
139
147
|
|
|
140
148
|
vm_pool.each do |vm|
|
|
@@ -184,8 +192,7 @@ module OpenNebula
|
|
|
184
192
|
# ["1337266088", "800"]]
|
|
185
193
|
# }
|
|
186
194
|
def monitoring(xpath_expressions)
|
|
187
|
-
return super(HOST_METHODS[:monitoring],
|
|
188
|
-
'LAST_MON_TIME', xpath_expressions)
|
|
195
|
+
return super(HOST_METHODS[:monitoring], xpath_expressions)
|
|
189
196
|
end
|
|
190
197
|
|
|
191
198
|
# Retrieves this Host's monitoring data from OpenNebula, in XML
|
|
@@ -240,7 +247,8 @@ module OpenNebula
|
|
|
240
247
|
vi_client = VCenterDriver::VIClient.new_from_host(self["ID"])
|
|
241
248
|
importer = VCenterDriver::VmmImporter.new(@client, vi_client)
|
|
242
249
|
|
|
243
|
-
return importer.import({wild: wild, template: template,
|
|
250
|
+
return importer.import({wild: wild, template: template,
|
|
251
|
+
one_item: vm, host: self['ID']})
|
|
244
252
|
else
|
|
245
253
|
rc = vm.allocate(template)
|
|
246
254
|
|
data/lib/opennebula/host_pool.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -94,15 +94,21 @@ module OpenNebula
|
|
|
94
94
|
# "HOST_SHARE/FREE_CPU"=>[["1337609673", "800"]],
|
|
95
95
|
# "HOST_SHARE/RUNNING_VMS"=>[["1337609673", "3"]]}}
|
|
96
96
|
def monitoring(xpath_expressions)
|
|
97
|
-
return super(HOST_POOL_METHODS[:monitoring],
|
|
98
|
-
'HOST', 'LAST_MON_TIME', xpath_expressions)
|
|
97
|
+
return super(HOST_POOL_METHODS[:monitoring], xpath_expressions)
|
|
99
98
|
end
|
|
100
99
|
|
|
101
100
|
# Retrieves the monitoring data for all the Hosts in the pool, in XML
|
|
102
101
|
#
|
|
102
|
+
# @param [Integer] num Optional Retrieve monitor records in the last num
|
|
103
|
+
# seconds. 0 just the last record, -1 or nil all records
|
|
104
|
+
#
|
|
103
105
|
# @return [String] VM monitoring data, in XML
|
|
104
|
-
def monitoring_xml()
|
|
105
|
-
return @client.call(HOST_POOL_METHODS[:monitoring])
|
|
106
|
+
def monitoring_xml(num = nil)
|
|
107
|
+
return @client.call(HOST_POOL_METHODS[:monitoring]) if num.nil?
|
|
108
|
+
|
|
109
|
+
@client.call(HOST_POOL_METHODS[:monitoring], num.to_i)
|
|
106
110
|
end
|
|
111
|
+
|
|
107
112
|
end
|
|
113
|
+
|
|
108
114
|
end
|
data/lib/opennebula/image.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
data/lib/opennebula/ldap_auth.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# ---------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -50,7 +50,8 @@ class OpenNebula::LdapAuth
|
|
|
50
50
|
:mapping_key => 'GROUP_DN',
|
|
51
51
|
:mapping_default => 1,
|
|
52
52
|
:attributes => [ "memberOf" ],
|
|
53
|
-
:rfc2307bis => true
|
|
53
|
+
:rfc2307bis => true,
|
|
54
|
+
:group_admin_group_dn => nil
|
|
54
55
|
}.merge(options)
|
|
55
56
|
|
|
56
57
|
ops={}
|
|
@@ -63,9 +64,8 @@ class OpenNebula::LdapAuth
|
|
|
63
64
|
}
|
|
64
65
|
end
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
end
|
|
67
|
+
# always fetch user_filed to compare whitespace diff
|
|
68
|
+
@options[:attributes] << @options[:user_field]
|
|
69
69
|
|
|
70
70
|
# fetch the user group field only if we need that
|
|
71
71
|
if @options[:group] or !@options[:rfc2307bis]
|
|
@@ -142,15 +142,20 @@ class OpenNebula::LdapAuth
|
|
|
142
142
|
|
|
143
143
|
if result && result.first
|
|
144
144
|
@user = result.first
|
|
145
|
-
|
|
145
|
+
|
|
146
|
+
[@user.dn,
|
|
147
|
+
@user[@options[:user_field]].first,
|
|
148
|
+
@user[@options[:user_group_field]]]
|
|
146
149
|
else
|
|
147
150
|
result=@ldap.search(:base => name)
|
|
148
151
|
|
|
149
152
|
if result && result.first
|
|
150
153
|
@user = result.first
|
|
151
|
-
[name,
|
|
154
|
+
[name,
|
|
155
|
+
@user[@options[:user_field]].first,
|
|
156
|
+
@user[@options[:user_group_field]]]
|
|
152
157
|
else
|
|
153
|
-
[nil, nil]
|
|
158
|
+
[nil, nil, nil]
|
|
154
159
|
end
|
|
155
160
|
end
|
|
156
161
|
end
|
|
@@ -190,26 +195,26 @@ class OpenNebula::LdapAuth
|
|
|
190
195
|
end
|
|
191
196
|
|
|
192
197
|
def get_groups
|
|
193
|
-
groups = []
|
|
194
|
-
|
|
195
198
|
if @options[:rfc2307bis]
|
|
196
|
-
[@user['memberOf']].flatten
|
|
197
|
-
if (g = in_hash_ignore_case?(@mapping, group))
|
|
198
|
-
groups << @mapping[g]
|
|
199
|
-
end
|
|
200
|
-
end
|
|
199
|
+
ldap_groups = [@user['memberOf']].flatten
|
|
201
200
|
else
|
|
202
201
|
group_base = @options[:group_base] ? @options[:group_base] : @options[:base]
|
|
203
202
|
filter = Net::LDAP::Filter.equals(@options[:group_field], @user[@options[:user_group_field]].first)
|
|
204
|
-
@ldap.search(
|
|
203
|
+
ldap_groups = @ldap.search(
|
|
205
204
|
:base => group_base,
|
|
206
205
|
:attributes => [ "dn" ],
|
|
207
206
|
:filter => filter
|
|
208
|
-
)
|
|
209
|
-
|
|
207
|
+
).map! { |entry| entry.dn }
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
groups = []
|
|
211
|
+
ldap_groups.each do |group|
|
|
212
|
+
if (g = in_hash_ignore_case?(@mapping, group))
|
|
213
|
+
if ldap_groups.include? @options[:group_admin_group_dn]
|
|
214
|
+
groups << "*#{@mapping[g]}"
|
|
215
|
+
else
|
|
210
216
|
groups << @mapping[g]
|
|
211
217
|
end
|
|
212
|
-
|
|
213
218
|
end
|
|
214
219
|
end
|
|
215
220
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# ---------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -192,8 +192,9 @@ module OpenNebula
|
|
|
192
192
|
options[:vmtemplate_name] = name unless options[:vmtemplate_name]
|
|
193
193
|
|
|
194
194
|
tmpl << "\n"
|
|
195
|
-
tmpl <<
|
|
196
|
-
tmpl <<
|
|
195
|
+
tmpl << 'NAME="' << name << "\"\n"
|
|
196
|
+
tmpl << 'FROM_APP="' << self['ID'] << "\"\n"
|
|
197
|
+
tmpl << 'URL_ARGS="' << options[:url_args] << "\"\n" if options[:url_args]
|
|
197
198
|
|
|
198
199
|
case type_str
|
|
199
200
|
when 'IMAGE'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -36,7 +36,12 @@ module Role
|
|
|
36
36
|
'reboot-hard',
|
|
37
37
|
'poweroff',
|
|
38
38
|
'poweroff-hard',
|
|
39
|
-
'snapshot-create'
|
|
39
|
+
'snapshot-create',
|
|
40
|
+
'snapshot-revert',
|
|
41
|
+
'snapshot-delete',
|
|
42
|
+
'disk-snapshot-create',
|
|
43
|
+
'disk-snapshot-revert',
|
|
44
|
+
'disk-snapshot-delete'
|
|
40
45
|
]
|
|
41
46
|
|
|
42
47
|
STATE = {
|
|
@@ -285,7 +290,7 @@ module Service
|
|
|
285
290
|
exit_code = 0
|
|
286
291
|
|
|
287
292
|
ids.each do |id|
|
|
288
|
-
response = block.call(id)
|
|
293
|
+
response = block.call(id) if block_given?
|
|
289
294
|
|
|
290
295
|
if CloudClient::is_error?(response)
|
|
291
296
|
puts response.to_s
|
|
@@ -296,6 +301,22 @@ module Service
|
|
|
296
301
|
exit_code
|
|
297
302
|
end
|
|
298
303
|
|
|
304
|
+
# Perform an action on a resource
|
|
305
|
+
# @param [Integer] id resource id
|
|
306
|
+
# @param [Block] block action to be performed
|
|
307
|
+
# @return [Integer] exit_code
|
|
308
|
+
def self.perform_action(id, &block)
|
|
309
|
+
exit_code = 0
|
|
310
|
+
response = block.call(id) if block_given?
|
|
311
|
+
|
|
312
|
+
if CloudClient::is_error?(response)
|
|
313
|
+
puts response.to_s
|
|
314
|
+
exit_code = response.code.to_i
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
exit_code
|
|
318
|
+
end
|
|
319
|
+
|
|
299
320
|
class Client
|
|
300
321
|
def initialize(opts={})
|
|
301
322
|
@username = opts[:username] || ENV['ONEFLOW_USER']
|
data/lib/opennebula/pool.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -91,9 +91,6 @@ module OpenNebula
|
|
|
91
91
|
# Retrieves the monitoring data for all the Objects in the pool
|
|
92
92
|
#
|
|
93
93
|
# @param [String] xml_method xml-rcp method
|
|
94
|
-
# @param [String] root_elem Root for each individual PoolElement
|
|
95
|
-
# @param [String] timestamp_elem Name of the XML element with the last
|
|
96
|
-
# monitorization timestamp
|
|
97
94
|
# @param [Array<String>] xpath_expressions Elements to retrieve.
|
|
98
95
|
# @param args arguemnts for the xml_method call
|
|
99
96
|
#
|
|
@@ -101,8 +98,7 @@ module OpenNebula
|
|
|
101
98
|
# OpenNebula::Error] The first level hash uses the Object ID as keys,
|
|
102
99
|
# and as value a Hash with the requested xpath expressions,
|
|
103
100
|
# and an Array of 'timestamp, value'.
|
|
104
|
-
def monitoring(xml_method,
|
|
105
|
-
*args)
|
|
101
|
+
def monitoring(xml_method, xpaths, *args)
|
|
106
102
|
|
|
107
103
|
rc = @client.call(xml_method, *args)
|
|
108
104
|
|
|
@@ -116,7 +112,7 @@ module OpenNebula
|
|
|
116
112
|
hash = {}
|
|
117
113
|
|
|
118
114
|
# Get all existing Object IDs
|
|
119
|
-
ids = xmldoc.retrieve_elements(
|
|
115
|
+
ids = xmldoc.retrieve_elements('/MONITORING_DATA/MONITORING/ID')
|
|
120
116
|
|
|
121
117
|
if ids.nil?
|
|
122
118
|
return hash
|
|
@@ -125,9 +121,7 @@ module OpenNebula
|
|
|
125
121
|
end
|
|
126
122
|
|
|
127
123
|
ids.each { |id|
|
|
128
|
-
hash[id] = OpenNebula.process_monitoring(
|
|
129
|
-
xmldoc, root_elem, timestamp_elem, id, xpath_expressions)
|
|
130
|
-
|
|
124
|
+
hash[id] = OpenNebula.process_monitoring(xmldoc, id, xpaths)
|
|
131
125
|
}
|
|
132
126
|
|
|
133
127
|
return hash
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
|
3
3
|
# #
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
|
@@ -183,15 +183,12 @@ module OpenNebula
|
|
|
183
183
|
# Retrieves this Element's monitoring data from OpenNebula
|
|
184
184
|
#
|
|
185
185
|
# @param [String] xml_method the name of the XML-RPC method
|
|
186
|
-
# @param [String]
|
|
187
|
-
#
|
|
188
|
-
# monitorization timestamp
|
|
189
|
-
# @param xpath_expressions [Array<String>] Xpath expressions for the
|
|
190
|
-
# elements to retrieve.
|
|
186
|
+
# @param xpaths [Array<String>] Xpath expressions for the elements to
|
|
187
|
+
# retrieve.
|
|
191
188
|
#
|
|
192
189
|
# @return [Hash<String, Array<Array<int>>, OpenNebula::Error] Hash with
|
|
193
190
|
# the requested xpath expressions, and an Array of [timestamp, value].
|
|
194
|
-
def monitoring(xml_method,
|
|
191
|
+
def monitoring(xml_method, xpaths)
|
|
195
192
|
return Error.new('ID not defined') if !@pe_id
|
|
196
193
|
|
|
197
194
|
rc = @client.call(xml_method, @pe_id)
|
|
@@ -204,8 +201,7 @@ module OpenNebula
|
|
|
204
201
|
xmldoc.initialize_xml(rc, 'MONITORING_DATA')
|
|
205
202
|
|
|
206
203
|
|
|
207
|
-
return OpenNebula.process_monitoring(
|
|
208
|
-
xmldoc, root_elem, timestamp_elem, @pe_id, xpath_expressions)
|
|
204
|
+
return OpenNebula.process_monitoring(xmldoc, @pe_id, xpaths)
|
|
209
205
|
end
|
|
210
206
|
|
|
211
207
|
public
|
|
@@ -261,21 +257,20 @@ module OpenNebula
|
|
|
261
257
|
# Processes the monitoring data in XML returned by OpenNebula
|
|
262
258
|
#
|
|
263
259
|
# @param [XMLElement] xmldoc monitoring data returned by OpenNebula
|
|
264
|
-
# @param [String] root_elem Root for each individual PoolElement
|
|
265
|
-
# @param [String] timestamp_elem Name of the XML element with the last
|
|
266
260
|
# monitorization timestamp
|
|
267
261
|
# @param [Integer] oid Id of the object to process
|
|
268
262
|
# @param [Array<String>] xpath_expressions Elements to retrieve.
|
|
269
263
|
#
|
|
270
264
|
# @return [Hash<String, Array<Array<int>>, OpenNebula::Error] Hash with
|
|
271
265
|
# the requested xpath expressions, and an Array of [timestamp, value].
|
|
272
|
-
def self.process_monitoring(xmldoc,
|
|
266
|
+
def self.process_monitoring(xmldoc, oid, xpath_expressions)
|
|
273
267
|
hash = {}
|
|
274
268
|
timestamps = xmldoc.retrieve_elements(
|
|
275
|
-
"
|
|
269
|
+
"/MONITORING_DATA/MONITORING[ID=#{oid}]/TIMESTAMP")
|
|
276
270
|
|
|
277
271
|
xpath_expressions.each { |xpath|
|
|
278
|
-
xpath_values = xmldoc.retrieve_elements(
|
|
272
|
+
xpath_values = xmldoc.retrieve_elements(
|
|
273
|
+
"/MONITORING_DATA/MONITORING[ID=#{oid}]/#{xpath}")
|
|
279
274
|
|
|
280
275
|
if ( xpath_values.nil? )
|
|
281
276
|
hash[xpath] = []
|
|
@@ -287,27 +282,4 @@ module OpenNebula
|
|
|
287
282
|
return hash
|
|
288
283
|
end
|
|
289
284
|
|
|
290
|
-
# Alternative method with better performance for huge number of timestamps.
|
|
291
|
-
# For reasonable amounts of data, the current method is quicker
|
|
292
|
-
=begin
|
|
293
|
-
def self.process_monitoring(xmldoc, root_elem, timestamp_elem, oid, xpath_expressions)
|
|
294
|
-
hash = {}
|
|
295
|
-
|
|
296
|
-
xpath_expressions.each { |xpath|
|
|
297
|
-
hash[xpath] = []
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
xmldoc.each("#{root_elem}[ID=#{oid}]") do |elem|
|
|
301
|
-
timestamp = elem[timestamp_elem]
|
|
302
|
-
|
|
303
|
-
xpath_expressions.each { |xpath|
|
|
304
|
-
xpath_value = elem[xpath]
|
|
305
|
-
|
|
306
|
-
hash[xpath] << [timestamp, xpath_value] if !xpath_value.nil?
|
|
307
|
-
}
|
|
308
|
-
end
|
|
309
|
-
|
|
310
|
-
return hash
|
|
311
|
-
end
|
|
312
|
-
=end
|
|
313
285
|
end
|