Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3 fix secgroup case #86

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions lib/cluster_chef/security_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,30 @@ def self.get_or_create group_name, description
group = all[group_name] || ClusterChef.fog_connection.security_groups.get(group_name)
if ! group
self.step(group_name, "creating (#{description})", :blue)
group = all[group_name] = ClusterChef.fog_connection.security_groups.new(:name => group_name, :description => description, :connection => ClusterChef.fog_connection)
group.save
begin
group = ClusterChef.fog_connection.security_groups.new(:name => group_name, :description => description, :connection => ClusterChef.fog_connection)
group.save
rescue Fog::Service::Error => fog_err
# I'm worried that in the future other exception types may be
# returned by the group.save() call, however at this time
# the only error returned by
# Fog::AWS::Compute::Real::create_security_group.rb currently
# (fog 0.8.2) is the call to
# Fog::AWS::Compute::Error.new("InvalidGroup.Duplicate => The security group '#{name}' already exists")
# So I'm going to just accomodate the case where Fog::Service::Error is
# due to the prior existence of the group.
ClusterChef.fog_connection.security_groups.all().each do |g|
if g.name.downcase == group_name.downcase then
self.step(group_name, "group_name isn't matching in a case-sensitive manner. Use #{g.name} instead")
group = g
break
end
end
if not group then
raise fog_err
end
end
all[group_name] = group
end
group
end
Expand Down