File: cluster_security_group_parser.rb

package info (click to toggle)
ruby-fog-aws 3.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,816 kB
  • sloc: ruby: 68,587; makefile: 6
file content (49 lines) | stat: -rw-r--r-- 1,470 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module Fog
  module Parsers
    module Redshift
      module AWS
        class ClusterSecurityGroupParser < Fog::Parsers::Base
          #   :cluster_security_group_name - (String)
          #   :description - (String)
          #   :ec_2_security_groups - (Array)
          #     :status - (String)
          #     :ec2_security_group_name - (String)
          #     :ec2_security_group_owner_id - (String)
          #   :ip_ranges - (Array)
          #     :status - (String)
          #     :cidrip - (String)

          def reset
            @cluster_security_group = fresh_cluster_security_group
          end

          def fresh_cluster_security_group
            {'EC2SecurityGroups' => [], 'IPRanges' => []}
          end

          def start_element(name, attrs = [])
            super
            case name
            when 'EC2SecurityGroups', 'IPRanges'
              @list = {}
              @list_name = name
            end
          end

          def end_element(name)
            super
            case name
            when 'ClusterSecurityGroupName', 'Description'
              @cluster_security_group[name] = value
            when 'EC2SecurityGroupName', 'EC2SecurityGroupOwnerId', 'CIDRIP', 'Status'
              @list[name] = value
            when 'EC2SecurityGroup', 'IPRange'
              @cluster_security_group[@list_name] << {name => @list}
              @list = {}
            end
          end
        end
      end
    end
  end
end