opennebula 5.12.13 → 5.13.80.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/ActionManager.rb +1 -1
- data/lib/CommandManager.rb +1 -1
- data/lib/DriverExecHelper.rb +44 -28
- data/lib/OpenNebulaDriver.rb +8 -4
- data/lib/VirtualMachineDriver.rb +9 -2
- data/lib/cloud/CloudClient.rb +3 -3
- data/lib/datacenter.rb +1258 -0
- data/lib/datastore.rb +1025 -0
- data/lib/distributed_firewall.rb +280 -0
- data/lib/file_helper.rb +370 -0
- data/lib/host.rb +1517 -0
- data/lib/logical_port.rb +50 -0
- data/lib/logical_switch.rb +77 -0
- data/lib/memoize.rb +74 -0
- data/lib/models/role.rb +39 -8
- data/lib/models/service.rb +92 -31
- data/lib/models.rb +5 -5
- data/lib/network.rb +635 -0
- data/lib/nsx_client.rb +144 -0
- data/lib/nsx_component.rb +28 -0
- data/lib/nsx_constants.rb +149 -0
- data/lib/nsx_driver.rb +78 -0
- data/lib/nsx_error.rb +77 -0
- data/lib/nsx_rule.rb +193 -0
- data/lib/nsxt_client.rb +176 -0
- data/lib/nsxt_dfw.rb +196 -0
- data/lib/nsxt_logical_port.rb +94 -0
- data/lib/nsxt_rule.rb +188 -0
- data/lib/nsxt_tz.rb +38 -0
- data/lib/nsxv_client.rb +176 -0
- data/lib/nsxv_dfw.rb +202 -0
- data/lib/nsxv_logical_port.rb +107 -0
- data/lib/nsxv_rule.rb +172 -0
- data/lib/nsxv_tz.rb +41 -0
- data/lib/opaque_network.rb +134 -0
- 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 +8 -29
- data/lib/opennebula/document_json.rb +42 -12
- data/lib/opennebula/document_pool.rb +1 -1
- data/lib/opennebula/document_pool_json.rb +1 -1
- data/lib/opennebula/error.rb +4 -1
- data/lib/opennebula/flow/grammar.rb +1195 -0
- data/lib/{models → opennebula/flow}/service_pool.rb +26 -2
- data/lib/{models → opennebula/flow}/service_template.rb +86 -17
- data/lib/opennebula/flow/service_template_ext.rb +84 -0
- data/lib/{models → opennebula/flow}/service_template_pool.rb +1 -1
- data/lib/opennebula/flow/validator.rb +499 -0
- data/lib/opennebula/flow.rb +23 -0
- data/lib/opennebula/group.rb +1 -1
- data/lib/opennebula/group_pool.rb +1 -1
- data/lib/opennebula/hook.rb +5 -12
- data/lib/opennebula/hook_log.rb +1 -1
- data/lib/opennebula/hook_pool.rb +1 -1
- data/lib/opennebula/host.rb +1 -1
- data/lib/opennebula/host_pool.rb +1 -1
- data/lib/opennebula/image.rb +17 -14
- data/lib/opennebula/image_pool.rb +1 -1
- data/lib/opennebula/ldap_auth.rb +1 -1
- data/lib/opennebula/ldap_auth_spec.rb +1 -1
- data/lib/opennebula/lockable_ext.rb +163 -0
- data/lib/opennebula/marketplace.rb +1 -1
- data/lib/opennebula/marketplace_pool.rb +1 -1
- data/lib/opennebula/marketplaceapp.rb +9 -119
- data/lib/opennebula/marketplaceapp_ext.rb +522 -0
- data/lib/opennebula/marketplaceapp_pool.rb +1 -1
- data/lib/opennebula/oneflow_client.rb +4 -3
- data/lib/opennebula/pool.rb +4 -3
- data/lib/opennebula/pool_element.rb +1 -1
- 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 +1 -1
- data/lib/opennebula/template.rb +4 -13
- data/lib/opennebula/template_ext.rb +325 -0
- data/lib/opennebula/template_pool.rb +1 -1
- data/lib/opennebula/user.rb +26 -2
- 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 +25 -207
- data/lib/opennebula/virtual_machine_ext.rb +469 -0
- data/lib/opennebula/virtual_machine_pool.rb +1 -5
- data/lib/opennebula/virtual_network.rb +4 -10
- data/lib/opennebula/virtual_network_pool.rb +1 -1
- data/lib/opennebula/virtual_router.rb +4 -12
- data/lib/opennebula/virtual_router_pool.rb +1 -1
- data/lib/opennebula/vm_group.rb +4 -11
- data/lib/opennebula/vm_group_pool.rb +1 -1
- data/lib/opennebula/vntemplate.rb +4 -13
- data/lib/opennebula/vntemplate_pool.rb +1 -1
- data/lib/opennebula/wait_ext.rb +222 -0
- 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/opennebula.rb +5 -2
- data/lib/rest_client.rb +201 -0
- data/lib/scripts_common.rb +180 -0
- data/lib/transport_zone.rb +43 -0
- data/lib/vcenter_driver.rb +9 -22
- data/lib/vcenter_importer.rb +616 -0
- data/lib/vi_client.rb +281 -0
- data/lib/vi_helper.rb +312 -0
- data/lib/virtual_machine.rb +3477 -0
- data/lib/virtual_wire.rb +158 -0
- data/lib/vm_device.rb +80 -0
- data/lib/vm_disk.rb +202 -0
- data/lib/vm_folder.rb +69 -0
- data/lib/vm_helper.rb +30 -0
- data/lib/vm_monitor.rb +303 -0
- data/lib/vm_nic.rb +70 -0
- data/lib/vm_template.rb +1961 -0
- data/lib/vmm_importer.rb +121 -0
- metadata +101 -35
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, 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 #
|
@@ -34,7 +34,7 @@ module OpenNebula
|
|
34
34
|
end
|
35
35
|
|
36
36
|
# ServicePool class
|
37
|
-
class ServicePool
|
37
|
+
class ServicePool < Pool
|
38
38
|
|
39
39
|
# rubocop:disable Style/ClassVars
|
40
40
|
@@mutex = Mutex.new
|
@@ -53,6 +53,13 @@ module OpenNebula
|
|
53
53
|
@cloud_auth = cloud_auth
|
54
54
|
@client = client
|
55
55
|
@one_pool = nil
|
56
|
+
|
57
|
+
if @client
|
58
|
+
info = Nokogiri::XML(@client.call('user.info', -1))
|
59
|
+
@user_id = Integer(info.xpath('/USER/ID').text)
|
60
|
+
end
|
61
|
+
|
62
|
+
super('DOCUMENT_POOL', 'DOCUMENT', @client)
|
56
63
|
end
|
57
64
|
|
58
65
|
def client
|
@@ -93,6 +100,23 @@ module OpenNebula
|
|
93
100
|
@one_pool.each(&block)
|
94
101
|
end
|
95
102
|
|
103
|
+
# Iterates over pool pages
|
104
|
+
# size:: nil => default page size
|
105
|
+
# > 0 => page size
|
106
|
+
# state state of objects
|
107
|
+
def each_page(size)
|
108
|
+
loop_page(size, Service::DOCUMENT_TYPE, false) do |element, page|
|
109
|
+
page.each("//#{element}") do |obj|
|
110
|
+
service = Service.new_with_id(obj['ID'], @client)
|
111
|
+
service.info
|
112
|
+
|
113
|
+
yield(service)
|
114
|
+
end
|
115
|
+
|
116
|
+
size
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
96
120
|
# Retrieves a Service element from OpenNebula. The Service::info()
|
97
121
|
# method is called
|
98
122
|
#
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, 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 #
|
@@ -18,7 +18,7 @@ require 'parse-cron'
|
|
18
18
|
|
19
19
|
module OpenNebula
|
20
20
|
|
21
|
-
# Service
|
21
|
+
# Service Template
|
22
22
|
class ServiceTemplate < DocumentJSON
|
23
23
|
|
24
24
|
ROLE_SCHEMA = {
|
@@ -204,6 +204,10 @@ module OpenNebula
|
|
204
204
|
:type => :boolean,
|
205
205
|
:required => false
|
206
206
|
},
|
207
|
+
'automatic_deletion' => {
|
208
|
+
:type => :boolean,
|
209
|
+
:required => false
|
210
|
+
},
|
207
211
|
'networks' => {
|
208
212
|
:type => :object,
|
209
213
|
:properties => {},
|
@@ -220,6 +224,13 @@ module OpenNebula
|
|
220
224
|
}
|
221
225
|
}
|
222
226
|
|
227
|
+
# List of attributes that can't be changed in update operation
|
228
|
+
#
|
229
|
+
# registration_time: this is internal info managed by OneFlow server
|
230
|
+
IMMUTABLE_ATTRS = %w[
|
231
|
+
registration_time
|
232
|
+
]
|
233
|
+
|
223
234
|
def self.init_default_vn_name_template(vn_name_template)
|
224
235
|
# rubocop:disable Style/ClassVars
|
225
236
|
@@vn_name_template = vn_name_template
|
@@ -233,9 +244,47 @@ module OpenNebula
|
|
233
244
|
|
234
245
|
ServiceTemplate.validate(template)
|
235
246
|
|
247
|
+
template['registration_time'] = Integer(Time.now)
|
248
|
+
|
236
249
|
super(template.to_json, template['name'])
|
237
250
|
end
|
238
251
|
|
252
|
+
# Delete service template
|
253
|
+
#
|
254
|
+
# @param type [String] Delete type
|
255
|
+
# - none: just the service template
|
256
|
+
# - all: delete VM templates, images and service template
|
257
|
+
# - templates: delete VM templates and service template
|
258
|
+
def delete(type = nil)
|
259
|
+
case type
|
260
|
+
when 'all'
|
261
|
+
recursive = true
|
262
|
+
when 'templates'
|
263
|
+
recursive = false
|
264
|
+
end
|
265
|
+
|
266
|
+
if type && type != 'none'
|
267
|
+
rc = vm_template_ids
|
268
|
+
|
269
|
+
return rc if OpenNebula.is_error?(rc)
|
270
|
+
|
271
|
+
rc = rc.each do |t_id|
|
272
|
+
t = OpenNebula::Template.new_with_id(t_id, @client)
|
273
|
+
rc = t.info
|
274
|
+
|
275
|
+
break rc if OpenNebula.is_error?(rc)
|
276
|
+
|
277
|
+
rc = t.delete(recursive)
|
278
|
+
|
279
|
+
break rc if OpenNebula.is_error?(rc)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
return rc if OpenNebula.is_error?(rc)
|
284
|
+
|
285
|
+
super()
|
286
|
+
end
|
287
|
+
|
239
288
|
# Retrieves the template
|
240
289
|
#
|
241
290
|
# @return [String] json template
|
@@ -252,16 +301,20 @@ module OpenNebula
|
|
252
301
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
253
302
|
# otherwise
|
254
303
|
def update(template_json, append = false)
|
255
|
-
|
304
|
+
rc = info
|
256
305
|
|
257
|
-
if
|
258
|
-
rc = info
|
306
|
+
return rc if OpenNebula.is_error?(rc)
|
259
307
|
|
260
|
-
|
308
|
+
template = JSON.parse(template_json)
|
261
309
|
|
262
|
-
|
310
|
+
IMMUTABLE_ATTRS.each do |attr|
|
311
|
+
next if template[attr] == @body[attr]
|
312
|
+
|
313
|
+
return [false, "service_template/#{attr}"]
|
263
314
|
end
|
264
315
|
|
316
|
+
template = @body.merge(template) if append
|
317
|
+
|
265
318
|
ServiceTemplate.validate(template)
|
266
319
|
|
267
320
|
super(template.to_json)
|
@@ -418,18 +471,16 @@ module OpenNebula
|
|
418
471
|
"lower than or equal to 'max_vms'"
|
419
472
|
end
|
420
473
|
|
421
|
-
if (role['elasticity_policies'] &&
|
474
|
+
if ((role['elasticity_policies'] &&
|
422
475
|
!role['elasticity_policies'].empty?) ||
|
423
476
|
(role['scheduled_policies'] &&
|
424
|
-
!role['scheduled_policies'].empty?)
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
" and 'max_vms'"
|
432
|
-
end
|
477
|
+
!role['scheduled_policies'].empty?)) &&
|
478
|
+
(role['min_vms'].nil? || role['max_vms'].nil?)
|
479
|
+
raise Validator::ParseException,
|
480
|
+
"Role '#{role['name']}' with " \
|
481
|
+
" 'elasticity_policies' or " \
|
482
|
+
"'scheduled_policies'must define both 'min_vms'" \
|
483
|
+
" and 'max_vms'"
|
433
484
|
end
|
434
485
|
|
435
486
|
if role['elasticity_policies']
|
@@ -498,6 +549,24 @@ module OpenNebula
|
|
498
549
|
end
|
499
550
|
end
|
500
551
|
|
552
|
+
# Retreives all associated VM templates IDs
|
553
|
+
#
|
554
|
+
# @return [Array] VM templates IDs
|
555
|
+
def vm_template_ids
|
556
|
+
rc = info
|
557
|
+
|
558
|
+
return rc if OpenNebula.is_error?(rc)
|
559
|
+
|
560
|
+
ret = []
|
561
|
+
|
562
|
+
@body['roles'].each do |role|
|
563
|
+
t_id = Integer(role['vm_template'])
|
564
|
+
ret << t_id unless ret.include?(t_id)
|
565
|
+
end
|
566
|
+
|
567
|
+
ret
|
568
|
+
end
|
569
|
+
|
501
570
|
end
|
502
571
|
|
503
572
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
3
|
+
# #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
6
|
+
# a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
#--------------------------------------------------------------------------- #
|
16
|
+
|
17
|
+
# Module to decorate ServiceTemplate class with additional helpers not directly
|
18
|
+
# exposed through the OpenNebula XMLRPC API. The extensions include
|
19
|
+
# - mp_import helper that imports a template into a marketplace
|
20
|
+
#
|
21
|
+
# rubocop:disable Style/ClassAndModuleChildren
|
22
|
+
module OpenNebula::ServiceTemplateExt
|
23
|
+
|
24
|
+
def self.extend_object(obj)
|
25
|
+
if !obj.is_a?(OpenNebula::ServiceTemplate)
|
26
|
+
raise StandardError, "Cannot extended #{obj.class} " \
|
27
|
+
'with MarketPlaceAppExt'
|
28
|
+
end
|
29
|
+
|
30
|
+
class << obj
|
31
|
+
|
32
|
+
####################################################################
|
33
|
+
# Public extended interface
|
34
|
+
####################################################################
|
35
|
+
# Imports service template into marketplace
|
36
|
+
#
|
37
|
+
# @param templates [Hash] Service roles templates information
|
38
|
+
# @param market_id [Integer] Marketplace ID to import app
|
39
|
+
# @param name [String] Service Template App name
|
40
|
+
def mp_import(templates, market_id, name)
|
41
|
+
template = ''
|
42
|
+
name ||= "#{@body['name']}-#{SecureRandom.hex[0..9]}"
|
43
|
+
|
44
|
+
template = <<-EOT
|
45
|
+
NAME = "#{name}"
|
46
|
+
ORIGIN_ID = "-1"
|
47
|
+
TYPE = "SERVICE_TEMPLATE"
|
48
|
+
APPTEMPLATE64 = "#{Base64.strict_encode64(@body.to_json)}"
|
49
|
+
EOT
|
50
|
+
|
51
|
+
# Add VM template name into roles information
|
52
|
+
@body['roles'].each do |role|
|
53
|
+
# Find role template into templates to get the name to use
|
54
|
+
t = templates.find do |_, v|
|
55
|
+
v[:template]['ID'].to_i == role['vm_template']
|
56
|
+
end
|
57
|
+
|
58
|
+
next if t.nil? || t[1].nil? || t[1][:name].nil?
|
59
|
+
|
60
|
+
app_name = t[1][:name]
|
61
|
+
|
62
|
+
template << <<-EOT
|
63
|
+
ROLE = [ NAME="#{role['name']}", APP="#{app_name}"]
|
64
|
+
EOT
|
65
|
+
|
66
|
+
role.delete('vm_template')
|
67
|
+
end
|
68
|
+
|
69
|
+
xml = MarketPlaceApp.build_xml
|
70
|
+
app = MarketPlaceApp.new(xml, @client)
|
71
|
+
rc = app.allocate(template, market_id)
|
72
|
+
|
73
|
+
if OpenNebula.is_error?(rc)
|
74
|
+
[-1, rc]
|
75
|
+
else
|
76
|
+
[0, app.id]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
# rubocop:enable Style/ClassAndModuleChildren
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, 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 #
|