Skip to content

Commit

Permalink
Updated, log message, access method for mandatory options.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitsethi committed Oct 26, 2012
1 parent 5eb5edd commit 573bcfd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
36 changes: 18 additions & 18 deletions lib/chef/knife/rackspace_base.rb
Expand Up @@ -74,34 +74,34 @@ def self.included(includer)
end

def connection
Chef::Log.debug("version #{Chef::Config[:knife][:rackspace_version]}") #config file
Chef::Log.debug("version #{config[:rackspace_version]}") #cli
Chef::Log.debug("rackspace_api_key #{Chef::Config[:knife][:rackspace_api_key]}")
Chef::Log.debug("rackspace_username #{Chef::Config[:knife][:rackspace_username]}")
Chef::Log.debug("rackspace_api_username #{Chef::Config[:knife][:rackspace_api_username]}")
Chef::Log.debug("rackspace_auth_url #{Chef::Config[:knife][:rackspace_auth_url]}")
Chef::Log.debug("rackspace_auth_url #{config[:rackspace_api_auth_url]}")
Chef::Log.debug("rackspace_endpoint #{Chef::Config[:knife][:rackspace_endpoint]}")
Chef::Log.debug("rackspace_endpoint #{config[:rackspace_endpoint]}")
if (Chef::Config[:knife][:rackspace_version] == 'v2') || (config[:rackspace_version] == 'v2')
Chef::Log.debug("version #{locate_config_value(:rackspace_version)}") #config file
Chef::Log.debug("version #{locate_config_value(:rackspace_version)}") #cli
Chef::Log.debug("rackspace_api_key #{locate_config_value(:rackspace_api_key)}")
Chef::Log.debug("rackspace_username #{locate_config_value(:rackspace_username)}")
Chef::Log.debug("rackspace_api_username #{locate_config_value(:rackspace_api_username)}")
Chef::Log.debug("rackspace_auth_url #{locate_config_value(:rackspace_auth_url)}")
Chef::Log.debug("rackspace_auth_url #{locate_config_value(:rackspace_api_auth_url)}")
Chef::Log.debug("rackspace_endpoint #{locate_config_value(:rackspace_endpoint)}")
Chef::Log.debug("rackspace_endpoint #{locate_config_value(:rackspace_endpoint)}")
if (locate_config_value(:rackspace_version) == 'v2') || (locate_config_value(:rackspace_version) == 'v2')
@connection ||= begin
connection = Fog::Compute.new(
:provider => 'Rackspace',
:version => 'v2',
:rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
:rackspace_username => (Chef::Config[:knife][:rackspace_username] || Chef::Config[:knife][:rackspace_api_username]),
:rackspace_auth_url => Chef::Config[:knife][:rackspace_api_auth_url] || config[:rackspace_api_auth_url],
:rackspace_endpoint => Chef::Config[:knife][:rackspace_endpoint] || config[:rackspace_endpoint]
:rackspace_api_key => locate_config_value(:rackspace_api_key),
:rackspace_username => (locate_config_value(:rackspace_username) || locate_config_value(:rackspace_api_username)),
:rackspace_auth_url => locate_config_value(:rackspace_api_auth_url) || locate_config_value(:rackspace_api_auth_url),
:rackspace_endpoint => locate_config_value(:rackspace_endpoint) || locate_config_value(:rackspace_endpoint)
)
end
else
@connection ||= begin
connection = Fog::Compute.new(
:provider => 'Rackspace',
:version => 'v1',
:rackspace_api_key => Chef::Config[:knife][:rackspace_api_key],
:rackspace_username => (Chef::Config[:knife][:rackspace_username] || Chef::Config[:knife][:rackspace_api_username]),
:rackspace_auth_url => Chef::Config[:knife][:rackspace_api_auth_url] || config[:rackspace_api_auth_url]
:rackspace_api_key => locate_config_value(:rackspace_api_key),
:rackspace_username => (locate_config_value(:rackspace_username) || locate_config_value(:rackspace_api_username)),
:rackspace_auth_url => locate_config_value(:rackspace_api_auth_url) || locate_config_value(:rackspace_api_auth_url)
)
end
end
Expand Down Expand Up @@ -151,7 +151,7 @@ def version_one?
end

def rackspace_api_version
version = Chef::Config[:knife][:rackspace_version] || 'v1'
version = locate_config_value(:rackspace_version) || 'v1'
version.downcase
end

Expand Down
6 changes: 3 additions & 3 deletions lib/chef/knife/rackspace_server_create.rb
Expand Up @@ -153,7 +153,7 @@ def tcp_test_ssh(hostname)
def run
$stdout.sync = true

unless Chef::Config[:knife][:image]
unless locate_config_value(:image)
ui.error("You have not provided a valid image value. Please note the short option for this value recently changed from '-i' to '-I'.")
exit 1
end
Expand All @@ -162,9 +162,9 @@ def run

server = connection.servers.create(
:name => node_name,
:image_id => Chef::Config[:knife][:image],
:image_id => locate_config_value(:image),
:flavor_id => locate_config_value(:flavor),
:metadata => Chef::Config[:knife][:rackspace_metadata]
:metadata => locate_config_value(:rackspace_metadata)
)

msg_pair("Instance ID", server.id)
Expand Down

0 comments on commit 573bcfd

Please sign in to comment.