mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #1327: disallow using template files and template options
This commit is contained in:
parent
3b86c195c8
commit
7d3b59fa0f
@ -572,4 +572,16 @@ EOT
|
||||
|
||||
[0, template]
|
||||
end
|
||||
|
||||
def self.create_template_options_used?(options)
|
||||
# Get the template options names as symbols. options hash
|
||||
# uses symbols
|
||||
template_options=OpenNebulaHelper::TEMPLATE_OPTIONS.map do |o|
|
||||
o[:name].to_sym
|
||||
end
|
||||
|
||||
# Check if one at least one of the template options is
|
||||
# in options hash
|
||||
(template_options-options.keys)!=template_options
|
||||
end
|
||||
end
|
||||
|
@ -86,6 +86,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
:options=>OpenNebulaHelper::TEMPLATE_OPTIONS do
|
||||
res=OpenNebulaHelper.create_template(options)
|
||||
|
||||
if args[0] && OpenNebulaHelper.create_template_options_used?(options)
|
||||
STDERR.puts "You can not use both template file and template"<<
|
||||
" creation options."
|
||||
next -1
|
||||
end
|
||||
|
||||
if res.first!=0
|
||||
STDERR.puts res.last
|
||||
next -1
|
||||
|
@ -114,6 +114,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
|
||||
if args[0]
|
||||
if OpenNebulaHelper.create_template_options_used?(options)
|
||||
STDERR.puts "You can not use both template file and template"<<
|
||||
" creation options."
|
||||
next -1
|
||||
end
|
||||
|
||||
begin
|
||||
template=File.read(args[0])
|
||||
rescue
|
||||
|
Loading…
x
Reference in New Issue
Block a user