diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index 570ffd1a24..4518d633b3 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -31,13 +31,14 @@ module CLIHelper # :description => "Order by these columns, column starting with - means decreasing order" #} # - #FILTER = { - # :name => "filter", - # :short => "-f x,y,z", - # :large => "--filter x,y,z", - # :format => Array, - # :description => "Filter data. An array is specified with column=value pairs." - #} + FILTER = { + :name => "filter", + :short => "-f x,y,z", + :large => "--filter x,y,z", + :format => Array, + :description => "Filter data. An array is specified with\n"<< + " "*31<<"column=value pairs." + } # #HEADER = { # :name => "header", @@ -55,7 +56,7 @@ module CLIHelper } #OPTIONS = [LIST, ORDER, FILTER, HEADER, DELAY] - OPTIONS = [LIST, DELAY] + OPTIONS = [LIST, DELAY, FILTER] # Sets bold font def CLIHelper.scr_bold @@ -287,7 +288,47 @@ module CLIHelper }.compact.join(' ') end - # TBD def filter_data! + def filter_data!(data, filter) + # TBD: add more operators + # operators=/(==|=|!=|<|<=|>|>=)/ + operators=/(=)/ + + stems=filter.map do |s| + m=s.match(/^(.*?)#{operators}(.*?)$/) + if m + left, operator, right=m[1..3] + index=@default_columns.index(left.to_sym) + + if index + { + :left => left, + :operator => operator, + :right => right, + :index => index + } + else + STDERR.puts "Column '#{left}' not found" + exit(-1) + end + else + STDERR.puts "Expresion '#{s}' incorrect" + exit(-1) + end + end + + data.reject! do |d| + pass=true + + stems.each do |s| + if d[s[:index]]!=s[:right] + pass=false + break + end + end + + !pass + end + end # TBD def sort_data! end diff --git a/src/cli/command_parser.rb b/src/cli/command_parser.rb index ab6c05e33b..41bcce9b78 100644 --- a/src/cli/command_parser.rb +++ b/src/cli/command_parser.rb @@ -65,6 +65,9 @@ module CommandParser @args = args @options = Hash.new + @before_proc=nil + @comm_name=nil + define_default_formats instance_eval(&block) @@ -97,6 +100,12 @@ module CommandParser @name = str end + # Defines a proc to be called before any command + # @param [Proc] block + def before_proc(&block) + @before_proc = block + end + # Defines a block that will be used to parse the arguments # of the command. Formats defined using this method con be used # in the arguments section of the command method, when defining a new @@ -399,7 +408,7 @@ module CommandParser comm = @main elsif if @args[0] && !@args[0].match(/^-/) - comm_name = @args.shift.to_sym + @comm_name = comm_name = @args.shift.to_sym comm = @commands[comm_name] end end @@ -413,6 +422,8 @@ module CommandParser parse(extra_options) if comm + @before_proc.call if @before_proc + check_args!(comm_name, comm[:arity], comm[:args_format]) rc = comm[:proc].call @@ -428,9 +439,12 @@ module CommandParser private def parse(extra_options) + with_proc=Array.new + @cmdparse=OptionParser.new do |opts| merge = @available_options merge = @available_options + extra_options if extra_options + merge.flatten.each do |e| args = [] args << e[:short] if e[:short] @@ -440,16 +454,8 @@ module CommandParser opts.on(*args) do |o| if e[:proc] - rc = e[:proc].call(o, @options) - if rc.instance_of?(Array) - if rc[0] == 0 - options[e[:name].to_sym] = rc[1] - else - puts rc[1] - puts "option #{e[:name]}: Parsing error" - exit -1 - end - end + @options[e[:name].to_sym]=o + with_proc< String } + DRY={ + :name => 'dry', + :large => '--dry', + :description => 'Just print the template' + } + + CLIENT_OPTIONS=[ + { + :name => 'user', + :large => '--user name', + :description => 'User name used to connect to OpenNebula', + :format => String + }, + { + :name => 'password', + :large => '--password password', + :description => 'Password to authenticate with OpenNebula', + :format => String + }, + { + :name => 'endpoint', + :large => '--endpoint endpoint', + :description => 'URL of OpenNebula xmlrpc frontend', + :format => String + } + ] + TEMPLATE_OPTIONS=[ { :name => 'cpu', :large => '--cpu cpu', :description => - 'CPU percentage reserved for the VM (1=100% one CPU)', + "CPU percentage reserved for the VM (1=100% one\n"<< + " "*31<<"CPU)", :format => Float }, + { + :name => 'vcpu', + :large => '--vcpu vcpu', + :description => + "Number of virtualized CPUs", + :format => Integer + }, { :name => 'arch', :large => '--arch arch', @@ -118,39 +153,130 @@ EOT { :name => 'disk', :large => '--disk disk0,disk1', - :description => 'Disks to attach. To use a disk owned by other user use user[disk]', + :description => "Disks to attach. To use a disk owned by other\n"<< + " "*31<<"user use user[disk]", :format => Array }, { :name => 'network', :large => '--network network0,network1', - :description => 'Networks to attach. To use a network owned by other user use user[network]', + :description => "Networks to attach. To use a network owned by\n"<< + " "*31<<"other user use user[network]", :format => Array }, { :name => 'raw', :large => '--raw string', - :description => 'Raw string to add to the template. Not to be confused with the RAW attribute', + :description => "Raw string to add to the template. Not to be\n"<< + " "*31<<"confused with the RAW attribute", + :format => String + }, + { + :name => 'vnc', + :large => '--vnc', + :description => 'Add VNC server to the VM' + }, + { + :name => 'ssh', + :large => '--ssh [file]', + :description => "Add an ssh public key to the context. If the \n"<< + (' '*31)<<"file is omited then the user variable \n"<< + (' '*31)<<"SSH_PUBLIC_KEY will be used.", + :format => String, + :proc => lambda do |o, options| + if !o + [0, true] + else + [0, o] + end + end + }, + { + :name => 'net_context', + :large => '--net_context', + :description => 'Add network contextualization parameters' + }, + { + :name => 'context', + :large => '--context line1,line2,line3', + :format => Array, + :description => 'Lines to add to the context section' + }, + { + :name => 'boot', + :large => '--boot device', + :description => 'Select boot device (hd|fd|cdrom|network)', :format => String } ] - TEMPLATE_OPTIONS_VM=[TEMPLATE_NAME_VM]+TEMPLATE_OPTIONS + TEMPLATE_OPTIONS_VM=[TEMPLATE_NAME_VM]+TEMPLATE_OPTIONS+[DRY] OPTIONS = XML, NUMERIC, KILOBYTES class OneHelper - def initialize(secret=nil, endpoint=nil) - begin - @client = OpenNebula::Client.new(secret,endpoint) - rescue Exception => e - puts e.message - exit -1 + attr_accessor :client + + def self.get_client(options) + if defined?(@@client) + @@client + else + secret=nil + user=options[:user] + if user + password=options[:password]||self.get_password + secret="#{user}:#{password}" + end + + endpoint=options[:endpoint] + + @@client=OpenNebula::Client.new(secret, endpoint) end + end + + def self.client + if defined?(@@client) + @@client + else + self.get_client({}) + end + end + + if RUBY_VERSION>="1.9.3" + require 'io/console' + def self.get_password + print "Password: " + pass=nil + STDIN.noecho {|io| pass=io.gets } + puts + + pass.chop! if pass + pass + end + else + # This function is copied from ruby net/imap.rb + def self.get_password + print "Password: " + system("stty", "-echo") + begin + return gets.chop + ensure + system("stty", "echo") + print "\n" + end + end + end + + def initialize(secret=nil, endpoint=nil) + @client=nil @translation_hash = nil end + def set_client(options) + @client=OpenNebulaHelper::OneHelper.get_client(options) + end + def create_resource(options, &block) resource = factory @@ -369,7 +495,7 @@ EOT end def pool_to_array(pool) - if !pool.instance_of?(Hash) + if !pool.instance_of?(Hash) phash = pool.to_hash else phash = pool @@ -408,7 +534,7 @@ EOT def OpenNebulaHelper.rname_to_id(name, poolname) return 0, name.to_i if name.match(/^[0123456789]+$/) - client = OpenNebula::Client.new + client=OneHelper.client pool = case poolname when "HOST" then OpenNebula::HostPool.new(client) @@ -557,7 +683,7 @@ EOT template<<"#{section.upcase}=[\n" template<<" #{name.upcase}_UNAME=\"#{user}\",\n" if user - if object.match(/^\d$/) + if object.match(/^\d+$/) template<<" #{name.upcase}_ID=#{object}\n" else template<<" #{name.upcase}=\"#{object}\"\n" @@ -568,12 +694,74 @@ EOT [0, template] end + def self.create_context(options) + if !(options.keys & [:ssh, :net_context, :context]).empty? + lines=[] + + if options[:ssh] + if options[:ssh]==true + lines<<"SSH_PUBLIC_KEY=\"$USER[SSH_PUBLIC_KEY]\"" + else + begin + key=File.read(options[:ssh]).strip + rescue Exception => e + STDERR.puts e.message + exit(-1) + end + lines<<"SSH_PUBLIC_KEY=\"#{key}\"" + end + end + + if options[:net_context] && options[:network] + nets=options[:network].map {|n| parse_user_object(n).last } + + if nets!=nets.uniq + STDERR.puts "Network context generation from command "<< + "line is not supported for VMs with\n"<< + "more than one network with the same name." + exit(-1) + end + + nets.each_with_index do |name, index| + lines<<"ETH#{index}_IP = \"$NIC[IP, NETWORK=\\\"#{name}\\\"]\"" + lines<<"ETH#{index}_NETWORK = \"$NETWORK[NETWORK_ADDRESS, NETWORK=\\\"#{name}\\\"]\"" + lines<<"ETH#{index}_MASK = \"$NETWORK[NETWORK_MASK, NETWORK=\\\"#{name}\\\"]\"" + lines<<"ETH#{index}_GATEWAY = \"$NETWORK[GATEWAY, NETWORK=\\\"#{name}\\\"]\"" + lines<<"ETH#{index}_DNS = \"$NETWORK[DNS, NETWORK=\\\"#{name}\\\"]\"" + end + end + + lines+=options[:context] if options[:context] + + if !lines.empty? + "CONTEXT=[\n"<["HOST=#{host.name}"]}, false) end end diff --git a/src/cli/one_helper/oneimage_helper.rb b/src/cli/one_helper/oneimage_helper.rb index 0fa428f12e..0155273a64 100644 --- a/src/cli/one_helper/oneimage_helper.rb +++ b/src/cli/one_helper/oneimage_helper.rb @@ -53,7 +53,8 @@ class OneImageHelper < OpenNebulaHelper::OneHelper { :name => "prefix", :large => "--prefix prefix", - :description => "Device prefix for the disk (eg. hd, sd, xvd or vd)", + :description => "Device prefix for the disk (eg. hd, sd, xvd\n"<< + " "*31<<"or vd)", :format => String, :proc => lambda do |o, options| prefix=o.strip.downcase @@ -76,7 +77,9 @@ class OneImageHelper < OpenNebulaHelper::OneHelper :description => "Path of the image file", :format => String, :proc => lambda do |o, options| - if o[0,1]=='/' + if o.match(/^https?:\/\//) + next [0, o] + elsif o[0,1]=='/' path=o else path=Dir.pwd+"/"+o @@ -113,7 +116,8 @@ class OneImageHelper < OpenNebulaHelper::OneHelper :name => "source", :large => "--source source", :description => - "Source to be used. Useful for not file-based images", + "Source to be used. Useful for not file-based\n"<< + " "*31<<"images", :format => String }, { @@ -147,8 +151,8 @@ class OneImageHelper < OpenNebulaHelper::OneHelper { :name => "fstype", :large => "--fstype fstype", - :description => "Type of file system to be built. This can be "<< - "any value understood by mkfs unix command.", + :description => "Type of file system to be built. This can be \n"<< + " "*31<<"any value understood by mkfs unix command.", :format => String, :proc => lambda do |o, options| if !options[:type] || !(options[:type].upcase=='DATABLOCK') @@ -157,7 +161,8 @@ class OneImageHelper < OpenNebulaHelper::OneHelper [0, o] end end - } + }, + OpenNebulaHelper::DRY ] def self.rname @@ -318,7 +323,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper end template=create_image_variables( - options, template_options-[:persistent]) + options, template_options-[:persistent, :dry]) template<<"PERSISTENT=YES\n" if options[:persistent] diff --git a/src/cli/oneacct b/src/cli/oneacct index 728984a53d..97a269c029 100755 --- a/src/cli/oneacct +++ b/src/cli/oneacct @@ -37,6 +37,7 @@ cmd = CommandParser::CmdParser.new(ARGV) do description "" version OpenNebulaHelper::ONE_VERSION + client = OpenNebulaHelper::OneHelper.get_client({}) option AcctHelper::ACCT_OPTIONS + CommandParser::OPTIONS @@ -53,10 +54,8 @@ cmd = CommandParser::CmdParser.new(ARGV) do :xpath => options[:xpath] } - client = OpenNebula::Client.new pool = OpenNebula::VirtualMachinePool.new(client) - if options[:json] || options[:xml] xml_str = pool.accounting_xml(filter_flag, common_opts) if OpenNebula.is_error?(xml_str) @@ -85,6 +84,7 @@ cmd = CommandParser::CmdParser.new(ARGV) do exit -1 end + if ( start_time != -1 or end_time != -1 ) AcctHelper.print_start_end_time_header(start_time, end_time) end diff --git a/src/cli/oneacl b/src/cli/oneacl index 7dc5281c2a..9ad216f9a5 100755 --- a/src/cli/oneacl +++ b/src/cli/oneacl @@ -36,10 +36,14 @@ cmd = CommandParser::CmdParser.new(ARGV) do helper = OneAclHelper.new + before_proc do + helper.set_client(options) + end + ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS + set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS ######################################################################## # Formatters for arguments diff --git a/src/cli/onecluster b/src/cli/onecluster index 9fc41c2e6b..0362d908bb 100755 --- a/src/cli/onecluster +++ b/src/cli/onecluster @@ -36,10 +36,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper = OneClusterHelper.new + before_proc do + helper.set_client(options) + end + ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS + set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS list_options = CLIHelper::OPTIONS list_options << OpenNebulaHelper::XML diff --git a/src/cli/onedatastore b/src/cli/onedatastore index 550d015003..9f58d16f6c 100755 --- a/src/cli/onedatastore +++ b/src/cli/onedatastore @@ -37,10 +37,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper = OneDatastoreHelper.new + before_proc do + helper.set_client(options) + end + ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS + set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS list_options = CLIHelper::OPTIONS list_options << OpenNebulaHelper::XML diff --git a/src/cli/onegroup b/src/cli/onegroup index bb191bc84d..6fc81e561e 100755 --- a/src/cli/onegroup +++ b/src/cli/onegroup @@ -36,10 +36,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper = OneGroupHelper.new + before_proc do + helper.set_client(options) + end + ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS + set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS list_options = CLIHelper::OPTIONS list_options << OpenNebulaHelper::XML diff --git a/src/cli/onehost b/src/cli/onehost index d08a487223..364dfcaf61 100755 --- a/src/cli/onehost +++ b/src/cli/onehost @@ -37,10 +37,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper = OneHostHelper.new + before_proc do + helper.set_client(options) + end + ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS + set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS IM = { :name => "im", diff --git a/src/cli/oneimage b/src/cli/oneimage index 8c5d8e16a3..dfc0735f3f 100755 --- a/src/cli/oneimage +++ b/src/cli/oneimage @@ -37,10 +37,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper = OneImageHelper.new + before_proc do + helper.set_client(options) + end + ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS + set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS list_options = CLIHelper::OPTIONS list_options << OpenNebulaHelper::XML @@ -72,6 +76,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper.filterflag_to_i(arg) end + format(:type, 'Image type: OS, DATABLOCK or CDROM') do |arg| + type=arg.strip.upcase + if %w{OS DATABLOCK CDROM}.include? type + [0, type] + else + [1, "Image type not supported. Must be OS, DATABLOCK or CDROM."] + end + end + ######################################################################## # Commands ######################################################################## @@ -103,7 +116,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :create, create_desc, [:file, nil], :options=>CREATE_OPTIONS + OneImageHelper::TEMPLATE_OPTIONS do - if options[:datastore].nil? + if options[:datastore].nil? && !options[:dry] STDERR.puts "Datastore to save the image is mandatory: " STDERR.puts "\t -d datastore_id" exit -1 @@ -130,6 +143,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do template = res.last end + if options[:dry] + puts template + exit 0 + end + image.allocate(template, options[:datastore]) rescue => e STDERR.puts e.messsage diff --git a/src/cli/onetemplate b/src/cli/onetemplate index a69bece307..396add5082 100755 --- a/src/cli/onetemplate +++ b/src/cli/onetemplate @@ -36,10 +36,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper = OneTemplateHelper.new + before_proc do + helper.set_client(options) + end + ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS + set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS list_options = CLIHelper::OPTIONS list_options << OpenNebulaHelper::XML @@ -98,7 +102,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :create, create_desc, [:file, nil], :options => - [OneTemplateHelper::VM_NAME]+OpenNebulaHelper::TEMPLATE_OPTIONS do + [OneTemplateHelper::VM_NAME]+OpenNebulaHelper::TEMPLATE_OPTIONS+ + [OpenNebulaHelper::DRY] do if args[0] && OpenNebulaHelper.create_template_options_used?(options) STDERR.puts "You can not use both template file and template"<< @@ -121,7 +126,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do template = res.last end - tmpl.allocate(template) + if options[:dry] + puts template + exit 0 + else + tmpl.allocate(template) + end rescue => e STDERR.puts e.messsage exit -1 diff --git a/src/cli/oneuser b/src/cli/oneuser index 12600e0412..5973f6e2ee 100755 --- a/src/cli/oneuser +++ b/src/cli/oneuser @@ -37,10 +37,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do usage "`oneuser` [] []" version OpenNebulaHelper::ONE_VERSION + helper = OneUserHelper.new + + before_proc do + helper.set_client(options) + end + ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS + set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS list_options = CLIHelper::OPTIONS list_options << OpenNebulaHelper::XML @@ -57,7 +63,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do SHA1={ :name => "sha1", :large => "--sha1", - :description => "The password will be hashed using the sha1 algorithm" + :description => "The password will be hashed using the sha1\n"<< + " "*31<<"algorithm" } SSH={ @@ -135,12 +142,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do end set :format, :userid, OneUserHelper.to_id_desc do |arg| - helper = OneUserHelper.new helper.to_id(arg) end set :format, :userid_list, OneUserHelper.list_to_id_desc do |arg| - helper = OneUserHelper.new helper.list_to_id(arg) end @@ -164,8 +169,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :create, create_desc, :username, [:password, nil], :options=>create_options do - helper = OneUserHelper.new - if args[1] pass = args[1] else @@ -190,8 +193,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :update, update_desc, :userid, [:file, nil] do - helper = OneUserHelper.new - helper.perform_action(args[0],options,"modified") do |user| str = OpenNebulaHelper.update_template(args[0], user, args[1]) user.update(str) @@ -204,8 +205,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :quota, quota_desc, :userid, [:file, nil] do - helper = OneUserHelper.new - helper.perform_action(args[0], options, "modified") do |user| str = OneQuotaHelper.set_quota(user, args[1]) rc = user.set_quota(str) @@ -224,8 +223,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :batchquota, batchquota_desc, [:range, :userid_list], [:file, nil] do - helper = OneUserHelper.new - batch_str = OneQuotaHelper.get_batch_quota(args[1]) helper.perform_actions(args[0], options, "modified") do |user| @@ -282,7 +279,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :delete, delete_desc, [:range, :userid_list] do - helper = OneUserHelper.new helper.perform_actions(args[0], options, "deleted") do |user| user.delete end @@ -294,8 +290,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :passwd, passwd_desc, :userid, [:password, nil], :options=>create_options do - helper = OneUserHelper.new - if args[1] pass = args[1] else @@ -317,7 +311,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :chgrp, chgrp_desc, [:range, :userid_list], :groupid do - helper = OneUserHelper.new helper.perform_actions(args[0],options,"Group changed") do |user| user.chgrp(args[1].to_i) end @@ -344,8 +337,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do exit_with_code 0, "An Auth driver should be specified" end - helper = OneUserHelper.new - if args[2] pass = args[2] else @@ -369,7 +360,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :list, list_desc, :options=>list_options do - helper = OneUserHelper.new helper.list_pool(options) end @@ -380,7 +370,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :show, show_desc, [:userid, nil], :options=>OpenNebulaHelper::XML do user=args[0] || OpenNebula::User::SELF - helper = OneUserHelper.new helper.show_resource(user,options) end diff --git a/src/cli/onevm b/src/cli/onevm index 9d612629d3..0e1f3c15de 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -36,6 +36,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper = OneVMHelper.new + before_proc do + helper.set_client(options) + end TYPE={ :name => "type", @@ -56,7 +59,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS + set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS ######################################################################## # Formatters for arguments @@ -139,11 +142,17 @@ cmd=CommandParser::CmdParser.new(ARGV) do template = res.last end + rescue Exception => e STDERR.puts "Error reading template." next -1 end + if options[:dry] + puts template + exit 0 + end + number.times do exit_code = helper.create_resource(options) do |vm| error = vm.allocate(template) diff --git a/src/cli/onevnet b/src/cli/onevnet index 7c28994113..12638fc2a8 100755 --- a/src/cli/onevnet +++ b/src/cli/onevnet @@ -37,10 +37,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper = OneVNetHelper.new + before_proc do + helper.set_client(options) + end + ######################################################################## # Global Options ######################################################################## - set :option, CommandParser::OPTIONS + set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS CREATE_OPTIONS = [OneClusterHelper::CLUSTER]