Feature #1852: Rename deploy action to recover, works from any failure state

This commit is contained in:
Carlos Martín committed 2013-06-03 17:52:41 +02:00
1 parent 02dffcfb3c
commit cc334ec551
4 files changed
+23 -18

No files matched your search

+8 -7
View File
@@ -367,8 +367,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
shutdown_desc = <<-EOT.unindent
Shutdown a service.
From RUNNING or UNKNOWN shutdowna the Service
From FAILED_UNDEPLOYING continues shutting down the Service
From RUNNING or UNKNOWN shuts down the Service
EOT
command :shutdown, shutdown_desc, [:range, :serviceid_list] do
@@ -386,15 +385,17 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
#
# Deploy
# Recover
#
deploy_desc = <<-EOT.unindent
Deploy a service
recover_desc = <<-EOT.unindent
Recover a failed service
From FAILED_DEPLOYING continues deploying the Service
From FAILED_SCALING continues scaling the Service
From FAILED_UNDEPLOYING continues shutting down the Service
EOT
command :deploy, deploy_desc, [:range, :serviceid_list] do
command :recover, recover_desc, [:range, :serviceid_list] do
client = Service::Client.new(
:username => options[:username],
:password => options[:password],
@@ -402,7 +403,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
:user_agent => USER_AGENT)
Service.perform_actions(args[0]) { |service_id|
json_action = Service.build_json_action('deploy')
json_action = Service.build_json_action('recover')
client.post("#{RESOURCE_PATH}/#{service_id}/action", json_action)
}
+2 -2
View File
@@ -184,8 +184,8 @@ post '/service/:id/action' do
rc = case action['perform']
when 'shutdown'
service.shutdown
when 'deploy'
service.deploy
when 'recover', 'deploy'
service.recover
when 'chown'
if opts && opts['owner_id']
args = Array.new
+2 -1
View File
@@ -85,7 +85,8 @@ module OpenNebula
# Sets a new cardinality for this role
# @param [Integer] the new cardinality
def set_cardinality(target_cardinality)
msg = "Role #{name} scaling up from #{cardinality} to #{target_cardinality} nodes"
dir = target_cardinality > cardinality ? "up" : "down"
msg = "Role #{name} scaling #{dir} from #{cardinality} to #{target_cardinality} nodes"
Log.info LOG_COMP, msg, @service.id()
@service.log_info(msg)
+11 -8
View File
@@ -191,17 +191,15 @@ module OpenNebula
end
end
# Deploy the service. This action is called when the Service is
# in FAILED_DEPLOYING and the user has fixed the problem and wants
# the deployment to continue
# Recover a failed service. This action is called when the Service is
# in FAILED_DEPLOYING or FAILED_SCALING and the user has fixed
# the problem and wants the action to continue
# @return [nil, OpenNebula::Error] nil in case of success, Error
# otherwise
def deploy
def recover
if [Service::STATE['FAILED_DEPLOYING']].include?(self.state)
self.set_state(Service::STATE['DEPLOYING'])
return self.update
# TODO: hijacked the deploy action to continue a failed scaling operation
elsif self.state == Service::STATE['FAILED_SCALING']
@roles.each do |name, role|
if role.state == Role::STATE['FAILED_SCALING']
@@ -211,11 +209,16 @@ module OpenNebula
end
self.set_state(Service::STATE['SCALING'])
return self.update
elsif self.state == Service::STATE['FAILED_UNDEPLOYING']
self.set_state(Service::STATE['UNDEPLOYING'])
else
return OpenNebula::Error.new("Action deploy: Wrong state" \
return OpenNebula::Error.new("Action recover: Wrong state" \
" #{self.state_str()}")
end
return self.update
end
# Delete the service. All the VMs are also deleted from OpenNebula.