Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (1.95 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
dfile = ARGV[0]
34
host  = ARGV[1]
35
id    = ARGV[2]
36

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

    
41
    lcm_state = vm.lcm_state_str
42
    deploy_id = vm.deploy_id
43

    
44
    ec2_drv = EC2Driver.new(host)
45

    
46
    text=File.read(dfile)
47

    
48
    puts ec2_drv.deploy(id, host, text, lcm_state, deploy_id)
49

    
50
rescue Exception => e
51
    handle_exception("Deploy", e, host, deploy_id, id, dfile)
52
end