diff --git a/README.md b/README.md index 2b10bb75..934cad9e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/chef/knife/openstack_base.rb b/lib/chef/knife/openstack_base.rb index 05e0f1f2..4344b953 100644 --- a/lib/chef/knife/openstack_base.rb +++ b/lib/chef/knife/openstack_base.rb @@ -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}") @@ -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] diff --git a/spec/unit/openstack_server_create_spec.rb b/spec/unit/openstack_server_create_spec.rb index 45d6835b..f19573ff 100644 --- a/spec/unit/openstack_server_create_spec.rb +++ b/spec/unit/openstack_server_create_spec.rb @@ -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