mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-03 13:47:01 +03:00
Merge branch 'feature-2289'
Conflicts: install.sh
This commit is contained in:
commit
fa5f2fb3f5
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 \
|
||||
@ -268,11 +266,13 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/im/xen3-probes.d \
|
||||
$VAR_LOCATION/remotes/im/xen4-probes.d \
|
||||
$VAR_LOCATION/remotes/im/vmware.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 \
|
||||
@ -456,6 +456,7 @@ INSTALL_FILES=(
|
||||
IM_PROBES_XEN4_FILES:$VAR_LOCATION/remotes/im/xen4.d
|
||||
IM_PROBES_XEN4_PROBES_FILES:$VAR_LOCATION/remotes/im/xen4-probes.d
|
||||
IM_PROBES_VMWARE_FILES:$VAR_LOCATION/remotes/im/vmware.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
|
||||
@ -467,6 +468,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_SHARED_LVM_FILES:$VAR_LOCATION/remotes/tm/shared_lvm
|
||||
@ -662,9 +664,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
|
||||
@ -749,15 +750,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 \
|
||||
src/im_mad/dummy/one_im_dummy.rb \
|
||||
src/im_mad/dummy/one_im_dummy \
|
||||
src/im_mad/collectd/collectd \
|
||||
@ -857,6 +855,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
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -892,6 +914,8 @@ IM_PROBES_XEN4_PROBES_FILES="src/im_mad/remotes/xen-probes.d/xen.rb \
|
||||
|
||||
IM_PROBES_VMWARE_FILES="src/im_mad/remotes/vmware.d/vmware.rb"
|
||||
|
||||
IM_PROBES_EC2_FILES="src/im_mad/remotes/ec2.d/poll"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Auth Manager drivers to be installed under $REMOTES_LOCATION/auth
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -1167,14 +1191,14 @@ ETC_FILES="share/etc/oned.conf \
|
||||
|
||||
VMWARE_ETC_FILES="src/vmm_mad/remotes/vmware/vmwarerc"
|
||||
|
||||
EC2_ETC_FILES="src/vmm_mad/remotes/ec2/ec2_driver.conf \
|
||||
src/vmm_mad/remotes/ec2/ec2_driver.default"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 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 \
|
||||
@ -1182,14 +1206,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
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -241,8 +241,8 @@ IM_MAD = [
|
||||
#-------------------------------------------------------------------------------
|
||||
#IM_MAD = [
|
||||
# name = "ec2",
|
||||
# executable = "one_im_ec2",
|
||||
# arguments = "im_ec2/im_ec2.conf" ]
|
||||
# executable = "one_im_sh",
|
||||
# arguments = "-c -t 1 -r 0 ec2" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -335,14 +335,13 @@ VM_MAD = [
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# EC2 Virtualization Driver Manager Configuration
|
||||
# arguments: default values for the EC2 driver, can be an absolute path or
|
||||
# relative to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was
|
||||
# installed in /).
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of actions performed at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#VM_MAD = [
|
||||
# name = "ec2",
|
||||
# executable = "one_vmm_ec2",
|
||||
# arguments = "vmm_ec2/vmm_ec2.conf",
|
||||
# executable = "one_vmm_sh",
|
||||
# arguments = "-t 15 -r 0 ec2",
|
||||
# type = "xml" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
# Max number of instances that can be launched into EC2
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
SMALL_INSTANCES=5
|
||||
LARGE_INSTANCES=
|
||||
EXTRALARGE_INSTANCES=
|
@ -1,76 +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"
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
||||
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}"
|
||||
info64 = Base64::encode64(info).strip.delete("\n")
|
||||
send_message("MONITOR", RESULT[:success], num, info64)
|
||||
end
|
||||
end
|
||||
|
||||
# The EC2 Information Driver main program
|
||||
im = EC2InformationManagerDriver.new
|
||||
im.start_driver
|
27
src/im_mad/remotes/ec2.d/poll
Executable file
27
src/im_mad/remotes/ec2.d/poll
Executable file
@ -0,0 +1,27 @@
|
||||
#!/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.join(File.dirname(__FILE__), '../../vmm/ec2')
|
||||
|
||||
require 'ec2_driver'
|
||||
|
||||
host = ARGV[2]
|
||||
ec2_drv = EC2Driver.new(host)
|
||||
|
||||
ec2_drv.monitor_all_vms
|
||||
|
@ -1,408 +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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# 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"]
|
||||
|
||||
ONE_LOCATION = ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION = "/usr/lib/one/ruby"
|
||||
ETC_LOCATION = "/etc/one/"
|
||||
else
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby"
|
||||
ETC_LOCATION = ONE_LOCATION + "/etc/"
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
require "VirtualMachineDriver"
|
||||
require "CommandManager"
|
||||
require 'scripts_common'
|
||||
require "rexml/document"
|
||||
|
||||
# The main class for the EC2 driver
|
||||
class EC2Driver < VirtualMachineDriver
|
||||
|
||||
# EC2 commands constants
|
||||
EC2 = {
|
||||
:run => {
|
||||
:cmd => "#{EC2_LOCATION}/bin/ec2-run-instances",
|
||||
:args => {
|
||||
"AKI" => {
|
||||
:opt => '--kernel'
|
||||
},
|
||||
"AMI" => {
|
||||
:opt => ''
|
||||
},
|
||||
"BLOCKDEVICEMAPPING" => {
|
||||
:opt => '-b'
|
||||
},
|
||||
"CLIENTTOKEN" => {
|
||||
:opt => '--client-token'
|
||||
},
|
||||
"INSTANCETYPE" => {
|
||||
:opt => '-t'
|
||||
},
|
||||
"KEYPAIR" => {
|
||||
:opt => '-k'
|
||||
},
|
||||
"LICENSEPOOL" => {
|
||||
:opt => '--license-pool'
|
||||
},
|
||||
"PLACEMENTGROUP" => {
|
||||
:opt => '--placement-group'
|
||||
},
|
||||
"PRIVATEIP" => {
|
||||
:opt => '--private-ip-address'
|
||||
},
|
||||
"RAMDISK" => {
|
||||
:opt => '--ramdisk'
|
||||
},
|
||||
"SUBNETID" => {
|
||||
:opt => '-s'
|
||||
},
|
||||
"TENANCY" => {
|
||||
:opt => '--tenancy'
|
||||
},
|
||||
"USERDATA" => {
|
||||
:opt => '-d'
|
||||
},
|
||||
"USERDATAFILE" => {
|
||||
:opt => '-f'
|
||||
},
|
||||
"SECURITYGROUPS" => {
|
||||
:opt => '-g',
|
||||
:proc => lambda {|str| str.split(',').join(' -g ')}
|
||||
},
|
||||
"AVAILABILITYZONE" => {
|
||||
:opt => '--availability-zone'
|
||||
}
|
||||
}
|
||||
},
|
||||
:terminate => {
|
||||
:cmd => "#{EC2_LOCATION}/bin/ec2-terminate-instances"
|
||||
},
|
||||
:describe => {
|
||||
:cmd => "#{EC2_LOCATION}/bin/ec2-describe-instances"
|
||||
},
|
||||
:associate => {
|
||||
:cmd => "#{EC2_LOCATION}/bin/ec2-associate-address",
|
||||
:args => {
|
||||
"SUBNETID" => {
|
||||
:opt => '-a',
|
||||
:proc => lambda {|str| ''}
|
||||
},
|
||||
"ELASTICIP" => {
|
||||
:opt => ''
|
||||
}
|
||||
}
|
||||
},
|
||||
:authorize => {
|
||||
:cmd => "#{EC2_LOCATION}/bin/ec2-authorize",
|
||||
:args => {
|
||||
"AUTHORIZEDPORTS" => {
|
||||
:opt => '-p',
|
||||
:proc => lambda {|str| str.split(',').join(' -p ')}
|
||||
}
|
||||
}
|
||||
},
|
||||
:reboot => {
|
||||
:cmd => "#{EC2_LOCATION}/bin/ec2-reboot-instances"
|
||||
},
|
||||
:stop => {
|
||||
:cmd => "#{EC2_LOCATION}/bin/ec2-stop-instances"
|
||||
},
|
||||
:start => {
|
||||
:cmd => "#{EC2_LOCATION}/bin/ec2-start-instances"
|
||||
},
|
||||
:tags => {
|
||||
:cmd => "#{EC2_LOCATION}/bin/ec2-create-tags",
|
||||
:args => {
|
||||
"TAGS" => {
|
||||
:opt => '-t',
|
||||
:proc => lambda {|str| str.split(',').join(' -t ')}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 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 && File.exists?(ec2_conf)
|
||||
fd = File.new(ec2_conf)
|
||||
xml = REXML::Document.new fd
|
||||
fd.close()
|
||||
|
||||
return if !xml || !xml.root
|
||||
|
||||
ec2 = xml.root.elements["EC2"]
|
||||
|
||||
return if !ec2
|
||||
|
||||
EC2.each {|action, hash|
|
||||
if hash[:args]
|
||||
hash[:args].each { |key, value|
|
||||
@defaults[key] = value_from_xml(ec2, key)
|
||||
}
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# DEPLOY action, also sets ports and ip if needed
|
||||
def deploy(id, drv_message)
|
||||
ec2_info = get_deployment_info(drv_message)
|
||||
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
|
||||
end
|
||||
|
||||
deploy_exe = exec_and_log_ec2(:run, ec2_info, "", id)
|
||||
if deploy_exe.code != 0
|
||||
msg = deploy_exe.stderr
|
||||
send_message(ACTION[:deploy], RESULT[:failure], id, msg)
|
||||
return
|
||||
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
|
||||
end
|
||||
|
||||
deploy_id = $1
|
||||
|
||||
if ec2_value(ec2_info, 'AUTHORIZEDPORTS')
|
||||
exec_and_log_ec2(:authorize, ec2_info, 'default', id)
|
||||
end
|
||||
|
||||
if ec2_value(ec2_info, 'TAGS')
|
||||
exec_and_log_ec2(:tags, ec2_info, deploy_id, id)
|
||||
end
|
||||
|
||||
if ec2_value(ec2_info, 'ELASTICIP')
|
||||
exec_and_log_ec2(:associate, ec2_info, "-i #{deploy_id}", id)
|
||||
end
|
||||
|
||||
send_message(ACTION[:deploy], RESULT[:success], id, deploy_id)
|
||||
end
|
||||
|
||||
# Shutdown a EC2 instance
|
||||
def shutdown(id, drv_message)
|
||||
ec2_action(drv_message, :terminate, ACTION[:shutdown], id)
|
||||
end
|
||||
|
||||
# Reboot a EC2 instance
|
||||
def reboot(id, drv_message)
|
||||
ec2_action(drv_message, :reboot, ACTION[:reboot], id)
|
||||
end
|
||||
|
||||
# Cancel a EC2 instance
|
||||
def cancel(id, drv_message)
|
||||
ec2_action(drv_message, :terminate, ACTION[:cancel], id)
|
||||
end
|
||||
|
||||
# Stop a EC2 instance
|
||||
def save(id, drv_message)
|
||||
ec2_action(drv_message, :stop, ACTION[:save], id)
|
||||
end
|
||||
|
||||
# Cancel a EC2 instance
|
||||
def restore(id, drv_message)
|
||||
ec2_action(drv_message, :start, ACTION[:restor], id)
|
||||
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
|
||||
|
||||
info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:usedcpu]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:nettx]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:netrx]}=0"
|
||||
|
||||
|
||||
exe = exec_and_log_ec2(:describe, nil, deploy_id, id)
|
||||
if exe.code != 0
|
||||
send_message(ACTION[:poll], RESULT[:failure], id, exe.stderr)
|
||||
return
|
||||
end
|
||||
|
||||
exe.stdout.match(Regexp.new("INSTANCE\\s+#{deploy_id}\\s+(.+)"))
|
||||
|
||||
if !$1
|
||||
info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:deleted]}"
|
||||
else
|
||||
monitor_data = $1.split(/\s+/)
|
||||
|
||||
case monitor_data[3]
|
||||
when "pending"
|
||||
info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]}"
|
||||
when "running"
|
||||
info<<" #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]}"<<
|
||||
" IP=#{monitor_data[1]}"
|
||||
when "shutting-down","terminated"
|
||||
info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:deleted]}"
|
||||
end
|
||||
end
|
||||
|
||||
send_message(ACTION[:poll], RESULT[:success], id, 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
|
||||
# +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)
|
||||
if exe.code != 0
|
||||
send_message(one_action, RESULT[:failure], id, exe.stderr)
|
||||
else
|
||||
send_message(one_action, RESULT[:success], id)
|
||||
end
|
||||
end
|
||||
|
||||
# Execute an EC2 command and log the message if error
|
||||
# This function will build the command joining the :cmd value of the EC2
|
||||
# hash, the extra_params string and the options built from the :args schema
|
||||
# of the EC2 hash and the xml
|
||||
# +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)
|
||||
cmd = EC2[action][:cmd].clone
|
||||
cmd << ' ' << extra_params << ' ' if extra_params
|
||||
|
||||
if EC2[action][:args]
|
||||
cmd << EC2[action][:args].map {|k,v|
|
||||
str = ec2_value(xml, k, &v[:proc])
|
||||
v[:opt] + ' ' + str if str
|
||||
}.join(' ')
|
||||
end
|
||||
|
||||
LocalCommand.run(cmd, log_method(id))
|
||||
end
|
||||
|
||||
# Returns the value of the xml specified by the name or the default
|
||||
# one if it does not exist
|
||||
# +xml+: REXML Document, containing EC2 information
|
||||
# +name+: String, xpath expression to retrieve the value
|
||||
# +block+: Block, block to be applied to the value before returning it
|
||||
def ec2_value(xml, name, &block)
|
||||
value = value_from_xml(xml, name) || @defaults[name]
|
||||
if block_given? && value
|
||||
block.call(value)
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
def value_from_xml(xml, name)
|
||||
if xml
|
||||
element = xml.elements[name]
|
||||
element.text.strip if element && element.text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# EC2Driver Main program
|
||||
|
||||
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
|
@ -1,35 +0,0 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
#May be needed in some setups
|
||||
#CLASSPATH=""
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# 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>"
|
||||
|
||||
#
|
||||
#----------------------------------------------------------------------------
|
||||
# Driver configuration
|
||||
#----------------------------------------------------------------------------
|
||||
# Arguments for the JAVA Virtual Machine
|
||||
EC2_JVM_ARGS="-Xms16m -Xmx64m"
|
||||
|
||||
# Number of concurrent EC2 operations (not instances)
|
||||
EC2_JVM_CONCURRENCY=10
|
@ -416,7 +416,7 @@ class ExecDriver < VirtualMachineDriver
|
||||
{
|
||||
:driver => :vmm,
|
||||
:action => :restore,
|
||||
:parameters => [:checkpoint_file, :host]
|
||||
:parameters => [:checkpoint_file, :host, :deploy_id]
|
||||
},
|
||||
# Execute post-boot networking setup
|
||||
{
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
@ -13,3 +15,6 @@
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
@ -16,28 +16,5 @@
|
||||
# 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
|
||||
|
||||
. $MADCOMMON
|
||||
|
||||
# Export the vmm_mad specific rc
|
||||
export_rc_vars $EC2RC
|
||||
|
||||
# Export max instance type usages
|
||||
export_rc_vars $EC2CONF
|
||||
|
||||
# Go to var directory ONE_LOCATION/var or /var/lib/one
|
||||
cd $VAR_LOCATION
|
||||
|
||||
# Execute the actual MAD
|
||||
execute_mad $*
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
29
src/vmm_mad/remotes/ec2/cancel
Executable file
29
src/vmm_mad/remotes/ec2/cancel
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(host)
|
||||
|
||||
ec2_drv.cancel(deploy_id)
|
||||
|
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
|
||||
|
@ -16,33 +16,5 @@
|
||||
# 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
|
||||
|
||||
. $MADCOMMON
|
||||
|
||||
# Export the vmm_mad specific rc
|
||||
export_rc_vars $DRIVERRC
|
||||
|
||||
# Go to ONE_LOCATION
|
||||
cd $VAR_LOCATION
|
||||
|
||||
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
|
||||
|
||||
# Execute the actual MAD
|
||||
execute_mad $*
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/ec2/detach_nic
Executable file
20
src/vmm_mad/remotes/ec2/detach_nic
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
125
src/vmm_mad/remotes/ec2/ec2_driver.conf
Normal file
125
src/vmm_mad/remotes/ec2/ec2_driver.conf
Normal file
@ -0,0 +1,125 @@
|
||||
regions:
|
||||
default:
|
||||
region_name: us-east-1
|
||||
access_key_id:
|
||||
secret_access_key:
|
||||
capacity:
|
||||
m1.small: 5
|
||||
m1.large: 0
|
||||
m1.xlarge: 0
|
||||
us-east-1:
|
||||
region_name: us-east-1
|
||||
access_key_id:
|
||||
secret_access_key:
|
||||
capacity:
|
||||
m1.small:
|
||||
m1.large:
|
||||
m1.xlarge:
|
||||
us-west-2:
|
||||
region_name: us-west-2
|
||||
access_key_id:
|
||||
secret_access_key:
|
||||
capacity:
|
||||
m1.small:
|
||||
m1.large:
|
||||
m1.xlarge:
|
||||
us-west-1:
|
||||
region_name: us-west-1
|
||||
access_key_id:
|
||||
secret_access_key:
|
||||
capacity:
|
||||
m1.small:
|
||||
m1.large:
|
||||
m1.xlarge:
|
||||
eu-west-1:
|
||||
region_name: eu-west-1
|
||||
access_key_id:
|
||||
secret_access_key:
|
||||
capacity:
|
||||
m1.small:
|
||||
m1.large:
|
||||
m1.xlarge:
|
||||
ap-southeast-1:
|
||||
region_name: ap-southeast-1
|
||||
access_key_id:
|
||||
secret_access_key:
|
||||
capacity:
|
||||
m1.small:
|
||||
m1.large:
|
||||
m1.xlarge:
|
||||
ap-southeast-2:
|
||||
region_name: ap-southeast-2
|
||||
access_key_id:
|
||||
secret_access_key:
|
||||
capacity:
|
||||
m1.small:
|
||||
m1.large:
|
||||
m1.xlarge:
|
||||
ap-northeast-1:
|
||||
region_name: ap-northeast-1
|
||||
access_key_id:
|
||||
secret_access_key:
|
||||
capacity:
|
||||
m1.small:
|
||||
m1.large:
|
||||
m1.xlarge:
|
||||
sa-east-1:
|
||||
region_name: sa-east-1
|
||||
access_key_id:
|
||||
secret_access_key:
|
||||
capacity:
|
||||
m1.small:
|
||||
m1.large:
|
||||
m1.xlarge:
|
||||
instance_types:
|
||||
m1.small:
|
||||
cpu: 1
|
||||
memory: 1.7
|
||||
m1.medium:
|
||||
cpu: 1
|
||||
memory: 3.75
|
||||
m1.large:
|
||||
cpu: 2
|
||||
memory: 7.5
|
||||
m1.xlarge:
|
||||
cpu: 4
|
||||
memory: 15
|
||||
m3.xlarge:
|
||||
cpu: 4
|
||||
memory: 15
|
||||
m3.2xlarge8:
|
||||
cpu: 26
|
||||
memory: 30
|
||||
c1.medium:
|
||||
cpu: 2
|
||||
memory: 1.7
|
||||
c1.xlarge:
|
||||
cpu: 8
|
||||
memory: 7
|
||||
cc2.8xlarge:
|
||||
cpu: 32
|
||||
memory: 60.5
|
||||
m2.xlarge:
|
||||
cpu: 2
|
||||
memory: 17.1
|
||||
m2.2xlarge4:
|
||||
cpu: 13
|
||||
memory: 34.2
|
||||
m2.4xlarge8:
|
||||
cpu: 26
|
||||
memory: 68.4
|
||||
cr1.8xlarge:
|
||||
cpu: 32
|
||||
memory: 244
|
||||
hi1.4xlarge:
|
||||
cpu: 16
|
||||
memory: 60.5
|
||||
hs1.8xlarge:
|
||||
cpu: 16
|
||||
memory: 117
|
||||
t1.micro:
|
||||
cpu: 1
|
||||
memory: 0.615
|
||||
cg1.4xlarge:
|
||||
cpu: 16
|
||||
memory: 22.5
|
@ -1,4 +1,3 @@
|
||||
<!--
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
@ -14,19 +13,17 @@
|
||||
# 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]
|
||||
Valid atributes are: AKI AMI CLIENTTOKEN INSTANCETYPE KEYPAIR LICENSEPOOL
|
||||
PLACEMENTGROUP PRIVATEIP RAMDISK SUBNETID TENANCY USERDATA SECURITYGROUPS
|
||||
AVAILABILITYZONE EBS_OPTIMIZED ELASTICIP AUTHORIZEDPORTS TAGS
|
||||
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>
|
480
src/vmm_mad/remotes/ec2/ec2_driver.rb
Executable file
480
src/vmm_mad/remotes/ec2/ec2_driver.rb
Executable file
@ -0,0 +1,480 @@
|
||||
#!/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 !defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION = "/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
ETC_LOCATION = "/etc/one/" if !defined?(ETC_LOCATION)
|
||||
else
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
ETC_LOCATION = ONE_LOCATION + "/etc/" if !defined?(ETC_LOCATION)
|
||||
end
|
||||
|
||||
EC2_DRIVER_CONF = "#{ETC_LOCATION}/ec2_driver.conf"
|
||||
EC2_DRIVER_DEFAULT = "#{ETC_LOCATION}/ec2_driver.default"
|
||||
|
||||
# Load EC2 credentials and environment
|
||||
require 'yaml'
|
||||
require 'rubygems'
|
||||
require 'aws-sdk'
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
require 'CommandManager'
|
||||
require 'scripts_common'
|
||||
require 'rexml/document'
|
||||
require 'VirtualMachineDriver'
|
||||
|
||||
# The main class for the EC2 driver
|
||||
class EC2Driver
|
||||
ACTION = VirtualMachineDriver::ACTION
|
||||
POLL_ATTRIBUTE = VirtualMachineDriver::POLL_ATTRIBUTE
|
||||
VM_STATE = VirtualMachineDriver::VM_STATE
|
||||
|
||||
# EC2 commands constants
|
||||
EC2 = {
|
||||
:run => {
|
||||
:cmd => :create,
|
||||
:args => {
|
||||
"AKI" => {
|
||||
:opt => 'kernel_id'
|
||||
},
|
||||
"AMI" => {
|
||||
:opt => 'image_id'
|
||||
},
|
||||
#"BLOCKDEVICEMAPPING" => {
|
||||
# :opt => '-b'
|
||||
#},
|
||||
"CLIENTTOKEN" => {
|
||||
:opt => 'client_token'
|
||||
},
|
||||
"INSTANCETYPE" => {
|
||||
:opt => 'instance_type'
|
||||
},
|
||||
"KEYPAIR" => {
|
||||
:opt => 'key_name'
|
||||
},
|
||||
"LICENSEPOOL" => {
|
||||
:opt => 'license/pool'
|
||||
},
|
||||
"PLACEMENTGROUP" => {
|
||||
:opt => 'placement/group_name'
|
||||
},
|
||||
"PRIVATEIP" => {
|
||||
:opt => 'private_ip_address'
|
||||
},
|
||||
"RAMDISK" => {
|
||||
:opt => 'ramdisk_id'
|
||||
},
|
||||
"SUBNETID" => {
|
||||
:opt => 'subnet_id'
|
||||
},
|
||||
"TENANCY" => {
|
||||
:opt => 'placement/tenancy'
|
||||
},
|
||||
"USERDATA" => {
|
||||
:opt => 'user_data'
|
||||
},
|
||||
#"USERDATAFILE" => {
|
||||
# :opt => '-f'
|
||||
#},
|
||||
"SECURITYGROUPS" => {
|
||||
:opt => 'security_groups',
|
||||
:proc => lambda {|str| str.split(',')}
|
||||
},
|
||||
"AVAILABILITYZONE" => {
|
||||
:opt => 'placement/availability-zone'
|
||||
},
|
||||
"EBS_OPTIMIZED" => {
|
||||
:opt => 'ebs_optimized'
|
||||
}
|
||||
}
|
||||
},
|
||||
:terminate => {
|
||||
:cmd => :terminate
|
||||
},
|
||||
:describe => {
|
||||
:cmd => :describe_instances
|
||||
},
|
||||
:associate => {
|
||||
:cmd => :associate_address,
|
||||
:args => {
|
||||
#"SUBNETID" => {
|
||||
# :opt => '-a',
|
||||
# :proc => lambda {|str| ''}
|
||||
#},
|
||||
"ELASTICIP" => {
|
||||
:opt => 'public_ip'
|
||||
}
|
||||
}
|
||||
},
|
||||
:authorize => {
|
||||
:cmd => :authorize,
|
||||
:args => {
|
||||
"AUTHORIZEDPORTS" => {
|
||||
:opt => '-p',
|
||||
:proc => lambda {|str| str.split(',').join(' -p ')}
|
||||
}
|
||||
}
|
||||
},
|
||||
:reboot => {
|
||||
:cmd => :reboot
|
||||
},
|
||||
:stop => {
|
||||
:cmd => :stop
|
||||
},
|
||||
:start => {
|
||||
:cmd => :start
|
||||
},
|
||||
:tags => {
|
||||
:cmd => :create_tags,
|
||||
:args => {
|
||||
"TAGS" => {
|
||||
:opt => '-t',
|
||||
:proc => lambda {|str|
|
||||
hash = {}
|
||||
str.split(',').each {|s|
|
||||
k,v = s.split('=')
|
||||
hash[k] = v
|
||||
}
|
||||
hash
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# EC2 constructor, loads credentials and endpoint
|
||||
def initialize(host)
|
||||
@host = host
|
||||
|
||||
hybrid_ec2_conf = YAML::load(File.read(EC2_DRIVER_CONF))
|
||||
|
||||
@instance_types = hybrid_ec2_conf['instance_types']
|
||||
|
||||
regions = hybrid_ec2_conf['regions']
|
||||
@region = regions[host] || regions["default"]
|
||||
|
||||
AWS.config(
|
||||
'access_key_id' => @region['access_key_id'],
|
||||
'secret_access_key' => @region['secret_access_key'],
|
||||
'region' => @region['region_name'])
|
||||
|
||||
@ec2 = AWS.ec2
|
||||
end
|
||||
|
||||
# DEPLOY action, also sets ports and ip if needed
|
||||
def deploy(id, host, xml_text)
|
||||
ec2_info = get_deployment_info(host, xml_text)
|
||||
|
||||
load_default_template_values
|
||||
|
||||
if !ec2_value(ec2_info, 'AMI')
|
||||
STDERR.puts("Cannot find AMI in deployment file")
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
opts = generate_options(:run, ec2_info, {
|
||||
:min_count => 1,
|
||||
:max_count => 1})
|
||||
|
||||
begin
|
||||
instance = AWS.ec2.instances.create(opts)
|
||||
rescue => e
|
||||
STDERR.puts(e.message)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
tags = generate_options(:tags, ec2_info) || {}
|
||||
tags['ONE_ID'] = id
|
||||
tags.each{ |key,value|
|
||||
begin
|
||||
instance.add_tag(key, :value => value)
|
||||
rescue => e
|
||||
STDERR.puts(e.message)
|
||||
exit(-1)
|
||||
end
|
||||
}
|
||||
|
||||
if ec2_value(ec2_info, 'ELASTICIP')
|
||||
begin
|
||||
instance.associate_elastic_ip(ec2_value(ec2_info, 'ELASTICIP'))
|
||||
rescue => e
|
||||
STDERR.puts(e.message)
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
puts(instance.id)
|
||||
end
|
||||
|
||||
# Shutdown a EC2 instance
|
||||
def shutdown(deploy_id)
|
||||
ec2_action(deploy_id, :terminate)
|
||||
end
|
||||
|
||||
# Reboot a EC2 instance
|
||||
def reboot(deploy_id)
|
||||
ec2_action(deploy_id, :reboot)
|
||||
end
|
||||
|
||||
# Cancel a EC2 instance
|
||||
def cancel(deploy_id)
|
||||
ec2_action(deploy_id, :terminate)
|
||||
end
|
||||
|
||||
# Stop a EC2 instance
|
||||
def save(deploy_id)
|
||||
ec2_action(deploy_id, :stop)
|
||||
end
|
||||
|
||||
# Cancel a EC2 instance
|
||||
def restore(deploy_id)
|
||||
ec2_action(deploy_id, :start)
|
||||
end
|
||||
|
||||
# Get info (IP, and state) for a EC2 instance
|
||||
def poll(id, deploy_id)
|
||||
i = get_instance(deploy_id)
|
||||
puts parse_poll(i)
|
||||
end
|
||||
|
||||
# Get the info of all the EC2 instances. An EC2 instance must include
|
||||
# the ONE_ID tag, otherwise it will be ignored
|
||||
def monitor_all_vms
|
||||
totalmemory = 0
|
||||
totalcpu = 0
|
||||
@region['capacity'].each { |name, size|
|
||||
totalmemory += @instance_types[name]['memory'] * size * 1024 * 1024
|
||||
totalcpu += @instance_types[name]['cpu'] * size * 100
|
||||
}
|
||||
|
||||
host_info = "HYPERVISOR=ec2\n"
|
||||
host_info << "TOTALMEMORY=#{totalmemory}\n"
|
||||
host_info << "TOTALCPU=#{totalcpu}\n"
|
||||
host_info << "CPUSPEED=1000\n"
|
||||
host_info << "HOSTNAME=\"#{@host}\"\n"
|
||||
|
||||
vms_info = "VM_POLL=YES\n"
|
||||
|
||||
usedcpu = 0
|
||||
usedmemory = 0
|
||||
begin
|
||||
AWS.ec2.instances.each do |i|
|
||||
poll_data=parse_poll(i)
|
||||
|
||||
one_id = i.tags['ONE_ID']
|
||||
|
||||
vms_info << "VM=[\n"
|
||||
vms_info << " ID=#{one_id || -1},\n"
|
||||
vms_info << " DEPLOY_ID=#{i.instance_id},\n"
|
||||
vms_info << " POLL=\"#{poll_data}\" ]\n"
|
||||
|
||||
if one_id
|
||||
name = i.instance_type
|
||||
usedcpu += @instance_types[name]['cpu'] * 100
|
||||
usedmemory += @instance_types[name]['memory'] * 1024 * 1024
|
||||
end
|
||||
|
||||
end
|
||||
rescue => e
|
||||
STDERR.puts(e.message)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
host_info << "USEDMEMORY=#{usedmemory.round}\n"
|
||||
host_info << "USEDCPU=#{usedcpu.round}\n"
|
||||
host_info << "FREEMEMORY=#{(totalmemory - usedmemory).round}\n"
|
||||
host_info << "FREECPU=#{(totalcpu - usedcpu).round}\n"
|
||||
|
||||
puts host_info
|
||||
puts vms_info
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Get the EC2 section of the template. If more than one EC2 section
|
||||
# the CLOUD element is used and matched with the host
|
||||
def get_deployment_info(host, xml_text)
|
||||
xml = REXML::Document.new xml_text
|
||||
|
||||
ec2 = nil
|
||||
ec2_deprecated = 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["HOST"]
|
||||
if cloud and cloud.text.upcase == host.upcase
|
||||
ec2 = element
|
||||
else
|
||||
cloud=element.elements["CLOUD"]
|
||||
if cloud and cloud.text.upcase == host.upcase
|
||||
ec2_deprecated = element
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
ec2 ||= ec2_deprecated
|
||||
|
||||
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
|
||||
|
||||
# Retrive the vm information from the EC2 instance
|
||||
def parse_poll(instance)
|
||||
info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:usedcpu]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:nettx]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:netrx]}=0"
|
||||
|
||||
if !instance.exists?
|
||||
info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:deleted]}"
|
||||
else
|
||||
case instance.status
|
||||
when :pending
|
||||
info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]}"
|
||||
when :running
|
||||
info<<" #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]}"<<
|
||||
" IP=#{instance.ip_address}"
|
||||
when :'shutting-down', :terminated
|
||||
info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:deleted]}"
|
||||
end
|
||||
end
|
||||
|
||||
info
|
||||
end
|
||||
|
||||
# Execute an EC2 command
|
||||
# +deploy_id+: String, VM id in EC2
|
||||
# +ec2_action+: Symbol, one of the keys of the EC2 hash constant (i.e :run)
|
||||
def ec2_action(deploy_id, ec2_action)
|
||||
i = get_instance(deploy_id)
|
||||
|
||||
begin
|
||||
i.send(EC2[ec2_action][:cmd])
|
||||
rescue => e
|
||||
STDERR.puts e.message
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
# Generate the options for the given command from the xml provided in the
|
||||
# template. The available options for each command are defined in the EC2
|
||||
# constant
|
||||
def generate_options(action, xml, extra_params={})
|
||||
opts = extra_params || {}
|
||||
|
||||
if EC2[action][:args]
|
||||
EC2[action][:args].each {|k,v|
|
||||
str = ec2_value(xml, k, &v[:proc])
|
||||
if str
|
||||
tmp = opts
|
||||
last_key = nil
|
||||
v[:opt].split('/').each { |k|
|
||||
tmp = tmp[last_key] if last_key
|
||||
tmp[k] = {}
|
||||
last_key = k
|
||||
}
|
||||
tmp[last_key] = str
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
opts
|
||||
end
|
||||
|
||||
# Returns the value of the xml specified by the name or the default
|
||||
# one if it does not exist
|
||||
# +xml+: REXML Document, containing EC2 information
|
||||
# +name+: String, xpath expression to retrieve the value
|
||||
# +block+: Block, block to be applied to the value before returning it
|
||||
def ec2_value(xml, name, &block)
|
||||
value = value_from_xml(xml, name) || @defaults[name]
|
||||
if block_given? && value
|
||||
block.call(value)
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
def value_from_xml(xml, name)
|
||||
if xml
|
||||
element = xml.elements[name]
|
||||
element.text.strip if element && element.text
|
||||
end
|
||||
end
|
||||
|
||||
# Load the default values that will be used to create a new instance, if
|
||||
# not provided in the template. These values are defined in the EC2_CONF
|
||||
# file
|
||||
def load_default_template_values
|
||||
@defaults = Hash.new
|
||||
|
||||
if File.exists?(EC2_DRIVER_DEFAULT)
|
||||
fd = File.new(EC2_DRIVER_DEFAULT)
|
||||
xml = REXML::Document.new fd
|
||||
fd.close()
|
||||
|
||||
return if !xml || !xml.root
|
||||
|
||||
ec2 = xml.root.elements["EC2"]
|
||||
|
||||
return if !ec2
|
||||
|
||||
EC2.each {|action, hash|
|
||||
if hash[:args]
|
||||
hash[:args].each { |key, value|
|
||||
@defaults[key] = value_from_xml(ec2, key)
|
||||
}
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# Retrive the instance from EC2
|
||||
def get_instance(id)
|
||||
begin
|
||||
instance = AWS.ec2.instances[id]
|
||||
if instance.exists?
|
||||
return instance
|
||||
else
|
||||
raise "Instance #{id} does not exist"
|
||||
end
|
||||
rescue => e
|
||||
STDERR.puts e.message
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
20
src/vmm_mad/remotes/ec2/migrate
Executable file
20
src/vmm_mad/remotes/ec2/migrate
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/ec2/migrate_local
Executable file
20
src/vmm_mad/remotes/ec2/migrate_local
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
30
src/vmm_mad/remotes/ec2/poll
Executable file
30
src/vmm_mad/remotes/ec2/poll
Executable file
@ -0,0 +1,30 @@
|
||||
#!/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]
|
||||
id = ARGV[2]
|
||||
|
||||
ec2_drv = EC2Driver.new(host)
|
||||
|
||||
ec2_drv.poll(id, deploy_id)
|
||||
|
29
src/vmm_mad/remotes/ec2/reboot
Executable file
29
src/vmm_mad/remotes/ec2/reboot
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(host)
|
||||
|
||||
ec2_drv.reboot(deploy_id)
|
||||
|
20
src/vmm_mad/remotes/ec2/reset
Executable file
20
src/vmm_mad/remotes/ec2/reset
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
28
src/vmm_mad/remotes/ec2/restore
Executable file
28
src/vmm_mad/remotes/ec2/restore
Executable file
@ -0,0 +1,28 @@
|
||||
#!/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 = ARGV[2]
|
||||
|
||||
ec2_drv = EC2Driver.new(host)
|
||||
ec2_drv.restore(deploy_id)
|
29
src/vmm_mad/remotes/ec2/save
Executable file
29
src/vmm_mad/remotes/ec2/save
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]
|
||||
file = ARGV[1]
|
||||
host = ARGV[2]
|
||||
|
||||
ec2_drv = EC2Driver.new(host)
|
||||
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(host)
|
||||
|
||||
ec2_drv.shutdown(deploy_id)
|
||||
|
20
src/vmm_mad/remotes/ec2/snapshot_create
Executable file
20
src/vmm_mad/remotes/ec2/snapshot_create
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/ec2/snapshot_delete
Executable file
20
src/vmm_mad/remotes/ec2/snapshot_delete
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/ec2/snapshot_revert
Executable file
20
src/vmm_mad/remotes/ec2/snapshot_revert
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
Loading…
x
Reference in New Issue
Block a user