Sha256: c679608c0388d1bff3acd384da32a354a146f369b1715f2940490615a2353c7d

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module Beaker
  class EC2Helper
    # Return a list of open ports for testing based on a hosts role
    #
    # @todo horribly hard-coded
    # @param [Host] host to find ports for
    # @return [Array<Number>] array of port numbers
    # @api private
    def self.amiports(host)
      ports = [22, 61613, 8139]

      roles = host['roles']

      if roles.include? 'database'
        ports << 5432
        ports << 8080
        ports << 8081
      end

      if roles.include? 'master'
        ports << 8140
        ports << 8142
        ports << 8170
      end

      if roles.include? 'dashboard'
        ports << 443
        ports << 4433
        ports << 4435
      end

      # If they only specified one port in the host config file, YAML will have converted it
      # into a string, but if it was more than one, an array.
      user_ports = []
      if host.has_key?('additional_ports')
        user_ports = host['additional_ports'].is_a?(Array) ? host['additional_ports'] : [host['additional_ports']]
      end

      additional_ports = ports + user_ports
      additional_ports.uniq
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
beaker-aws-0.2.0 lib/beaker/hypervisor/ec2_helper.rb