diff --git a/src/cli/one_helper/oneprovision_helper.rb b/src/cli/one_helper/oneprovision_helper.rb index ec1fdf122c..08f1179ae6 100644 --- a/src/cli/one_helper/oneprovision_helper.rb +++ b/src/cli/one_helper/oneprovision_helper.rb @@ -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) diff --git a/src/cli/oneprovision b/src/cli/oneprovision index f8ff7eb58b..08f62a100c 100755 --- a/src/cli/oneprovision +++ b/src/cli/oneprovision @@ -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 ### diff --git a/src/oneprovision/lib/provision.rb b/src/oneprovision/lib/provision.rb index 39122662da..e26d5d99f6 100644 --- a/src/oneprovision/lib/provision.rb +++ b/src/oneprovision/lib/provision.rb @@ -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