Class: Fog::Bouncer::CLI::Diff::EC2

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/bouncer/cli/diff.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doorlist) ⇒ EC2

Returns a new instance of EC2.



29
30
31
# File 'lib/fog/bouncer/cli/diff.rb', line 29

def initialize(doorlist)
  @doorlist = doorlist
end

Instance Attribute Details

#doorlistObject (readonly)

Returns the value of attribute doorlist.



23
24
25
# File 'lib/fog/bouncer/cli/diff.rb', line 23

def doorlist
  @doorlist
end

Class Method Details

.diff(doorlist) ⇒ Object



25
26
27
# File 'lib/fog/bouncer/cli/diff.rb', line 25

def self.diff(doorlist)
  new(doorlist).diff
end

Instance Method Details

#diffObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/bouncer/cli/diff.rb', line 33

def diff
  @doorlist.groups.each do |group|
    if group.local? && !group.remote?
      puts "ec2-create-group #{group.name} -d '#{group.description}'"
    end

    group.sources.each do |source|
      source.protocols.each do |protocol|
        if protocol.local? && !protocol.remote?
          puts command(protocol, :authorize)
        elsif !protocol.local? && protocol.remote?
          puts command(protocol, :revoke)
        end
      end
    end

    if group.remote? && !group.local?
      puts "ec2-delete-group #{group.name}"
    end
  end
end