opennebula 5.10.3 → 5.11.90.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ActionManager.rb +1 -1
  3. data/lib/CommandManager.rb +1 -1
  4. data/lib/DriverExecHelper.rb +19 -18
  5. data/lib/OpenNebulaDriver.rb +38 -62
  6. data/lib/VirtualMachineDriver.rb +1 -1
  7. data/lib/cloud/CloudClient.rb +3 -3
  8. data/lib/opennebula.rb +2 -2
  9. data/lib/opennebula/acl.rb +1 -1
  10. data/lib/opennebula/acl_pool.rb +1 -1
  11. data/lib/opennebula/client.rb +1 -1
  12. data/lib/opennebula/cluster.rb +1 -1
  13. data/lib/opennebula/cluster_pool.rb +1 -1
  14. data/lib/opennebula/datastore.rb +1 -1
  15. data/lib/opennebula/datastore_pool.rb +1 -1
  16. data/lib/opennebula/document.rb +1 -1
  17. data/lib/opennebula/document_json.rb +1 -1
  18. data/lib/opennebula/document_pool.rb +2 -2
  19. data/lib/opennebula/document_pool_json.rb +1 -1
  20. data/lib/opennebula/error.rb +1 -1
  21. data/lib/opennebula/group.rb +3 -1
  22. data/lib/opennebula/group_pool.rb +1 -1
  23. data/lib/opennebula/hook.rb +1 -1
  24. data/lib/opennebula/hook_log.rb +1 -1
  25. data/lib/opennebula/hook_pool.rb +1 -1
  26. data/lib/opennebula/host.rb +4 -4
  27. data/lib/opennebula/host_pool.rb +11 -5
  28. data/lib/opennebula/image.rb +1 -1
  29. data/lib/opennebula/image_pool.rb +1 -1
  30. data/lib/opennebula/ldap_auth.rb +24 -19
  31. data/lib/opennebula/ldap_auth_spec.rb +1 -1
  32. data/lib/opennebula/marketplace.rb +1 -1
  33. data/lib/opennebula/marketplace_pool.rb +1 -1
  34. data/lib/opennebula/marketplaceapp.rb +4 -3
  35. data/lib/opennebula/marketplaceapp_pool.rb +1 -1
  36. data/lib/opennebula/oneflow_client.rb +24 -3
  37. data/lib/opennebula/pool.rb +4 -10
  38. data/lib/opennebula/pool_element.rb +9 -37
  39. data/lib/opennebula/security_group.rb +1 -1
  40. data/lib/opennebula/security_group_pool.rb +1 -1
  41. data/lib/opennebula/server_cipher_auth.rb +1 -1
  42. data/lib/opennebula/server_x509_auth.rb +1 -1
  43. data/lib/opennebula/ssh_auth.rb +1 -1
  44. data/lib/opennebula/system.rb +3 -3
  45. data/lib/opennebula/template.rb +1 -1
  46. data/lib/opennebula/template_pool.rb +1 -1
  47. data/lib/opennebula/user.rb +1 -1
  48. data/lib/opennebula/user_pool.rb +1 -1
  49. data/lib/opennebula/utils.rb +1 -1
  50. data/lib/opennebula/vdc.rb +1 -1
  51. data/lib/opennebula/vdc_pool.rb +1 -1
  52. data/lib/opennebula/virtual_machine.rb +10 -7
  53. data/lib/opennebula/virtual_machine_pool.rb +9 -7
  54. data/lib/opennebula/virtual_network.rb +9 -3
  55. data/lib/opennebula/virtual_network_pool.rb +1 -1
  56. data/lib/opennebula/virtual_router.rb +1 -1
  57. data/lib/opennebula/virtual_router_pool.rb +1 -1
  58. data/lib/opennebula/vm_group.rb +1 -1
  59. data/lib/opennebula/vm_group_pool.rb +1 -1
  60. data/lib/opennebula/vntemplate.rb +1 -1
  61. data/lib/opennebula/vntemplate_pool.rb +1 -1
  62. data/lib/opennebula/x509_auth.rb +1 -1
  63. data/lib/opennebula/xml_element.rb +1 -1
  64. data/lib/opennebula/xml_pool.rb +1 -1
  65. data/lib/opennebula/xml_utils.rb +1 -1
  66. data/lib/opennebula/zone.rb +1 -1
  67. data/lib/opennebula/zone_pool.rb +1 -1
  68. data/lib/vcenter_driver.rb +8 -2
  69. metadata +6 -6
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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 #
@@ -330,6 +330,8 @@ module OpenNebula
330
330
  end
331
331
 
332
332
  def create_default_acls(resources=nil)
333
+ return if resources && resources.strip.empty?
334
+
333
335
  resources = GROUP_DEFAULT_ACLS if !resources
334
336
 
335
337
  acls = Array.new
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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 #
@@ -184,8 +184,7 @@ module OpenNebula
184
184
  # ["1337266088", "800"]]
185
185
  # }
186
186
  def monitoring(xpath_expressions)
187
- return super(HOST_METHODS[:monitoring], 'HOST',
188
- 'LAST_MON_TIME', xpath_expressions)
187
+ return super(HOST_METHODS[:monitoring], xpath_expressions)
189
188
  end
190
189
 
191
190
  # Retrieves this Host's monitoring data from OpenNebula, in XML
@@ -240,7 +239,8 @@ module OpenNebula
240
239
  vi_client = VCenterDriver::VIClient.new_from_host(self["ID"])
241
240
  importer = VCenterDriver::VmmImporter.new(@client, vi_client)
242
241
 
243
- return importer.import({wild: wild, template: template, one_item: vm, host: self['ID']})
242
+ return importer.import({wild: wild, template: template,
243
+ one_item: vm, host: self['ID']})
244
244
  else
245
245
  rc = vm.allocate(template)
246
246
 
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
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 number of monitoring records to be
103
+ # retrieved. If nill all records are retrieved
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
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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
- if !@options[:rfc2307bis]
67
- @options[:attributes] << @options[:user_field]
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
- [@user.dn, @user[@options[:user_group_field]]]
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, @user[@options[:user_group_field]]]
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.each do |group|
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
- ) do |entry|
209
- if (g = in_hash_ignore_case?(@mapping, entry.dn))
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-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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 << "NAME=\"" << name << "\"\n"
196
- tmpl << "FROM_APP=\"" << self['ID'] << "\"\n"
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-2019, OpenNebula Project, OpenNebula Systems #
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-2019, OpenNebula Project, OpenNebula Systems #
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']
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
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, root_elem, timestamp_elem, xpath_expressions,
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("#{root_elem}/ID")
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-2019, OpenNebula Project, OpenNebula Systems #
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] root_elem Root for each individual PoolElement
187
- # @param [String] timestamp_elem Name of the XML element with the last
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, root_elem, timestamp_elem, xpath_expressions)
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, root_elem, timestamp_elem, oid, xpath_expressions)
266
+ def self.process_monitoring(xmldoc, oid, xpath_expressions)
273
267
  hash = {}
274
268
  timestamps = xmldoc.retrieve_elements(
275
- "#{root_elem}[ID=#{oid}]/#{timestamp_elem}")
269
+ "/MONITORING_DATA/MONITORING[ID=#{oid}]/TIMESTAMP")
276
270
 
277
271
  xpath_expressions.each { |xpath|
278
- xpath_values = xmldoc.retrieve_elements("#{root_elem}[ID=#{oid}]/#{xpath}")
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