opennebula 5.6.2 → 5.7.80.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cloud/CloudClient.rb +1 -1
- data/lib/opennebula.rb +3 -1
- data/lib/opennebula/acl.rb +2 -1
- data/lib/opennebula/host.rb +4 -3
- data/lib/opennebula/ldap_auth.rb +9 -4
- data/lib/opennebula/virtual_machine.rb +44 -14
- data/lib/opennebula/vntemplate.rb +260 -0
- data/lib/opennebula/vntemplate_pool.rb +79 -0
- data/lib/vcenter_driver.rb +24 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: deb89f9163327f290a995f3318e5c9d4ef11e035
|
4
|
+
data.tar.gz: 50bcd5012425d6880b15d9f07411b7fbef65d64d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13e09da10e18bf2ee093b5e35c51862d9bafdb329538aac0a25a386be02f9f8c03d1f6b26c26b5fc90221c481e50c62442040d661afc9cebddcd071ab24cad1e
|
7
|
+
data.tar.gz: 596263c07baa18b494b71cedfd10a42bcf7fbf78c869f4eff0d2eec998633b4b44ac6c6336ed17a1d068abf7e6ce7c1348b56d3e3c3d2c6f13f29f2f1b5628ee
|
data/lib/cloud/CloudClient.rb
CHANGED
data/lib/opennebula.rb
CHANGED
@@ -65,9 +65,11 @@ require 'opennebula/marketplaceapp'
|
|
65
65
|
require 'opennebula/marketplaceapp_pool'
|
66
66
|
require 'opennebula/vm_group'
|
67
67
|
require 'opennebula/vm_group_pool'
|
68
|
+
require 'opennebula/vntemplate'
|
69
|
+
require 'opennebula/vntemplate_pool'
|
68
70
|
|
69
71
|
module OpenNebula
|
70
72
|
|
71
73
|
# OpenNebula version
|
72
|
-
VERSION = '5.
|
74
|
+
VERSION = '5.7.80'
|
73
75
|
end
|
data/lib/opennebula/acl.rb
CHANGED
data/lib/opennebula/host.rb
CHANGED
@@ -237,9 +237,10 @@ module OpenNebula
|
|
237
237
|
vcenter_wild_vm = wild.key? "VCENTER_TEMPLATE"
|
238
238
|
if vcenter_wild_vm
|
239
239
|
require 'vcenter_driver'
|
240
|
-
|
241
|
-
|
242
|
-
|
240
|
+
vi_client = VCenterDriver::VIClient.new_from_host(self["ID"])
|
241
|
+
importer = VCenterDriver::VmmImporter.new(@client, vi_client)
|
242
|
+
|
243
|
+
return importer.import({wild: wild, template: template, one_item: vm, host: self['ID']})
|
243
244
|
else
|
244
245
|
rc = vm.allocate(template)
|
245
246
|
|
data/lib/opennebula/ldap_auth.rb
CHANGED
@@ -184,13 +184,17 @@ class OpenNebula::LdapAuth
|
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
+
def in_hash_ignore_case?(hash, key)
|
188
|
+
return hash.keys.find {|k| key.downcase == k.downcase}
|
189
|
+
end
|
190
|
+
|
187
191
|
def get_groups
|
188
192
|
groups = []
|
189
193
|
|
190
194
|
if @options[:rfc2307bis]
|
191
195
|
[@user['memberOf']].flatten.each do |group|
|
192
|
-
if @mapping
|
193
|
-
groups << @mapping[
|
196
|
+
if (g = in_hash_ignore_case?(@mapping, group))
|
197
|
+
groups << @mapping[g]
|
194
198
|
end
|
195
199
|
end
|
196
200
|
else
|
@@ -200,9 +204,10 @@ class OpenNebula::LdapAuth
|
|
200
204
|
:attributes => [ "dn" ],
|
201
205
|
:filter => filter
|
202
206
|
) do |entry|
|
203
|
-
if @mapping
|
204
|
-
groups << @mapping[
|
207
|
+
if (g = in_hash_ignore_case?(@mapping, entry.dn))
|
208
|
+
groups << @mapping[g]
|
205
209
|
end
|
210
|
+
|
206
211
|
end
|
207
212
|
end
|
208
213
|
|
@@ -46,6 +46,7 @@ module OpenNebula
|
|
46
46
|
:disksnapshotcreate => "vm.disksnapshotcreate",
|
47
47
|
:disksnapshotrevert => "vm.disksnapshotrevert",
|
48
48
|
:disksnapshotdelete => "vm.disksnapshotdelete",
|
49
|
+
:disksnapshotrename => "vm.disksnapshotrename",
|
49
50
|
:diskresize => "vm.diskresize",
|
50
51
|
:updateconf => "vm.updateconf",
|
51
52
|
:lock => "vm.lock",
|
@@ -211,7 +212,9 @@ module OpenNebula
|
|
211
212
|
disk-snapshot-create disk-snapshot-delete terminate terminate-hard
|
212
213
|
disk-resize deploy chown chmod updateconf rename resize update
|
213
214
|
snapshot-resize snapshot-delete snapshot-revert disk-saveas
|
214
|
-
disk-snapshot-revert recover retry monitor
|
215
|
+
disk-snapshot-revert recover retry monitor disk-snapshot-rename
|
216
|
+
alias-attach alias-detach poweroff-migrate poweroff-hard-migrate
|
217
|
+
}
|
215
218
|
|
216
219
|
EXTERNAL_IP_ATTRS = [
|
217
220
|
'GUEST_IP',
|
@@ -341,9 +344,10 @@ module OpenNebula
|
|
341
344
|
#
|
342
345
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
343
346
|
# otherwise
|
344
|
-
def deploy(host_id, enforce=false, ds_id=-1)
|
347
|
+
def deploy(host_id, enforce=false, ds_id=-1, extra_template="")
|
345
348
|
enforce ||= false
|
346
349
|
ds_id ||= -1
|
350
|
+
extra_template ||= ""
|
347
351
|
|
348
352
|
self.info
|
349
353
|
|
@@ -351,7 +355,8 @@ module OpenNebula
|
|
351
355
|
@pe_id,
|
352
356
|
host_id.to_i,
|
353
357
|
enforce,
|
354
|
-
ds_id.to_i
|
358
|
+
ds_id.to_i,
|
359
|
+
extra_template)
|
355
360
|
end
|
356
361
|
|
357
362
|
# Shutdowns an already deployed VM
|
@@ -463,12 +468,16 @@ module OpenNebula
|
|
463
468
|
# overcommited. Defaults to false
|
464
469
|
# @param ds_id [Integer] The System Datastore where to migrate the VM.
|
465
470
|
# To use the current one, set it to -1
|
471
|
+
# @param mtype [Integer] How to perform the cold migration:
|
472
|
+
# - 0: save - restore,
|
473
|
+
# - 1: power off - boot
|
474
|
+
# - 2: power off hard - boot
|
466
475
|
#
|
467
476
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
468
477
|
# otherwise
|
469
|
-
def migrate(host_id, live=false, enforce=false, ds_id=-1)
|
478
|
+
def migrate(host_id, live=false, enforce=false, ds_id=-1, mtype=0)
|
470
479
|
call(VM_METHODS[:migrate], @pe_id, host_id.to_i, live==true,
|
471
|
-
enforce, ds_id.to_i)
|
480
|
+
enforce, ds_id.to_i, mtype)
|
472
481
|
end
|
473
482
|
|
474
483
|
# @deprecated use {#migrate} instead
|
@@ -649,6 +658,18 @@ module OpenNebula
|
|
649
658
|
return call(VM_METHODS[:disksnapshotdelete], @pe_id, disk_id, snap_id)
|
650
659
|
end
|
651
660
|
|
661
|
+
# Renames a disk snapshot
|
662
|
+
#
|
663
|
+
# @param disk_id [Integer] Id of the disk
|
664
|
+
# @param snap_id [Integer] Id of the snapshot
|
665
|
+
# @param new_name [String] New name for the snapshot
|
666
|
+
#
|
667
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
668
|
+
# otherwise
|
669
|
+
def disk_snapshot_rename(disk_id, snap_id, new_name)
|
670
|
+
return call(VM_METHODS[:disksnapshotrename], @pe_id, disk_id, snap_id, new_name)
|
671
|
+
end
|
672
|
+
|
652
673
|
# Changes the size of a disk
|
653
674
|
#
|
654
675
|
# @param disk_id [Integer] Id of the disk
|
@@ -662,7 +683,7 @@ module OpenNebula
|
|
662
683
|
# Recovers an ACTIVE VM
|
663
684
|
#
|
664
685
|
# @param result [Integer] Recover with failure (0), success (1),
|
665
|
-
# retry (2), delete (3), delete-recreate (4)
|
686
|
+
# retry (2), delete (3), delete-recreate (4), delete-db (5)
|
666
687
|
# @param result [info] Additional information needed to recover the VM
|
667
688
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
668
689
|
# otherwise
|
@@ -840,17 +861,25 @@ module OpenNebula
|
|
840
861
|
image_id = disk["IMAGE_ID"]
|
841
862
|
|
842
863
|
if !image_id.nil? && !image_id.empty?
|
843
|
-
|
864
|
+
if disk['TYPE'] == 'CDROM'
|
865
|
+
replace << "DISK = [ IMAGE_ID = #{image_id}"
|
866
|
+
if disk["OPENNEBULA_MANAGED"]
|
867
|
+
replace << ", OPENNEBULA_MANAGED=#{disk["OPENNEBULA_MANAGED"]}"
|
868
|
+
end
|
869
|
+
replace << " ]\n"
|
870
|
+
else
|
871
|
+
rc = disk_saveas(disk_id.to_i,"#{name}-disk-#{disk_id}","",-1)
|
844
872
|
|
845
|
-
|
873
|
+
raise if OpenNebula.is_error?(rc)
|
846
874
|
|
847
|
-
|
848
|
-
|
849
|
-
|
875
|
+
if persistent == true
|
876
|
+
OpenNebula::Image.new_with_id(rc.to_i, @client).persistent()
|
877
|
+
end
|
850
878
|
|
851
|
-
|
879
|
+
img_ids << rc.to_i
|
852
880
|
|
853
|
-
|
881
|
+
replace << "DISK = [ IMAGE_ID = #{rc} ]\n"
|
882
|
+
end
|
854
883
|
else
|
855
884
|
# Volatile disks cannot be saved, so the definition is copied
|
856
885
|
replace << self.template_like_str(
|
@@ -859,12 +888,13 @@ module OpenNebula
|
|
859
888
|
end
|
860
889
|
|
861
890
|
self.each('TEMPLATE/NIC') do |nic|
|
862
|
-
|
863
891
|
nic_id = nic["NIC_ID"]
|
892
|
+
|
864
893
|
if nic_id.nil? || nic_id.empty?
|
865
894
|
rc = Error.new('The NIC_ID is missing from the VM template')
|
866
895
|
raise
|
867
896
|
end
|
897
|
+
|
868
898
|
REMOVE_VNET_ATTRS.each do |attr|
|
869
899
|
nic.delete_element(attr)
|
870
900
|
end
|
@@ -0,0 +1,260 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2018, 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
|
+
|
18
|
+
require 'opennebula/pool_element'
|
19
|
+
|
20
|
+
module OpenNebula
|
21
|
+
class VNTemplate < PoolElement
|
22
|
+
#######################################################################
|
23
|
+
# Constants and Class Methods
|
24
|
+
#######################################################################
|
25
|
+
|
26
|
+
|
27
|
+
TEMPLATE_METHODS = {
|
28
|
+
:allocate => "vntemplate.allocate",
|
29
|
+
:instantiate => "vntemplate.instantiate",
|
30
|
+
:info => "vntemplate.info",
|
31
|
+
:update => "vntemplate.update",
|
32
|
+
:delete => "vntemplate.delete",
|
33
|
+
:chown => "vntemplate.chown",
|
34
|
+
:chmod => "vntemplate.chmod",
|
35
|
+
:clone => "vntemplate.clone",
|
36
|
+
:rename => "vntemplate.rename",
|
37
|
+
:lock => "vntemplate.lock",
|
38
|
+
:unlock => "vntemplate.unlock"
|
39
|
+
}
|
40
|
+
|
41
|
+
# Creates a VNTemplate description with just its identifier
|
42
|
+
# this method should be used to create plain VNTemplate objects.
|
43
|
+
# +id+ the id of the user
|
44
|
+
#
|
45
|
+
# Example:
|
46
|
+
# vntemplate = VNTemplate.new(VNTemplate.build_xml(3),rpc_client)
|
47
|
+
#
|
48
|
+
def VNTemplate.build_xml(pe_id=nil)
|
49
|
+
if pe_id
|
50
|
+
obj_xml = "<VNTEMPLATE><ID>#{pe_id}</ID></VNTEMPLATE>"
|
51
|
+
else
|
52
|
+
obj_xml = "<VNTEMPLATE></VNTEMPLATE>"
|
53
|
+
end
|
54
|
+
|
55
|
+
XMLElement.build_xml(obj_xml,'VNTEMPLATE')
|
56
|
+
end
|
57
|
+
|
58
|
+
# Class constructor
|
59
|
+
def initialize(xml, client)
|
60
|
+
super(xml,client)
|
61
|
+
|
62
|
+
@client = client
|
63
|
+
end
|
64
|
+
|
65
|
+
#######################################################################
|
66
|
+
# XML-RPC Methods for the Template Object
|
67
|
+
#######################################################################
|
68
|
+
|
69
|
+
# Retrieves the information of the given VNTemplate.
|
70
|
+
# include extended information, such as the SIZE for each DISK
|
71
|
+
def info()
|
72
|
+
return Error.new('ID not defined') if !@pe_id
|
73
|
+
|
74
|
+
rc = @client.call(TEMPLATE_METHODS[:info], @pe_id, false)
|
75
|
+
|
76
|
+
if !OpenNebula.is_error?(rc)
|
77
|
+
initialize_xml(rc, 'VNTEMPLATE')
|
78
|
+
rc = nil
|
79
|
+
|
80
|
+
@pe_id = self['ID'].to_i if self['ID']
|
81
|
+
@name = self['NAME'] if self['NAME']
|
82
|
+
end
|
83
|
+
|
84
|
+
return rc
|
85
|
+
end
|
86
|
+
|
87
|
+
alias_method :info!, :info
|
88
|
+
|
89
|
+
# Allocates a new VNTemplate in OpenNebula
|
90
|
+
#
|
91
|
+
# @param description [String] The contents of the VNTemplate.
|
92
|
+
#
|
93
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
94
|
+
# otherwise
|
95
|
+
def allocate(description)
|
96
|
+
super(TEMPLATE_METHODS[:allocate], description)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Deletes the Template
|
100
|
+
#
|
101
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
102
|
+
# otherwise
|
103
|
+
def delete()
|
104
|
+
return call(TEMPLATE_METHODS[:delete], @pe_id, false)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Creates a VNet instance from a VNTemplate
|
108
|
+
#
|
109
|
+
# @param name [String] Name for the VNet instance. If it is an empty
|
110
|
+
# string OpenNebula will set a default name
|
111
|
+
# @param template [String] User provided VNTemplate to merge with the
|
112
|
+
# one being instantiated
|
113
|
+
#
|
114
|
+
# @return [Integer, OpenNebula::Error] The new VNet id, Error
|
115
|
+
# otherwise
|
116
|
+
def instantiate(name="", template="")
|
117
|
+
return Error.new('ID not defined') if !@pe_id
|
118
|
+
|
119
|
+
name ||= ""
|
120
|
+
template ||= ""
|
121
|
+
|
122
|
+
rc = @client.call(TEMPLATE_METHODS[:instantiate], @pe_id,
|
123
|
+
name, template)
|
124
|
+
|
125
|
+
return rc
|
126
|
+
end
|
127
|
+
|
128
|
+
# Replaces the vntemplate contents
|
129
|
+
#
|
130
|
+
# @param new_template [String] New vntemplate contents
|
131
|
+
# @param append [true, false] True to append new attributes instead of
|
132
|
+
# replace the whole template
|
133
|
+
#
|
134
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
135
|
+
# otherwise
|
136
|
+
def update(new_template, append=false)
|
137
|
+
super(TEMPLATE_METHODS[:update], new_template, append ? 1 : 0)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Publishes the Template, to be used by other users
|
141
|
+
def publish
|
142
|
+
set_publish(true)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Unplubishes the Image
|
146
|
+
def unpublish
|
147
|
+
set_publish(false)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Changes the owner/group
|
151
|
+
# uid:: _Integer_ the new owner id. Set to -1 to leave the current one
|
152
|
+
# gid:: _Integer_ the new group id. Set to -1 to leave the current one
|
153
|
+
# [return] nil in case of success or an Error object
|
154
|
+
def chown(uid, gid)
|
155
|
+
super(TEMPLATE_METHODS[:chown], uid, gid)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Changes the VNTemplate permissions.
|
159
|
+
#
|
160
|
+
# @param octet [String] Permissions octed , e.g. 640
|
161
|
+
# @param recursive [true,false] optional, chmods the vntemplate plus
|
162
|
+
# any image defined in DISK.
|
163
|
+
#
|
164
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
165
|
+
# otherwise
|
166
|
+
def chmod_octet(octet, recursive=false)
|
167
|
+
owner_u = octet[0..0].to_i & 4 != 0 ? 1 : 0
|
168
|
+
owner_m = octet[0..0].to_i & 2 != 0 ? 1 : 0
|
169
|
+
owner_a = octet[0..0].to_i & 1 != 0 ? 1 : 0
|
170
|
+
group_u = octet[1..1].to_i & 4 != 0 ? 1 : 0
|
171
|
+
group_m = octet[1..1].to_i & 2 != 0 ? 1 : 0
|
172
|
+
group_a = octet[1..1].to_i & 1 != 0 ? 1 : 0
|
173
|
+
other_u = octet[2..2].to_i & 4 != 0 ? 1 : 0
|
174
|
+
other_m = octet[2..2].to_i & 2 != 0 ? 1 : 0
|
175
|
+
other_a = octet[2..2].to_i & 1 != 0 ? 1 : 0
|
176
|
+
|
177
|
+
chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
|
178
|
+
other_m, other_a, recursive)
|
179
|
+
end
|
180
|
+
|
181
|
+
# Changes the VNTemplate permissions.
|
182
|
+
# Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
|
183
|
+
#
|
184
|
+
# @param recursive [true,false] optional, chmods the vntemplate plus
|
185
|
+
# any image defined in DISK.
|
186
|
+
#
|
187
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
188
|
+
# otherwise
|
189
|
+
def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
|
190
|
+
other_m, other_a, recursive=false)
|
191
|
+
return call(TEMPLATE_METHODS[:chmod], @pe_id, owner_u, owner_m, owner_a, group_u,
|
192
|
+
group_m, group_a, other_u, other_m, other_a, recursive)
|
193
|
+
end
|
194
|
+
|
195
|
+
# Clones this VNTemplate into a new one
|
196
|
+
#
|
197
|
+
# @param [String] name for the new VNTemplate.
|
198
|
+
# any image defined in DISK. The new IMAGE_ID is set into each DISK.
|
199
|
+
#
|
200
|
+
# @return [Integer, OpenNebula::Error] The new Template ID in case
|
201
|
+
# of success, Error otherwise
|
202
|
+
def clone(name)
|
203
|
+
return Error.new('ID not defined') if !@pe_id
|
204
|
+
|
205
|
+
rc = @client.call(TEMPLATE_METHODS[:clone], @pe_id, name, false)
|
206
|
+
|
207
|
+
return rc
|
208
|
+
end
|
209
|
+
|
210
|
+
# Renames this VNTemplate
|
211
|
+
#
|
212
|
+
# @param name [String] New name for the VNTemplate.
|
213
|
+
#
|
214
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
215
|
+
# otherwise
|
216
|
+
def rename(name)
|
217
|
+
return call(TEMPLATE_METHODS[:rename], @pe_id, name)
|
218
|
+
end
|
219
|
+
|
220
|
+
#######################################################################
|
221
|
+
# Helpers to get VNTemplate information
|
222
|
+
#######################################################################
|
223
|
+
|
224
|
+
# Returns the group identifier
|
225
|
+
# [return] _Integer_ the element's group ID
|
226
|
+
def gid
|
227
|
+
self['GID'].to_i
|
228
|
+
end
|
229
|
+
|
230
|
+
def owner_id
|
231
|
+
self['UID'].to_i
|
232
|
+
end
|
233
|
+
|
234
|
+
# Lock a VNTemplate
|
235
|
+
def lock(level)
|
236
|
+
return call(TEMPLATE_METHODS[:lock], @pe_id, level)
|
237
|
+
end
|
238
|
+
|
239
|
+
# Unlock a VNTemplate
|
240
|
+
def unlock()
|
241
|
+
return call(TEMPLATE_METHODS[:unlock], @pe_id)
|
242
|
+
end
|
243
|
+
|
244
|
+
def public?
|
245
|
+
if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1"
|
246
|
+
true
|
247
|
+
else
|
248
|
+
false
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
private
|
253
|
+
|
254
|
+
def set_publish(published)
|
255
|
+
group_u = published ? 1 : 0
|
256
|
+
|
257
|
+
chmod(-1, -1, -1, group_u, -1, -1, -1, -1, -1)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2018, 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
|
+
|
18
|
+
require 'opennebula/pool'
|
19
|
+
|
20
|
+
module OpenNebula
|
21
|
+
class VNTemplatePool < Pool
|
22
|
+
#######################################################################
|
23
|
+
# Constants and Class attribute accessors
|
24
|
+
#######################################################################
|
25
|
+
|
26
|
+
|
27
|
+
TEMPLATE_POOL_METHODS = {
|
28
|
+
:info => "vntemplatepool.info"
|
29
|
+
}
|
30
|
+
|
31
|
+
#######################################################################
|
32
|
+
# Class constructor & Pool Methods
|
33
|
+
#######################################################################
|
34
|
+
|
35
|
+
# +client+ a Client object that represents an XML-RPC connection
|
36
|
+
# +user_id+ used to refer to a Pool with Templates from that user
|
37
|
+
def initialize(client, user_id=-1)
|
38
|
+
super('VNTEMPLATE_POOL','VNTEMPLATE',client)
|
39
|
+
|
40
|
+
@user_id = user_id
|
41
|
+
end
|
42
|
+
|
43
|
+
# Factory method to create Template objects
|
44
|
+
def factory(element_xml)
|
45
|
+
OpenNebula::VNTemplate.new(element_xml,@client)
|
46
|
+
end
|
47
|
+
|
48
|
+
#######################################################################
|
49
|
+
# XML-RPC Methods for the Template Object
|
50
|
+
#######################################################################
|
51
|
+
|
52
|
+
# Retrieves all or part of the Templates in the pool.
|
53
|
+
def info(*args)
|
54
|
+
case args.size
|
55
|
+
when 0
|
56
|
+
info_filter(TEMPLATE_POOL_METHODS[:info],@user_id,-1,-1)
|
57
|
+
when 3
|
58
|
+
info_filter(TEMPLATE_POOL_METHODS[:info],args[0],args[1],args[2])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def info_all()
|
63
|
+
return super(TEMPLATE_POOL_METHODS[:info])
|
64
|
+
end
|
65
|
+
|
66
|
+
def info_mine()
|
67
|
+
return super(TEMPLATE_POOL_METHODS[:info])
|
68
|
+
end
|
69
|
+
|
70
|
+
def info_group()
|
71
|
+
return super(TEMPLATE_POOL_METHODS[:info])
|
72
|
+
end
|
73
|
+
|
74
|
+
alias_method :info!, :info
|
75
|
+
alias_method :info_all!, :info_all
|
76
|
+
alias_method :info_mine!, :info_mine
|
77
|
+
alias_method :info_group!, :info_group
|
78
|
+
end
|
79
|
+
end
|
data/lib/vcenter_driver.rb
CHANGED
@@ -38,11 +38,29 @@ $LOAD_PATH << LIB_LOCATION + '/ruby/vendors/rbvmomi/lib'
|
|
38
38
|
$LOAD_PATH << LIB_LOCATION + '/ruby'
|
39
39
|
$LOAD_PATH << LIB_LOCATION + '/ruby/vcenter_driver'
|
40
40
|
|
41
|
+
class VCenterConf < Hash
|
42
|
+
DEFAULT_CONFIGURATION = {
|
43
|
+
delete_images: false,
|
44
|
+
vm_poweron_wait_default: 300,
|
45
|
+
debug_information: false
|
46
|
+
}
|
47
|
+
|
48
|
+
def initialize
|
49
|
+
self.replace(DEFAULT_CONFIGURATION)
|
50
|
+
begin
|
51
|
+
self.merge!(YAML.load_file("#{VAR_LOCATION}/remotes/etc/vmm/vcenter/vcenterrc"))
|
52
|
+
rescue
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
41
57
|
require 'rbvmomi'
|
42
58
|
require 'yaml'
|
43
59
|
require 'opennebula'
|
44
60
|
require 'base64'
|
45
61
|
require 'openssl'
|
62
|
+
require 'digest'
|
63
|
+
require 'resolv'
|
46
64
|
|
47
65
|
# ---------------------------------------------------------------------------- #
|
48
66
|
# vCenter Library #
|
@@ -55,12 +73,17 @@ require 'vi_helper'
|
|
55
73
|
require 'datacenter'
|
56
74
|
require 'host'
|
57
75
|
require 'datastore'
|
76
|
+
require 'vm_template'
|
58
77
|
require 'virtual_machine'
|
59
78
|
require 'network'
|
60
79
|
require 'file_helper'
|
61
|
-
require 'importer'
|
62
80
|
|
63
81
|
CHECK_REFS = true
|
82
|
+
|
83
|
+
module VCenterDriver
|
84
|
+
CONFIG = VCenterConf.new
|
85
|
+
end
|
86
|
+
|
64
87
|
# ---------------------------------------------------------------------------- #
|
65
88
|
# Helper functions #
|
66
89
|
# ---------------------------------------------------------------------------- #
|
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.
|
4
|
+
version: 5.7.80.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenNebula
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -108,6 +108,8 @@ files:
|
|
108
108
|
- lib/opennebula/virtual_router_pool.rb
|
109
109
|
- lib/opennebula/vm_group.rb
|
110
110
|
- lib/opennebula/vm_group_pool.rb
|
111
|
+
- lib/opennebula/vntemplate.rb
|
112
|
+
- lib/opennebula/vntemplate_pool.rb
|
111
113
|
- lib/opennebula/xml_element.rb
|
112
114
|
- lib/opennebula/xml_pool.rb
|
113
115
|
- lib/opennebula/xml_utils.rb
|
@@ -137,9 +139,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
139
|
version: '0'
|
138
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
141
|
requirements:
|
140
|
-
- - '
|
142
|
+
- - '>'
|
141
143
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
144
|
+
version: 1.3.1
|
143
145
|
requirements: []
|
144
146
|
rubyforge_project:
|
145
147
|
rubygems_version: 2.0.14.1
|