opennebula 5.6.0 → 5.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 368b25e39516bc7f4cc4eb9a5d458596e044ff4a
4
- data.tar.gz: 47fd8dc77024e585e2a0c37f5f04ac58e2151fad
3
+ metadata.gz: bef9b2183a0d6a9255fc9a4304f876b2bb46d7d3
4
+ data.tar.gz: ef4f6c545dd5d962ff6053c823e2c6933aa3057b
5
5
  SHA512:
6
- metadata.gz: 2f928dc1d7ec80058752a9efdb421e9d3fffff0dec5a3e2733c40bf660eb5bd8fa000e2725ec14afb74c6fd26ab2bf5c54072f80e29eb2bc0d948feefe6be5c2
7
- data.tar.gz: fb37b947efe168a8feaee8dd9e9031c23316665845d00fa6f7146f81aab93e412ed8e5a322de080c22ce79dfc41486fca6a20355e3d09ad149d66048db61ccb5
6
+ metadata.gz: 829850fa4829aacb804c0df3a585dbc6db72430c64f7d86be705a7b02a593a92f867a0e3d42fed0b58b7f6d978b6dbf775aefd7ef36151ccfd40c6169c3517e3
7
+ data.tar.gz: bd4f6776d73e0091545cc8afacd64a8bcb447a4b23604ed57cfd617bd1b0d9fac8f2594caba70daaf5342283200c1fccce20ede5687b80e5bbed8f82601ca343
@@ -50,7 +50,7 @@ end
50
50
  module CloudClient
51
51
 
52
52
  # OpenNebula version
53
- VERSION = '5.6.0'
53
+ VERSION = '5.6.1'
54
54
 
55
55
  # #########################################################################
56
56
  # Default location for the authentication file
@@ -69,5 +69,5 @@ require 'opennebula/vm_group_pool'
69
69
  module OpenNebula
70
70
 
71
71
  # OpenNebula version
72
- VERSION = '5.6.0'
72
+ VERSION = '5.6.1'
73
73
  end
@@ -131,7 +131,7 @@ class OpenNebula::LdapAuth
131
131
  end
132
132
 
133
133
  def find_user(name)
134
- filter = Net::LDAP::Filter.eq(@options[:user_field], escape(name))
134
+ filter = Net::LDAP::Filter.equals(@options[:user_field], name)
135
135
 
136
136
  result = @ldap.search(
137
137
  :base => @options[:base],
@@ -194,7 +194,7 @@ class OpenNebula::LdapAuth
194
194
  end
195
195
  end
196
196
  else
197
- filter = "(#{@options[:group_field]}=#{@user[@options[:user_group_field]].first})"
197
+ filter = Net::LDAP::Filter.equals(@options[:group_field], @user[@options[:user_group_field]].first)
198
198
  @ldap.search(
199
199
  :base => @options[:base],
200
200
  :attributes => [ "dn" ],
@@ -209,23 +209,4 @@ class OpenNebula::LdapAuth
209
209
  groups.delete(false)
210
210
  groups.compact.uniq
211
211
  end
212
-
213
- private
214
-
215
- # The escapes code has been copied from <net-ldap>/lib/net/ldap/filter.rb
216
- FILTER_ESCAPES = {
217
- "\0" => '00',
218
- '*' => '2A',
219
- '(' => '28',
220
- ')' => '29',
221
- '\\' => '5C',
222
- '?' => '3F',
223
- '=' => '3D'
224
- }
225
-
226
- FILTER_ESCAPE_RE = Regexp.new("[" + FILTER_ESCAPES.keys.map { |e| Regexp.escape(e) }.join + "]")
227
-
228
- def escape(string)
229
- string.gsub(FILTER_ESCAPE_RE) { |char| "\\" + FILTER_ESCAPES[char] }
230
- end
231
212
  end
@@ -24,6 +24,9 @@ module OpenNebula
24
24
  include Enumerable
25
25
  alias_method :each_with_xpath, :each
26
26
 
27
+ attr_reader :pool_name
28
+ attr_reader :element_name
29
+
27
30
  PAGINATED_POOLS=%w{VM_POOL IMAGE_POOL TEMPLATE_POOL VN_POOL
28
31
  DOCUMENT_POOL SECGROUP_POOL}
29
32
 
@@ -132,12 +135,13 @@ module OpenNebula
132
135
  # xml_method:: _String_ the name of the XML-RPC method
133
136
  # args:: _Array_ with additional arguments for the info call
134
137
  # [return] nil in case of success or an Error object
135
- def xmlrpc_info(xml_method,*args)
136
- rc = @client.call(xml_method,*args)
138
+ def xmlrpc_info(xml_method, *args)
139
+ rc = @client.call(xml_method, *args)
137
140
 
138
141
  if !OpenNebula.is_error?(rc)
139
- initialize_xml(rc,@pool_name)
140
- rc = nil
142
+ initialize_xml(rc, @pool_name)
143
+
144
+ rc = nil
141
145
  end
142
146
 
143
147
  return rc
@@ -179,14 +183,17 @@ module OpenNebula
179
183
 
180
184
  if OpenNebula.pool_page_size && allow_paginated &&
181
185
  ( ( size && size >= 2 ) || !size )
186
+
182
187
  size = OpenNebula.pool_page_size if !size
183
- hash=info_paginated(size)
188
+ hash = info_paginated(size)
184
189
 
185
190
  return hash if OpenNebula.is_error?(hash)
191
+
186
192
  { @pool_name => { @element_name => hash } }
187
193
  else
188
- rc=info
194
+ rc = info
189
195
  return rc if OpenNebula.is_error?(rc)
196
+
190
197
  to_hash
191
198
  end
192
199
  end
@@ -195,14 +202,15 @@ module OpenNebula
195
202
  #
196
203
  # size:: _Integer_ size of each page
197
204
  def info_paginated(size)
198
- array=Array.new
199
- current=0
205
+ array = Array.new
206
+ current = 0
200
207
 
201
- parser=ParsePoolSax.new(@pool_name, @element_name)
208
+ parser = ParsePoolSax.new(@pool_name, @element_name)
202
209
 
203
210
  while true
204
- a=@client.call("#{@pool_name.delete('_').downcase}.info",
205
- @user_id, current, -size, -1)
211
+ a = @client.call("#{@pool_name.delete('_').downcase}.info",
212
+ @user_id, current, -size, -1)
213
+
206
214
  return a if OpenNebula.is_error?(a)
207
215
 
208
216
  a_array=parser.parse(a)
@@ -214,9 +222,35 @@ module OpenNebula
214
222
  end
215
223
 
216
224
  array.compact!
217
- array=nil if array.length == 0
225
+ array = nil if array.length == 0
218
226
 
219
227
  array
220
228
  end
229
+
230
+ # Gets a hash from a info page from pool
231
+ # size:: nil => default page size
232
+ # > 0 => page size
233
+ # current first element of the page
234
+ # hash:: return page as a hash
235
+ def get_page(size, current)
236
+ rc = nil
237
+
238
+ if PAGINATED_POOLS.include?(@pool_name)
239
+ size = OpenNebula.pool_page_size if (!size || size == 0)
240
+ rc = @client.call("#{@pool_name.delete('_').downcase}.info",
241
+ @user_id, current, -size, -1)
242
+
243
+ initialize_xml(rc, @pool_name)
244
+ else
245
+ rc = info
246
+ end
247
+
248
+ return rc
249
+ end
250
+
251
+ # Return true if pool is paginated
252
+ def is_paginated?
253
+ PAGINATED_POOLS.include?(@pool_name)
254
+ end
221
255
  end
222
256
  end
@@ -430,30 +430,5 @@ module OpenNebula
430
430
  return attr
431
431
  end
432
432
  end
433
-
434
- # The XMLUtilsPool module provides an abstraction of the underlying
435
- # XML parser engine. It provides XML-related methods for the Pools
436
- class XMLPool < XMLElement
437
-
438
- def initialize(xml=nil)
439
- super(xml)
440
- end
441
-
442
- #Executes the given block for each element of the Pool
443
- #block:: _Block_
444
- def each_element(block)
445
- if NOKOGIRI
446
- @xml.xpath(
447
- "#{@element_name}").each {|pelem|
448
- block.call self.factory(pelem)
449
- }
450
- else
451
- @xml.elements.each(
452
- "#{@element_name}") {|pelem|
453
- block.call self.factory(pelem)
454
- }
455
- end
456
- end
457
- end
458
-
459
433
  end
434
+
@@ -18,25 +18,25 @@
18
18
  # Set up the environment for the driver #
19
19
  # ---------------------------------------------------------------------------- #
20
20
 
21
- ONE_LOCATION = ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
21
+ ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION)
22
22
 
23
23
  if !ONE_LOCATION
24
- BIN_LOCATION = "/usr/bin" if !defined?(BIN_LOCATION)
25
- LIB_LOCATION = "/usr/lib/one" if !defined?(LIB_LOCATION)
26
- ETC_LOCATION = "/etc/one/" if !defined?(ETC_LOCATION)
27
- VAR_LOCATION = "/var/lib/one" if !defined?(VAR_LOCATION)
24
+ BIN_LOCATION = '/usr/bin' unless defined?(BIN_LOCATION)
25
+ LIB_LOCATION = '/usr/lib/one' unless defined?(LIB_LOCATION)
26
+ ETC_LOCATION = '/etc/one/' unless defined?(ETC_LOCATION)
27
+ VAR_LOCATION = '/var/lib/one' unless defined?(VAR_LOCATION)
28
28
  else
29
- BIN_LOCATION = ONE_LOCATION + "/bin" if !defined?(BIN_LOCATION)
30
- LIB_LOCATION = ONE_LOCATION + "/lib" if !defined?(LIB_LOCATION)
31
- ETC_LOCATION = ONE_LOCATION + "/etc/" if !defined?(ETC_LOCATION)
32
- VAR_LOCATION = ONE_LOCATION + "/var/" if !defined?(VAR_LOCATION)
29
+ BIN_LOCATION = ONE_LOCATION + '/bin' unless defined?(BIN_LOCATION)
30
+ LIB_LOCATION = ONE_LOCATION + '/lib' unless defined?(LIB_LOCATION)
31
+ ETC_LOCATION = ONE_LOCATION + '/etc/' unless defined?(ETC_LOCATION)
32
+ VAR_LOCATION = ONE_LOCATION + '/var/' unless defined?(VAR_LOCATION)
33
33
  end
34
34
 
35
35
  ENV['LANG'] = 'C'
36
36
 
37
- $: << LIB_LOCATION + '/ruby/vendors/rbvmomi/lib'
38
- $: << LIB_LOCATION + '/ruby'
39
- $: << LIB_LOCATION + '/ruby/vcenter_driver'
37
+ $LOAD_PATH << LIB_LOCATION + '/ruby/vendors/rbvmomi/lib'
38
+ $LOAD_PATH << LIB_LOCATION + '/ruby'
39
+ $LOAD_PATH << LIB_LOCATION + '/ruby/vcenter_driver'
40
40
 
41
41
  require 'rbvmomi'
42
42
  require 'yaml'
@@ -70,13 +70,13 @@ def error_message(message)
70
70
  error_str << message
71
71
  error_str << "\nERROR MESSAGE ------>8--"
72
72
 
73
- return error_str
73
+ error_str
74
74
  end
75
75
 
76
76
  def check_valid(parameter, label)
77
77
  if parameter.nil? || parameter.empty?
78
78
  STDERR.puts error_message("The parameter '#{label}' is required for this action.")
79
- exit -1
79
+ exit(-1)
80
80
  end
81
81
  end
82
82
 
@@ -85,11 +85,11 @@ def check_item(item, target_class)
85
85
  item.name if CHECK_REFS
86
86
  if target_class
87
87
  if !item.instance_of?(target_class)
88
- raise "Expecting type 'RbVmomi::VIM::#{target_class}'. " <<
88
+ raise "Expecting type 'RbVmomi::VIM::#{target_class}'. " \
89
89
  "Got '#{item.class} instead."
90
90
  end
91
91
  end
92
92
  rescue RbVmomi::Fault => e
93
- raise "Reference \"#{item._ref}\" error. The reference does not exist"
93
+ raise "Reference \"#{item._ref}\" error [#{e.message}]. The reference does not exist"
94
94
  end
95
95
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opennebula
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0
4
+ version: 5.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-15 00:00:00.000000000 Z
11
+ date: 2018-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri