Class: Puppet::Provider::PanosProvider
- Inherits:
-
ResourceApi::SimpleProvider
- Object
- ResourceApi::SimpleProvider
- Puppet::Provider::PanosProvider
show all
- Defined in:
- lib/puppet/provider/panos_provider.rb
Overview
A base provider for all PANOS providers
Direct Known Subclasses
Puppet::Provider::PanosAddress::PanosAddress, Puppet::Provider::PanosAddressGroup::PanosAddressGroup, Puppet::Provider::PanosAdmin::PanosAdmin, Puppet::Provider::PanosNatPolicy::PanosNatPolicy, PanosPathMonitorBase, Puppet::Provider::PanosSecurityPolicyRule::PanosSecurityPolicyRule, Puppet::Provider::PanosService::PanosService, Puppet::Provider::PanosServiceGroup::PanosServiceGroup, PanosStaticRouteBase, Puppet::Provider::PanosTag::PanosTag, Puppet::Provider::PanosVirtualRouter::PanosVirtualRouter, Puppet::Provider::PanosZone::PanosZone
Instance Method Summary
collapse
-
#bool_to_string(value) ⇒ Object
Puppet type uses bool, convert to Yes/No to suit PANOS system.
-
#build_tags(builder, should) ⇒ Object
-
#create(context, name, should) ⇒ Object
-
#delete(context, name) ⇒ Object
-
#get(context) ⇒ Object
-
#initialize ⇒ PanosProvider
constructor
rubocop:disable Lint/MissingSuper.
-
#match(entry, attr, attr_name) ⇒ Object
-
#string_to_bool(value) ⇒ Object
PANOS uses Yes/No, convert to bool if the type expects it.
-
#update(context, name, should) ⇒ Object
Constructor Details
rubocop:disable Lint/MissingSuper
5
6
7
8
9
|
# File 'lib/puppet/provider/panos_provider.rb', line 5
def initialize require 'rexml/document'
require 'rexml/xpath'
require 'builder'
end
|
Instance Method Details
#bool_to_string(value) ⇒ Object
Puppet type uses bool, convert to Yes/No to suit PANOS system
55
56
57
58
59
|
# File 'lib/puppet/provider/panos_provider.rb', line 55
def bool_to_string(value)
return 'yes' if value == true
return 'no' if value == false
value end
|
61
62
63
64
65
66
67
68
|
# File 'lib/puppet/provider/panos_provider.rb', line 61
def build_tags(builder, should)
return unless should[:tags]
builder.tag do
should[:tags].each do |tag|
builder.member(tag)
end
end
end
|
#create(context, name, should) ⇒ Object
22
23
24
25
26
|
# File 'lib/puppet/provider/panos_provider.rb', line 22
def create(context, name, should)
validate_should(should) if defined? validate_should
context.transport.set_config(context.type.definition[:base_xpath], xml_from_should(name, should))
context.transport.move(context.type.definition[:base_xpath], name, should[:insert_after]) unless should[:insert_after].nil?
end
|
#delete(context, name) ⇒ Object
34
35
36
|
# File 'lib/puppet/provider/panos_provider.rb', line 34
def delete(context, name)
context.transport.delete_config(context.type.definition[:base_xpath] + "/entry[@name='#{name}']")
end
|
#get(context) ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/puppet/provider/panos_provider.rb', line 11
def get(context)
config = context.transport.get_config(context.type.definition[:base_xpath] + '/entry')
config.elements.collect('/response/result/entry') do |entry| result = {}
context.type.attributes.each do |attr_name, attr|
result[attr_name] = match(entry, attr, attr_name)
end
defined?(munge) ? munge(result) : result
end
end
|
#match(entry, attr, attr_name) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/puppet/provider/panos_provider.rb', line 38
def match(entry, attr, attr_name)
return 'present' if attr_name == :ensure
if attr.key? :xpath
text_match(entry, attr)
elsif attr.key? :xpath_array
array_match(entry, attr)
end
end
|
#string_to_bool(value) ⇒ Object
PANOS uses Yes/No, convert to bool if the type expects it
48
49
50
51
52
|
# File 'lib/puppet/provider/panos_provider.rb', line 48
def string_to_bool(value)
return false if value.nil? || value.casecmp('no').zero?
return true if value.casecmp('yes').zero?
value end
|
#update(context, name, should) ⇒ Object
28
29
30
31
32
|
# File 'lib/puppet/provider/panos_provider.rb', line 28
def update(context, name, should)
validate_should(should) if defined? validate_should
context.transport.edit_config(context.type.definition[:base_xpath] + "/entry[@name='#{name}']", xml_from_should(name, should))
context.transport.move(context.type.definition[:base_xpath], name, should[:insert_after]) unless should[:insert_after].nil?
end
|