Skip to content

Commit

Permalink
Added/Updated test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragos Stan committed Jun 7, 2018
1 parent 1596184 commit 0de2b9d
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 93 deletions.
10 changes: 5 additions & 5 deletions napalm_panos/panos.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,15 @@ def get_route_to(self, destination='', protocol=''):
return routes

def get_interfaces(self):
LOOPBACK_SUBIF_DEFAULTS = {
SUBIF_DEFAULTS = {
'is_up': True,
'is_enabled': True,
'speed': 0,
'last_flapped': -1.0,
'mac_address': '',
'description': 'N/A'
}
interface_pattern = re.compile(r"(ethernet\d+/\d+\.\d+)|(ae\d+\.\d+)|(loopback\.)|(tunnel\.)")
subintf_pattern = re.compile(r"(ethernet\d+/\d+\.\d+)|(ae\d+\.\d+)|(loopback\.)|(tunnel\.)")
interface_dict = {}
interface_list = self._extract_interface_list()

Expand All @@ -530,9 +530,9 @@ def get_interfaces(self):
interface_info_json = json.dumps(interface_info_xml['response']['result']['hw'])
interface_info = json.loads(interface_info_json)
except KeyError as err:
if interface_pattern.search(intf) and 'hw' in str(err):
# loopback sub-ifs don't return a 'hw' key
interface_dict[intf] = LOOPBACK_SUBIF_DEFAULTS
if subintf_pattern.search(intf) and 'hw' in str(err):
# physical/ae/tunnel/loopback sub-ifs don't return a 'hw' key
interface_dict[intf] = SUBIF_DEFAULTS
continue
raise

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ifnet>
<entry>
<name>ethernet1/1</name>
<zone>Trust</zone>
<zone/>
<fwd>N/A</fwd>
<vsys>1</vsys>
<dyn-addr/>
Expand All @@ -12,6 +12,18 @@
<id>16</id>
<addr/>
</entry>
<entry>
<name>ethernet1/1.143</name>
<zone>Untrust</zone>
<fwd>vr:default</fwd>
<vsys>1</vsys>
<dyn-addr/>
<addr6/>
<tag>143</tag>
<ip>1.2.3.4/28</ip>
<id>256</id>
<addr/>
</entry>
<entry>
<name>ethernet1/2</name>
<zone>Untrust</zone>
Expand Down Expand Up @@ -48,17 +60,41 @@
<id>256</id>
<addr/>
</entry>
<entry>
<name>tunnel</name>
<zone/>
<fwd>N/A</fwd>
<vsys>1</vsys>
<dyn-addr/>
<addr6/>
<tag>0</tag>
<ip>N/A</ip>
<id>4</id>
<addr/>
</entry>
<entry>
<name>tunnel.100</name>
<zone>zone1</zone>
<fwd>vr:default</fwd>
<vsys>1</vsys>
<dyn-addr/>
<addr6/>
<tag>0</tag>
<ip>2.3.4.5/30</ip>
<id>259</id>
<addr/>
</entry>
</ifnet>
<hw>
<entry>
<name>ethernet1/1</name>
<duplex>full</duplex>
<type>0</type>
<state>up</state>
<st>1000/full/up</st>
<mac>ba:db:ee:fb:ad:10</mac>
<st>10000/full/up</st>
<mac>00:50:56:11:22:33</mac>
<mode>(autoneg)</mode>
<speed>1000</speed>
<speed>10000</speed>
<id>16</id>
</entry>
<entry>
Expand Down Expand Up @@ -105,5 +141,16 @@
<speed>[n/a]</speed>
<id>3</id>
</entry>
<entry>
<name>tunnel</name>
<duplex>[n/a]</duplex>
<type>6</type>
<state>up</state>
<st>[n/a]/[n/a]/up</st>
<mac>e4:a7:49:aa:bb:cc</mac>
<mode>(unknown)</mode>
<speed>[n/a]</speed>
<id>4</id>
</entry>
</hw>
</result></response>
Original file line number Diff line number Diff line change
@@ -1,83 +1,92 @@
<response status="success"><result>
<ifnet>
<addr/>
<service/>
<tunnel/>
<vsys>vsys1</vsys>
<dyn-addr/>
<counters>
<ifnet>
<entry>
<icmp_frag>0</icmp_frag>
<ifwderrors>0</ifwderrors>
<ierrors>0</ierrors>
<macspoof>0</macspoof>
<pod>0</pod>
<flowstate>0</flowstate>
<ipspoof>0</ipspoof>
<teardrop>0</teardrop>
<ibytes>0</ibytes>
<noarp>0</noarp>
<noroute>0</noroute>
<noneigh>0</noneigh>
<nomac>0</nomac>
<l2_encap>0</l2_encap>
<zonechange>0</zonechange>
<obytes>0</obytes>
<land>0</land>
<name>ethernet1/1</name>
<neighpend>0</neighpend>
<ipackets>0</ipackets>
<opackets>0</opackets>
<l2_decap>0</l2_decap>
<idrops>0</idrops>
</entry>
</ifnet>
<hw>
<entry>
<obytes>0</obytes>
<name>ethernet1/1</name>
<idrops>0</idrops>
<ipackets>431</ipackets>
<opackets>0</opackets>
<ierrors>431</ierrors>
<ibytes>27642</ibytes>
<port>
<tx-unicast>0</tx-unicast>
<tx-multicast>1</tx-multicast>
<rx-broadcast>426</rx-broadcast>
<rx-unicast>0</rx-unicast>
<rx-multicast>1</rx-multicast>
<rx-bytes>27354</rx-bytes>
<tx-broadcast>0</tx-broadcast>
<tx-bytes>90</tx-bytes>
</port>
</entry>
</hw>
</counters>
<addr6/>
<ra>False</ra>
<tcpmss>False</tcpmss>
<tag>0</tag>
<mode>layer3</mode>
<zone>Trust</zone>
<id>16</id>
<mgt_subnet>False</mgt_subnet>
<name>ethernet1/1</name>
</ifnet>
<hw>
<name>ethernet1/1</name>
<duplex>full</duplex>
<type>0</type>
<state_c>auto</state_c>
<mac>ba:db:ee:fb:ad:10</mac>
<state>up</state>
<duplex_c>auto</duplex_c>
<mode>layer3</mode>
<speed_c>auto</speed_c>
<speed>1000</speed>
<id>16</id>
<untag>False</untag>
</hw>
<dp>dp0</dp>
</result></response>
<response status="success">
<result>
<ifnet>
<dad>False</dad>
<mssadjv4>0</mssadjv4>
<addr/>
<service/>
<tunnel/>
<vsys>vsys1</vsys>
<dyn-addr/>
<counters>
<ifnet>
<entry>
<icmp_frag>0</icmp_frag>
<ifwderrors>0</ifwderrors>
<ierrors>0</ierrors>
<macspoof>0</macspoof>
<pod>0</pod>
<flowstate>0</flowstate>
<ipspoof>0</ipspoof>
<teardrop>0</teardrop>
<ibytes>2906986214</ibytes>
<noarp>0</noarp>
<noroute>0</noroute>
<noneigh>0</noneigh>
<nomac>0</nomac>
<l2_encap>0</l2_encap>
<zonechange>0</zonechange>
<other_conn>0</other_conn>
<obytes>0</obytes>
<land>0</land>
<name>ethernet1/1</name>
<tcp_conn>0</tcp_conn>
<neighpend>0</neighpend>
<ipackets>8476173</ipackets>
<opackets>0</opackets>
<l2_decap>0</l2_decap>
<udp_conn>0</udp_conn>
<idrops>8476173</idrops>
</entry>
</ifnet>
<hw>
<entry>
<obytes>14379659738635</obytes>
<name>ethernet1/1</name>
<idrops>0</idrops>
<ipackets>3672234582</ipackets>
<opackets>2957211983</opackets>
<ierrors>717527578</ierrors>
<ibytes>1569907802791</ibytes>
<port>
<tx-unicast>11547146575</tx-unicast>
<tx-multicast>0</tx-multicast>
<rx-broadcast>0</rx-broadcast>
<rx-unicast>3672234582</rx-unicast>
<rx-multicast>0</rx-multicast>
<rx-bytes>1569907802791</rx-bytes>
<tx-broadcast>0</tx-broadcast>
<tx-bytes>14379659738635</tx-bytes>
</port>
</entry>
</hw>
</counters>
<addr6/>
<ra>False</ra>
<tcpmss>False</tcpmss>
<tag>0</tag>
<mode>layer3</mode>
<mssadjv6>0</mssadjv6>
<ndpmon>False</ndpmon>
<zone>N/A</zone>
<id>16</id>
<mgt_subnet>False</mgt_subnet>
<name>ethernet1/1</name>
</ifnet>
<hw>
<name>ethernet1/1</name>
<duplex>full</duplex>
<type>0</type>
<state_c>auto</state_c>
<mac>00:50:56:11:22:33</mac>
<state>up</state>
<duplex_c>auto</duplex_c>
<mode>layer3</mode>
<speed_c>auto</speed_c>
<speed>10000</speed>
<id>16</id>
<untag>False</untag>
</hw>
<dp>dp0</dp>
</result>
</response>
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,42 @@
"ethernet1/1": {
"is_enabled": true,
"is_up": true,
"mac_address": "BA:DB:EE:FB:AD:10",
"mac_address": "00:50:56:11:22:33",
"speed": 1000,
"description": "N/A",
"last_flapped": -1.0
},
"tunnel": {
"is_enabled": true,
"is_up": true,
"mac_address": "E4:A7:49:AA:BB:CC",
"speed": 0,
"description": "N/A",
"last_flapped": -1.0
},
"loopback.100": {
"is_enabled": true,
"last_flapped": -1.0,
"mac_address": "",
"speed": 0,
"description": "N/A",
"is_up": true
},
"tunnel.100": {
"is_enabled": true,
"last_flapped": -1.0,
"mac_address": "",
"speed": 0,
"description": "N/A",
"is_up": true
},
"ethernet1/1.143": {
"is_enabled": true,
"last_flapped": -1.0,
"mac_address": "",
"speed": 0,
"description": "N/A",
"is_up": true

}
}

0 comments on commit 0de2b9d

Please sign in to comment.