occi 2.0.1 → 2.0.2

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.
@@ -1,131 +0,0 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain 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
- # Description: OpenNebula Backend
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
22
- require 'rubygems'
23
-
24
- require 'occi/backend/opennebula/opennebula'
25
- require 'occi/backend/ec2/ec2'
26
- require 'occi/backend/dummy'
27
-
28
- #require 'uuidtools'
29
- #require 'OpenNebula/OpenNebula'
30
- #require 'occi/CategoryRegistry'
31
- #require 'occi/rendering/http/LocationRegistry'
32
-
33
- # OpenNebula backend
34
- #require 'occi/backend/opennebula/Compute'
35
- #require 'occi/backend/opennebula/Network'
36
- #require 'occi/backend/opennebula/Storage'
37
-
38
- # OpenNebula backend based mixins
39
- #require 'occi/extensions/one/Image'
40
- #require 'occi/extensions/one/Network'
41
- #require 'occi/extensions/one/VirtualMachine'
42
- #require 'occi/extensions/one/VNC'
43
-
44
- #require 'occi/extensions/Reservation'
45
-
46
- #include OpenNebula
47
-
48
- module OCCI
49
- module Backend
50
-
51
- # ---------------------------------------------------------------------------------------------------------------------
52
- RESOURCE_DEPLOY = :deploy
53
- RESOURCE_UPDATE_STATE = :update_state
54
- RESOURCE_DELETE = :delete
55
-
56
- # ---------------------------------------------------------------------------------------------------------------------
57
- class Manager
58
-
59
- # ---------------------------------------------------------------------------------------------------------------------
60
- private
61
- # ---------------------------------------------------------------------------------------------------------------------
62
-
63
- @@backends_classes = {}
64
- @@backends_operations = {}
65
-
66
- # ---------------------------------------------------------------------------------------------------------------------
67
- public
68
- # ---------------------------------------------------------------------------------------------------------------------
69
-
70
- # ---------------------------------------------------------------------------------------------------------------------
71
- def self.register_backend(backend_class, operations)
72
-
73
- # Get ident of backend = class name downcased
74
- # backend_ident = Object.const_get(backend_class).name.downcase
75
-
76
- backend_ident = backend_class.name.downcase
77
-
78
- @@backends_classes[backend_ident] = backend_class
79
- @@backends_operations[backend_ident] = operations
80
- end
81
-
82
- # ---------------------------------------------------------------------------------------------------------------------
83
- def self.signal_resource(backend, operation, resource, operation_parameters = nil)
84
-
85
- resource_type = resource.kind
86
- backend_ident = backend.class.name.downcase
87
-
88
- raise OCCI::BackendError, "Unknown backend: '#{backend_ident}'" unless @@backends_classes.has_key?(backend_ident)
89
-
90
- operations = @@backends_operations[backend_ident]
91
-
92
- raise OCCI::BackendError, "Resource type '#{resource_type}' not supported!" unless operations.has_key?(resource_type)
93
- raise OCCI::BackendError, "Operation '#{operation}' not supported on resource category '#{resource_type}'!" unless operations[resource_type].has_key?(operation.to_sym)
94
-
95
- # Delegate
96
-
97
- if operations[resource_type][operation.to_sym].nil?
98
- OCCI::Log.debug("No backend method configured => doing nothing...")
99
- return
100
- end
101
-
102
- if operation_parameters.nil?
103
- # Generic resource operation
104
- backend.send(operations[resource_type][operation.to_sym], resource)
105
- else
106
- # Action related operation, we need to pass on the action parameters
107
- backend.send(operations[resource_type][operation.to_sym], resource, operation_parameters)
108
- end
109
-
110
- end
111
-
112
- # ---------------------------------------------------------------------------------------------------------------------
113
- def self.delegate_action(backend, action, parameters, resource)
114
-
115
- OCCI::Log.debug("Delegating invocation of action [#{action}] on resource [#{resource}] with parameters [#{parameters}] to backend...")
116
-
117
- # Use action term as ident
118
- operation = action.term
119
-
120
- begin
121
- # TODO: define some convention for result handling!
122
- signal_resource(backend, operation, resource, parameters)
123
-
124
- rescue OCCI::BackendError
125
- OCCI::Log.error("Action invocation failed!")
126
- raise
127
- end
128
- end
129
- end
130
- end
131
- end
@@ -1,360 +0,0 @@
1
- ##############################################################################
2
- # Copyright 2011 Service Computing group, TU Dortmund
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain 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
- # Description: OpenNebula Backend
19
- # Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
20
- ##############################################################################
21
-
22
- require 'occi/log'
23
- require 'erubis'
24
-
25
- module OCCI
26
- module Backend
27
- module OpenNebula
28
-
29
- # ---------------------------------------------------------------------------------------------------------------------
30
- module Compute
31
-
32
- TEMPLATECOMPUTERAWFILE = 'compute.erb'
33
-
34
- # ---------------------------------------------------------------------------------------------------------------------
35
- # private
36
- # ---------------------------------------------------------------------------------------------------------------------
37
-
38
- # ---------------------------------------------------------------------------------------------------------------------
39
- # PARSE OPENNEBULA COMPUTE OBJECT
40
- def compute_parse_backend_object(backend_object)
41
-
42
- # get information on compute object from OpenNebula backend
43
- backend_object.info
44
-
45
- compute_kind = OCCI::Registry.get_by_id("http://schemas.ogf.org/occi/infrastructure#compute")
46
-
47
- compute = Hashie::Mash.new
48
-
49
- compute.kind = compute_kind.type_identifier
50
- compute.mixins = %w|http://opennebula.org/occi/infrastructure#compute|
51
- compute.id = self.generate_occi_id(compute_kind, backend_object.id.to_s)
52
- compute.title = backend_object['NAME']
53
- compute.summary = backend_object['TEMPLATE/DESCRIPTION'] if backend_object['TEMPLATE/DESCRIPTION']
54
-
55
- compute.attributes!.occi!.compute!.cores = backend_object['TEMPLATE/VCPU'].to_i if backend_object['TEMPLATE/VCPU']
56
- compute.attributes!.occi!.compute!.architecture = "x64" if backend_object['TEMPLATE/ARCHITECTURE'] == "x86_64"
57
- compute.attributes!.occi!.compute!.architecture = "x86" if backend_object['TEMPLATE/ARCHITECTURE'] == "i686"
58
- compute.attributes!.occi!.compute!.memory = backend_object['TEMPLATE/MEMORY'].to_f/1000 if backend_object['TEMPLATE/MEMORY']
59
-
60
- compute.attributes!.org!.opennebula!.compute!.cpu = backend_object['TEMPLATE/CPU'].to_f if backend_object['TEMPLATE/CPU']
61
- compute.attributes!.org!.opennebula!.compute!.kernel = backend_object['TEMPLATE/KERNEL'] if backend_object['TEMPLATE/KERNEL']
62
- compute.attributes!.org!.opennebula!.compute!.initrd = backend_object['TEMPLATE/INITRD'] if backend_object['TEMPLATE/INITRD']
63
- compute.attributes!.org!.opennebula!.compute!.root = backend_object['TEMPLATE/ROOT'] if backend_object['TEMPLATE/ROOT']
64
- compute.attributes!.org!.opennebula!.compute!.kernel_cmd = backend_object['TEMPLATE/KERNEL_CMD'] if backend_object['TEMPLATE/KERNEL_CMD']
65
- compute.attributes!.org!.opennebula!.compute!.bootloader = backend_object['TEMPLATE/BOOTLOADER'] if backend_object['TEMPLATE/BOOTLOADER']
66
- compute.attributes!.org!.opennebula!.compute!.boot = backend_object['TEMPLATE/BOOT'] if backend_object['TEMPLATE/BOOT']
67
-
68
- compute = OCCI::Core::Resource.new(compute)
69
-
70
- compute_set_state(backend_object, compute)
71
-
72
- # TODO: refactor VNC handling
73
- #if backend_object['TEMPLATE/GRAPHICS/TYPE'] == 'vnc' \
74
- #and backend_object['HISTORY_RECORDS/HISTORY/HOSTNAME'] \
75
- #and not OCCI::Server.config[:novnc_path].nil? \
76
- #and not OCCI::Server.config[:vnc_proxy_base_port].nil?
77
- #
78
- # vnc_host = backend_object['HISTORY_RECORDS/HISTORY/HOSTNAME']
79
- # vnc_port = backend_object['TEMPLATE/GRAPHICS/PORT']
80
- #
81
- # vnc_proxy_host = URI.parse(OCCI::Server.location).host
82
- #
83
- # # The noVNC proxy_port
84
- # proxy_port = OCCI::Server.config[:vnc_proxy_base_port].to_i + vnc_port.to_i
85
- #
86
- # OCCI::Log.debug("NOVNC path: #{OCCI::Server.config[:novnc_path]}")
87
- # OCCI::Log.debug("Graphics type: #{backend_object['TEMPLATE/GRAPHICS/TYPE']}")
88
- # OCCI::Log.debug("VNC base port: #{OCCI::Server.config[:vnc_proxy_base_port]}")
89
- # OCCI::Log.debug("VNC port: #{vnc_port}")
90
- # OCCI::Log.debug("VNC host: #{vnc_host}")
91
- #
92
- # compute.mixins << OCCI::Registry.get_by_id("http://schemas.ogf.org/occi/infrastructure/compute#console")
93
- #
94
- # if occi_object.attributes['opennebula.vm.vnc'].nil? or occi_object.backend[:novnc_pipe].nil?
95
- #
96
- # # CREATE PROXY FOR VNC SERVER
97
- # begin
98
- # novnc_cmd = "#{OCCI::Server.config[:novnc_path]}/utils/websockify"
99
- # pipe = IO.popen("#{novnc_cmd} --web #{OCCI::Server.config[:novnc_path]} #{proxy_port} #{vnc_host}:#{vnc_port}")
100
- #
101
- # if pipe
102
- # vnc_url = OCCI::Server.config[:server].chomp('/') + ':' + vnc_port + '/vnc_auto.html?host=' + vnc_proxy_host + '&port=' + vnc_port
103
- # OCCI::Log.debug("VNC URL: #{vnc_url}")
104
- # occi_object.backend[:novnc_pipe] = pipe
105
- # occi_object.attributes['opennebula.vm.vnc'] = vnc_host + ':' + vnc_port
106
- # occi_object.attributes['opennebula.vm.web_vnc'] = vnc_url
107
- # end
108
- # rescue Exception => e
109
- # OCCI::Log.error("Error in creating VNC proxy: #{e.message}")
110
- # end
111
- # end
112
- # OCCI::Registry.get_by_id(kind).entities << compute
113
- #end
114
-
115
- compute_parse_links(compute, backend_object)
116
-
117
- # register compute resource in entities of compute kind
118
- compute_kind.entities << compute
119
- end
120
-
121
- # ---------------------------------------------------------------------------------------------------------------------
122
- # PARSE OPENNEBULA DEPENDENCIES TO E.G. STORAGE AND NETWORK LINKS
123
- def compute_parse_links(compute, backend_object)
124
- # create links for all storage instances
125
- backend_object.each('TEMPLATE/DISK') do |disk|
126
- OCCI::Log.debug("Storage Backend ID: #{disk['IMAGE_ID']}")
127
-
128
- link = OCCI::Core::Link.new
129
- storagelink_kind = OCCI::Registry.get_by_id('http://schemas.ogf.org/occi/infrastructure#storagelink')
130
- link.kind = storagelink_kind.type_identifier
131
- link.id = self.generate_occi_id(storagelink_kind, disk['IMAGE_ID'].to_s)
132
- storage_kind = OCCI::Registry.get_by_id('http://schemas.ogf.org/occi/infrastructure#storage')
133
- storage_id = self.generate_occi_id(storage_kind, disk['IMAGE_ID'].to_s)
134
- target = storage_kind.entities.select { |entity| entity.id == storage_id }.first
135
- if target.nil?
136
- one_storage = Image.new(Image.build_xml(disk['IMAGE_ID']), @one_client)
137
- self.storage_parse_backend_object(one_storage)
138
- target = storage_kind.entities.select { |entity| entity.id == storage_id }.first
139
- end
140
- link.target = target.location
141
- link.title = target.title
142
- link.summary = target.summary
143
- link.rel = storage_kind.type_identifier
144
- link.source = compute.location
145
- link.mixins << OCCI::Registry.get_by_id('http://opennebula.org/occi/infrastructure#storagelink')
146
- link.attributes!.occi!.storagelink!.deviceid = disk['TARGET'] if disk['TARGET']
147
- link.attributes!.org!.opennebula!.storagelink!.bus = disk['BUS'] if disk['BUS']
148
- link.attributes!.org!.opennebula!.storagelink!.driver = disk['DRIVER'] if disk['TARGET']
149
-
150
- # check link attributes against definition in kind and mixins
151
- link.check
152
-
153
- storagelink_kind.entities << link
154
- end
155
-
156
- #create links for all network instances
157
- backend_object.each('TEMPLATE/NIC') do |nic|
158
- OCCI::Log.debug("Network Backend ID: #{nic['NETWORK_ID']}")
159
-
160
- link = OCCI::Core::Link.new
161
- networkinterface_kind = OCCI::Registry.get_by_id('http://schemas.ogf.org/occi/infrastructure#networkinterface')
162
- link.kind = networkinterface_kind.type_identifier
163
- link.id = self.generate_occi_id(networkinterface_kind, nic['NETWORK_ID'].to_s)
164
- network_kind = OCCI::Registry.get_by_id('http://schemas.ogf.org/occi/infrastructure#network')
165
- network_id = self.generate_occi_id(network_kind, nic['NETWORK_ID'].to_s)
166
- target = network_kind.entitis.select { |entity| entity.id == network_id }.first
167
- if target.nil?
168
- one_network = VirtualNetwork.new(VirtualNetwork.build_xml(nic['NETWORK_ID']), @one_client)
169
- self.network_parse_backend_object(one_network)
170
- target = network_kind.entities.select { |entity| entity.id == network_id }.first
171
- end
172
- link.target = target.location
173
- link.title = target.title
174
- link.summary = target.summary
175
- link.rel = network_kind.type_identifier
176
- link.source = compute.location
177
- link.mixins << OCCI::Registry.get_by_id('http://schemas.ogf.org/occi/infrastructure/networkinterface#ipnetworkinterface')
178
- link.mixins << OCCI::Registry.get_by_id('http://opennebula.org/occi/infrastructure#networkinterface')
179
- link.attributes!.occi!.networkinterface!.address = nic['IP'] if nic['IP']
180
- link.attributes!.occi!.networkinterface!.mac = nic['MAC'] if nic['MAC']
181
- link.attributes!.occi!.networkinterface!.interface = nic['TARGET'] if nic['TARGET']
182
- link.attributes!.org!.opennebula!.networkinterface!.bridge = nic['BRIDGE'] if nic['BRIDGE']
183
- link.attributes!.org!.opennebula!.networkinterface!.script = nic['SCRIPT'] if nic['SCRIPT']
184
- link.attributes!.org!.opennebula!.networkinterface!.white_ports_tcp = nic['WHITE_PORTS_TCP'] if nic['WHITE_PORTS_TCP']
185
- link.attributes!.org!.opennebula!.networkinterface!.black_ports_tcp = nic['BLACK_PORTS_TCP'] if nic['BLACK_PORTS_TCP']
186
- link.attributes!.org!.opennebula!.networkinterface!.white_ports_udp = nic['WHITE_PORTS_UDP'] if nic['WHITE_PORTS_UDP']
187
- link.attributes!.org!.opennebula!.networkinterface!.black_ports_udp = nic['BLACK_PORTS_UDP'] if nic['BLACK_PORTS_UDP ']
188
- link.attributes!.org!.opennebula!.networkinterface!.icmp = nic['ICMP'] if nic['ICMP ']
189
-
190
- # check link attributes against definition in kind and mixins
191
- link.check
192
-
193
- networkinterface_kind.entities << link
194
- end
195
- end
196
-
197
- # ---------------------------------------------------------------------------------------------------------------------
198
- public
199
- # ---------------------------------------------------------------------------------------------------------------------
200
-
201
- # ---------------------------------------------------------------------------------------------------------------------
202
- def compute_deploy(compute)
203
- os_tpl = compute.mixins!.select { |mixin| mixin.related_to?("http://schemas.ogf.org/occi/infrastructure#os_tpl") }.first
204
-
205
- backend_object = nil
206
-
207
- templates = TemplatePool.new(@one_client, OpenNebula::INFO_ACL)
208
- templates.info
209
- template = templates.select { |template| template['NAME'] == os_tpl.title }.first
210
- if template
211
- template.info
212
- template['TEMPLATE/VCPU'] = compute.attributes.occi.compute.cores if compute.attributes!.occi!.compute!.cores
213
- template['TEMPLATE/MEMORY'] = (compute.attributes.occi.compute.memory.to_f * 1000).to_s if compute.attributes!.occi!.compute!.memory
214
- template['TEMPLATE/ARCHITECTURE'] = compute.attributes.occi.compute.architecture if compute.attributes!.occi!.compute!.architecture
215
- template['TEMPLATE/CPU'] = compute.attributes.occi.compute.speed if compute.attributes!.occi!.compute!.speed
216
- backend_object = template.instantiate
217
- check_rc(backend_object)
218
- else
219
- backend_object = VirtualMachine.new(VirtualMachine.build_xml, @one_client)
220
-
221
- template_location = OCCI::Server.config["TEMPLATE_LOCATION"] + TEMPLATECOMPUTERAWFILE
222
- template = Erubis::Eruby.new(File.read(template_location)).evaluate(:compute => compute)
223
-
224
- OCCI::Log.debug("Parsed template #{template}")
225
- rc = backend_object.allocate(template)
226
- check_rc(rc)
227
- OCCI::Log.debug("Return code from OpenNebula #{rc}") if rc != nil
228
- end
229
-
230
- backend_object.info
231
- compute.id = self.generate_occi_id(OCCI::Registry.get_by_id(compute.kind), backend_object['ID'].to_s)
232
-
233
- compute_set_state(backend_object, compute)
234
-
235
- OCCI::Log.debug("OpenNebula automatically triggers action start for Virtual Machines")
236
- OCCI::Log.debug("Changing state to started")
237
- end
238
-
239
- # ---------------------------------------------------------------------------------------------------------------------
240
- def compute_set_state(backend_object, compute)
241
- OCCI::Log.debug("current VM state is: #{backend_object.lcm_state_str}")
242
- compute.links ||= []
243
- case backend_object.lcm_state_str
244
- when "RUNNING" then
245
- compute.attributes!.occi!.compute!.state = "active"
246
- compute.links << OCCI::Core::Link.new(:target=>compute.location + '?action=stop',:rel=>'http://schemas.ogf.org/occi/infrastructure/compute/action#stop')
247
- compute.links << OCCI::Core::Link.new(:target=>compute.location + '?action=restart',:rel=>'http://schemas.ogf.org/occi/infrastructure/compute/action#restart')
248
- compute.links << OCCI::Core::Link.new(:target=>compute.location + '?action=suspend',:rel=>'http://schemas.ogf.org/occi/infrastructure/compute/action#suspend')
249
- when "PROLOG", "BOOT", "SAVE_STOP", "SAVE_SUSPEND", "SAVE_MIGRATE", "MIGRATE", "PROLOG_MIGRATE", "PROLOG_RESUME" then
250
- compute.attributes!.occi!.compute!.state = "inactive"
251
- compute.links << OCCI::Core::Link.new(:target=>compute.location + '?action=stop',:rel=>'http://schemas.ogf.org/occi/infrastructure/compute/action#stop')
252
- compute.links << OCCI::Core::Link.new(:target=>compute.location + '?action=restart',:rel=>'http://schemas.ogf.org/occi/infrastructure/compute/action#restart')
253
- when "SUSPENDED" then
254
- compute.attributes!.occi!.compute!.state = "suspended"
255
- compute.links << OCCI::Core::Link.new(:target=>compute.location + '?action=start',:rel=>'http://schemas.ogf.org/occi/infrastructure/compute/action#start')
256
- when "FAIL" then
257
- compute.attributes!.occi!.compute!.state = "error"
258
- compute.links << OCCI::Core::Link.new(:target=>compute.location + '?action=start',:rel=>'http://schemas.ogf.org/occi/infrastructure/compute/action#start')
259
- else
260
- compute.attributes!.occi!.compute!.state = "inactive"
261
- compute.links << OCCI::Core::Link.new(:target=>compute.location + '?action=start',:rel=>'http://schemas.ogf.org/occi/infrastructure/compute/action#start')
262
- end
263
- end
264
-
265
- # ---------------------------------------------------------------------------------------------------------------------
266
- def compute_delete(compute)
267
- backend_object=VirtualMachine.new(VirtualMachine.build_xml(compute.backend[:id]), @one_client)
268
-
269
- rc = backend_object.finalize
270
- check_rc(rc)
271
- # TODO: VNC
272
- #OCCI::Log.debug("killing NoVNC pipe with pid #{compute.backend[:novnc_pipe].pid}") unless compute.backend[:novnc_pipe].nil?
273
- #Process.kill 'INT', compute.backend[:novnc_pipe].pid unless compute.backend[:novnc_pipe].nil?
274
- end
275
-
276
- # ---------------------------------------------------------------------------------------------------------------------
277
- # GET ALL COMPUTE INSTANCES
278
- def compute_register_all_instances
279
- backend_object_pool = VirtualMachinePool.new(@one_client)
280
- backend_object_pool.info(OCCI::Backend::OpenNebula::OpenNebula::INFO_ACL, -1, -1, OpenNebula::VirtualMachinePool::INFO_NOT_DONE)
281
- compute_register_all_objects(backend_object_pool)
282
- end
283
-
284
- # ---------------------------------------------------------------------------------------------------------------------
285
- # GET ALL COMPUTE TEMPLATES
286
- def compute_register_all_templates
287
- backend_object_pool = TemplatePool.new(@one_client, INFO_ACL)
288
- backend_object_pool.info
289
- compute_register_all_objects(backend_object_pool, template = true)
290
- end
291
-
292
- # ---------------------------------------------------------------------------------------------------------------------
293
- # GET ALL COMPUTE OBJECTS
294
- def compute_register_all_objects(backend_object_pool, template = false)
295
- backend_object_pool.each { |backend_object| compute_parse_backend_object(backend_object) }
296
- end
297
-
298
- # ---------------------------------------------------------------------------------------------------------------------
299
- # COMPUTE ACTIONS
300
- # ---------------------------------------------------------------------------------------------------------------------
301
-
302
- # ---------------------------------------------------------------------------------------------------------------------
303
- def compute_action_dummy(compute, parameters)
304
- end
305
-
306
- # ---------------------------------------------------------------------------------------------------------------------
307
- # COMPUTE Action start
308
- def compute_start(compute, parameters)
309
- backend_object = VirtualMachine.new(VirtualMachine.build_xml(compute.backend[:id]), @one_client)
310
- rc = backend_object.resume
311
- check_rc(rc)
312
- end
313
-
314
- # ---------------------------------------------------------------------------------------------------------------------
315
- # Action stop
316
- def compute_stop(compute, parameters)
317
- backend_object = VirtualMachine.new(VirtualMachine.build_xml(compute.backend[:id]), @one_client)
318
- # TODO: implement parameters when available in OpenNebula
319
- case parameters
320
- when 'method="graceful"'
321
- OCCI::Log.debug("Trying to stop VM graceful")
322
- rc = backend_object.shutdown
323
- when 'method="acpioff"'
324
- OCCI::Log.debug("Trying to stop VM via ACPI off")
325
- rc = backend_object.shutdown
326
- else # method="poweroff" or no method specified
327
- OCCI::Log.debug("Powering off VM")
328
- rc = backend_object.shutdown
329
- end
330
- check_rc(rc)
331
- end
332
-
333
- # ---------------------------------------------------------------------------------------------------------------------
334
- # Action restart
335
- def compute_restart(compute, parameters)
336
- backend_object = VirtualMachine.new(VirtualMachine.build_xml(compute.backend[:id]), @one_client)
337
- # TODO: implement parameters when available in OpenNebula
338
- case parameters
339
- when "graceful"
340
- rc = vm.reboot
341
- when "warm"
342
- rc = vm.reboot
343
- else # "cold" or no parameter specified
344
- rc = vm.resubmit
345
- end
346
- check_rc(rc)
347
- end
348
-
349
- # ---------------------------------------------------------------------------------------------------------------------
350
- # Action suspend
351
- def compute_suspend(compute, parameters)
352
- backend_object = VirtualMachine.new(VirtualMachine.build_xml(compute.backend[:id]), @one_client)
353
- rc = vm.suspend
354
- check_rc(rc)
355
- end
356
-
357
- end
358
- end
359
- end
360
- end