Skip to content

Commit

Permalink
Merge pull request #87 from opscode/adamed/knife-395
Browse files Browse the repository at this point in the history
KNIFE-395: Add support for setting service endpoint type
  • Loading branch information
Adam Edwards committed Feb 22, 2014
2 parents 8b8fd13 + fef9ee8 commit 30f17db
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ If your OpenStack deployment is over SSL, but does not have a valid certificate,

knife[:openstack_insecure] = true

If you need to use alternate service endpoints for communicating with OpenStack, you can set the following option:

knife[:openstack_endpoint_type] = "internalURL"

You also have the option of passing your OpenStack API Username/Password into the individual knife subcommands using the `-A` (or `--openstack-username`) `-K` (or `--openstack-password`) command options

# provision a new image named kb01
Expand Down
8 changes: 8 additions & 0 deletions lib/chef/knife/openstack_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,25 @@ def self.included(includer)
:description => "Your OpenStack API endpoint",
:proc => Proc.new { |endpoint| Chef::Config[:knife][:openstack_auth_url] = endpoint }

option :openstack_endpoint_type,
:long => "--openstack-endpoint-type ENDPOINT_TYPE",
:description => "OpenStack endpoint type to use (publicURL, internalURL, adminURL)",
:proc => Proc.new { |type| Chef::Config[:knife][:openstack_endpoint_type] = type }

option :openstack_insecure,
:long => "--insecure",
:description => "Ignore SSL certificate on the Auth URL",
:boolean => true,
:default => false,
:proc => Proc.new { |key| Chef::Config[:knife][:openstack_insecure] = key }

end
end

def connection
Chef::Log.debug("openstack_username #{Chef::Config[:knife][:openstack_username]}")
Chef::Log.debug("openstack_auth_url #{Chef::Config[:knife][:openstack_auth_url]}")
Chef::Log.debug("openstack_endpoint_type #{Chef::Config[:knife][:openstack_endpoint_type] || 'publicURL' }")
Chef::Log.debug("openstack_tenant #{Chef::Config[:knife][:openstack_tenant]}")
Chef::Log.debug("openstack_insecure #{Chef::Config[:knife][:openstack_insecure].to_s}")

Expand All @@ -80,6 +87,7 @@ def connection
:openstack_username => Chef::Config[:knife][:openstack_username],
:openstack_api_key => Chef::Config[:knife][:openstack_password],
:openstack_auth_url => Chef::Config[:knife][:openstack_auth_url],
:openstack_endpoint_type => Chef::Config[:knife][:openstack_endpoint_type],
:openstack_tenant => Chef::Config[:knife][:openstack_tenant],
:connection_options => {
:ssl_verify_peer => !Chef::Config[:knife][:openstack_insecure]
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/openstack_server_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
@options[:ssh_port][:default].should == '22'
@options[:ssh_user][:default].should == 'root'
end

it "doesn't set an OpenStack endpoint type by default" do
Chef::Config[:knife][:openstack_endpoint_type].should == nil
end
end

describe "run" do
Expand Down

0 comments on commit 30f17db

Please sign in to comment.