1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B #3234: add cleanup and timeout to delete function (#3238)

This commit is contained in:
Alejandro Huertas Herrero 2019-04-16 12:50:53 +02:00 committed by Tino Vázquez
parent 52897d6a1f
commit 1b513a92d5
3 changed files with 21 additions and 8 deletions

View File

@ -75,14 +75,14 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
# Helper provision functions
#######################################################################
def create(config)
def create(config, cleanup, timeout)
msg = 'OpenNebula is not running'
OneProvision::Utils.fail(msg) if OneProvision::Utils.one_running?
provision = OneProvision::Provision.new(SecureRandom.uuid)
provision.create(config)
provision.create(config, cleanup, timeout)
end
def configure(provision_id, force)

View File

@ -165,7 +165,7 @@ CommandParser::CmdParser.new(ARGV) do
CLEANUP_TIMEOUT = {
:name => 'cleanup_timeout',
:large => '--cleanup-timeout timeout',
:description => 'Change the default timeout when deleting VMs.'
:description => 'Change the default timeout when deleting VMs/Images.'
}
INCREMENTAL = {
@ -190,7 +190,12 @@ CommandParser::CmdParser.new(ARGV) do
FAIL_SKIP,
FAIL_QUIT]
CREATE_OPTIONS = [THREADS, MODES, PING_TIMEOUT, PING_RETRIES]
CREATE_OPTIONS = [THREADS,
MODES,
PING_TIMEOUT,
PING_RETRIES,
CLEANUP,
CLEANUP_TIMEOUT]
ONE_OPTIONS = CommandParser::OPTIONS +
CLIHelper::OPTIONS +
@ -207,7 +212,13 @@ CommandParser::CmdParser.new(ARGV) do
command :create, create_desc, :config, :options => CREATE_OPTIONS do
helper.parse_options(options)
helper.create(args[0])
if options[:cleanup_timeout].nil?
timeout = 20
else
timeout = options[:cleanup_timeout]
end
helper.create(args[0], (options.key? :cleanup), timeout)
end
###

View File

@ -165,8 +165,10 @@ module OneProvision
# Creates a new PROVISION
#
# @param config [String] Path to the configuration file
def create(config)
# @param config [String] Path to the configuration file
# @param cleanup [Boolean] True to delete running VMs and images
# @param timeout [Integer] Timeout for deleting running VMs
def create(config, cleanup, timeout)
Ansible.check_ansible_version
begin
@ -223,7 +225,7 @@ module OneProvision
0
rescue OneProvisionCleanupException
delete
delete(cleanup, timeout)
-1
end