opennebula 5.8.0 → 5.8.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: 569ac708944804df9cca52281833b1a3c382fba0
4
- data.tar.gz: 567bc53b12a85dd81f1ef644e54373074cc8fa06
3
+ metadata.gz: a1806ffa746e5ae8534ea0bc1cd08afb5e0724c3
4
+ data.tar.gz: a483faf5b0133eec5e50190d642ba42a2a07def8
5
5
  SHA512:
6
- metadata.gz: ee01e030e359ca720b7069750f9fa6522a89757eadbf5d96d225c30666f14da876f584aadaff373e371e173e61f753f0995fc8a3d6a38c8e775d181f4a8a8155
7
- data.tar.gz: c9a50bd7207e7373e2a675471ea905210ded882ecb710a1877eb0656de777c46160c387009b7ef32998e87a58742818a85d13815baba0d1a08705475df7a4db2
6
+ metadata.gz: 05939c12f4cf7689a9c81bcf1dbc99b805b4509505d25fec3d3193e0aeba98169042d7874b781aa2e02382a14d360ccd6893fcb644b85416ddf9256303e7ad58
7
+ data.tar.gz: 54d34d8da90fa155e030eab67093da2148a3a18b3d5fcf7e52711fda19b25b465e443ee38fababdb9d459094ba833b37e6ea70bafccfc0db60d4158fa7c5eb75
@@ -50,7 +50,7 @@ end
50
50
  module CloudClient
51
51
 
52
52
  # OpenNebula version
53
- VERSION = '5.8.0'
53
+ VERSION = '5.8.1'
54
54
 
55
55
  # #########################################################################
56
56
  # Default location for the authentication file
@@ -71,5 +71,5 @@ require 'opennebula/vntemplate_pool'
71
71
  module OpenNebula
72
72
 
73
73
  # OpenNebula version
74
- VERSION = '5.8.0'
74
+ VERSION = '5.8.1'
75
75
  end
@@ -43,7 +43,7 @@ module OpenNebula
43
43
  Ox.sax_parse(self, StringIO.new(str),
44
44
  :symbolize => false,
45
45
  :convert_special => true,
46
- :skip => false)
46
+ :skip => :skip_none)
47
47
  end
48
48
  end
49
49
  end
@@ -17,42 +17,45 @@
17
17
  require 'opennebula/pool_element'
18
18
 
19
19
  module OpenNebula
20
+
20
21
  class MarketPlaceApp < PoolElement
22
+
21
23
  #######################################################################
22
24
  # Constants and Class Methods
23
25
  #######################################################################
24
26
 
25
27
  MARKETPLACEAPP_METHODS = {
26
- :info => "marketapp.info",
27
- :allocate => "marketapp.allocate",
28
- :delete => "marketapp.delete",
29
- :update => "marketapp.update",
30
- :chown => "marketapp.chown",
31
- :chmod => "marketapp.chmod",
32
- :rename => "marketapp.rename",
33
- :enable => "marketapp.enable",
34
- :lock => "marketapp.lock",
35
- :unlock => "marketapp.unlock"
28
+ :info => 'marketapp.info',
29
+ :allocate => 'marketapp.allocate',
30
+ :delete => 'marketapp.delete',
31
+ :update => 'marketapp.update',
32
+ :chown => 'marketapp.chown',
33
+ :chmod => 'marketapp.chmod',
34
+ :rename => 'marketapp.rename',
35
+ :enable => 'marketapp.enable',
36
+ :lock => 'marketapp.lock',
37
+ :unlock => 'marketapp.unlock'
36
38
  }
37
39
 
38
- MARKETPLACEAPP_STATES=%w{INIT READY LOCKED ERROR DISABLED}
40
+ MARKETPLACEAPP_STATES = %w{INIT READY LOCKED ERROR DISABLED}
39
41
 
40
42
  SHORT_MARKETPLACEAPP_STATES={
41
- "INIT" => "ini",
42
- "READY" => "rdy",
43
- "LOCKED" => "lck",
44
- "ERROR" => "err",
45
- "DISABLED" => "dis"
43
+ 'INIT' => 'ini',
44
+ 'READY' => 'rdy',
45
+ 'LOCKED' => 'lck',
46
+ 'ERROR' => 'err',
47
+ 'DISABLED' => 'dis'
46
48
  }
47
49
 
48
- MARKETPLACEAPP_TYPES=%w{UNKNOWN IMAGE VMTEMPLATE SERVICE_TEMPLATE}
50
+ MARKETPLACEAPP_TYPES = %w{UNKNOWN IMAGE VMTEMPLATE SERVICE_TEMPLATE}
49
51
 
50
52
  SHORT_MARKETPLACEAPP_TYPES = {
51
- "UNKNOWN" => "unk",
52
- "IMAGE" => "img",
53
- "VMTEMPLATE" => "tpl",
54
- "SERVICE_TEMPLATE" => "srv"
53
+ 'UNKNOWN' => 'unk',
54
+ 'IMAGE' => 'img',
55
+ 'VMTEMPLATE' => 'tpl',
56
+ 'SERVICE_TEMPLATE' => 'srv'
55
57
  }
58
+
56
59
  # Creates a MarketPlace description with just its identifier
57
60
  # this method should be used to create plain MarketPlace objects.
58
61
  # +id+ the id of the user
@@ -60,14 +63,14 @@ module OpenNebula
60
63
  # Example:
61
64
  # app = MarketPlaceApp.new(MarketPlace.build_xml(3),rpc_client)
62
65
  #
63
- def MarketPlaceApp.build_xml(pe_id=nil)
66
+ def MarketPlaceApp.build_xml(pe_id = nil)
64
67
  if pe_id
65
68
  app_xml = "<MARKETPLACEAPP><ID>#{pe_id}</ID></MARKETPLACEAPP>"
66
69
  else
67
- app_xml = "<MARKETPLACEAPP></MARKETPLACEAPP>"
70
+ app_xml = '<MARKETPLACEAPP></MARKETPLACEAPP>'
68
71
  end
69
72
 
70
- XMLElement.build_xml(app_xml,'MARKETPLACEAPP')
73
+ XMLElement.build_xml(app_xml, 'MARKETPLACEAPP')
71
74
  end
72
75
 
73
76
  # Class constructor
@@ -80,7 +83,7 @@ module OpenNebula
80
83
  #######################################################################
81
84
 
82
85
  # Retrieves the information of the given marketplace app
83
- def info()
86
+ def info
84
87
  super(MARKETPLACEAPP_METHODS[:info], 'MARKETPLACEAPP')
85
88
  end
86
89
 
@@ -98,7 +101,7 @@ module OpenNebula
98
101
  end
99
102
 
100
103
  # Deletes the marketplace app
101
- def delete()
104
+ def delete
102
105
  super(MARKETPLACEAPP_METHODS[:delete])
103
106
  end
104
107
 
@@ -110,7 +113,7 @@ module OpenNebula
110
113
  #
111
114
  # @return [nil, OpenNebula::Error] nil in case of success, Error
112
115
  # otherwise
113
- def update(new_template, append=false)
116
+ def update(new_template, append = false)
114
117
  super(MARKETPLACEAPP_METHODS[:update], new_template, append ? 1 : 0)
115
118
  end
116
119
 
@@ -152,7 +155,7 @@ module OpenNebula
152
155
  # @return [nil, OpenNebula::Error] nil in case of success, Error
153
156
  # otherwise
154
157
  def rename(name)
155
- return call(MARKETPLACEAPP_METHODS[:rename], @pe_id, name)
158
+ call(MARKETPLACEAPP_METHODS[:rename], @pe_id, name)
156
159
  end
157
160
 
158
161
  # Exports this app to a suitable OpenNebula object
@@ -168,79 +171,80 @@ module OpenNebula
168
171
  # { :vm => [ vm ids/OpenNebula::Error ],
169
172
  # :vmtemplate => [ vmtemplates ids/OpenNebula::Error ],
170
173
  # :image => [ vm ids/OpenNebula::Error ] }
171
- def export(options={})
172
- return Error.new("Missing datastore id") if options[:dsid].nil?
173
- return Error.new("Missing name to export app") if options[:name].nil?
174
-
175
- rc = info
174
+ def export(options = {})
175
+ rc = info
176
176
  return rc if OpenNebula.is_error?(rc)
177
- return Error.new("App is not in READY state") if state_str!="READY"
177
+ return Error.new('App is not READY') if state_str != 'READY'
178
178
 
179
- case type_str
180
- when "IMAGE"
181
- if !self['APPTEMPLATE64'].nil?
182
- tmpl=Base64::decode64(self['APPTEMPLATE64'])
183
- else
184
- tmpl=""
185
- end
179
+ if options[:dsid].nil? && type_str != 'VMTEMPLATE'
180
+ return Error.new('Missing datastore id')
181
+ end
186
182
 
187
- name = options[:name] || "marketapp-#{self.id}"
183
+ return Error.new('Missing name to export app') if options[:name].nil?
188
184
 
189
- tmpl << "\n"
190
- tmpl << "NAME=\"" << name << "\"\n"
191
- tmpl << "FROM_APP=\"" << self['ID'] << "\"\n"
185
+ if !self['APPTEMPLATE64'].nil?
186
+ tmpl = Base64.decode64(self['APPTEMPLATE64'])
187
+ else
188
+ tmpl = ''
189
+ end
190
+
191
+ name = options[:name] || "marketapp-#{id}"
192
+ options[:vmtemplate_name] = name unless options[:vmtemplate_name]
192
193
 
194
+ tmpl << "\n"
195
+ tmpl << "NAME=\"" << name << "\"\n"
196
+ tmpl << "FROM_APP=\"" << self['ID'] << "\"\n"
197
+
198
+ case type_str
199
+ when 'IMAGE'
193
200
  image = Image.new(Image.build_xml, @client)
194
201
  rc = image.allocate(tmpl, options[:dsid])
195
202
 
196
203
  ds = OpenNebula::Datastore.new_with_id(options[:dsid], @client)
197
- image.info
198
- ds.info
199
-
200
- xpath = 'TEMPLATE/DRIVER'
201
- if ds[xpath] == 'vcenter' && self['FORMAT'] != 'iso' && self['FORMAT'] != 'vmdk'
202
- image.replace({'FORMAT' => 'vmdk'})
203
- elsif ds[xpath] && ds[xpath] != 'vcenter' && self['FORMAT'] == 'vmdk'
204
- image.replace({'FORMAT' => ds[xpath] })
205
- end
206
204
 
207
- return { :image => [rc] } if OpenNebula.is_error?(rc)
205
+ rc_image = image.info
206
+ rc_ds = ds.info
208
207
 
209
- image_id = image.id
210
- vmtpl_id = -1
208
+ image_error = OpenNebula.is_error?(rc_image)
209
+ ds_error = OpenNebula.is_error?(rc_ds)
211
210
 
212
- if !self['TEMPLATE/VMTEMPLATE64'].nil?
213
- tmpl=Base64::decode64(self['TEMPLATE/VMTEMPLATE64'])
211
+ xpath = 'TEMPLATE/DRIVER'
212
+ format = self['FORMAT']
213
+ type = ds[xpath]
214
214
 
215
- tmpl_name = options[:vmtemplate_name] || name
215
+ if !image_error && !ds_error
216
+ if type == 'vcenter' && format != 'iso' && format != 'vmdk'
217
+ image.replace('FORMAT' => 'vmdk')
218
+ elsif type && type != 'vcenter' && format == 'vmdk'
219
+ image.replace('FORMAT' => type)
220
+ end
221
+ end
216
222
 
217
- tmpl << "\nNAME=\"#{tmpl_name}\"\n"
218
- tmpl << "DISK=[ IMAGE_ID = #{image.id} ]\n"
223
+ return { :image => [rc] } if OpenNebula.is_error?(rc)
219
224
 
220
- vmtpl = Template.new(Template.build_xml, @client)
221
- rc = vmtpl.allocate(tmpl)
225
+ vmtpl_id = create_vmtemplate(options, image.id)
222
226
 
223
- if OpenNebula.is_error?(rc)
224
- return { :image => [image_id], :vmtemplate => [rc] }
225
- end
227
+ return { :image => [image.id], :vmtemplate => [vmtpl_id] }
226
228
 
227
- vmtpl_id = vmtpl.id
228
- end
229
+ when 'VMTEMPLATE'
230
+ # TODO import all the images associated to a VMTEMPLATE app
231
+ # current version only support no-image based apps (e.g. hybrid)
232
+ vmtpl_id = create_vmtemplate(options)
229
233
 
230
- return { :image => [image_id], :vmtemplate => [vmtpl_id] }
234
+ return { :image => [], :vmtemplate => [vmtpl_id] }
231
235
  else
232
- return Error.new("App type #{app.type_str} not supported")
236
+ return Error.new("App type #{type_str} not supported")
233
237
  end
234
238
  end
235
239
 
236
240
  # Enables this app
237
241
  def enable
238
- return call(MARKETPLACEAPP_METHODS[:enable], @pe_id, true)
242
+ call(MARKETPLACEAPP_METHODS[:enable], @pe_id, true)
239
243
  end
240
244
 
241
245
  # Enables this app
242
246
  def disable
243
- return call(MARKETPLACEAPP_METHODS[:enable], @pe_id, false)
247
+ call(MARKETPLACEAPP_METHODS[:enable], @pe_id, false)
244
248
  end
245
249
 
246
250
  # ---------------------------------------------------------------------
@@ -277,14 +281,37 @@ module OpenNebula
277
281
  SHORT_MARKETPLACEAPP_STATES[state_str]
278
282
  end
279
283
 
280
- #Locked a MarketplaceApp
284
+ # Locked a MarketplaceApp
281
285
  def lock(level)
282
- return call(MARKETPLACEAPP_METHODS[:lock], @pe_id, level)
286
+ call(MARKETPLACEAPP_METHODS[:lock], @pe_id, level)
283
287
  end
284
288
 
285
- #Unlocked a MarketplaceApp
289
+ # Unlocked a MarketplaceApp
286
290
  def unlock()
287
- return call(MARKETPLACEAPP_METHODS[:unlock], @pe_id)
291
+ call(MARKETPLACEAPP_METHODS[:unlock], @pe_id)
288
292
  end
293
+
294
+ private
295
+
296
+ # Creates a VM template based on the VMTEMPLATE64 attribute
297
+ # @return [Integer, OpenNebula::Error] template id or error
298
+ # TODO this method needs to be extended to support [image_ids]
299
+ def create_vmtemplate(options, image_id = nil)
300
+ return -1 if self['TEMPLATE/VMTEMPLATE64'].nil?
301
+
302
+ tmpl = Base64.decode64(self['TEMPLATE/VMTEMPLATE64'])
303
+
304
+ tmpl << "\nNAME=\"#{options[:vmtemplate_name]}\"\n"
305
+ tmpl << "DISK=[ IMAGE_ID = #{image_id} ]\n" if image_id
306
+
307
+ vmtpl = Template.new(Template.build_xml, @client)
308
+ rc = vmtpl.allocate(tmpl)
309
+
310
+ return rc if OpenNebula.is_error?(rc)
311
+
312
+ vmtpl.id
313
+ end
314
+
289
315
  end
316
+
290
317
  end
@@ -64,6 +64,10 @@ module OpenNebula
64
64
 
65
65
  alias_method :info!, :info
66
66
 
67
+ def info_extended(xml_method)
68
+ return xmlrpc_info(xml_info)
69
+ end
70
+
67
71
  def info_all(xml_method, *args)
68
72
  return xmlrpc_info(xml_method, INFO_ALL, -1, -1, *args)
69
73
  end
@@ -232,13 +236,20 @@ module OpenNebula
232
236
  # > 0 => page size
233
237
  # current first element of the page
234
238
  # hash:: return page as a hash
235
- def get_page(size, current)
239
+ def get_page(size, current, extended = false)
236
240
  rc = nil
237
241
 
238
- if PAGINATED_POOLS.include?(@pool_name)
242
+ if PAGINATED_POOLS.include?(@pool_name)
243
+ pool_name = @pool_name.delete('_').downcase
244
+
245
+ if extended && pool_name == "vmpool"
246
+ method = "#{pool_name}.infoextended"
247
+ else
248
+ method = "#{pool_name}.info"
249
+ end
250
+
239
251
  size = OpenNebula.pool_page_size if (!size || size == 0)
240
- rc = @client.call("#{@pool_name.delete('_').downcase}.info",
241
- @user_id, current, -size, -1)
252
+ rc = @client.call(method, @user_id, current, -size, -1)
242
253
 
243
254
  initialize_xml(rc, @pool_name)
244
255
  else
@@ -26,6 +26,7 @@ module OpenNebula
26
26
 
27
27
  VM_POOL_METHODS = {
28
28
  :info => "vmpool.info",
29
+ :info_extended => "vmpool.infoextended",
29
30
  :monitoring => "vmpool.monitoring",
30
31
  :accounting => "vmpool.accounting",
31
32
  :showback => "vmpool.showback",
@@ -62,57 +63,70 @@ module OpenNebula
62
63
  # No arguments, returns the not-in-done VMs for the user
63
64
  # [user_id, start_id, end_id]
64
65
  # [user_id, start_id, end_id, state]
66
+ alias_method :info!, :info
67
+
65
68
  def info(*args)
66
69
  case args.size
67
- when 0
68
- info_filter(VM_POOL_METHODS[:info],
69
- @user_id,
70
- -1,
71
- -1,
72
- INFO_NOT_DONE)
73
- when 1
74
- info_filter(VM_POOL_METHODS[:info],
75
- args[0],
76
- -1,
77
- -1,
78
- INFO_NOT_DONE)
79
- when 3
80
- info_filter(VM_POOL_METHODS[:info],
81
- args[0],
82
- args[1],
83
- args[2],
84
- INFO_NOT_DONE)
85
- when 4
86
- info_filter(VM_POOL_METHODS[:info],
87
- args[0],
88
- args[1],
89
- args[2],
90
- args[3])
70
+ when 0
71
+ info_filter(VM_POOL_METHODS[:info],
72
+ @user_id,
73
+ -1,
74
+ -1,
75
+ INFO_NOT_DONE)
76
+ when 1
77
+ info_filter(VM_POOL_METHODS[:info],
78
+ args[0],
79
+ -1,
80
+ -1,
81
+ INFO_NOT_DONE)
82
+ when 3
83
+ info_filter(VM_POOL_METHODS[:info],
84
+ args[0],
85
+ args[1],
86
+ args[2],
87
+ INFO_NOT_DONE)
88
+ when 4
89
+ info_filter(VM_POOL_METHODS[:info],
90
+ args[0],
91
+ args[1],
92
+ args[2],
93
+ args[3])
91
94
  end
92
95
  end
93
96
 
94
- def info_all()
95
- return info_filter(VM_POOL_METHODS[:info],
96
- INFO_ALL,
97
- -1,
98
- -1,
99
- INFO_NOT_DONE)
100
- end
97
+ # Define info methods shortcuts for different filters
98
+ # info_all()
99
+ # info_all!()
100
+ # info_all_extended
101
+ # info_all_extended!()
102
+ # info_mine()
103
+ # info_mine!()
104
+ # info_mine_extended
105
+ # info_mine_extended!()
106
+ # info_group()
107
+ # info_group!()
108
+ # info_group_extended
109
+ # info_group_extended!()
110
+ # info_primary_group()
111
+ # info_primary_group!()
112
+ # info_primary_group_extended
113
+ # info_primary_group_extended!()
114
+ %w[mine all group primary_group].each do |ifilter|
115
+ const_name = "OpenNebula::Pool::INFO_#{ifilter.upcase}"
116
+
117
+ define_method("info_#{ifilter}") do
118
+ info_filter(VM_POOL_METHODS[:info],
119
+ Object.const_get(const_name), -1, -1,INFO_NOT_DONE)
120
+ end
101
121
 
102
- def info_mine()
103
- return info_filter(VM_POOL_METHODS[:info],
104
- INFO_MINE,
105
- -1,
106
- -1,
107
- INFO_NOT_DONE)
108
- end
122
+ define_method("info_#{ifilter}_extended") do
123
+ info_filter(VM_POOL_METHODS[:info_extended],
124
+ Object.const_get(const_name), -1, -1,
125
+ INFO_NOT_DONE)
126
+ end
109
127
 
110
- def info_group()
111
- return info_filter(VM_POOL_METHODS[:info],
112
- INFO_GROUP,
113
- -1,
114
- -1,
115
- INFO_NOT_DONE)
128
+ alias_method "info_#{ifilter}!".to_sym, "info_#{ifilter}".to_sym
129
+ alias_method "info_#{ifilter}_extended!".to_sym, "info_#{ifilter}_extended".to_sym
116
130
  end
117
131
 
118
132
  def info_search(args = {})
@@ -121,21 +135,24 @@ module OpenNebula
121
135
  :start_id => -1,
122
136
  :end_id => -1,
123
137
  :state => INFO_NOT_DONE,
124
- :query => ""
138
+ :query => "",
139
+ :extended => false
125
140
  }.merge!(args)
126
141
 
127
- return info_filter(VM_POOL_METHODS[:info],
128
- default_args[:who],
129
- default_args[:start_id],
130
- default_args[:end_id],
131
- default_args[:state],
132
- default_args[:query])
142
+ if args[:extended]
143
+ method = VM_POOL_METHODS[:info_extended]
144
+ else
145
+ method = VM_POOL_METHODS[:info]
146
+ end
147
+
148
+ info_filter(method,
149
+ default_args[:who],
150
+ default_args[:start_id],
151
+ default_args[:end_id],
152
+ default_args[:state],
153
+ default_args[:query])
133
154
  end
134
155
 
135
- alias_method :info!, :info
136
- alias_method :info_all!, :info_all
137
- alias_method :info_mine!, :info_mine
138
- alias_method :info_group!, :info_group
139
156
 
140
157
  # Retrieves the monitoring data for all the VMs in the pool
141
158
  #
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.8.0
4
+ version: 5.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-26 00:00:00.000000000 Z
11
+ date: 2019-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri