Class: JunosConfig::Security::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/junos-config/security/policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, raw, from_zone, to_zone) ⇒ Policy

Returns a new instance of Policy.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/junos-config/security/policy.rb', line 13

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

Instance Attribute Details

#applicationObject

Returns the value of attribute application.



4
5
6
# File 'lib/junos-config/security/policy.rb', line 4

def application
  @application
end

#configObject

Returns the value of attribute config.



4
5
6
# File 'lib/junos-config/security/policy.rb', line 4

def config
  @config
end

#destination_addressObject

Returns the value of attribute destination_address.



4
5
6
# File 'lib/junos-config/security/policy.rb', line 4

def destination_address
  @destination_address
end

#from_zoneObject

Returns the value of attribute from_zone.



4
5
6
# File 'lib/junos-config/security/policy.rb', line 4

def from_zone
  @from_zone
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/junos-config/security/policy.rb', line 4

def name
  @name
end

#rawObject

Returns the value of attribute raw.



4
5
6
# File 'lib/junos-config/security/policy.rb', line 4

def raw
  @raw
end

#source_addressObject

Returns the value of attribute source_address.



4
5
6
# File 'lib/junos-config/security/policy.rb', line 4

def source_address
  @source_address
end

#to_zoneObject

Returns the value of attribute to_zone.



4
5
6
# File 'lib/junos-config/security/policy.rb', line 4

def to_zone
  @to_zone
end