Class: Puppet::Provider::PanosPathMonitorBase
- Inherits:
-
PanosProvider
- Object
- PanosProvider
- Puppet::Provider::PanosPathMonitorBase
show all
- Defined in:
- lib/puppet/provider/panos_path_monitor_base.rb
Overview
Implementation for the panos_path_monitor_base type using the Resource API, which has been implemented to remove the common functionality of the ipv4 and ipv6 static routes, which path monitors are associated with
Instance Method Summary
collapse
Constructor Details
Returns a new instance of PanosPathMonitorBase.
6
7
8
9
|
# File 'lib/puppet/provider/panos_path_monitor_base.rb', line 6
def initialize(version_label)
super()
@version_label = version_label
end
|
Instance Method Details
#create(context, name, should) ⇒ Object
51
52
53
54
55
|
# File 'lib/puppet/provider/panos_path_monitor_base.rb', line 51
def create(context, name, should)
paths = name[:route].split('/')
context.type.definition[:base_xpath] = "/config/devices/entry/network/virtual-router/entry[@name='#{paths[0]}']/routing-table/#{@version_label}/static-route/entry[@name='#{paths[1]}']/path-monitor/monitor-destinations" context.transport.set_config(context.type.definition[:base_xpath], xml_from_should(name, should))
end
|
#delete(context, name) ⇒ Object
63
64
65
66
|
# File 'lib/puppet/provider/panos_path_monitor_base.rb', line 63
def delete(context, name)
names = name[:route].split('/')
context.transport.delete_config(context.type.definition[:base_xpath] + "/entry[@name='#{names[0]}']/routing-table/#{@version_label}/static-route/entry[@name='#{names[1]}']/path-monitor/monitor-destinations/entry[@name='#{name[:path]}']") end
|
#get(context) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/puppet/provider/panos_path_monitor_base.rb', line 27
def get(context)
results = []
config = context.transport.get_config(context.type.definition[:base_xpath] + '/entry')
config.elements.collect('/response/result/entry') do |entry| vr_name = REXML::XPath.match(entry, 'string(@name)').first
config.elements.collect("/response/result/entry[@name='#{vr_name}']/routing-table/#{@version_label}/static-route/entry") do |static_route_entry| route = REXML::XPath.match(static_route_entry, 'string(@name)').first
config.elements.collect("/response/result/entry[@name='#{vr_name}']/routing-table/#{@version_label}/static-route/entry[@name='#{route}']/path-monitor/monitor-destinations/entry") do |path_monitor_entry| result = {}
context.type.attributes.each do |attr_name, attr|
result[attr_name] = match(path_monitor_entry, attr, attr_name)
end
result[:route] = vr_name + '/' + route
result[:title] = result[:route] + '/' + result[:path]
results.push(result)
defined?(munge) ? munge(result) : result
end
end
end
results
end
|
#munge(entry) ⇒ Object
11
12
13
14
|
# File 'lib/puppet/provider/panos_path_monitor_base.rb', line 11
def munge(entry)
entry[:enable] = string_to_bool(entry[:enable])
entry
end
|
#update(context, name, should) ⇒ Object
57
58
59
60
61
|
# File 'lib/puppet/provider/panos_path_monitor_base.rb', line 57
def update(context, name, should)
paths = name[:route].split('/')
context.type.definition[:base_xpath] = "/config/devices/entry/network/virtual-router/entry[@name='#{paths[0]}']/routing-table/#{@version_label}/static-route/entry[@name='#{paths[1]}']/path-monitor/monitor-destinations" context.transport.set_config(context.type.definition[:base_xpath], xml_from_should(name, should))
end
|
#xml_from_should(name, should) ⇒ Object
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/puppet/provider/panos_path_monitor_base.rb', line 16
def xml_from_should(name, should)
builder = Builder::XmlMarkup.new
builder.entry('name' => name[:path]) do
builder.source(should[:source])
builder.destination(should[:destination])
builder.interval(should[:interval])
builder.count(should[:count])
builder.enable(bool_to_string(should[:enable])) if should[:enable]
end
end
|