Sha256: 6eb09aa18e1475e66a3d3d51c7194653f311f1529fbc90438701a730454269af

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module JunosConfig
  module Security
    class Policy
      attr_accessor :raw,
                    :config,
                    :name,
                    :from_zone,
                    :to_zone,
                    :source_address,
                    :destination_address,
                    :application
      
      def initialize(config, raw, from_zone, to_zone)
        @config    = config
        @raw       = raw
        @from_zone = from_zone
        @to_zone   = to_zone
        @name      = raw.match(/^\ {12}policy (\S+)\ \{$/)[1]
        
        raw.scan(/^\ {20}source\-address\ ([^;]+);/).each do |src|
          s = src[0].split(" ")
          s = s.slice(1,s.length-2) if s.length > 1
          @source_address =  s
        end
        raw.scan(/^\ {20}destination\-address\ ([^;]+);/).each do |dst|
          s = dst[0].split(" ")
          s = s.slice(1,s.length-2) if s.length > 1
          @destination_address = s
        end
        raw.scan(/^\ {20}application\ ([^;]+);/).each do |app|
          s = app[0].split(" ")
          s = s.slice(1,s.length-2) if s.length > 1
          @application = s
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
junos-config-0.3.0 lib/junos-config/security/policy.rb