opennebula 6.2.1 → 6.3.85.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ActionManager.rb +1 -1
- data/lib/CommandManager.rb +1 -1
- data/lib/DriverExecHelper.rb +1 -1
- data/lib/OpenNebulaDriver.rb +1 -1
- data/lib/VirtualMachineDriver.rb +1 -1
- data/lib/cloud/CloudClient.rb +3 -3
- data/lib/datacenter.rb +1 -1
- data/lib/datastore.rb +2 -2
- data/lib/distributed_firewall.rb +1 -1
- data/lib/file_helper.rb +2 -2
- data/lib/host.rb +4 -3
- data/lib/logical_port.rb +1 -1
- data/lib/logical_switch.rb +1 -1
- data/lib/memoize.rb +1 -1
- data/lib/models/role.rb +1 -1
- data/lib/models/service.rb +98 -56
- data/lib/models.rb +1 -1
- data/lib/network.rb +1 -1
- data/lib/nsx_client.rb +1 -1
- data/lib/nsx_component.rb +1 -1
- data/lib/nsx_constants.rb +1 -1
- data/lib/nsx_driver.rb +1 -1
- data/lib/nsx_error.rb +1 -1
- data/lib/nsx_rule.rb +1 -1
- data/lib/nsxt_client.rb +1 -1
- data/lib/nsxt_dfw.rb +1 -1
- data/lib/nsxt_logical_port.rb +1 -1
- data/lib/nsxt_rule.rb +1 -1
- data/lib/nsxt_tz.rb +1 -1
- data/lib/nsxv_client.rb +1 -1
- data/lib/nsxv_dfw.rb +1 -1
- data/lib/nsxv_logical_port.rb +1 -1
- data/lib/nsxv_rule.rb +1 -1
- data/lib/nsxv_tz.rb +1 -1
- data/lib/opaque_network.rb +1 -1
- 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 +1 -1
- data/lib/opennebula/document_pool_json.rb +1 -1
- data/lib/opennebula/error.rb +1 -1
- data/lib/opennebula/flow/grammar.rb +1 -1
- data/lib/opennebula/flow/service_pool.rb +7 -3
- data/lib/opennebula/flow/service_template.rb +7 -1
- data/lib/opennebula/flow/service_template_ext.rb +1 -1
- data/lib/opennebula/flow/service_template_pool.rb +1 -1
- data/lib/opennebula/flow/validator.rb +1 -1
- data/lib/opennebula/flow.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 +1 -1
- data/lib/opennebula/image.rb +1 -1
- 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 +1 -1
- data/lib/opennebula/marketplace.rb +1 -1
- data/lib/opennebula/marketplace_pool.rb +1 -1
- data/lib/opennebula/marketplaceapp.rb +1 -1
- data/lib/opennebula/marketplaceapp_ext.rb +158 -33
- data/lib/opennebula/marketplaceapp_pool.rb +1 -1
- data/lib/opennebula/oneflow_client.rb +53 -26
- data/lib/opennebula/pool.rb +1 -1
- 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 +1 -1
- data/lib/opennebula/template_ext.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 +27 -2
- data/lib/opennebula/virtual_machine_ext.rb +1 -1
- data/lib/opennebula/virtual_machine_pool.rb +1 -1
- data/lib/opennebula/virtual_network.rb +39 -2
- 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/wait_ext.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/opennebula.rb +2 -2
- data/lib/rest_client.rb +1 -1
- data/lib/scripts_common.rb +6 -1
- data/lib/transport_zone.rb +1 -1
- data/lib/vcenter_driver.rb +1 -1
- data/lib/vcenter_importer.rb +10 -12
- data/lib/vi_client.rb +1 -1
- data/lib/vi_helper.rb +18 -3
- data/lib/virtual_machine.rb +21 -12
- data/lib/virtual_wire.rb +1 -1
- data/lib/vm_disk.rb +1 -1
- data/lib/vm_folder.rb +1 -1
- data/lib/vm_helper.rb +1 -1
- data/lib/vm_monitor.rb +5 -1
- data/lib/vm_nic.rb +1 -1
- data/lib/vm_template.rb +60 -4
- data/lib/vmm_importer.rb +10 -7
- metadata +4 -4
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2022, 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/datastore.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2022, 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-2022, 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/document.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2022, 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-2022, 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-2022, 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-2022, 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-2022, 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 #
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Autogenerated from a Treetop grammar. Edits may be lost.
|
3
3
|
|
4
4
|
|
5
|
-
# Copyright 2002-
|
5
|
+
# Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
|
6
6
|
# #
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
8
8
|
# 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-2022, 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 #
|
@@ -55,8 +55,12 @@ module OpenNebula
|
|
55
55
|
@one_pool = nil
|
56
56
|
|
57
57
|
if @client
|
58
|
-
|
59
|
-
|
58
|
+
rc = @client.call('user.info', -1)
|
59
|
+
|
60
|
+
unless OpenNebula.is_error?(rc)
|
61
|
+
info = Nokogiri::XML(rc)
|
62
|
+
@user_id = Integer(info.xpath('/USER/ID').text)
|
63
|
+
end
|
60
64
|
end
|
61
65
|
|
62
66
|
super('DOCUMENT_POOL', 'DOCUMENT', @client)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2022, 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 #
|
@@ -315,6 +315,12 @@ module OpenNebula
|
|
315
315
|
end
|
316
316
|
else
|
317
317
|
IMMUTABLE_ATTRS.each do |attr|
|
318
|
+
# Allows updating the template without
|
319
|
+
# specifying the immutable attributes
|
320
|
+
if template[attr].nil?
|
321
|
+
template[attr] = @body[attr]
|
322
|
+
end
|
323
|
+
|
318
324
|
next if template[attr] == @body[attr]
|
319
325
|
|
320
326
|
return [false, "service_template/#{attr}"]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2022, 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-2022, 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-2022, 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/flow.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2022, 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-2022, 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-2022, 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-2022, 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-2022, 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-2022, 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-2022, 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 #
|
@@ -14,7 +14,6 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
-
|
18
17
|
require 'opennebula/pool_element'
|
19
18
|
require 'base64'
|
20
19
|
require 'yaml'
|
@@ -217,10 +216,12 @@ module OpenNebula
|
|
217
216
|
# Imports a wild VM from the host and puts it in running state
|
218
217
|
#
|
219
218
|
# @param name [String] Name of the VM to import
|
219
|
+
# @param ipv4 [Array] Array with IP4s to set
|
220
|
+
# @param ipv6 [Array] Array with IP6s to set
|
220
221
|
#
|
221
222
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
222
223
|
# otherwise
|
223
|
-
def import_wild(name)
|
224
|
+
def import_wild(name, ipv4 = nil, ipv6 = nil)
|
224
225
|
vms = importable_wilds.select {|vm| vm['VM_NAME'] == name }
|
225
226
|
|
226
227
|
if vms.length == 0
|
@@ -247,8 +248,15 @@ module OpenNebula
|
|
247
248
|
vi_client = VCenterDriver::VIClient.new_from_host(self["ID"])
|
248
249
|
importer = VCenterDriver::VmmImporter.new(@client, vi_client)
|
249
250
|
|
250
|
-
return importer.import(
|
251
|
-
|
251
|
+
return importer.import(
|
252
|
+
{ :wild => wild,
|
253
|
+
:template => template,
|
254
|
+
:one_item => vm,
|
255
|
+
:host => self['ID'],
|
256
|
+
:ipv4 => ipv4,
|
257
|
+
:ipv6 => ipv6
|
258
|
+
}
|
259
|
+
)
|
252
260
|
else
|
253
261
|
rc = vm.allocate(template)
|
254
262
|
|
data/lib/opennebula/host_pool.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2022, 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/image.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2022, 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-2022, 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-2022, 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-2022, 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-2022, 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-2022, 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-2022, 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-2022, 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-2022, 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 #
|
@@ -185,9 +185,28 @@ module OpenNebula::MarketPlaceAppExt
|
|
185
185
|
#---------------------------------------------------------------
|
186
186
|
# Created an associated VMTemplate if needed
|
187
187
|
#---------------------------------------------------------------
|
188
|
-
if
|
189
|
-
options[:notemplate]
|
190
|
-
options[:template] == -1
|
188
|
+
if is_vcenter &&
|
189
|
+
!options[:notemplate] &&
|
190
|
+
(!options[:template] || options[:template] == -1)
|
191
|
+
tmpl = create_vcenter_template(
|
192
|
+
ds,
|
193
|
+
options,
|
194
|
+
self['TEMPLATE/VMTEMPLATE64'],
|
195
|
+
image
|
196
|
+
)
|
197
|
+
|
198
|
+
if OpenNebula.is_error?(tmpl)
|
199
|
+
rc_info[:vmtemplate] = [tmpl]
|
200
|
+
else
|
201
|
+
rc_info[:vmtemplate] = [tmpl.id]
|
202
|
+
end
|
203
|
+
|
204
|
+
return rc_info
|
205
|
+
end
|
206
|
+
|
207
|
+
if self['TEMPLATE/VMTEMPLATE64'].nil? ||
|
208
|
+
options[:notemplate] ||
|
209
|
+
options[:template] == -1
|
191
210
|
return rc_info
|
192
211
|
end
|
193
212
|
|
@@ -286,33 +305,139 @@ module OpenNebula::MarketPlaceAppExt
|
|
286
305
|
rc
|
287
306
|
end
|
288
307
|
|
289
|
-
|
290
|
-
|
291
|
-
|
308
|
+
# Create a VM template in vCenter in order to use it when
|
309
|
+
# deploying an app from the marketplace
|
310
|
+
#
|
311
|
+
# @param ds [OpenNebula::Datastore] Datastore information
|
312
|
+
# @param options [Hash] Export options
|
313
|
+
# @param template [String] App template
|
314
|
+
# @param image [OpenNebula::Image] Image information
|
315
|
+
def create_vcenter_template(ds, options, template, image = nil)
|
316
|
+
ret = {}
|
317
|
+
keys = %w[VCENTER_TEMPLATE_REF
|
318
|
+
VCENTER_CCR_REF
|
319
|
+
VCENTER_INSTANCE_ID]
|
320
|
+
|
321
|
+
if ds['//VCENTER_TEMPLATE_REF']
|
322
|
+
keys.each do |key|
|
323
|
+
ret[key] = ds["//#{key}"]
|
324
|
+
end
|
325
|
+
else
|
326
|
+
require 'vcenter_driver'
|
292
327
|
|
293
|
-
|
294
|
-
|
328
|
+
# Get vi client for current datastore
|
329
|
+
vi_client = VCenterDriver::VIClient.new_from_datastore(
|
330
|
+
ds.id
|
331
|
+
)
|
295
332
|
|
296
|
-
|
297
|
-
|
298
|
-
|
333
|
+
# Get datastore object
|
334
|
+
ds_ref = ds['//VCENTER_DS_REF']
|
335
|
+
datastore = VCenterDriver::Datastore.new_from_ref(
|
336
|
+
ds_ref,
|
337
|
+
vi_client
|
338
|
+
)
|
299
339
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
340
|
+
# Get resource pool
|
341
|
+
host_ref = datastore['host'].first.key.parent._ref
|
342
|
+
vi_client.ccr_ref = host_ref
|
343
|
+
|
344
|
+
host = VCenterDriver::ClusterComputeResource.new_from_ref(
|
345
|
+
host_ref,
|
346
|
+
vi_client
|
347
|
+
)
|
348
|
+
|
349
|
+
rp = host.resource_pools.first
|
350
|
+
|
351
|
+
# Get vCentrer instance ID
|
352
|
+
uuid = vi_client.vim.serviceContent.about.instanceUuid
|
353
|
+
|
354
|
+
# Create VM folder it not exists
|
355
|
+
dc = datastore.obtain_dc.item
|
356
|
+
vm_folder = dc.find_folder('one_default_template')
|
357
|
+
|
358
|
+
if vm_folder.nil?
|
359
|
+
dc.vmFolder.CreateFolder(
|
360
|
+
:name => 'one_default_template'
|
361
|
+
)
|
362
|
+
vm_folder = dc.find_folder('one_default_template')
|
308
363
|
end
|
364
|
+
|
365
|
+
# Define default VM config
|
366
|
+
vm_cfg = { :name => "one_app_template-#{ds.id}",
|
367
|
+
:guestId => 'otherGuest',
|
368
|
+
:numCPUs => 1,
|
369
|
+
:memoryMB => 128,
|
370
|
+
:files => {
|
371
|
+
:vmPathName => "[#{datastore.item.name}]"
|
372
|
+
} }
|
373
|
+
|
374
|
+
# Create the VM
|
375
|
+
vm = vm_folder.CreateVM_Task(
|
376
|
+
:config => vm_cfg,
|
377
|
+
:pool => rp
|
378
|
+
).wait_for_completion
|
379
|
+
|
380
|
+
# Create the VM template
|
381
|
+
vm.MarkAsTemplate
|
382
|
+
|
383
|
+
ret['VCENTER_TEMPLATE_REF'] = vm._ref
|
384
|
+
ret['VCENTER_CCR_REF'] = host_ref
|
385
|
+
ret['VCENTER_INSTANCE_ID'] = uuid
|
386
|
+
|
387
|
+
ret.each do |key, value|
|
388
|
+
ds.update("#{key}=\"#{value}\"", true)
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
tmpl = <<-EOT
|
393
|
+
NAME = "#{options[:vmtemplate_name] || options[:name]}"
|
394
|
+
HYPERVISOR = "vcenter"
|
395
|
+
EOT
|
396
|
+
|
397
|
+
tmpl << "DISK = [ IMAGE_ID = \"#{image.id}\" ]" if image
|
398
|
+
|
399
|
+
template ||= ''
|
400
|
+
template = Base64.decode64(template)
|
401
|
+
|
402
|
+
template.split("\n").each do |line|
|
403
|
+
# Legacy, some apps in the marketplace have the sched
|
404
|
+
# requirement to just be run on KVM, with this
|
405
|
+
# the template cannot be run on vCenter, so don't add
|
406
|
+
# it in the final VM template
|
407
|
+
next if line =~ /SCHED_REQUIREMENTS/ || line.empty?
|
408
|
+
|
409
|
+
tmpl << "#{line}\n"
|
410
|
+
end
|
411
|
+
|
412
|
+
ret.each do |key, value|
|
413
|
+
tmpl << "#{key}=\"#{value}\"\n"
|
414
|
+
end
|
415
|
+
|
416
|
+
vmtpl = Template.new(Template.build_xml, @client)
|
417
|
+
|
418
|
+
rc = vmtpl.allocate(tmpl)
|
419
|
+
|
420
|
+
if OpenNebula.is_error?(rc)
|
421
|
+
rc
|
309
422
|
else
|
310
|
-
|
311
|
-
' Please use the --template file to define' \
|
312
|
-
' a VM Template ID if needed.'
|
423
|
+
Template.new_with_id(vmtpl.id, @client)
|
313
424
|
end
|
314
425
|
end
|
315
426
|
|
427
|
+
def update_options_with_template(options)
|
428
|
+
path = "#{VAR_LOCATION}/remotes/etc/vmm/vcenter/vcenterrc"
|
429
|
+
|
430
|
+
return options unless File.file?(path)
|
431
|
+
|
432
|
+
config = YAML.load_file(path)
|
433
|
+
|
434
|
+
return options unless config.key?(:default_template)
|
435
|
+
|
436
|
+
options[:template] = config[:default_template]
|
437
|
+
|
438
|
+
options
|
439
|
+
end
|
440
|
+
|
316
441
|
# Creates a VM template based on the APPTEMPLATE64 attribute
|
317
442
|
# @param [Hash] options
|
318
443
|
# :export_name [String] name of the vm template
|
@@ -334,19 +459,19 @@ module OpenNebula::MarketPlaceAppExt
|
|
334
459
|
options = update_options_with_template(options)
|
335
460
|
end
|
336
461
|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
462
|
+
if !options[:template] || options[:template] == -1
|
463
|
+
vmtpl = create_vcenter_template(ds, options)
|
464
|
+
else
|
465
|
+
template_id = options[:template]
|
466
|
+
template = Template.new_with_id(template_id, @client)
|
342
467
|
|
343
|
-
|
468
|
+
vmtpl_id = template.clone(
|
469
|
+
options[:vmtemplate_name] || options[:name]
|
470
|
+
)
|
344
471
|
|
345
|
-
|
346
|
-
|
347
|
-
)
|
472
|
+
vmtpl = Template.new_with_id(vmtpl_id, @client)
|
473
|
+
end
|
348
474
|
|
349
|
-
vmtpl = Template.new_with_id(vmtpl_id, @client)
|
350
475
|
rc = vmtpl.info
|
351
476
|
else
|
352
477
|
# ----------------------------------------------------------
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2022, 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 #
|