Class: YangNetconfProperty
- Inherits:
-
Puppet::Property
- Object
- Puppet::Property
- YangNetconfProperty
- Defined in:
- lib/puppet/property/yang_netconf_property.rb
Overview
This subclass of Puppet::Property manages YANG content.
Direct Known Subclasses
Instance Method Summary collapse
-
#inline_yang?(_yang_or_file) ⇒ Boolean
Determine if the specified value is inline YANG or a file path.
-
#insync?(is) ⇒ Boolean
Determine if the “is” value is the same as the “should” value (has the value of this property changed?).
- #should ⇒ Object
- #yang_content(yang_or_file) ⇒ Object
Instance Method Details
#inline_yang?(_yang_or_file) ⇒ Boolean
Determine if the specified value is inline YANG or a file path
8 9 10 |
# File 'lib/puppet/property/yang_netconf_property.rb', line 8 def inline_yang?(_yang_or_file) false end |
#insync?(is) ⇒ Boolean
Determine if the “is” value is the same as the “should” value (has the value of this property changed?)
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/puppet/property/yang_netconf_property.rb', line 48 def insync?(is) replace = @resource && @resource[:mode] == :replace should_yang = should if is == :unknown # if the current config is unknown, assume configs are not in-sync insync = false else if replace insync = Cisco::Netconf.insync_for_replace(should_yang, is) else insync = Cisco::Netconf.insync_for_merge(should_yang, is) end end if insync debug '**************** IDEMPOTENT -- NO CHANGES DETECTED ****************' elsif debug '**************** IS vs SHOULD CHANGES DETECTED ****************' end insync end |
#should ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/puppet/property/yang_netconf_property.rb', line 33 def should return @should_yang if @should_yang result = super # need better way to determine life-cycle stage of provider if provider && provider.respond_to?(:active?) && provider.active? @should_yang = result = yang_content(result) end result end |
#yang_content(yang_or_file) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/puppet/property/yang_netconf_property.rb', line 12 def yang_content(yang_or_file) return '' if yang_or_file.nil? # If it's not inline YANG, then assume it's a file, so read it in. if !inline_yang?(yang_or_file) # begin content = File.read(yang_or_file) debug "-----> read YANG from file #{yang_or_file}:" debug content # rescue Exception => e # puts "**************** ERROR DETECTED WHILE READING YANG FILE #{yang_or_file} ****************" # puts e.message # content = nil # end content else debug "-----> value is inline YANG: #{yang_or_file}" yang_or_file end end |