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 Jun 1, 2015
1 parent fba367c commit a46f23f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ This plugin provides the following Knife subcommands. Specific command options c
knife openstack server create
-----------------------------

Provisions a new server in an OpenStack Compute cloud and then perform a Chef bootstrap (using the SSH protocol). The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists (provided by the provisioning). It is primarily intended for Chef Client systems that talk to a Chef server. By default the server is bootstrapped using the [chef-full](https://github.com/opscode/chef/blob/master/chef/lib/chef/knife/bootstrap/chef-full.erb) template (default since the 10.10 release). This may be overridden using the `-d` or `--template-file` command options. If you do not have public IP addresses, use the `--private-network` option to use the private IP address for bootstrapping or `--bootstrap-network NAME` to specify an alternate network. Please see `knife openstack server create --help` for all of the supported options.
Provisions a new server in an OpenStack Compute cloud and then perform a Chef bootstrap (using the SSH protocol). The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists (provided by the provisioning). It is primarily intended for Chef Client systems that talk to a Chef server. By default the server is bootstrapped using the [chef-full](https://github.com/opscode/chef/blob/master/chef/lib/chef/knife/bootstrap/chef-full.erb) template (default since the 10.10 release). This may be overridden using the `-d` or `--template-file` command options. If you do not have public IP addresses, use the `--openstack-private-network` option to use the private IP address for bootstrapping. In addition, you can use the `--bootstrap-network NAME` option to specify an alternate network for either a private or public network. If a network name isn't specified, the default name will be `'public'` for a public network and `'private'` for a private network e.g. when the `--openstack-private-network` option is specified. Please see `knife openstack server create --help` for all of the supported options.

knife openstack server delete
-----------------------------
Expand Down
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 a46f23f

Please sign in to comment.