Skip to content

Commit

Permalink
Merge pull request napalm-automation-community#65 from jbemmel/R23-fixes
Browse files Browse the repository at this point in the history
R23 fixes
  • Loading branch information
jbemmel authored Jun 26, 2023
2 parents 76534bb + a808e99 commit 29ea64f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion napalm_sros/api/get_bgp_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"""

GET_BGP_NEIGHBORS = """
<filter>
<filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf">
<router>
<router-name/>
Expand Down
2 changes: 1 addition & 1 deletion napalm_sros/api/get_bgp_neighbors_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"""

GET_BGP_NEIGHBORS_DETAILS = """
<filter>
<filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf">
<router>
<router-name/>
Expand Down
7 changes: 3 additions & 4 deletions napalm_sros/nc_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
}


GET_INTERFACES = {
"_": """
def GET_INTERFACES(R19):
return f"""
<filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<state xmlns="urn:nokia.com:sros:ns:yang:sr:state">
<port>
Expand All @@ -49,7 +49,7 @@
<router>
<interface>
<oper-ip-mtu />
<if-oper-status />
{ '<if-oper-status/>' if R19 else '<oper-state/>' }
<last-oper-change/>
</interface>
</router>
Expand Down Expand Up @@ -80,7 +80,6 @@
</configure>
</filter>
"""
}

GET_INTERFACES_COUNTERS = {
"_": """
Expand Down
18 changes: 9 additions & 9 deletions napalm_sros/sros.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def open(self):
hostkey_verify=False,
timeout=self.timeout,
)
revision = re.compile( ".*&revision=(.*).*" )
self.state_revisions = [ revision.match(i).groups()[0] for i in self.conn.server_capabilities if "nokia-state" in i ]
log.info( self.state_revisions )
self.R19 = '2016-07-06' in self.state_revisions # Older SR OS release e.g. '2022-10-19' or '2016-07-06'
except ConnectionException as ce:
print("Error in opening netconf connection : {}".format(ce))
log.error(
Expand Down Expand Up @@ -641,7 +645,7 @@ def get_interfaces(self):
interfaces = {}
result = to_ele(
self.conn.get(
filter=GET_INTERFACES["_"], with_defaults="report-all"
filter=GET_INTERFACES(R19=self.R19), with_defaults="report-all"
).data_xml
)
# get physical interfaces (ports) information
Expand Down Expand Up @@ -787,14 +791,10 @@ def get_interfaces(self):
)
ifd["speed"] = if_speed

ifd["is_up"] = (
True
if self._find_txt(
if_state, "state_ns:if-oper-status", namespaces=self.nsmap
)
== "up"
else False
)
ifd["is_up"] = self._find_txt(
if_state, "state_ns:if-oper-status" if self.R19 else "state_ns:oper-state",
namespaces=self.nsmap
) == "up"

flap_time = self._find_txt(
if_state, "state_ns:last-oper-change", namespaces=self.nsmap
Expand Down
1 change: 1 addition & 0 deletions test/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None)
self.ssh_channel = FakeSSHConnectionChannel()
self.conn_ssh = FakeSSHConnection()
self.manager = FakeManager()
self.R19 = False

def is_alive(self):
return {"is_alive": True}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<interface>
<interface-name>system</interface-name>
<oper-ip-mtu>1500</oper-ip-mtu>
<if-oper-status>up</if-oper-status>
<oper-state>up</oper-state>
<last-oper-change>2020-04-13T15:53:27.0Z</last-oper-change>
</interface>
</router>
Expand Down

0 comments on commit 29ea64f

Please sign in to comment.