lib/vagrant-rackspace/config.rb in vagrant-rackspace-0.1.4 vs lib/vagrant-rackspace/config.rb in vagrant-rackspace-0.1.5

- old
+ new

@@ -20,11 +20,11 @@ # The compute_url to access RackSpace. If nil, it will default # to DFW. # (formerly know as 'endpoint') # - # expected to be a string url - + # expected to be a string url - # 'https://dfw.servers.api.rackspacecloud.com/v2' # 'https://ord.servers.api.rackspacecloud.com/v2' # 'https://lon.servers.api.rackspacecloud.com/v2' # # alternatively, can use constants if you require 'fog/rackspace' in your Vagrantfile @@ -52,10 +52,16 @@ # This should match the private key configured with `config.ssh.private_key_path`. # # @return [String] attr_accessor :public_key_path + # Alternately, if a keypair were already uploaded to Rackspace, + # the key name could be provided. + # + # @return [String] + attr_accessor :key_name + # The option that indicates RackConnect usage or not. # # @return [Boolean] attr_accessor :rackconnect @@ -152,24 +158,27 @@ @networks.delete net_id end end def validate(machine) - errors = [] + errors = _detected_errors errors << I18n.t("vagrant_rackspace.config.api_key_required") if !@api_key errors << I18n.t("vagrant_rackspace.config.username_required") if !@username + errors << I18n.t("one of vagrant.rackspace.config.key_name or vagrant.rackspace.config.public_key_path required") if !@key_name && !@public_key_path { :rackspace_compute_url => @rackspace_compute_url, :rackspace_auth_url => @rackspace_auth_url }.each_pair do |key, value| errors << I18n.t("vagrant_rackspace.config.invalid_uri", :key => key, :uri => value) unless value.nil? || valid_uri?(value) end - public_key_path = File.expand_path(@public_key_path, machine.env.root_path) - if !File.file?(public_key_path) - errors << I18n.t("vagrant_rackspace.config.public_key_not_found") + if !@key_name + public_key_path = File.expand_path(@public_key_path, machine.env.root_path) + if !File.file?(public_key_path) + errors << I18n.t("vagrant_rackspace.config.public_key_not_found") + end end { "RackSpace Provider" => errors } end