Class: Puppet::Provider::Junos
- Inherits:
-
Puppet::Provider
- Object
- Puppet::Provider
- Puppet::Provider::Junos
- Defined in:
- lib/puppet/provider/junos/junos_parent.rb
Direct Known Subclasses
BridgeDomain, Group, Interface, InterfaceClassic, L2Interface, L2InterfaceBridgeDomain, L2InterfaceL2NG, LAG, Vlan
Instance Attribute Summary collapse
-
#ndev_res ⇒ Object
Returns the value of attribute ndev_res.
Class Method Summary collapse
- .mk_netdev_resource_methods ⇒ Object
-
.netdev ⇒ Object
———————————————————— Provider class methods to automatically build property reader methods ————————————————————.
Instance Method Summary collapse
- #config_del(name) ⇒ Object
-
#config_update(name) ⇒ Object
———————————————————— Methods that build up the configuration changes ————————————————————.
-
#create ⇒ Object
———————————————————— Device provider methods expected by Puppet ————————————————————.
- #destroy ⇒ Object
- #exists? ⇒ Boolean
- #flush ⇒ Object
- #netdev_create ⇒ Object
- #netdev_get ⇒ Object
- #netdev_res_property(key) ⇒ Object
-
#netdev_resxml_change_active(xml) ⇒ Object
mark the config item for ‘active’ or ‘inactive’ this assumes the caller has already set xml to top.
-
#netdev_resxml_delete(xml) ⇒ Object
mark the config item for delete.
-
#netdev_resxml_edit(xml) ⇒ Object
default edit ‘dot’ assumes top.
-
#netdev_resxml_new(edit_xml) ⇒ Object
this assumes the caller has already set xml to the ‘edit’ of the config item.
-
#netdev_resxml_top(xml) ⇒ Object
put the ‘dot’ inside the top of the config item.
- #properties ⇒ Object
- #refresh ⇒ Object
Instance Attribute Details
#ndev_res ⇒ Object
Returns the value of attribute ndev_res.
42 43 44 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 42 def ndev_res @ndev_res end |
Class Method Details
.mk_netdev_resource_methods ⇒ Object
95 96 97 98 99 100 101 102 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 95 def self.mk_netdev_resource_methods (resource_type.validproperties - [:ensure]).sort.each do |prop| prop_sym = Facter.value(:puppetversion).to_i >= 3 ? prop.intern : symbolize(prop) define_method(prop_sym) do netdev_res_property( prop_sym ) end end end |
.netdev ⇒ Object
Provider class methods to automatically build property reader methods
91 92 93 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 91 def self.netdev return (@@netdev.ready) ? @@netdev : nil end |
Instance Method Details
#config_del(name) ⇒ Object
121 122 123 124 125 126 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 121 def config_del( name ) @ndev_res.del name # do not invoke @@netdev.edit_config ... just mark the # item for deletion and it will get picked up by a later # call to config_edit in #flush end |
#config_update(name) ⇒ Object
Methods that build up the configuration changes
116 117 118 119 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 116 def config_update( name ) @ndev_res.update name @@netdev.edit_config( @ndev_res, "xml" ) end |
#create ⇒ Object
Device provider methods expected by Puppet
48 49 50 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 48 def create Puppet.debug( "#{self.resource.type}: CREATE #{resource[:name]}" ) end |
#destroy ⇒ Object
52 53 54 55 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 52 def destroy Puppet.debug( "#{self.resource.type}:: DESTROY #{resource[:name]}" ) config_del resource[:name] end |
#exists? ⇒ Boolean
57 58 59 60 61 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 57 def exists? Puppet.debug( "#{self.resource.type}: checking #{resource[:name]}" ) return false unless netdev_res_exists? netdev_res_property :name end |
#flush ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 63 def flush if defined? @ndev_res[:name] Puppet.debug( "#{self.resource.type}:: Flusing #{resource[:name]}" ) config_update resource[:name] else Puppet.debug( "#{self.resource.type}:: Nothing to flush #{resource[:name]}" ) end end |
#netdev_create ⇒ Object
77 78 79 80 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 77 def netdev_create @@netdev ||= NetdevJunos::Device.new( resource.catalog.version ) netdev_get end |
#netdev_get ⇒ Object
82 83 84 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 82 def netdev_get return (@@netdev.ready) ? @@netdev : nil end |
#netdev_res_property(key) ⇒ Object
104 105 106 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 104 def netdev_res_property(key) @ndev_res[key] end |
#netdev_resxml_change_active(xml) ⇒ Object
mark the config item for ‘active’ or ‘inactive’ this assumes the caller has already set xml to top
158 159 160 161 162 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 158 def netdev_resxml_change_active( xml ) par = xml.instance_variable_get(:@parent) admin = resource[:active] == :false ? 'inactive' : 'active' par[admin] = admin end |
#netdev_resxml_delete(xml) ⇒ Object
mark the config item for delete
149 150 151 152 153 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 149 def netdev_resxml_delete( xml ) top = netdev_resxml_top( xml ) par = top.instance_variable_get(:@parent) par['delete'] = 'delete' end |
#netdev_resxml_edit(xml) ⇒ Object
default edit ‘dot’ assumes top
143 144 145 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 143 def netdev_resxml_edit( xml ) return xml end |
#netdev_resxml_new(edit_xml) ⇒ Object
this assumes the caller has already set xml to the ‘edit’ of the config item
167 168 169 170 171 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 167 def netdev_resxml_new( edit_xml ) self.properties.each do |p| self.send("xml_change_#{p}", edit_xml ) end end |
#netdev_resxml_top(xml) ⇒ Object
put the ‘dot’ inside the top of the config item
134 135 136 137 138 139 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 134 def netdev_resxml_top( xml ) xml.send( @ndev_res.edit_item ) { xml.name resource[:name] return xml } end |
#properties ⇒ Object
108 109 110 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 108 def properties self.class.resource_type.validproperties.flatten - [:ensure, :active] end |
#refresh ⇒ Object
72 73 74 75 |
# File 'lib/puppet/provider/junos/junos_parent.rb', line 72 def refresh Puppet.debug( "#{self.resource.type}: REFRESH #{resource[:name]}" ) flush end |