Statistics
| Branch: | Tag: | Revision:

one / src / vmm_mad / remotes / ec2 / shutdown @ 8cd7d0df

History | View | Annotate | Download (1.86 KB)

1
#!/usr/bin/env ruby
2

    
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2017, OpenNebula Project, OpenNebula Systems                #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
# -------------------------------------------------------------------------- #
18

    
19
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
20

    
21
if !ONE_LOCATION
22
    RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
23
else
24
    RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
25
end
26

    
27
$: << RUBY_LIB_LOCATION
28
$: << File.dirname(__FILE__)
29

    
30
require 'ec2_driver'
31
require 'opennebula'
32

    
33
deploy_id = ARGV[0]
34
host      = ARGV[1]
35
vm_id     = ARGV[2]
36

    
37
begin
38
    vm = OpenNebula::VirtualMachine.new_with_id(vm_id, OpenNebula::Client.new)
39
    vm.info
40

    
41
    lcm_state = vm.lcm_state_str
42

    
43
    ec2_drv = EC2Driver.new(host)
44

    
45
    ec2_drv.shutdown(deploy_id, lcm_state)
46
rescue Exception => e
47
    handle_exception("Save", e, host, deploy_id, vm_id)
48
end
49

    
50