lib/vmc/cli/service/create.rb in cloulu-0.6.6 vs lib/vmc/cli/service/create.rb in cloulu-0.7.0

- old
+ new

@@ -9,10 +9,11 @@ desc "Create a service" group :services, :manage input :offering, :desc => "What kind of service (e.g. redis, mysql)", :argument => :optional, :from_given => offerings_from_label input :name, :desc => "Name for your service", :argument => :optional + input :options, :desc => "Service options", :argument => :optional input :plan, :desc => "Service plan", :from_given => find_by_name_insensitive("plan"), :default => proc { |plans| plans.find { |p| p.name == "D100" } || interact @@ -70,10 +71,21 @@ service.vendor = offering.label service.version = offering.version service.tier = v1_service_tier(offering) end + if service.name.start_with?("user_provided") + keys, values = input[:options, service.type] + + plan_option = {} + keys.each_index do |index| + plan_option[keys[index]] = values[index] + end + + service.options = {:plan_option => plan_option} + end + with_progress("Creating service #{c(service.name, :name)}") do service.create! end if app = input[:app] @@ -98,9 +110,20 @@ end def ask_name(offering) random = sprintf("%x", rand(1000000)) ask "Name?", :default => "#{offering.label}-#{random}" + end + + def ask_options(offering) + begin + keys = ask "Option keys? (with out empty space)" , :default => "host,name,passwd" + keys = keys.sub(" ","").split(",") + values = ask "Option values? (with out empty space)" , :default => "127.0.0.1,service_name,service_passwd" + values = values.sub(" ","").split(",") + err "Keys and Values are not correct. input again.\n" if keys.length != values.length + end while keys.length != values.length + return keys, values end def ask_plan(plans, default_plan = nil) ask "Which plan?", :choices => plans.sort_by(&:name),