mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #2259: Add configurable actions for instances
This commit is contained in:
parent
afbec25583
commit
eff878c697
@ -47,6 +47,13 @@ module Instance
|
|||||||
'unkn' => :terminated
|
'unkn' => :terminated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EC2_ACTIONS = {
|
||||||
|
:start => :resume,
|
||||||
|
:stop => :poweroff,
|
||||||
|
:terminate => :shutdown,
|
||||||
|
:reboot => :reboot
|
||||||
|
}
|
||||||
|
|
||||||
# Include terminated instances in the describe_instances xml
|
# Include terminated instances in the describe_instances xml
|
||||||
DESCRIBE_WITH_TERMINATED_INSTANCES = true
|
DESCRIBE_WITH_TERMINATED_INSTANCES = true
|
||||||
# Terminated VMs will be included in the list
|
# Terminated VMs will be included in the list
|
||||||
@ -234,7 +241,7 @@ module Instance
|
|||||||
def terminate_instances(params)
|
def terminate_instances(params)
|
||||||
perform_action(params, "terminate_instances.erb") { |vm|
|
perform_action(params, "terminate_instances.erb") { |vm|
|
||||||
if vm.status == 'runn'
|
if vm.status == 'runn'
|
||||||
vm.shutdown
|
vm.send(EC2_ACTIONS[:terminate])
|
||||||
else
|
else
|
||||||
vm.finalize
|
vm.finalize
|
||||||
end
|
end
|
||||||
@ -243,19 +250,19 @@ module Instance
|
|||||||
|
|
||||||
def start_instances(params)
|
def start_instances(params)
|
||||||
perform_action(params, "start_instances.erb") { |vm|
|
perform_action(params, "start_instances.erb") { |vm|
|
||||||
vm.resume
|
vm.send(EC2_ACTIONS[:start])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def stop_instances(params)
|
def stop_instances(params)
|
||||||
perform_action(params, "stop_instances.erb") { |vm|
|
perform_action(params, "stop_instances.erb") { |vm|
|
||||||
vm.stop
|
vm.send(EC2_ACTIONS[:stop])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def reboot_instances(params)
|
def reboot_instances(params)
|
||||||
perform_action(params, "reboot_instances.erb") { |vm|
|
perform_action(params, "reboot_instances.erb") { |vm|
|
||||||
vm.reboot
|
vm.send(EC2_ACTIONS[:reboot])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user