Class: Puppet::Provider::Comware::L2Interface

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

Instance Method Summary collapse

Instance Method Details

#get_edit_xpathObject

Deal which table of netconf we should use AccessInterfaces,TrunkInterfaces,or HybridInterfaces



32
33
34
35
36
37
38
39
# File 'lib/puppet/provider/comware/comware_l2_interface.rb', line 32

def get_edit_xpath
  linktype = @ndev_res[:linkType]
  case linktype
    when 1 then 'AccessInterfaces'
    when 2 then 'TrunkInterfaces'
    when 3 then 'HybridInterfaces'
  end
end

#init_resourceObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/puppet/provider/comware/comware_l2_interface.rb', line 19

def init_resource
  @ndev_res ||= NetdevComware::Resource.new( self, "VLAN/Interfaces/Interface" )

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

  @ndev_res.set_active_state( ifd )

  return ifd
end

#netdev_res_exists?Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/puppet/provider/comware/comware_l2_interface.rb', line 5

def netdev_res_exists?

  return false unless (ifd = init_resource)

  @ndev_res[:pvid] = ifd.xpath('PVID')
  @ndev_res[:linkType] = (linktype = ifd.xpath('LinkType')).nil? ? nil:linktype.text.to_i
  @ndev_res[:permit_vlan_list] = (vlan_list = ifd.xpath('PermitVlanList')).nil? ? nil : vlan_list.to_s
  @ndev_res[:untagged_vlan_list] = (vlan_list = ifd.xpath('UntaggedVlanList')).nil? ? nil : vlan_list.to_s
  @ndev_res[:tagged_vlan_list] = (vlan_list = ifd.xpath('TaggedVlanList')).nil? ? nil : vlan_list.to_s

  @ndev_res.change_edit_path("VLAN/" + get_edit_xpath + "/Interface")
  return true
end

#netdev_resxml_top(xml) ⇒ Object



41
42
43
44
# File 'lib/puppet/provider/comware/comware_l2_interface.rb', line 41

def netdev_resxml_top( xml )
    xml.IfIndex resource[:ifindex]
    return xml
end

#xml_change_permit_vlan_list(xml) ⇒ Object



51
52
53
# File 'lib/puppet/provider/comware/comware_l2_interface.rb', line 51

def xml_change_permit_vlan_list(xml)
  xml.PermitVlanList resource[:permit_vlan_list]
end

#xml_change_pvid(xml) ⇒ Object

XML BUILD Method



47
48
49
# File 'lib/puppet/provider/comware/comware_l2_interface.rb', line 47

def xml_change_pvid(xml)
  xml.PVID resource[:pvid]
end

#xml_change_tagged_vlan_list(xml) ⇒ Object



59
60
61
# File 'lib/puppet/provider/comware/comware_l2_interface.rb', line 59

def xml_change_tagged_vlan_list(xml)
  xml.TaggedVlanList resource[:tagged_vlan_list]
end

#xml_change_untagged_vlan_list(xml) ⇒ Object



55
56
57
# File 'lib/puppet/provider/comware/comware_l2_interface.rb', line 55

def xml_change_untagged_vlan_list(xml)
  xml.UntaggedVlanList resource[:untagged_vlan_list]
end