Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

adding option to disable public IP allocation #8

Merged
merged 1 commit into from

2 participants

@lusis
Collaborator

Provides a method to disable the allocation of a public IP mapping for a new instance.

@wfarr wfarr commented on the diff
lib/chef/knife/cs_server_create.rb
@@ -228,15 +234,15 @@ def validate_options
def find_or_create_public_ip(server, connection)
nic = connection.get_server_default_nic(server) || {}
- if nic['type'] == 'Virtual' then
+ #puts "#{ui.color("Not allocating public IP for server", :red)}" unless config[:public_ip]
@wfarr
wfarr added a note

Looks like a commented line crept in here. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lusis
Collaborator

Any chance this will get merged?

@lusis
Collaborator

Just pinging on this request again.

@lusis lusis merged commit 7aee6ca into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 10, 2012
  1. @lusis
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 4 deletions.
  1. +2 −0  README.rdoc
  2. +10 −4 lib/chef/knife/cs_server_create.rb
View
2  README.rdoc
@@ -51,6 +51,8 @@ system so it can run Chef Client with a Chef Server. The main assumption is a ba
intended for Chef Client systems that talk to a Chef server. By default the server is bootstrapped using the {ubuntu10.04-gems}[https://github.com/opscode/chef/bl
ob/master/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb] template. This can be overridden using the <tt>-d</tt> or <tt>--template-file</tt> command options.
+By default, new servers are allocated a public IP address mapping to the CloudStack private IP address. If you do not want this behavior, pass the <tt>--no-public-ip</tt> option.
+
==== Port forwarding rules for virtual networks
The <tt>--port-rules</tt> option takes a comma separated list of port forwarding rules. These rules are created on the
virtual public ip address of the server. Note that this option only applies to servers using a virtual network; it is
View
14 lib/chef/knife/cs_server_create.rb
@@ -65,6 +65,12 @@ class CsServerCreate < Chef::Knife
:proc => lambda { |n| n.split(/[\s,]+/) },
:default => []
+ option :public_ip,
+ :long => "--[no-]public-ip",
+ :description => "Allocate a public IP for this server",
+ :boolean => true,
+ :default => true
+
option :chef_node_name,
:short => "-N NAME",
:long => "--node-name NAME",
@@ -228,15 +234,15 @@ def validate_options
def find_or_create_public_ip(server, connection)
nic = connection.get_server_default_nic(server) || {}
- if nic['type'] == 'Virtual' then
+ #puts "#{ui.color("Not allocating public IP for server", :red)}" unless config[:public_ip]
@wfarr
wfarr added a note

Looks like a commented line crept in here. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if (config[:public_ip] == false) || (nic['type'] != 'Virtual') then
+ nic['ipaddress']
+ else
# create ip address, ssh forwarding rule and optional forwarding rules
ip_address = connection.associate_ip_address(server['zoneid'])
ssh_rule = connection.create_port_forwarding_rule(ip_address['id'], "22", "TCP", "22", server['id'])
create_port_forwarding_rules(ip_address['id'], server['id'], connection)
ssh_rule['ipaddress']
- else
- # otherwise return the nic ip address
- nic['ipaddress']
end
end
Something went wrong with that request. Please try again.