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
data/lib/nsxv_tz.rb
ADDED
@@ -0,0 +1,41 @@
|
|
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
|
+
module NSXDriver
|
17
|
+
|
18
|
+
# Class Transport Zone
|
19
|
+
class NSXVtz < TransportZone
|
20
|
+
|
21
|
+
# ATTRIBUTES
|
22
|
+
attr_reader :tz_id
|
23
|
+
|
24
|
+
# CONSTRUCTOR
|
25
|
+
def initialize(nsx_client)
|
26
|
+
super(nsx_client)
|
27
|
+
# Construct base URLs
|
28
|
+
@url_tzs_nsxv = NSXConstants::NSXV_TZS
|
29
|
+
end
|
30
|
+
|
31
|
+
# METHODS
|
32
|
+
# Return the transport zones list
|
33
|
+
def tzs
|
34
|
+
@nsx_client
|
35
|
+
.get(@url_tzs_nsxv)
|
36
|
+
.xpath(NSXConstants::NSXV_TZS_XPATH)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,134 @@
|
|
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
|
+
module NSXDriver
|
17
|
+
|
18
|
+
# Class Opaque Network NSX-T Network
|
19
|
+
class OpaqueNetwork < LogicalSwitch
|
20
|
+
|
21
|
+
# ATTRIBUTES
|
22
|
+
# attr_reader :ls_id, :admin_display
|
23
|
+
|
24
|
+
# CONSTRUCTOR
|
25
|
+
def initialize(nsx_client, ls_id = nil, tz_id = nil, ls_data = nil)
|
26
|
+
super(nsx_client)
|
27
|
+
if ls_id
|
28
|
+
initialize_with_id(ls_id)
|
29
|
+
else
|
30
|
+
if tz_id && ls_data
|
31
|
+
begin
|
32
|
+
@ls_id = new_logical_switch(ls_data)
|
33
|
+
rescue NSXError::IncorrectResponseCodeError => e
|
34
|
+
raise 'Opaque Network not created in ' \
|
35
|
+
"NSX Manager: #{e.message}"
|
36
|
+
end
|
37
|
+
unless @ls_id
|
38
|
+
raise 'Opaque Network not created in NSX Manager: '\
|
39
|
+
'generic error'
|
40
|
+
end
|
41
|
+
|
42
|
+
# Construct URL of the created logical switch
|
43
|
+
@url_ls = NSXConstants::NSXT_LS_SECTION + @ls_id
|
44
|
+
@ls_vni = ls_vni
|
45
|
+
@ls_name = ls_name
|
46
|
+
@tz_id = ls_tz
|
47
|
+
@admin_display = 'UP'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Creates a OpaqueNetwork from its name
|
53
|
+
def self.new_from_name(nsx_client, ls_name)
|
54
|
+
lswitch = new(nsx_client)
|
55
|
+
ls_id = lswitch.ls_id_from_name(nsx_client, ls_name)
|
56
|
+
unless ls_id
|
57
|
+
error_msg = "Opaque Network with name: #{ls_name} not found"
|
58
|
+
error = NSXError::ObjectNotFound
|
59
|
+
.new(error_msg)
|
60
|
+
raise error
|
61
|
+
end
|
62
|
+
|
63
|
+
# initialize_with_id(@ls_id)
|
64
|
+
lswitch.initialize_with_id(ls_id)
|
65
|
+
lswitch
|
66
|
+
end
|
67
|
+
|
68
|
+
# Creates a OpaqueNetwork from its id
|
69
|
+
def initialize_with_id(ls_id)
|
70
|
+
@ls_id = ls_id
|
71
|
+
# Construct URL of the created logical switch
|
72
|
+
@url_ls = NSXConstants::NSXT_LS_SECTION + \
|
73
|
+
@ls_id
|
74
|
+
if ls?
|
75
|
+
@ls_vni = ls_vni
|
76
|
+
@ls_name = ls_name
|
77
|
+
@tz_id = ls_tz
|
78
|
+
@admin_display = 'UP'
|
79
|
+
else
|
80
|
+
error_msg = "Opaque Network with id: #{ls_id} not found"
|
81
|
+
error = NSXError::ObjectNotFound
|
82
|
+
.new(error_msg)
|
83
|
+
raise error
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Get the logical switch id from its name
|
88
|
+
def ls_id_from_name(nsx_client, name)
|
89
|
+
url = NSXConstants::NSXT_LS_SECTION
|
90
|
+
lswitches = nsx_client.get(url)['results']
|
91
|
+
lswitches.each do |lswitch|
|
92
|
+
lsname = lswitch['display_name']
|
93
|
+
lsid = lswitch['id']
|
94
|
+
if lsname == name && lsid
|
95
|
+
return lsid
|
96
|
+
end
|
97
|
+
end
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
|
101
|
+
# METHODS
|
102
|
+
# Check if logical switch exists
|
103
|
+
def ls?
|
104
|
+
@nsx_client.get(@url_ls) ? true : false
|
105
|
+
end
|
106
|
+
|
107
|
+
# Get logical switch's name
|
108
|
+
def ls_name
|
109
|
+
@nsx_client.get(@url_ls)['display_name']
|
110
|
+
end
|
111
|
+
|
112
|
+
# Get logical switch's vni
|
113
|
+
def ls_vni
|
114
|
+
@nsx_client.get(@url_ls)['vni']
|
115
|
+
end
|
116
|
+
|
117
|
+
# Get the Transport Zone of the logical switch
|
118
|
+
def ls_tz
|
119
|
+
@nsx_client.get(@url_ls)['transport_zone_id']
|
120
|
+
end
|
121
|
+
|
122
|
+
# Create a new logical switch (NSX-T: opaque network)
|
123
|
+
def new_logical_switch(ls_data)
|
124
|
+
@nsx_client.post(NSXConstants::NSXT_LS_SECTION, ls_data)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Delete a logical switch
|
128
|
+
def delete_logical_switch
|
129
|
+
@nsx_client.delete(@url_ls)
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
data/lib/opennebula/acl.rb
CHANGED
@@ -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 #
|
data/lib/opennebula/acl_pool.rb
CHANGED
@@ -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 #
|
data/lib/opennebula/client.rb
CHANGED
@@ -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 #
|
data/lib/opennebula/cluster.rb
CHANGED
@@ -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 #
|
@@ -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 #
|
data/lib/opennebula/datastore.rb
CHANGED
@@ -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 #
|
@@ -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 #
|
data/lib/opennebula/document.rb
CHANGED
@@ -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 #
|
@@ -14,6 +14,7 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
require 'opennebula/lockable_ext'
|
17
18
|
require 'opennebula/pool_element'
|
18
19
|
|
19
20
|
module OpenNebula
|
@@ -75,6 +76,8 @@ module OpenNebula
|
|
75
76
|
# @example
|
76
77
|
# doc = Document.new(Document.build_xml(3),rpc_client)
|
77
78
|
def initialize(xml, client)
|
79
|
+
LockableExt.make_lockable(self, DOCUMENT_METHODS)
|
80
|
+
|
78
81
|
super(xml,client)
|
79
82
|
end
|
80
83
|
|
@@ -86,8 +89,8 @@ module OpenNebula
|
|
86
89
|
#
|
87
90
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
88
91
|
# otherwise
|
89
|
-
def info()
|
90
|
-
rc = super(DOCUMENT_METHODS[:info], 'DOCUMENT')
|
92
|
+
def info(decrypt = false)
|
93
|
+
rc = super(DOCUMENT_METHODS[:info], 'DOCUMENT', decrypt)
|
91
94
|
|
92
95
|
if !OpenNebula.is_error?(rc) && self['TYPE'].to_i != document_type
|
93
96
|
return OpenNebula::Error.new("[DocumentInfo] Error getting document [#{@pe_id}].")
|
@@ -108,6 +111,8 @@ module OpenNebula
|
|
108
111
|
super(DOCUMENT_METHODS[:allocate], description, document_type)
|
109
112
|
end
|
110
113
|
|
114
|
+
alias_method :allocate_xml, :allocate
|
115
|
+
|
111
116
|
# Deletes the Document
|
112
117
|
#
|
113
118
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
@@ -217,32 +222,6 @@ module OpenNebula
|
|
217
222
|
return call(DOCUMENT_METHODS[:rename], @pe_id, name)
|
218
223
|
end
|
219
224
|
|
220
|
-
# Locks this object
|
221
|
-
#
|
222
|
-
# @param owner [String] String to identify the application requestiong
|
223
|
-
# the lock
|
224
|
-
#
|
225
|
-
# @return [Bool, OpenNebula::Error] In case of success, true if the
|
226
|
-
# lock was granted, and false if the object is already locked.
|
227
|
-
def lock(owner="")
|
228
|
-
return Error.new('ID not defined') if !@pe_id
|
229
|
-
|
230
|
-
rc = @client.call(DOCUMENT_METHODS[:lock], @pe_id, owner)
|
231
|
-
|
232
|
-
return rc
|
233
|
-
end
|
234
|
-
|
235
|
-
# Unlocks this object
|
236
|
-
#
|
237
|
-
# @param owner [String] String to identify the application requestiong
|
238
|
-
# the unlock
|
239
|
-
#
|
240
|
-
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
241
|
-
# otherwise
|
242
|
-
def unlock(owner="")
|
243
|
-
return call(DOCUMENT_METHODS[:unlock], @pe_id, owner)
|
244
|
-
end
|
245
|
-
|
246
225
|
#######################################################################
|
247
226
|
# Helpers to get Document information
|
248
227
|
#######################################################################
|
@@ -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 #
|
@@ -21,6 +21,15 @@ module OpenNebula
|
|
21
21
|
|
22
22
|
TEMPLATE_TAG = "BODY"
|
23
23
|
|
24
|
+
# Returns current template tag
|
25
|
+
def template_tag
|
26
|
+
if @tag
|
27
|
+
@tag
|
28
|
+
else
|
29
|
+
TEMPLATE_TAG
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
24
33
|
# Allocate a new Document containing the json inside the TEMPLATE
|
25
34
|
#
|
26
35
|
# @param [String] template_json json to be inserted in the TEMPLATE
|
@@ -30,19 +39,28 @@ module OpenNebula
|
|
30
39
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
31
40
|
# otherwise
|
32
41
|
#
|
33
|
-
def allocate(template_json, name=nil)
|
42
|
+
def allocate(template_json, name = nil, tag = nil)
|
43
|
+
@tag = tag if tag
|
44
|
+
|
34
45
|
text = build_template_xml(template_json, name)
|
35
46
|
|
36
47
|
super(text)
|
37
48
|
end
|
38
49
|
|
50
|
+
# Allocate XML Document
|
51
|
+
#
|
52
|
+
# @param xml [String] XML document content
|
53
|
+
def allocate_xml(xml)
|
54
|
+
super(xml)
|
55
|
+
end
|
56
|
+
|
39
57
|
# Retrieves the information of the Service and all its Nodes.
|
40
58
|
#
|
41
59
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
42
60
|
# otherwise
|
43
61
|
#
|
44
|
-
def info
|
45
|
-
rc = super
|
62
|
+
def info(decrypt = false)
|
63
|
+
rc = super(decrypt)
|
46
64
|
if OpenNebula.is_error?(rc)
|
47
65
|
return rc
|
48
66
|
end
|
@@ -90,10 +108,10 @@ module OpenNebula
|
|
90
108
|
def to_json(pretty_generate=true)
|
91
109
|
hash = self.to_hash
|
92
110
|
|
93
|
-
body = hash['DOCUMENT']['TEMPLATE']["#{
|
111
|
+
body = hash['DOCUMENT']['TEMPLATE']["#{template_tag}"]
|
94
112
|
if body
|
95
113
|
body_hash = JSON.parse(body)
|
96
|
-
hash['DOCUMENT']['TEMPLATE']["#{
|
114
|
+
hash['DOCUMENT']['TEMPLATE']["#{template_tag}"] = body_hash
|
97
115
|
end
|
98
116
|
|
99
117
|
if pretty_generate
|
@@ -106,7 +124,7 @@ module OpenNebula
|
|
106
124
|
|
107
125
|
# Fill the @body hash with the values of the template
|
108
126
|
def load_body
|
109
|
-
body_str = self["TEMPLATE/#{
|
127
|
+
body_str = self["TEMPLATE/#{template_tag}"]
|
110
128
|
|
111
129
|
if body_str
|
112
130
|
begin
|
@@ -116,27 +134,39 @@ module OpenNebula
|
|
116
134
|
end
|
117
135
|
end
|
118
136
|
|
137
|
+
plain_str = self['TEMPLATE/PLAIN']
|
138
|
+
|
139
|
+
if plain_str
|
140
|
+
begin
|
141
|
+
@plain = JSON.parse(plain_str)
|
142
|
+
rescue JSON::JSONError
|
143
|
+
return OpenNebula::Error.new($!)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
119
147
|
return nil
|
120
148
|
end
|
121
149
|
|
122
|
-
private
|
123
|
-
|
124
150
|
# Build an xml string incluiding the provided json
|
125
151
|
#
|
126
152
|
# @param [String] template_json The template to be inserted
|
127
153
|
# @param [String, nil] name The string to be inserted as name
|
154
|
+
# @param [String, nil] plain information to add to the document
|
128
155
|
# @return [String] The xml containing the json
|
129
156
|
#
|
130
|
-
def build_template_xml(template_json, name=nil)
|
157
|
+
def build_template_xml(template_json, name = nil, plain = nil)
|
131
158
|
template_json ||= ""
|
159
|
+
plain ||= @plain
|
160
|
+
plain = plain.to_json if plain && !(plain.is_a? String)
|
132
161
|
|
133
162
|
text = "<TEMPLATE>"
|
134
163
|
|
135
164
|
text << "<NAME>#{name}</NAME>" if name
|
165
|
+
text << "<PLAIN><![CDATA[#{plain}]]></PLAIN>" if plain
|
136
166
|
|
137
|
-
text << "<#{
|
167
|
+
text << "<#{template_tag}>"
|
138
168
|
text << "<![CDATA[#{template_json}]]>"
|
139
|
-
text << "</#{
|
169
|
+
text << "</#{template_tag}>"
|
140
170
|
|
141
171
|
text << "</TEMPLATE>"
|
142
172
|
|
@@ -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 #
|
@@ -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 #
|
data/lib/opennebula/error.rb
CHANGED
@@ -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,6 +34,7 @@ module OpenNebula
|
|
34
34
|
|
35
35
|
attr_reader :message, :errno
|
36
36
|
|
37
|
+
|
37
38
|
# +message+ Description of the error
|
38
39
|
# +errno+ OpenNebula code error
|
39
40
|
def initialize(message=nil, errno=0x1111)
|
@@ -45,6 +46,8 @@ module OpenNebula
|
|
45
46
|
@message
|
46
47
|
end
|
47
48
|
|
49
|
+
alias inspect to_str
|
50
|
+
|
48
51
|
def is_exml_rpc_call?()
|
49
52
|
@errno == EXML_RPC_CALL
|
50
53
|
end
|