mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
feature #2289: refactor ec2 drivers to standard form
This commit is contained in:
parent
93ffea79f9
commit
b4c05bd62b
54
install.sh
54
install.sh
@ -227,9 +227,7 @@ SHARE_DIRS="$SHARE_LOCATION/examples \
|
||||
$SHARE_LOCATION/tgt \
|
||||
$SHARE_LOCATION/websockify"
|
||||
|
||||
ETC_DIRS="$ETC_LOCATION/im_ec2 \
|
||||
$ETC_LOCATION/vmm_ec2 \
|
||||
$ETC_LOCATION/vmm_exec \
|
||||
ETC_DIRS="$ETC_LOCATION/vmm_exec \
|
||||
$ETC_LOCATION/hm \
|
||||
$ETC_LOCATION/auth \
|
||||
$ETC_LOCATION/auth/certificates \
|
||||
@ -266,11 +264,13 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/im/xen4.d \
|
||||
$VAR_LOCATION/remotes/im/vmware.d \
|
||||
$VAR_LOCATION/remotes/im/ganglia.d \
|
||||
$VAR_LOCATION/remotes/im/ec2.d \
|
||||
$VAR_LOCATION/remotes/vmm \
|
||||
$VAR_LOCATION/remotes/vmm/kvm \
|
||||
$VAR_LOCATION/remotes/vmm/xen3 \
|
||||
$VAR_LOCATION/remotes/vmm/xen4 \
|
||||
$VAR_LOCATION/remotes/vmm/vmware \
|
||||
$VAR_LOCATION/remotes/vmm/ec2 \
|
||||
$VAR_LOCATION/remotes/vnm \
|
||||
$VAR_LOCATION/remotes/vnm/802.1Q \
|
||||
$VAR_LOCATION/remotes/vnm/dummy \
|
||||
@ -451,6 +451,7 @@ INSTALL_FILES=(
|
||||
IM_PROBES_XEN4_FILES:$VAR_LOCATION/remotes/im/xen4.d
|
||||
IM_PROBES_VMWARE_FILES:$VAR_LOCATION/remotes/im/vmware.d
|
||||
IM_PROBES_GANGLIA_FILES:$VAR_LOCATION/remotes/im/ganglia.d
|
||||
IM_PROBES_EC2_FILES:$VAR_LOCATION/remotes/im/ec2.d
|
||||
AUTH_SSH_FILES:$VAR_LOCATION/remotes/auth/ssh
|
||||
AUTH_X509_FILES:$VAR_LOCATION/remotes/auth/x509
|
||||
AUTH_LDAP_FILES:$VAR_LOCATION/remotes/auth/ldap
|
||||
@ -462,6 +463,7 @@ INSTALL_FILES=(
|
||||
VMM_EXEC_XEN3_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen3
|
||||
VMM_EXEC_XEN4_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen4
|
||||
VMM_EXEC_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/vmm/vmware
|
||||
VMM_EXEC_EC2_SCRIPTS:$VAR_LOCATION/remotes/vmm/ec2
|
||||
TM_FILES:$VAR_LOCATION/remotes/tm
|
||||
TM_SHARED_FILES:$VAR_LOCATION/remotes/tm/shared
|
||||
TM_QCOW2_FILES:$VAR_LOCATION/remotes/tm/qcow2
|
||||
@ -656,9 +658,8 @@ INSTALL_ONEFLOW_ETC_FILES=(
|
||||
INSTALL_ETC_FILES=(
|
||||
ETC_FILES:$ETC_LOCATION
|
||||
VMWARE_ETC_FILES:$ETC_LOCATION
|
||||
VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2
|
||||
EC2_ETC_FILES:$ETC_LOCATION
|
||||
VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec
|
||||
IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2
|
||||
HM_ETC_FILES:$ETC_LOCATION/hm
|
||||
AUTH_ETC_FILES:$ETC_LOCATION/auth
|
||||
ECO_ETC_FILES:$ETC_LOCATION
|
||||
@ -744,16 +745,12 @@ MADS_LIB_FILES="src/mad/sh/madcommon.sh \
|
||||
src/vmm_mad/exec/one_vmm_exec \
|
||||
src/vmm_mad/exec/one_vmm_sh \
|
||||
src/vmm_mad/exec/one_vmm_ssh \
|
||||
src/vmm_mad/ec2/one_vmm_ec2.rb \
|
||||
src/vmm_mad/ec2/one_vmm_ec2 \
|
||||
src/vmm_mad/dummy/one_vmm_dummy.rb \
|
||||
src/vmm_mad/dummy/one_vmm_dummy \
|
||||
src/im_mad/im_exec/one_im_exec.rb \
|
||||
src/im_mad/im_exec/one_im_exec \
|
||||
src/im_mad/im_exec/one_im_ssh \
|
||||
src/im_mad/im_exec/one_im_sh \
|
||||
src/im_mad/ec2/one_im_ec2.rb \
|
||||
src/im_mad/ec2/one_im_ec2 \
|
||||
src/im_mad/dummy/one_im_dummy.rb \
|
||||
src/im_mad/dummy/one_im_dummy \
|
||||
src/tm_mad/one_tm \
|
||||
@ -855,6 +852,30 @@ VMM_EXEC_VMWARE_SCRIPTS="src/vmm_mad/remotes/vmware/cancel \
|
||||
src/vmm_mad/remotes/vmware/vmware_driver.rb \
|
||||
src/vmm_mad/remotes/vmware/vi_driver.rb"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VMM Driver EC2 scripts, to be installed under $REMOTES_LOCATION/vmm/ec2
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
VMM_EXEC_EC2_SCRIPTS="src/vmm_mad/remotes/ec2/cancel \
|
||||
src/vmm_mad/remotes/ec2/attach_disk \
|
||||
src/vmm_mad/remotes/ec2/detach_disk \
|
||||
src/vmm_mad/remotes/ec2/attach_nic \
|
||||
src/vmm_mad/remotes/ec2/detach_nic \
|
||||
src/vmm_mad/remotes/ec2/snapshot_create \
|
||||
src/vmm_mad/remotes/ec2/snapshot_revert \
|
||||
src/vmm_mad/remotes/ec2/snapshot_delete \
|
||||
src/vmm_mad/remotes/ec2/scripts_common_sh.sh \
|
||||
src/vmm_mad/remotes/ec2/deploy \
|
||||
src/vmm_mad/remotes/ec2/migrate \
|
||||
src/vmm_mad/remotes/ec2/restore \
|
||||
src/vmm_mad/remotes/ec2/reboot \
|
||||
src/vmm_mad/remotes/ec2/reset \
|
||||
src/vmm_mad/remotes/ec2/save \
|
||||
src/vmm_mad/remotes/ec2/poll \
|
||||
src/vmm_mad/remotes/ec2/checkpoint \
|
||||
src/vmm_mad/remotes/ec2/shutdown \
|
||||
src/vmm_mad/remotes/ec2/ec2_driver.rb"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Information Manager Probes, to be installed under $REMOTES_LOCATION/im
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -883,6 +904,9 @@ IM_PROBES_VMWARE_FILES="src/im_mad/remotes/vmware.d/vmware.rb"
|
||||
|
||||
IM_PROBES_GANGLIA_FILES="src/im_mad/remotes/ganglia.d/ganglia_probe"
|
||||
|
||||
IM_PROBES_EC2_FILES="src/im_mad/remotes/ec2.d/monitor \
|
||||
src/im_mad/remotes/ec2.d/poll"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Auth Manager drivers to be installed under $REMOTES_LOCATION/auth
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -1146,15 +1170,13 @@ ETC_FILES="share/etc/oned.conf \
|
||||
src/cli/etc/group.default"
|
||||
|
||||
VMWARE_ETC_FILES="src/vmm_mad/remotes/vmware/vmwarerc"
|
||||
EC2_ETC_FILES="src/vmm_mad/remotes/ec2/ec2rc"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Virtualization drivers config. files, to be installed under $ETC_LOCATION
|
||||
# - ec2, $ETC_LOCATION/vmm_ec2
|
||||
# - ssh, $ETC_LOCATION/vmm_exec
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
VMM_EC2_ETC_FILES="src/vmm_mad/ec2/vmm_ec2rc \
|
||||
src/vmm_mad/ec2/vmm_ec2.conf"
|
||||
|
||||
VMM_EXEC_ETC_FILES="src/vmm_mad/exec/vmm_execrc \
|
||||
src/vmm_mad/exec/vmm_exec_kvm.conf \
|
||||
@ -1162,14 +1184,6 @@ VMM_EXEC_ETC_FILES="src/vmm_mad/exec/vmm_execrc \
|
||||
src/vmm_mad/exec/vmm_exec_xen4.conf \
|
||||
src/vmm_mad/exec/vmm_exec_vmware.conf"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Information drivers config. files, to be installed under $ETC_LOCATION
|
||||
# - ec2, $ETC_LOCATION/im_ec2
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
IM_EC2_ETC_FILES="src/im_mad/ec2/im_ec2rc \
|
||||
src/im_mad/ec2/im_ec2.conf"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Hook Manager driver config. files, to be installed under $ETC_LOCATION/hm
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -1,7 +0,0 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
# Max number of instances that can be launched into EC2
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
SMALL_INSTANCES=5
|
||||
LARGE_INSTANCES=
|
||||
EXTRALARGE_INSTANCES=
|
@ -1,89 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
||||
MAD_LOCATION="/usr/lib/one/mads"
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
||||
MAD_LOCATION=ONE_LOCATION+"/lib/mads"
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
require 'pp'
|
||||
require 'OpenNebulaDriver'
|
||||
require 'base64'
|
||||
|
||||
# The EC2 Information Manager Driver
|
||||
class EC2InformationManagerDriver < OpenNebulaDriver
|
||||
# Init the driver, and compute the predefined maximum capacity for this
|
||||
# EC2 cloud
|
||||
def initialize()
|
||||
super('',
|
||||
:concurrency => 1,
|
||||
:threaded => false
|
||||
)
|
||||
|
||||
register_action(:MONITOR, method("action_monitor"))
|
||||
|
||||
sinst = ENV["SMALL_INSTANCES"].to_i
|
||||
linst = ENV["LARGE_INSTANCES"].to_i
|
||||
xlinst = ENV["EXTRALARGE_INSTANCES"].to_i
|
||||
|
||||
smem = 1048576 * 1.7 * sinst
|
||||
scpu = 100 * sinst
|
||||
|
||||
lmem = 1048576 * 7.5 * linst
|
||||
lcpu = 400 * linst
|
||||
|
||||
xlmem = 1048576 * 15 * xlinst
|
||||
xlcpu = 800 * xlinst
|
||||
|
||||
totalmemory = smem + lmem + xlmem
|
||||
totalcpu = scpu + lcpu + xlcpu
|
||||
|
||||
@info="HYPERVISOR=ec2\nTOTALMEMORY=#{totalmemory}\n"<<
|
||||
"TOTALCPU=#{totalcpu}\nCPUSPEED=1000\nFREEMEMORY=#{totalmemory}"<<
|
||||
"\nFREECPU=#{totalcpu}\n"
|
||||
end
|
||||
|
||||
# The monitor action, just print the capacity info and hostname
|
||||
def action_monitor(num, host, not_used)
|
||||
info = "HOSTNAME=\"#{host}\"\n#{@info}"
|
||||
info << get_vm_info
|
||||
info64 = Base64::encode64(info).strip.delete("\n")
|
||||
send_message("MONITOR", RESULT[:success], num, info64)
|
||||
end
|
||||
|
||||
def get_vm_info
|
||||
exe=LocalCommand.run(MAD_LOCATION+'/one_vmm_ec2 --poll')
|
||||
|
||||
if exe.code==0
|
||||
exe.stdout
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# The EC2 Information Driver main program
|
||||
im = EC2InformationManagerDriver.new
|
||||
im.start_driver
|
63
src/im_mad/remotes/ec2.d/monitor
Executable file
63
src/im_mad/remotes/ec2.d/monitor
Executable file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
||||
MAD_LOCATION="/usr/lib/one/mads"
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
||||
MAD_LOCATION=ONE_LOCATION+"/lib/mads"
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
$: << File.join(File.dirname(__FILE__), '../../vmm/ec2')
|
||||
|
||||
require 'pp'
|
||||
require 'OpenNebulaDriver'
|
||||
require 'ec2_driver'
|
||||
|
||||
host = ARGV[2]
|
||||
|
||||
def monitor(host)
|
||||
sinst = ENV["SMALL_INSTANCES"].to_i
|
||||
linst = ENV["LARGE_INSTANCES"].to_i
|
||||
xlinst = ENV["EXTRALARGE_INSTANCES"].to_i
|
||||
|
||||
smem = 1048576 * 1.7 * sinst
|
||||
scpu = 100 * sinst
|
||||
|
||||
lmem = 1048576 * 7.5 * linst
|
||||
lcpu = 400 * linst
|
||||
|
||||
xlmem = 1048576 * 15 * xlinst
|
||||
xlcpu = 800 * xlinst
|
||||
|
||||
totalmemory = smem + lmem + xlmem
|
||||
totalcpu = scpu + lcpu + xlcpu
|
||||
|
||||
info="HYPERVISOR=ec2\nTOTALMEMORY=#{totalmemory}\n"<<
|
||||
"TOTALCPU=#{totalcpu}\nCPUSPEED=1000\nFREEMEMORY=#{totalmemory}"<<
|
||||
"\nFREECPU=#{totalcpu}\n"
|
||||
info << "HOSTNAME=\"#{host}\"\n"
|
||||
|
||||
puts info
|
||||
end
|
||||
|
||||
monitor(host)
|
15
src/im_mad/ec2/im_ec2rc → src/im_mad/remotes/ec2.d/poll
Normal file → Executable file
15
src/im_mad/ec2/im_ec2rc → src/im_mad/remotes/ec2.d/poll
Normal file → Executable file
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# Copyright 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
@ -12,4 +14,13 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.join(File.dirname(__FILE__), '../../vmm/ec2')
|
||||
|
||||
require 'ec2_driver'
|
||||
|
||||
ec2_drv = EC2Driver.new
|
||||
|
||||
ec2_drv.monitor_all_vms
|
||||
|
38
src/vmm_mad/ec2/vmm_ec2.conf → src/vmm_mad/remotes/ec2/cancel
Normal file → Executable file
38
src/vmm_mad/ec2/vmm_ec2.conf → src/vmm_mad/remotes/ec2/cancel
Normal file → Executable file
@ -1,6 +1,7 @@
|
||||
<!--
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# Copyright 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
@ -13,27 +14,16 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
-->
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
<!--
|
||||
Default configuration attributes for the EC2 driver
|
||||
(all domains will use these values as defaults)
|
||||
Valid atributes are:
|
||||
- ec2[keypair,authorizedports,instancetype]
|
||||
Use XML syntax to specify defaults, note elements are UPCASE
|
||||
Example:
|
||||
<TEMPLATE>
|
||||
<EC2>
|
||||
<KEYPAIR>gsg-keypair</KEYPAIR>
|
||||
<AUTHORIZEDPORTS>22</AUTHORIZEDPORTS>
|
||||
<INSTANCETYPE>m1.small</INSTANCETYPE>
|
||||
</EC2>
|
||||
</TEMPLATE>
|
||||
-->
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'ec2_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
ec2_drv = EC2Driver.new
|
||||
|
||||
ec2_drv.cancel(deploy_id)
|
||||
|
||||
<TEMPLATE>
|
||||
<EC2>
|
||||
<INSTANCETYPE>m1.small</INSTANCETYPE>
|
||||
</EC2>
|
||||
</TEMPLATE>
|
34
src/vmm_mad/remotes/ec2/deploy
Executable file
34
src/vmm_mad/remotes/ec2/deploy
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'ec2_driver'
|
||||
|
||||
dfile = ARGV[0]
|
||||
host = ARGV[1]
|
||||
id = ARGV[2]
|
||||
|
||||
ec2_drv = EC2Driver.new(host)
|
||||
|
||||
text=File.read(dfile)
|
||||
|
||||
puts ec2_drv.deploy(id, host, text)
|
||||
|
||||
exit 0
|
||||
|
@ -1,30 +1,19 @@
|
||||
#!/usr/bin/env ruby
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# Set up the environment for the driver
|
||||
|
||||
EC2_LOCATION = ENV["EC2_HOME"]
|
||||
|
||||
if !EC2_LOCATION
|
||||
puts "EC2_HOME not set"
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
EC2_JVM_CONCURRENCY = ENV["EC2_JVM_CONCURRENCY"]
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION = ENV["ONE_LOCATION"]
|
||||
|
||||
@ -36,15 +25,37 @@ else
|
||||
ETC_LOCATION = ONE_LOCATION + "/etc/"
|
||||
end
|
||||
|
||||
# Load EC2 credentials and environment
|
||||
require 'yaml'
|
||||
|
||||
ec2_env = "#{ETC_LOCATION}/ec2rc"
|
||||
if File.exist?(ec2_env)
|
||||
env = YAML::load(File.read(ec2_env))
|
||||
env.each do |key, value|
|
||||
ENV[key] = value.to_s
|
||||
end
|
||||
end
|
||||
|
||||
# Set up the environment for the driver
|
||||
EC2_LOCATION = ENV["EC2_HOME"]
|
||||
|
||||
if !EC2_LOCATION
|
||||
STDERR.puts "EC2_HOME not set"
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
require "VirtualMachineDriver"
|
||||
require "CommandManager"
|
||||
require 'CommandManager'
|
||||
require 'scripts_common'
|
||||
require "rexml/document"
|
||||
require 'rexml/document'
|
||||
require 'VirtualMachineDriver'
|
||||
|
||||
# The main class for the EC2 driver
|
||||
class EC2Driver < VirtualMachineDriver
|
||||
class EC2Driver
|
||||
ACTION = VirtualMachineDriver::ACTION
|
||||
POLL_ATTRIBUTE = VirtualMachineDriver::POLL_ATTRIBUTE
|
||||
VM_STATE = VirtualMachineDriver::VM_STATE
|
||||
|
||||
# EC2 commands constants
|
||||
EC2 = {
|
||||
@ -151,16 +162,12 @@ class EC2Driver < VirtualMachineDriver
|
||||
|
||||
# EC2 constructor, loads defaults for the EC2Driver
|
||||
def initialize(ec2_conf = nil)
|
||||
if !EC2_JVM_CONCURRENCY
|
||||
concurrency = 5
|
||||
else
|
||||
concurrency = EC2_JVM_CONCURRENCY.to_i
|
||||
end
|
||||
|
||||
super('', :concurrency => concurrency, :threaded => true)
|
||||
|
||||
@defaults = Hash.new
|
||||
|
||||
if !ec2_conf && ENV['EC2_CONF']
|
||||
ec2_conf = ENV['EC2_CONF']
|
||||
end
|
||||
|
||||
if ec2_conf && File.exists?(ec2_conf)
|
||||
fd = File.new(ec2_conf)
|
||||
xml = REXML::Document.new fd
|
||||
@ -183,93 +190,153 @@ class EC2Driver < VirtualMachineDriver
|
||||
end
|
||||
|
||||
# DEPLOY action, also sets ports and ip if needed
|
||||
def deploy(id, drv_message)
|
||||
ec2_info = get_deployment_info(drv_message)
|
||||
def deploy(id, host, xml_text)
|
||||
ec2_info = get_deployment_info(host, xml_text)
|
||||
return unless ec2_info
|
||||
|
||||
if !ec2_value(ec2_info, 'AMI')
|
||||
msg = "Cannot find AMI in deployment file"
|
||||
send_message(ACTION[:deploy], RESULT[:failure], id, msg)
|
||||
return
|
||||
STDERR.puts(msg)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
deploy_exe = exec_and_log_ec2(:run, ec2_info, "", id)
|
||||
deploy_exe = exec_and_log_ec2(:run, ec2_info, "")
|
||||
if deploy_exe.code != 0
|
||||
msg = deploy_exe.stderr
|
||||
send_message(ACTION[:deploy], RESULT[:failure], id, msg)
|
||||
return
|
||||
STDERR.puts(msg)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
if !deploy_exe.stdout.match(/^INSTANCE\s*(.+?)\s/)
|
||||
msg = "Could not find instance id. Check ec2-describe-instances"
|
||||
send_message(ACTION[:deploy], RESULT[:failure], id, msg)
|
||||
return
|
||||
STDERR.puts(msg)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
deploy_id = $1
|
||||
|
||||
if ec2_value(ec2_info, 'AUTHORIZEDPORTS')
|
||||
exec_and_log_ec2(:authorize, ec2_info, 'default', id)
|
||||
exec_and_log_ec2(:authorize, ec2_info, 'default')
|
||||
end
|
||||
|
||||
LocalCommand.run(
|
||||
"#{EC2_LOCATION}/bin/ec2-create-tags #{deploy_id} -t ONE_ID=#{id}",
|
||||
log_method(id))
|
||||
lambda {|str| STDERR.puts(str) })
|
||||
|
||||
if ec2_value(ec2_info, 'TAGS')
|
||||
exec_and_log_ec2(:tags, ec2_info, deploy_id, id)
|
||||
exec_and_log_ec2(:tags, ec2_info, deploy_id)
|
||||
end
|
||||
|
||||
if ec2_value(ec2_info, 'ELASTICIP')
|
||||
exec_and_log_ec2(:associate, ec2_info, "-i #{deploy_id}", id)
|
||||
exec_and_log_ec2(:associate, ec2_info, "-i #{deploy_id}")
|
||||
end
|
||||
|
||||
send_message(ACTION[:deploy], RESULT[:success], id, deploy_id)
|
||||
puts(deploy_id)
|
||||
end
|
||||
|
||||
# Shutdown a EC2 instance
|
||||
def shutdown(id, drv_message)
|
||||
ec2_action(drv_message, :terminate, ACTION[:shutdown], id)
|
||||
def shutdown(deploy_id)
|
||||
ec2_action(deploy_id, :terminate, ACTION[:shutdown])
|
||||
end
|
||||
|
||||
# Reboot a EC2 instance
|
||||
def reboot(id, drv_message)
|
||||
ec2_action(drv_message, :reboot, ACTION[:reboot], id)
|
||||
def reboot(deploy_id)
|
||||
ec2_action(deploy_id, :reboot, ACTION[:reboot])
|
||||
end
|
||||
|
||||
# Cancel a EC2 instance
|
||||
def cancel(id, drv_message)
|
||||
ec2_action(drv_message, :terminate, ACTION[:cancel], id)
|
||||
def cancel(deploy_id)
|
||||
ec2_action(deploy_id, :terminate, ACTION[:cancel])
|
||||
end
|
||||
|
||||
# Stop a EC2 instance
|
||||
def save(id, drv_message)
|
||||
ec2_action(drv_message, :stop, ACTION[:save], id)
|
||||
def save(deploy_id)
|
||||
ec2_action(deploy_id, :stop, ACTION[:save])
|
||||
end
|
||||
|
||||
# Cancel a EC2 instance
|
||||
def restore(id, drv_message)
|
||||
ec2_action(drv_message, :start, ACTION[:restor], id)
|
||||
def restore(deploy_id)
|
||||
ec2_action(deploy_id, :start, ACTION[:restore])
|
||||
end
|
||||
|
||||
# Get info (IP, and state) for a EC2 instance
|
||||
def poll(id, drv_message)
|
||||
msg = decode(drv_message)
|
||||
|
||||
deploy_id = msg.elements["DEPLOY_ID"].text
|
||||
|
||||
exe = exec_and_log_ec2(:describe, nil, deploy_id, id)
|
||||
def poll(id, deploy_id)
|
||||
exe = exec_and_log_ec2(:describe, nil, deploy_id)
|
||||
if exe.code != 0
|
||||
send_message(ACTION[:poll], RESULT[:failure], id, exe.stderr)
|
||||
return
|
||||
STDERR.puts(exe.stderr)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
info = EC2Driver.parse_poll(exe.stdout, deploy_id)
|
||||
|
||||
send_message(ACTION[:poll], RESULT[:success], id, info)
|
||||
info = parse_poll(exe.stdout, deploy_id)
|
||||
puts info
|
||||
end
|
||||
|
||||
def self.parse_poll(text, deploy_id)
|
||||
def monitor_all_vms
|
||||
exe = LocalCommand.run(
|
||||
"#{EC2_LOCATION}/bin/ec2-describe-instances",
|
||||
lambda { |str| STDERR.puts str })
|
||||
|
||||
if exe.code != 0
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
puts "VM_POLL=YES"
|
||||
|
||||
exe.stdout.split(/^RESERVATION\s.*?$/).each do |vm|
|
||||
m=vm.match(/^INSTANCE\s+(\S+)/)
|
||||
next if !m
|
||||
|
||||
deploy_id = m[1]
|
||||
|
||||
one_id='-1'
|
||||
|
||||
vm.scan(/^TAG.*ONE_ID\s+(\d+)/) {|i| one_id = i.first }
|
||||
|
||||
poll_data=parse_poll(vm, deploy_id)
|
||||
|
||||
puts "VM=["
|
||||
puts " ID=#{one_id},"
|
||||
puts " DEPLOY_ID=#{deploy_id},"
|
||||
puts " POLL=\"#{poll_data}\" ]"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_deployment_info(host, xml_text)
|
||||
xml = REXML::Document.new xml_text
|
||||
|
||||
ec2 = nil
|
||||
|
||||
all_ec2_elements = xml.root.get_elements("//USER_TEMPLATE/EC2")
|
||||
|
||||
# First, let's see if we have an EC2 site that matches
|
||||
# our desired host name
|
||||
all_ec2_elements.each { |element|
|
||||
cloud=element.elements["CLOUD"]
|
||||
if cloud and cloud.text.upcase == host.upcase
|
||||
ec2 = element
|
||||
end
|
||||
}
|
||||
|
||||
if !ec2
|
||||
# If we don't find the EC2 site, and ONE just
|
||||
# knows about one EC2 site, let's use that
|
||||
if all_ec2_elements.size == 1
|
||||
ec2 = all_ec2_elements[0]
|
||||
else
|
||||
STDERR.puts(
|
||||
"Cannot find EC2 element in deployment file "<<
|
||||
"#{local_dfile} or couldn't find any EC2 site matching "<<
|
||||
"one of the template.")
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
ec2
|
||||
end
|
||||
|
||||
def parse_poll(text, deploy_id)
|
||||
text.match(Regexp.new("INSTANCE\\s+#{deploy_id}\\s+(.+)"))
|
||||
|
||||
info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \
|
||||
@ -296,69 +363,15 @@ class EC2Driver < VirtualMachineDriver
|
||||
info
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_deployment_info(drv_message)
|
||||
msg = decode(drv_message)
|
||||
|
||||
host = msg.elements["HOST"].text
|
||||
local_dfile = msg.elements["LOCAL_DEPLOYMENT_FILE"].text
|
||||
|
||||
if !local_dfile
|
||||
send_message(ACTION[:deploy],RESULT[:failure],id,
|
||||
"Cannot open deployment file #{local_dfile}")
|
||||
return
|
||||
end
|
||||
|
||||
tmp = File.new(local_dfile)
|
||||
xml = REXML::Document.new tmp
|
||||
tmp.close()
|
||||
|
||||
ec2 = nil
|
||||
|
||||
all_ec2_elements = xml.root.get_elements("USER_TEMPLATE/EC2")
|
||||
|
||||
# First, let's see if we have an EC2 site that matches
|
||||
# our desired host name
|
||||
all_ec2_elements.each { |element|
|
||||
cloud=element.elements["CLOUD"]
|
||||
if cloud and cloud.text.upcase == host.upcase
|
||||
ec2 = element
|
||||
end
|
||||
}
|
||||
|
||||
if !ec2
|
||||
# If we don't find the EC2 site, and ONE just
|
||||
# knows about one EC2 site, let's use that
|
||||
if all_ec2_elements.size == 1
|
||||
ec2 = all_ec2_elements[0]
|
||||
else
|
||||
send_message(ACTION[:deploy],RESULT[:failure],id,
|
||||
"Cannot find EC2 element in deployment file "<<
|
||||
"#{local_dfile} or couldn't find any EC2 site matching "<<
|
||||
"one of the template.")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
ec2
|
||||
end
|
||||
|
||||
# Execute an EC2 command and send the SUCCESS or FAILURE signal
|
||||
# +drv_message+: String, base64 encoded info sent by ONE
|
||||
# +deploy_id+: String, VM id in EC2
|
||||
# +ec2_action+: Symbol, one of the keys of the EC2 hash constant (i.e :run)
|
||||
# +one_action+: String, OpenNebula action
|
||||
# +id+: String, action id
|
||||
def ec2_action(drv_message, ec2_action, one_action, id)
|
||||
msg = decode(drv_message)
|
||||
|
||||
deploy_id = msg.elements["DEPLOY_ID"].text
|
||||
|
||||
exe = exec_and_log_ec2(ec2_action, nil, deploy_id, id)
|
||||
def ec2_action(deploy_id, ec2_action, one_action)
|
||||
exe = exec_and_log_ec2(ec2_action, nil, deploy_id)
|
||||
if exe.code != 0
|
||||
send_message(one_action, RESULT[:failure], id, exe.stderr)
|
||||
else
|
||||
send_message(one_action, RESULT[:success], id)
|
||||
STDERR.puts(exe.stderr)
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
@ -369,7 +382,7 @@ private
|
||||
# +action+: Symbol, one of the keys of the EC2 hash constant (i.e :run)
|
||||
# +xml+: REXML Document, containing EC2 information
|
||||
# +extra_params+: String, extra information to be added to the command
|
||||
def exec_and_log_ec2(action, xml, extra_params, id)
|
||||
def exec_and_log_ec2(action, xml, extra_params)
|
||||
cmd = EC2[action][:cmd].clone
|
||||
cmd << ' ' << extra_params << ' ' if extra_params
|
||||
|
||||
@ -380,7 +393,7 @@ private
|
||||
}.join(' ')
|
||||
end
|
||||
|
||||
LocalCommand.run(cmd, log_method(id))
|
||||
LocalCommand.run(cmd, lambda {|str| STDERR.puts(str) })
|
||||
end
|
||||
|
||||
# Returns the value of the xml specified by the name or the default
|
||||
@ -405,48 +418,3 @@ private
|
||||
end
|
||||
end
|
||||
|
||||
def monitor_all_vms
|
||||
exe = LocalCommand.run(
|
||||
"#{EC2_LOCATION}/bin/ec2-describe-instances",
|
||||
lambda { |str| STDERR.puts str })
|
||||
|
||||
if exe.code != 0
|
||||
exit -1
|
||||
end
|
||||
|
||||
puts "VM_POLL=YES"
|
||||
|
||||
exe.stdout.split(/^RESERVATION\s.*?$/).each do |vm|
|
||||
m=vm.match(/^INSTANCE\s+(\S+)/)
|
||||
next if !m
|
||||
|
||||
deploy_id = m[1]
|
||||
|
||||
one_id='-1'
|
||||
|
||||
vm.scan(/^TAG.*ONE_ID\s+(\d+)/) {|i| one_id = i.first }
|
||||
|
||||
poll_data=EC2Driver.parse_poll(vm, deploy_id)
|
||||
|
||||
puts "VM=["
|
||||
puts " ID=#{one_id},"
|
||||
puts " DEPLOY_ID=#{deploy_id},"
|
||||
puts " POLL=\"#{poll_data}\" ]"
|
||||
end
|
||||
end
|
||||
|
||||
# EC2Driver Main program
|
||||
|
||||
if ARGV[0]=='--poll'
|
||||
monitor_all_vms
|
||||
exit(0)
|
||||
end
|
||||
|
||||
ec2_conf = ARGV.last
|
||||
|
||||
if ec2_conf
|
||||
ec2_conf = ETC_LOCATION + ec2_conf if ec2_conf[0] != ?/
|
||||
end
|
||||
|
||||
ec2_driver = EC2Driver.new(ec2_conf)
|
||||
ec2_driver.start_driver
|
@ -14,22 +14,28 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
#May be needed in some setups
|
||||
#CLASSPATH=""
|
||||
# May be needed in some setups
|
||||
#CLASSPATH: ""
|
||||
#JAVA_HOME: ""
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# EC2 API TOOLS Configuration.
|
||||
#----------------------------------------------------------------------------
|
||||
#EC2_HOME="<path_to_ec2_utils>"
|
||||
#EC2_PRIVATE_KEY="<path_to_your_ec2_pem_key>"
|
||||
#EC2_CERT="<path_to_your_ec2_pem_cert>"
|
||||
#EC2_HOME: "<path_to_ec2_utils>"
|
||||
#EC2_PRIVATE_KEY: "<path_to_your_ec2_pem_key>"
|
||||
#EC2_CERT: "<path_to_your_ec2_pem_cert>"
|
||||
|
||||
#
|
||||
#----------------------------------------------------------------------------
|
||||
# Driver configuration
|
||||
#----------------------------------------------------------------------------
|
||||
# Arguments for the JAVA Virtual Machine
|
||||
EC2_JVM_ARGS="-Xms16m -Xmx64m"
|
||||
EC2_JVM_ARGS: "-Xms16m -Xmx64m"
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Max number of instances that can be launched into EC2
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
SMALL_INSTANCES: 5
|
||||
LARGE_INSTANCES: 0
|
||||
EXTRALARGE_INSTANCES: 0
|
||||
|
||||
# Number of concurrent EC2 operations (not instances)
|
||||
EC2_JVM_CONCURRENCY=10
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# Copyright 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
@ -14,30 +14,17 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
EC2RC=/etc/one/im_ec2/im_ec2rc
|
||||
EC2CONF=/etc/one/im_ec2/im_ec2.conf
|
||||
MADCOMMON=/usr/lib/one/mads/madcommon.sh
|
||||
VAR_LOCATION=/var/lib/one
|
||||
else
|
||||
EC2RC=$ONE_LOCATION/etc/im_ec2/im_ec2rc
|
||||
EC2CONF=$ONE_LOCATION/etc/im_ec2/im_ec2.conf
|
||||
MADCOMMON=$ONE_LOCATION/lib/mads/madcommon.sh
|
||||
VAR_LOCATION=$ONE_LOCATION/var
|
||||
fi
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
. $MADCOMMON
|
||||
require 'ec2_driver'
|
||||
|
||||
# Export the vmm_mad specific rc
|
||||
export_rc_vars $EC2RC
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
id = ARGV[2]
|
||||
|
||||
# Export max instance type usages
|
||||
export_rc_vars $EC2CONF
|
||||
ec2_drv = EC2Driver.new
|
||||
|
||||
# Go to var directory ONE_LOCATION/var or /var/lib/one
|
||||
cd $VAR_LOCATION
|
||||
ec2_drv.poll(id, deploy_id)
|
||||
|
||||
# Execute the actual MAD
|
||||
execute_mad $*
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# Copyright 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
@ -14,35 +14,16 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
DRIVERRC=/etc/one/vmm_ec2/vmm_ec2rc
|
||||
MADCOMMON=/usr/lib/one/mads/madcommon.sh
|
||||
VAR_LOCATION=/var/lib/one
|
||||
else
|
||||
DRIVERRC=$ONE_LOCATION/etc/vmm_ec2/vmm_ec2rc
|
||||
MADCOMMON=$ONE_LOCATION/lib/mads/madcommon.sh
|
||||
VAR_LOCATION=$ONE_LOCATION/var
|
||||
fi
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
. $MADCOMMON
|
||||
require 'ec2_driver'
|
||||
|
||||
# Export the vmm_mad specific rc
|
||||
export_rc_vars $DRIVERRC
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
# Go to ONE_LOCATION
|
||||
cd $VAR_LOCATION
|
||||
ec2_drv = EC2Driver.new
|
||||
|
||||
while getopts u:h:k:c: option $@
|
||||
do
|
||||
case $option in
|
||||
u) export EC2_URL="$OPTARG";;
|
||||
h) export EC2_HOME="$OPTARG";;
|
||||
k) export EC2_PRIVATE_KEY="$OPTARG";;
|
||||
c) export EC2_CERT="$OPTARG";;
|
||||
esac
|
||||
done
|
||||
ec2_drv.reboot(deploy_id)
|
||||
|
||||
# Execute the actual MAD
|
||||
execute_mad $*
|
32
src/vmm_mad/remotes/ec2/restore
Executable file
32
src/vmm_mad/remotes/ec2/restore
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'ec2_driver'
|
||||
|
||||
checkpoint_file = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
deploy_id=File.read(checkpoint_file).strip
|
||||
|
||||
ec2_drv = EC2Driver.new
|
||||
|
||||
ec2_drv.restore(deploy_id)
|
||||
|
||||
#File.rm(checkpoint_file)
|
37
src/vmm_mad/remotes/ec2/save
Executable file
37
src/vmm_mad/remotes/ec2/save
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'ec2_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
file = ARGV[1]
|
||||
host = ARGV[2]
|
||||
|
||||
ec2_drv = EC2Driver.new
|
||||
|
||||
dir=File.dirname(file)
|
||||
Dir.mkdir(dir) if !Dir.exist?(dir)
|
||||
|
||||
f=open(file, "w")
|
||||
f.write(deploy_id)
|
||||
f.close
|
||||
|
||||
ec2_drv.save(deploy_id)
|
||||
|
29
src/vmm_mad/remotes/ec2/shutdown
Executable file
29
src/vmm_mad/remotes/ec2/shutdown
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'ec2_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
ec2_drv = EC2Driver.new
|
||||
|
||||
ec2_drv.shutdown(deploy_id)
|
||||
|
Loading…
Reference in New Issue
Block a user