Class: Piculet::Exporter
- Inherits:
-
Object
- Object
- Piculet::Exporter
- Defined in:
- lib/piculet/exporter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(ec2, options = {}) ⇒ Exporter
constructor
of class methods.
Constructor Details
#initialize(ec2, options = {}) ⇒ Exporter
of class methods
9 10 11 12 |
# File 'lib/piculet/exporter.rb', line 9 def initialize(ec2, = {}) @ec2 = ec2 @options = end |
Class Method Details
.export(ec2, options = {}) ⇒ Object
4 5 6 |
# File 'lib/piculet/exporter.rb', line 4 def export(ec2, = {}) self.new(ec2, ).export end |
Instance Method Details
#export ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/piculet/exporter.rb', line 14 def export result = {} ec2s = @options[:ec2s] sg_names = @options[:sg_names] sgs = @ec2.security_groups sgs = sgs.filter('group-name', *sg_names) if sg_names sgs = sgs.sort_by {|sg| sg.name } sgs.each do |sg| vpc = sg.vpc vpc = vpc.id if vpc if ec2s next unless ec2s.any? {|i| (i == 'classic' and vpc.nil?) or i == vpc } end result[vpc] ||= {} result[vpc][sg.id] = export_security_group(sg) end return result end |