Statistics
| Branch: | Tag: | Revision:

one / src / vmm_mad / remotes / vcenter / cancel @ 05ed37c9

History | View | Annotate | Download (1.95 KB)

1
#!/usr/bin/env ruby
2

    
3
# ---------------------------------------------------------------------------- #
4
# Copyright 2010-2015, C12G Labs S.L                                           #
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 'vcenter_driver'
31

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

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

    
39
lcm_state   = vm.lcm_state_str
40
keep_disks  = vm.keep_disks?
41

    
42
begin
43
    VCenterDriver::VCenterVm.cancel(deploy_id, host, lcm_state, keep_disks)
44
rescue Exception => e
45
    STDERR.puts "Cancel of VM #{deploy_id} on host #{host} failed " +
46
                "due to \"#{e.message}\""
47
    exit -1
48
end