opennebula 4.14.2 → 4.90.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NOTICE +1 -1
- data/lib/cloud/CloudClient.rb +3 -3
- data/lib/opennebula.rb +8 -2
- data/lib/opennebula/acl.rb +20 -14
- 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 +2 -2
- data/lib/opennebula/datastore_pool.rb +3 -3
- data/lib/opennebula/document.rb +16 -1
- data/lib/opennebula/document_json.rb +13 -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/group.rb +17 -10
- data/lib/opennebula/group_pool.rb +1 -1
- data/lib/opennebula/host.rb +26 -14
- data/lib/opennebula/host_pool.rb +1 -1
- data/lib/opennebula/image.rb +7 -3
- data/lib/opennebula/image_pool.rb +1 -2
- data/lib/opennebula/ldap_auth.rb +1 -1
- data/lib/opennebula/ldap_auth_spec.rb +1 -1
- data/lib/opennebula/marketplace.rb +161 -0
- data/lib/opennebula/marketplace_pool.rb +55 -0
- data/lib/opennebula/marketplaceapp.rb +267 -0
- data/lib/opennebula/marketplaceapp_pool.rb +77 -0
- data/lib/opennebula/oneflow_client.rb +10 -8
- data/lib/opennebula/pool.rb +1 -1
- data/lib/opennebula/pool_element.rb +1 -1
- data/lib/opennebula/security_group.rb +43 -2
- 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 +42 -13
- 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/vdc.rb +1 -1
- data/lib/opennebula/vdc_pool.rb +1 -1
- data/lib/opennebula/virtual_machine.rb +65 -50
- data/lib/opennebula/virtual_machine_pool.rb +1 -1
- data/lib/opennebula/virtual_network.rb +13 -2
- data/lib/opennebula/virtual_network_pool.rb +1 -1
- data/lib/opennebula/virtual_router.rb +203 -0
- data/lib/opennebula/virtual_router_pool.rb +79 -0
- data/lib/opennebula/x509_auth.rb +1 -1
- data/lib/opennebula/xml_element.rb +6 -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
- metadata +11 -5
@@ -0,0 +1,77 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2016, 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 MarketPlaceAppPool < Pool
|
22
|
+
#######################################################################
|
23
|
+
# Constants and Class attribute accessors
|
24
|
+
#######################################################################
|
25
|
+
|
26
|
+
MARKETPLACEAPP_POOL_METHODS = {
|
27
|
+
:info => "marketapppool.info"
|
28
|
+
}
|
29
|
+
|
30
|
+
#######################################################################
|
31
|
+
# Class constructor & Pool Methods
|
32
|
+
#######################################################################
|
33
|
+
|
34
|
+
# +client+ a Client object that represents a XML-RPC connection
|
35
|
+
def initialize(client, user_id=-1)
|
36
|
+
super('MARKETPLACEAPP_POOL','MARKETPLACEAPP', client)
|
37
|
+
|
38
|
+
@user_id = user_id
|
39
|
+
end
|
40
|
+
|
41
|
+
# Factory method to create MarketPlaceApp objects
|
42
|
+
def factory(element_xml)
|
43
|
+
OpenNebula::MarketPlaceApp.new(element_xml, @client)
|
44
|
+
end
|
45
|
+
|
46
|
+
#######################################################################
|
47
|
+
# XML-RPC Methods for the User Object
|
48
|
+
#######################################################################
|
49
|
+
|
50
|
+
# Retrieves all or part of the Images in the pool.
|
51
|
+
def info(*args)
|
52
|
+
case args.size
|
53
|
+
when 0
|
54
|
+
info_filter(MARKETPLACEAPP_POOL_METHODS[:info],@user_id,-1,-1)
|
55
|
+
when 3
|
56
|
+
info_filter(MARKETPLACEAPP_POOL_METHODS[:info],args[0],args[1],args[2])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def info_all()
|
61
|
+
return super(MARKETPLACEAPP_POOL_METHODS[:info])
|
62
|
+
end
|
63
|
+
|
64
|
+
def info_mine()
|
65
|
+
return super(MARKETPLACEAPP_POOL_METHODS[:info])
|
66
|
+
end
|
67
|
+
|
68
|
+
def info_group()
|
69
|
+
return super(MARKETPLACEAPP_POOL_METHODS[:info])
|
70
|
+
end
|
71
|
+
|
72
|
+
alias_method :info!, :info
|
73
|
+
alias_method :info_all!, :info_all
|
74
|
+
alias_method :info_mine!, :info_mine
|
75
|
+
alias_method :info_group!, :info_group
|
76
|
+
end
|
77
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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 #
|
@@ -22,8 +22,8 @@ include CloudCLI
|
|
22
22
|
module Role
|
23
23
|
# Actions that can be performed on the VMs of a given Role
|
24
24
|
SCHEDULE_ACTIONS = [
|
25
|
-
'
|
26
|
-
'
|
25
|
+
'terminate',
|
26
|
+
'terminate-hard',
|
27
27
|
'undeploy',
|
28
28
|
'undeploy-hard',
|
29
29
|
'hold',
|
@@ -31,8 +31,6 @@ module Role
|
|
31
31
|
'stop',
|
32
32
|
'suspend',
|
33
33
|
'resume',
|
34
|
-
'delete',
|
35
|
-
'delete-recreate',
|
36
34
|
'reboot',
|
37
35
|
'reboot-hard',
|
38
36
|
'poweroff',
|
@@ -114,7 +112,7 @@ module Service
|
|
114
112
|
end
|
115
113
|
|
116
114
|
# Build a json specifying an action
|
117
|
-
# @param [String] perform action to be performed (
|
115
|
+
# @param [String] perform action to be performed (e.g.: shutdown)
|
118
116
|
# @param [Hash, nil] params contains the params for the action
|
119
117
|
# @return [String] json representing the action
|
120
118
|
def self.build_json_action(perform, params=nil)
|
@@ -307,11 +305,15 @@ module Service
|
|
307
305
|
if @username.nil? && @password.nil?
|
308
306
|
if ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and File.file?(ENV["ONE_AUTH"])
|
309
307
|
one_auth = File.read(ENV["ONE_AUTH"])
|
310
|
-
elsif File.file?(ENV["HOME"]+"/.one/one_auth")
|
308
|
+
elsif ENV["HOME"] and File.file?(ENV["HOME"]+"/.one/one_auth")
|
311
309
|
one_auth = File.read(ENV["HOME"]+"/.one/one_auth")
|
310
|
+
elsif File.file?("/var/lib/one/.one/one_auth")
|
311
|
+
one_auth = File.read("/var/lib/one/.one/one_auth")
|
312
|
+
else
|
313
|
+
raise "ONE_AUTH file not present"
|
312
314
|
end
|
313
315
|
|
314
|
-
one_auth.rstrip
|
316
|
+
one_auth = one_auth.rstrip
|
315
317
|
|
316
318
|
@username, @password = one_auth.split(':')
|
317
319
|
end
|
data/lib/opennebula/pool.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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-2016, 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-2016, 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 #
|
@@ -32,7 +32,8 @@ module OpenNebula
|
|
32
32
|
:chown => "secgroup.chown",
|
33
33
|
:chmod => "secgroup.chmod",
|
34
34
|
:clone => "secgroup.clone",
|
35
|
-
:rename => "secgroup.rename"
|
35
|
+
:rename => "secgroup.rename",
|
36
|
+
:commit => "secgroup.commit"
|
36
37
|
}
|
37
38
|
|
38
39
|
# Creates a SecurityGroup description with just its identifier
|
@@ -147,10 +148,50 @@ module OpenNebula
|
|
147
148
|
return call(SECGROUP_METHODS[:rename], @pe_id, name)
|
148
149
|
end
|
149
150
|
|
151
|
+
# Commit SG changes to associated VMs
|
152
|
+
#
|
153
|
+
# @param recover [Bool] If true will only operate on outdated and error
|
154
|
+
# VMs. This is intended for retrying updates of VMs or reinitialize the
|
155
|
+
# updating process if oned stopped or fail.
|
156
|
+
#
|
157
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
158
|
+
# otherwise
|
159
|
+
def commit(recover)
|
160
|
+
return call(SECGROUP_METHODS[:commit], @pe_id, recover)
|
161
|
+
end
|
162
|
+
|
150
163
|
#######################################################################
|
151
164
|
# Helpers to get SecurityGroup information
|
152
165
|
#######################################################################
|
153
166
|
|
167
|
+
# Returns three arrays with the numeric vm ids for vms updated,
|
168
|
+
# outdated (include updating) and error
|
169
|
+
def vm_ids
|
170
|
+
updated = Array.new
|
171
|
+
|
172
|
+
self.each("UPDATED_VMS/ID") do |id|
|
173
|
+
updated << id.text.to_i
|
174
|
+
end
|
175
|
+
|
176
|
+
outdated = Array.new
|
177
|
+
|
178
|
+
self.each("OUTDATED_VMS/ID") do |id|
|
179
|
+
outdated << id.text.to_i
|
180
|
+
end
|
181
|
+
|
182
|
+
self.each("UPDATING_VMS/ID") do |id|
|
183
|
+
outdated << id.text.to_i
|
184
|
+
end
|
185
|
+
|
186
|
+
error = Array.new
|
187
|
+
|
188
|
+
self.each("ERROR_VMS/ID") do |id|
|
189
|
+
error << id.text.to_i
|
190
|
+
end
|
191
|
+
|
192
|
+
return [updated, outdated, error]
|
193
|
+
end
|
194
|
+
|
154
195
|
# Returns the group identifier
|
155
196
|
# [return] _Integer_ the element's group ID
|
156
197
|
def gid
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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-2016, 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-2016, 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/ssh_auth.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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/system.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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/template.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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 #
|
@@ -96,8 +96,14 @@ module OpenNebula
|
|
96
96
|
end
|
97
97
|
|
98
98
|
# Deletes the Template
|
99
|
-
|
100
|
-
|
99
|
+
#
|
100
|
+
# @param recursive [true,false] optional, deletes the template plus
|
101
|
+
# any image defined in DISK.
|
102
|
+
#
|
103
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
104
|
+
# otherwise
|
105
|
+
def delete(recursive=false)
|
106
|
+
return call(TEMPLATE_METHODS[:delete], @pe_id, recursive)
|
101
107
|
end
|
102
108
|
|
103
109
|
# Creates a VM instance from a Template
|
@@ -108,18 +114,22 @@ module OpenNebula
|
|
108
114
|
# true to create it on hold
|
109
115
|
# @param template [String] User provided Template to merge with the
|
110
116
|
# one being instantiated
|
117
|
+
# @param persistent [true,false] true to create a private persistent
|
118
|
+
# copy of the template plus any image defined in DISK, and instantiate
|
119
|
+
# that copy
|
111
120
|
#
|
112
121
|
# @return [Integer, OpenNebula::Error] The new VM id, Error
|
113
122
|
# otherwise
|
114
|
-
def instantiate(name="", hold=false, template="")
|
123
|
+
def instantiate(name="", hold=false, template="", persistent=false)
|
115
124
|
return Error.new('ID not defined') if !@pe_id
|
116
125
|
|
117
126
|
name ||= ""
|
118
127
|
hold = false if hold.nil?
|
119
128
|
template ||= ""
|
129
|
+
persistent = false if persistent.nil?
|
120
130
|
|
121
|
-
rc = @client.call(
|
122
|
-
|
131
|
+
rc = @client.call(TEMPLATE_METHODS[:instantiate], @pe_id,
|
132
|
+
name, hold, template, persistent)
|
123
133
|
|
124
134
|
return rc
|
125
135
|
end
|
@@ -157,33 +167,52 @@ module OpenNebula
|
|
157
167
|
# Changes the Template permissions.
|
158
168
|
#
|
159
169
|
# @param octet [String] Permissions octed , e.g. 640
|
170
|
+
# @param recursive [true,false] optional, chmods the template plus
|
171
|
+
# any image defined in DISK.
|
172
|
+
#
|
160
173
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
161
174
|
# otherwise
|
162
|
-
def chmod_octet(octet)
|
163
|
-
|
175
|
+
def chmod_octet(octet, recursive=false)
|
176
|
+
owner_u = octet[0..0].to_i & 4 != 0 ? 1 : 0
|
177
|
+
owner_m = octet[0..0].to_i & 2 != 0 ? 1 : 0
|
178
|
+
owner_a = octet[0..0].to_i & 1 != 0 ? 1 : 0
|
179
|
+
group_u = octet[1..1].to_i & 4 != 0 ? 1 : 0
|
180
|
+
group_m = octet[1..1].to_i & 2 != 0 ? 1 : 0
|
181
|
+
group_a = octet[1..1].to_i & 1 != 0 ? 1 : 0
|
182
|
+
other_u = octet[2..2].to_i & 4 != 0 ? 1 : 0
|
183
|
+
other_m = octet[2..2].to_i & 2 != 0 ? 1 : 0
|
184
|
+
other_a = octet[2..2].to_i & 1 != 0 ? 1 : 0
|
185
|
+
|
186
|
+
chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
|
187
|
+
other_m, other_a, recursive)
|
164
188
|
end
|
165
189
|
|
166
190
|
# Changes the Template permissions.
|
167
191
|
# Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
|
168
192
|
#
|
193
|
+
# @param recursive [true,false] optional, chmods the template plus
|
194
|
+
# any image defined in DISK.
|
195
|
+
#
|
169
196
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
170
197
|
# otherwise
|
171
198
|
def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
|
172
|
-
other_m, other_a)
|
173
|
-
|
174
|
-
group_m, group_a, other_u, other_m, other_a)
|
199
|
+
other_m, other_a, recursive=false)
|
200
|
+
return call(TEMPLATE_METHODS[:chmod], @pe_id, owner_u, owner_m, owner_a, group_u,
|
201
|
+
group_m, group_a, other_u, other_m, other_a, recursive)
|
175
202
|
end
|
176
203
|
|
177
204
|
# Clones this Template into a new one
|
178
205
|
#
|
179
206
|
# @param [String] name for the new Template.
|
207
|
+
# @param recursive [true,false] optional, clones the template plus
|
208
|
+
# any image defined in DISK. The new IMAGE_ID is set into each DISK.
|
180
209
|
#
|
181
210
|
# @return [Integer, OpenNebula::Error] The new Template ID in case
|
182
211
|
# of success, Error otherwise
|
183
|
-
def clone(name)
|
212
|
+
def clone(name, recursive=false)
|
184
213
|
return Error.new('ID not defined') if !@pe_id
|
185
214
|
|
186
|
-
rc = @client.call(TEMPLATE_METHODS[:clone], @pe_id, name)
|
215
|
+
rc = @client.call(TEMPLATE_METHODS[:clone], @pe_id, name, recursive)
|
187
216
|
|
188
217
|
return rc
|
189
218
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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/user.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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/user_pool.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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/vdc.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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/vdc_pool.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2016, 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-2016, 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 #
|
@@ -46,11 +46,12 @@ module OpenNebula
|
|
46
46
|
:disksaveas => "vm.disksaveas",
|
47
47
|
:disksnapshotcreate => "vm.disksnapshotcreate",
|
48
48
|
:disksnapshotrevert => "vm.disksnapshotrevert",
|
49
|
-
:disksnapshotdelete => "vm.disksnapshotdelete"
|
49
|
+
:disksnapshotdelete => "vm.disksnapshotdelete",
|
50
|
+
:updateconf => "vm.updateconf"
|
50
51
|
}
|
51
52
|
|
52
53
|
VM_STATE=%w{INIT PENDING HOLD ACTIVE STOPPED SUSPENDED DONE FAILED
|
53
|
-
POWEROFF UNDEPLOYED}
|
54
|
+
POWEROFF UNDEPLOYED CLONING CLONING_FAILURE}
|
54
55
|
|
55
56
|
LCM_STATE=%w{
|
56
57
|
LCM_INIT
|
@@ -111,21 +112,24 @@ module OpenNebula
|
|
111
112
|
DISK_SNAPSHOT_REVERT_SUSPENDED
|
112
113
|
DISK_SNAPSHOT_DELETE_SUSPENDED
|
113
114
|
DISK_SNAPSHOT
|
114
|
-
DISK_SNAPSHOT_REVERT
|
115
115
|
DISK_SNAPSHOT_DELETE
|
116
|
+
PROLOG_MIGRATE_UNKNOWN
|
117
|
+
PROLOG_MIGRATE_UNKNOWN_FAILURE
|
116
118
|
}
|
117
119
|
|
118
120
|
SHORT_VM_STATES={
|
119
|
-
"INIT"
|
120
|
-
"PENDING"
|
121
|
-
"HOLD"
|
122
|
-
"ACTIVE"
|
123
|
-
"STOPPED"
|
124
|
-
"SUSPENDED"
|
125
|
-
"DONE"
|
126
|
-
"FAILED"
|
127
|
-
"POWEROFF"
|
128
|
-
"UNDEPLOYED"=> "unde"
|
121
|
+
"INIT" => "init",
|
122
|
+
"PENDING" => "pend",
|
123
|
+
"HOLD" => "hold",
|
124
|
+
"ACTIVE" => "actv",
|
125
|
+
"STOPPED" => "stop",
|
126
|
+
"SUSPENDED" => "susp",
|
127
|
+
"DONE" => "done",
|
128
|
+
"FAILED" => "fail",
|
129
|
+
"POWEROFF" => "poff",
|
130
|
+
"UNDEPLOYED" => "unde",
|
131
|
+
"CLONING" => "clon",
|
132
|
+
"CLONING_FAILURE" => "fail"
|
129
133
|
}
|
130
134
|
|
131
135
|
SHORT_LCM_STATES={
|
@@ -186,8 +190,9 @@ module OpenNebula
|
|
186
190
|
"DISK_SNAPSHOT_REVERT_SUSPENDED"=> "snap",
|
187
191
|
"DISK_SNAPSHOT_DELETE_SUSPENDED"=> "snap",
|
188
192
|
"DISK_SNAPSHOT" => "snap",
|
189
|
-
"
|
190
|
-
"
|
193
|
+
"DISK_SNAPSHOT_DELETE" => "snap",
|
194
|
+
"PROLOG_MIGRATE_UNKNOWN" => "migr",
|
195
|
+
"PROLOG_MIGRATE_UNKNOWN_FAILURE" => "fail"
|
191
196
|
}
|
192
197
|
|
193
198
|
MIGRATE_REASON=%w{NONE ERROR USER}
|
@@ -202,7 +207,7 @@ module OpenNebula
|
|
202
207
|
undeploy undeploy-hard hold release stop suspend resume boot delete
|
203
208
|
delete-recreate reboot reboot-hard resched unresched poweroff
|
204
209
|
poweroff-hard disk-attach disk-detach nic-attach nic-detach
|
205
|
-
snap-create snap-delete}
|
210
|
+
snap-create snap-delete terminate terminate-hard}
|
206
211
|
|
207
212
|
EXTERNAL_IP_ATTRS = [
|
208
213
|
'GUEST_IP',
|
@@ -316,6 +321,19 @@ module OpenNebula
|
|
316
321
|
def deploy(host_id, enforce=false, ds_id=-1)
|
317
322
|
enforce ||= false
|
318
323
|
ds_id ||= -1
|
324
|
+
|
325
|
+
self.info
|
326
|
+
|
327
|
+
# Add dsid as VM template parameter for vcenter
|
328
|
+
if ds_id!=-1 &&
|
329
|
+
!self["/VM/USER_TEMPLATE/PUBLIC_CLOUD/TYPE"].nil? &&
|
330
|
+
self["/VM/USER_TEMPLATE/PUBLIC_CLOUD/TYPE"].downcase == "vcenter"
|
331
|
+
ds = OpenNebula::Datastore.new_with_id(ds_id, @client)
|
332
|
+
rc = ds.info
|
333
|
+
return rc if OpenNebula.is_error?(rc)
|
334
|
+
self.update("VCENTER_DATASTORE=#{ds['/DATASTORE/NAME']}", true)
|
335
|
+
end
|
336
|
+
|
319
337
|
return call(VM_METHODS[:deploy],
|
320
338
|
@pe_id,
|
321
339
|
host_id.to_i,
|
@@ -324,10 +342,12 @@ module OpenNebula
|
|
324
342
|
end
|
325
343
|
|
326
344
|
# Shutdowns an already deployed VM
|
327
|
-
def
|
328
|
-
action(hard ? '
|
345
|
+
def terminate(hard=false)
|
346
|
+
action(hard ? 'terminate-hard' : 'terminate')
|
329
347
|
end
|
330
348
|
|
349
|
+
alias_method :shutdown, :terminate
|
350
|
+
|
331
351
|
# Shuts down an already deployed VM, saving its state in the system DS
|
332
352
|
def undeploy(hard=false)
|
333
353
|
action(hard ? 'undeploy-hard' : 'undeploy')
|
@@ -343,16 +363,6 @@ module OpenNebula
|
|
343
363
|
action(hard ? 'reboot-hard' : 'reboot')
|
344
364
|
end
|
345
365
|
|
346
|
-
# @deprecated use {#reboot}
|
347
|
-
def reset
|
348
|
-
reboot(true)
|
349
|
-
end
|
350
|
-
|
351
|
-
# @deprecated use {#shutdown}
|
352
|
-
def cancel
|
353
|
-
shutdown(true)
|
354
|
-
end
|
355
|
-
|
356
366
|
# Sets a VM to hold state, scheduler will not deploy it
|
357
367
|
def hold
|
358
368
|
action('hold')
|
@@ -418,25 +428,6 @@ module OpenNebula
|
|
418
428
|
return call(VM_METHODS[:detachnic], @pe_id, nic_id)
|
419
429
|
end
|
420
430
|
|
421
|
-
# Deletes a VM from the pool
|
422
|
-
def delete(recreate=false)
|
423
|
-
if recreate
|
424
|
-
action('delete-recreate')
|
425
|
-
else
|
426
|
-
action('delete')
|
427
|
-
end
|
428
|
-
end
|
429
|
-
|
430
|
-
# @deprecated use {#delete} instead
|
431
|
-
def finalize(recreate=false)
|
432
|
-
delete(recreate)
|
433
|
-
end
|
434
|
-
|
435
|
-
# @deprecated use {#delete} instead
|
436
|
-
def resubmit
|
437
|
-
action('delete-recreate')
|
438
|
-
end
|
439
|
-
|
440
431
|
# Sets the re-scheduling flag for the VM
|
441
432
|
def resched
|
442
433
|
action('resched')
|
@@ -647,8 +638,8 @@ module OpenNebula
|
|
647
638
|
|
648
639
|
# Recovers an ACTIVE VM
|
649
640
|
#
|
650
|
-
# @param result [Integer] Recover with failure (0), success (1)
|
651
|
-
# retry (2)
|
641
|
+
# @param result [Integer] Recover with failure (0), success (1),
|
642
|
+
# retry (2), delete (3), delete-recreate (4)
|
652
643
|
# @param result [info] Additional information needed to recover the VM
|
653
644
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
654
645
|
# otherwise
|
@@ -656,6 +647,29 @@ module OpenNebula
|
|
656
647
|
return call(VM_METHODS[:recover], @pe_id, result)
|
657
648
|
end
|
658
649
|
|
650
|
+
# Deletes a VM from the pool
|
651
|
+
def delete(recreate=false)
|
652
|
+
if recreate
|
653
|
+
recover(4)
|
654
|
+
else
|
655
|
+
recover(3)
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
# Changes the attributes of a VM in power off, failure and undeploy
|
660
|
+
# states
|
661
|
+
# @param new_conf, string describing the new attributes. Each attribute
|
662
|
+
# will replace the existing ones or delete it if empty. Attributes that
|
663
|
+
# can be updated are: INPUT/{TYPE, BUS}; RAW/{TYPE, DATA, DATA_VMX},
|
664
|
+
# OS/{BOOT, BOOTLOADER, ARCH, MACHINE, KERNEL, INITRD},
|
665
|
+
# FEATURES/{ACPI, APIC, PAE, LOCALTIME, HYPERV, GUEST_AGENT},
|
666
|
+
# and GRAPHICS/{TYPE, LISTEN, PASSWD, KEYMAP}
|
667
|
+
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
668
|
+
# otherwise
|
669
|
+
def updateconf(new_conf)
|
670
|
+
return call(VM_METHODS[:updateconf], @pe_id, new_conf)
|
671
|
+
end
|
672
|
+
|
659
673
|
########################################################################
|
660
674
|
# Helpers to get VirtualMachine information
|
661
675
|
########################################################################
|
@@ -708,6 +722,7 @@ module OpenNebula
|
|
708
722
|
self['USER_TEMPLATE/KEEP_DISKS_ON_DONE'].downcase=="yes"
|
709
723
|
end
|
710
724
|
|
725
|
+
|
711
726
|
# Clones the VM's source Template, replacing the disks with live snapshots
|
712
727
|
# of the current disks. The VM capacity and NICs are also preserved
|
713
728
|
#
|