Class: Puppet::Provider::OpnsenseDevice::OpnsenseDevice
- Inherits:
-
Puppet::Provider::OpnsenseProvider
- Object
- Puppet::Provider::OpnsenseProvider
- Puppet::Provider::OpnsenseDevice::OpnsenseDevice
- Defined in:
- lib/puppet/provider/opnsense_device/opnsense_device.rb
Overview
Implementation for the opnsense_device type using the Resource API.
Instance Method Summary collapse
- #canonicalize(_context, resources) ⇒ Object
- #create(_context, name, should) ⇒ File
- #delete(_context, name) ⇒ Object
- #get(_context, filter) ⇒ Array<Hash<Symbol>>
- #get_device_names_by_filter(filter) ⇒ Array<Hash<Symbol>>, Array<String>
- #update(_context, name, should) ⇒ Object
Instance Method Details
#canonicalize(_context, resources) ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/puppet/provider/opnsense_device/opnsense_device.rb', line 136 def canonicalize(_context, resources) resources.each do |r| if r.key?(:api_secret) && r[:api_secret].is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive) r[:api_secret] = _gen_pw(_extract_pw(r[:api_secret])) end end end |
#create(_context, name, should) ⇒ File
74 75 76 |
# File 'lib/puppet/provider/opnsense_device/opnsense_device.rb', line 74 def create(_context, name, should) _write_config(name, should) end |
#delete(_context, name) ⇒ Object
129 130 131 132 |
# File 'lib/puppet/provider/opnsense_device/opnsense_device.rb', line 129 def delete(_context, name) path = get_config_path(name) FileUtils.rm(path, force: true) end |
#get(_context, filter) ⇒ Array<Hash<Symbol>>
14 15 16 17 |
# File 'lib/puppet/provider/opnsense_device/opnsense_device.rb', line 14 def get(_context, filter) device_names = get_device_names_by_filter(filter) _get_devices(device_names) end |
#get_device_names_by_filter(filter) ⇒ Array<Hash<Symbol>>, Array<String>
21 22 23 24 25 26 |
# File 'lib/puppet/provider/opnsense_device/opnsense_device.rb', line 21 def get_device_names_by_filter(filter) if filter.empty? return get_configured_devices end filter end |
#update(_context, name, should) ⇒ Object
81 82 83 |
# File 'lib/puppet/provider/opnsense_device/opnsense_device.rb', line 81 def update(_context, name, should) _write_config(name, should) end |