mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-05 21:57:24 +03:00
feature #595: cleanup comments and code
This commit is contained in:
parent
c57a0959d1
commit
62bb25a2e0
@ -15,9 +15,7 @@
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Set up the environment for the driver #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Set up the environment for the driver
|
||||
|
||||
EC2_LOCATION = ENV["EC2_HOME"]
|
||||
|
||||
@ -45,15 +43,10 @@ require "VirtualMachineDriver"
|
||||
require "CommandManager"
|
||||
require "rexml/document"
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# The main class for the EC2 driver #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# The main class for the EC2 driver
|
||||
class EC2Driver < VirtualMachineDriver
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# EC2 commands constants #
|
||||
# ------------------------------------------------------------------------ #
|
||||
# EC2 commands constants
|
||||
EC2 = {
|
||||
:run => "#{EC2_LOCATION}/bin/ec2-run-instances",
|
||||
:terminate => "#{EC2_LOCATION}/bin/ec2-terminate-instances",
|
||||
@ -62,9 +55,7 @@ class EC2Driver < VirtualMachineDriver
|
||||
:authorize => "#{EC2_LOCATION}bin/ec2-authorize"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# EC2 constructor, loads defaults for the EC2Driver #
|
||||
# ------------------------------------------------------------------------ #
|
||||
# EC2 constructor, loads defaults for the EC2Driver
|
||||
def initialize(ec2_conf = nil)
|
||||
|
||||
if !EC2_JVM_CONCURRENCY
|
||||
@ -97,9 +88,7 @@ class EC2Driver < VirtualMachineDriver
|
||||
end
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# DEPLOY action, also sets ports and ip if needed #
|
||||
# ------------------------------------------------------------------------ #
|
||||
# DEPLOY action, also sets ports and ip if needed
|
||||
def deploy(id, host, remote_dfile, not_used)
|
||||
|
||||
local_dfile = get_local_deployment_file(remote_dfile)
|
||||
@ -134,8 +123,9 @@ class EC2Driver < VirtualMachineDriver
|
||||
ec2 = all_ec2_elements[0]
|
||||
else
|
||||
send_message(ACTION[:deploy],RESULT[:failure],id,
|
||||
"Can not find EC2 element in deployment file #{local_dfile}" +
|
||||
" or couldn't find any EC2 site matching one of the template.")
|
||||
"Can not find EC2 element in deployment file "<<
|
||||
"#{local_dfile} or couldn't find any EC2 site matching "<<
|
||||
"one of the template.")
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -184,23 +174,17 @@ class EC2Driver < VirtualMachineDriver
|
||||
send_message(ACTION[:deploy],RESULT[:success],id,deploy_id)
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Shutdown a EC2 instance #
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Shutdown a EC2 instance
|
||||
def shutdown(id, host, deploy_id, not_used)
|
||||
ec2_terminate(ACTION[:shutdown], id, deploy_id)
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Cancel a EC2 instance #
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Cancel a EC2 instance
|
||||
def cancel(id, host, deploy_id, not_used)
|
||||
ec2_terminate(ACTION[:cancel], id, deploy_id)
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Get info (IP, and state) for a EC2 instance #
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Get info (IP, and state) for a EC2 instance
|
||||
def poll(id, host, deploy_id, not_used)
|
||||
|
||||
info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \
|
||||
@ -227,7 +211,7 @@ class EC2Driver < VirtualMachineDriver
|
||||
when "pending"
|
||||
info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]}"
|
||||
when "running"
|
||||
info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]}" \
|
||||
info<<" #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]}"<<
|
||||
" IP=#{monitor_data[1]}"
|
||||
when "shutting-down","terminated"
|
||||
info << " #{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:deleted]}"
|
||||
@ -265,9 +249,7 @@ private
|
||||
end
|
||||
end
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# EC2Driver Main program
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
ec2_conf = ARGV.last
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user