Skip to content

Commit

Permalink
Allow users to specify alternate private networks.
Browse files Browse the repository at this point in the history
  • Loading branch information
elbandito committed May 28, 2015
1 parent fba367c commit cab046b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/chef/knife/openstack_server_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ def before_bootstrap
# Use SSH password either specified from command line or from openstack server instance
config[:ssh_password] = locate_config_value(:ssh_password) || server.password unless config[:openstack_ssh_key_id]

# private_network means bootstrap_network = 'private'
config[:bootstrap_network] = 'private' if config[:private_network]
# The bootstrap network is always initialised to 'public' when a network name isn't specified. Therefore,
# only set the bootstrap network to 'private' if still initialised to public and nothing was specified for
# the private network name.
config[:bootstrap_network] = 'private' if (config[:private_network] && config[:bootstrap_network] == 'public')

# Which IP address to bootstrap
unless config[:network] # --no-network
Expand Down
15 changes: 15 additions & 0 deletions spec/unit/openstack_server_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@
@instance.before_bootstrap
expect(@instance.config[:ssh_password]).to be == server_password
end

it "configures the default private bootstrap network to use 'private'" do
allow(@instance.server).to receive(:addresses).and_return({"private"=>[{"version"=>4, "addr"=>"127.0.0.1"}]})
@instance.config[:private_network] = true
@instance.before_bootstrap
expect(@instance.config[:bootstrap_network]).to be == 'private'
end

it "configures the bootstrap to use alternate private network" do
allow(@instance.server).to receive(:addresses).and_return({"secure"=>[{"version"=>4, "addr"=>"127.0.0.1"}]})
@instance.config[:bootstrap_network] = 'secure'
@instance.config[:private_network] = true
@instance.before_bootstrap
expect(@instance.config[:bootstrap_network]).to be == 'secure'
end
end

describe "#post_connection_validations" do
Expand Down

0 comments on commit cab046b

Please sign in to comment.