Class: Puppet::Util::NetworkDevice::Cisco_ios::Device
- Inherits:
-
ResourceApi::Transport::Wrapper
- Object
- ResourceApi::Transport::Wrapper
- Puppet::Util::NetworkDevice::Cisco_ios::Device
- Defined in:
- lib/puppet/util/network_device/cisco_ios/device.rb
Overview
The main class for handling the connection and command parsing to the IOS Catalyst device
Instance Method Summary collapse
- #backwards_compatible_schema_load(url_or_config) ⇒ Object
-
#initialize(url_or_config, _options = {}) ⇒ Device
constructor
A new instance of Device.
Constructor Details
#initialize(url_or_config, _options = {}) ⇒ Device
Returns a new instance of Device.
39 40 41 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 39 def initialize(url_or_config, = {}) super('cisco_ios', backwards_compatible_schema_load(url_or_config)) end |
Instance Method Details
#backwards_compatible_schema_load(url_or_config) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/puppet/util/network_device/cisco_ios/device.rb', line 12 def backwards_compatible_schema_load(url_or_config) if url_or_config.is_a? String url = URI.parse(url_or_config) raise "Unexpected url '#{url_or_config}' found. Only file:/// URLs for configuration supported at the moment." unless url.scheme == 'file' raise "Trying to load config from '#{url.path}, but file does not exist." if url && !File.exist?(url.path) url_or_config = self.class.deep_symbolize(Hocon.load(url.path, syntax: Hocon::ConfigSyntax::HOCON) || {}) end # Allow for backwards compatibility with the fields # - address (map to host) # - username (map to user) if url_or_config[:address] unless url_or_config[:host] url_or_config[:host] = url_or_config[:address] end url_or_config.delete(:address) end if url_or_config[:username] unless url_or_config[:user] url_or_config[:user] = url_or_config[:username] end url_or_config.delete(:username) end url_or_config end |