module Blimpy::SecurityGroups
Public Class Methods
create_group(fog, ports)
click to toggle source
# File lib/blimpy/securitygroups.rb, line 30 def self.create_group(fog, ports) name = group_id(ports) group = fog.security_groups.create(:name => name, :description => "Custom Blimpy security group for #{ports.to_a}") unless ports.is_a? Set ports = Set.new(ports) end ports.each do |port| group.authorize_port_range(port .. port) end name end
ensure_group(fog, ports)
click to toggle source
# File lib/blimpy/securitygroups.rb, line 19 def self.ensure_group(fog, ports) name = group_id(ports) exists = fog.security_groups.get(name) if exists.nil? name = create_group(fog, ports) end name end
group_id(ports)
click to toggle source
# File lib/blimpy/securitygroups.rb, line 6 def self.group_id(ports) if ports.nil? or ports.empty? return nil end unless ports.is_a? Set ports = Set.new(ports) end # Lolwut, #hash is inconsistent between ruby processes "Blimpy-#{Zlib.crc32(ports.inspect)}" end