Class: Puppet::Util::NetworkDevice::Base_ios
- Inherits:
-
Object
- Object
- Puppet::Util::NetworkDevice::Base_ios
- Defined in:
- lib/puppet/util/network_device/base_ios.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#crypt ⇒ Object
Returns the value of attribute crypt.
-
#transport ⇒ Object
Returns the value of attribute transport.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #decrypt(master, str) ⇒ Object
-
#initialize(url) ⇒ Base_ios
constructor
A new instance of Base_ios.
Constructor Details
#initialize(url) ⇒ Base_ios
Returns a new instance of Base_ios.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/puppet/util/network_device/base_ios.rb', line 10 def initialize(url) @url = URI.parse(url) @query = CGI.parse(@url.query) if @url.query require "puppet/util/network_device/transport_ios/#{@url.scheme}" unless @transport @transport = Puppet::Util::NetworkDevice::Transport_ios.const_get(@url.scheme.capitalize).new @transport.host = @url.host @transport.port = @url.port || case @url.scheme ; when "ssh" ; 22 ; when "telnet" ; 23 ; end if @query && @query['crypt'] && @query['crypt'] == ['true'] self.crypt = true # FIXME: https://github.com/puppetlabs/puppet/blob/master/lib/puppet/application/device.rb#L181 master = File.read(File.join('/etc/puppet', 'networkdevice-secret')) master = master.strip @transport.user = decrypt(master, [@url.user].pack('h*')) @transport.password = decrypt(master, [@url.password].pack('h*')) else @transport.user = @url.user @transport.password = @url.password end end end |
Instance Attribute Details
#crypt ⇒ Object
Returns the value of attribute crypt.
8 9 10 |
# File 'lib/puppet/util/network_device/base_ios.rb', line 8 def crypt @crypt end |
#transport ⇒ Object
Returns the value of attribute transport.
8 9 10 |
# File 'lib/puppet/util/network_device/base_ios.rb', line 8 def transport @transport end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/puppet/util/network_device/base_ios.rb', line 8 def url @url end |
Instance Method Details
#decrypt(master, str) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/puppet/util/network_device/base_ios.rb', line 34 def decrypt(master, str) cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc") cipher.decrypt cipher.key = key = OpenSSL::Digest::SHA512.new(master).digest out = cipher.update(str) out << cipher.final return out end |