Class: Puppet::Provider::Comware::Vlan

Inherits:
Puppet::Provider::Comware
  • Object
show all
Defined in:
lib/puppet/provider/comware/comware_vlan.rb

Instance Method Summary collapse

Instance Method Details

#default_descriptionObject



52
53
54
# File 'lib/puppet/provider/comware/comware_vlan.rb', line 52

def default_description
  "Puppet created vlan: #{resource[:name]}"
end

#init_resourceObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/puppet/provider/comware/comware_vlan.rb', line 14

def init_resource

  resource[:description] ||= default_description

  @ndev_res ||= NetdevComware::Resource.new( self, "VLAN/VLANs/VLANID" )

  ndev_config = @ndev_res.getconfig
  return false unless (ifd = ndev_config.xpath('////VLANID')[0])

  #update index here
  resource[:name] = resource[:id]
  @ndev_res.set_active_state( ifd )
  return ifd
end

#netdev_res_exists?Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
# File 'lib/puppet/provider/comware/comware_vlan.rb', line 5

def netdev_res_exists?
  return false unless (ifd = init_resource)

  @ndev_res[:description] = ifd.xpath('Description').text.chomp
  @ndev_res[:name] = ifd.xpath('Name').text.chomp

  return true
end

#netdev_resxml_create_top(xml) ⇒ Object



35
36
37
38
# File 'lib/puppet/provider/comware/comware_vlan.rb', line 35

def netdev_resxml_create_top( xml )
  xml.ID resource[:id]
  xml.Description resource[:description] if resource[:description]
end

#netdev_resxml_delete(xml) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/puppet/provider/comware/comware_vlan.rb', line 44

def netdev_resxml_delete( xml )
  if mod = xml.doc.at("VLANID")
    mod['xc:operation'] = 'delete'
  end

  xml.ID resource[:id]
end

#netdev_resxml_top(xml) ⇒ Object

override the method:add IfIndex as the get Index



30
31
32
33
# File 'lib/puppet/provider/comware/comware_vlan.rb', line 30

def netdev_resxml_top( xml )
  xml.ID resource[:id]
  return xml
end

#xml_change_description(xml) ⇒ Object



40
41
42
# File 'lib/puppet/provider/comware/comware_vlan.rb', line 40

def xml_change_description( xml )
  xml.Description resource[:description]
end