Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] models #1651

Merged
merged 5 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions napalm/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def get_interfaces(self) -> Dict[str, models.InterfaceDict]:
* is_enabled (True/False)
* description (string)
* last_flapped (float in seconds)
* speed (int in Mbit)
* speed (float in Mbit)
* MTU (in Bytes)
* mac_address (string)

Expand All @@ -356,7 +356,7 @@ def get_interfaces(self) -> Dict[str, models.InterfaceDict]:
'is_enabled': False,
'description': '',
'last_flapped': -1.0,
'speed': 1000,
'speed': 1000.0,
'mtu': 1500,
'mac_address': 'FA:16:3E:57:33:61',
},
Expand All @@ -366,7 +366,7 @@ def get_interfaces(self) -> Dict[str, models.InterfaceDict]:
'is_enabled': True,
'description': 'foo',
'last_flapped': 1429978575.1554043,
'speed': 1000,
'speed': 1000.0,
'mtu': 1500,
'mac_address': 'FA:16:3E:57:33:62',
},
Expand All @@ -376,7 +376,7 @@ def get_interfaces(self) -> Dict[str, models.InterfaceDict]:
'is_enabled': True,
'description': 'bla',
'last_flapped': 1429978575.1555667,
'speed': 1000,
'speed': 1000.0,
'mtu': 1500,
'mac_address': 'FA:16:3E:57:33:63',
},
Expand All @@ -386,7 +386,7 @@ def get_interfaces(self) -> Dict[str, models.InterfaceDict]:
'is_enabled': True,
'description': 'bar',
'last_flapped': -1.0,
'speed': 1000,
'speed': 1000.0,
'mtu': 1500,
'mac_address': 'FA:16:3E:57:33:64',
}
Expand Down Expand Up @@ -1383,7 +1383,7 @@ def ping(
OR

{
'error': 'unknown host 8.8.8.8.8'
'error': 'unknown host 8.8.8.8'
}

"""
Expand Down Expand Up @@ -1503,7 +1503,7 @@ def traceroute(
OR

{
'error': 'unknown host 8.8.8.8.8'
'error': 'unknown host 8.8.8.8'
}
"""
raise NotImplementedError
Expand Down
2 changes: 1 addition & 1 deletion napalm/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"FactsDict",
{
"os_version": str,
"uptime": int,
"uptime": float,
"interface_list": List,
"vendor": str,
"serial_number": str,
Expand Down
2 changes: 1 addition & 1 deletion napalm/eos/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def get_facts(self):
"model": version["modelName"],
"serial_number": version["serialNumber"],
"os_version": version["internalVersion"],
"uptime": int(uptime),
"uptime": float(uptime),
"interface_list": interfaces,
}

Expand Down
2 changes: 1 addition & 1 deletion napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ def get_facts(self):
interface_list.append(interface)

return {
"uptime": uptime,
"uptime": float(uptime),
"vendor": vendor,
"os_version": str(os_version),
"serial_number": str(serial_number),
Expand Down
4 changes: 2 additions & 2 deletions napalm/iosxr/iosxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def get_facts(self):
"vendor": "Cisco",
"os_version": "",
"hostname": "",
"uptime": -1,
"uptime": -1.0,
"serial_number": "",
"fqdn": "",
"model": "",
Expand All @@ -185,7 +185,7 @@ def get_facts(self):
str, napalm.base.helpers.find_txt(system_time_tree, "Hostname")
)
uptime = napalm.base.helpers.convert(
int, napalm.base.helpers.find_txt(system_time_tree, "Uptime"), -1
float, napalm.base.helpers.find_txt(system_time_tree, "Uptime"), -1.0
)
serial = napalm.base.helpers.convert(
str, napalm.base.helpers.find_txt(platform_attr_tree, "SerialNumber")
Expand Down
6 changes: 3 additions & 3 deletions napalm/iosxr_netconf/iosxr_netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def get_facts(self):
"vendor": "Cisco",
"os_version": "",
"hostname": "",
"uptime": -1,
"uptime": -1.0,
"serial_number": "",
"fqdn": "",
"model": "",
Expand All @@ -362,15 +362,15 @@ def get_facts(self):

# Retrieves uptime
uptime = napalm.base.helpers.convert(
int,
float,
self._find_txt(
facts_rpc_reply_etree,
".//suo:system-time/\
suo:uptime/suo:uptime",
default="",
namespaces=C.NS,
),
-1,
-1.0,
)

# Retrieves interfaces name
Expand Down
2 changes: 1 addition & 1 deletion napalm/junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def get_facts(self):
"os_version": str(output["version"]),
"hostname": str(output["hostname"]),
"fqdn": str(output["fqdn"]),
"uptime": uptime,
"uptime": float(uptime),
"interface_list": interface_list,
}

Expand Down
2 changes: 1 addition & 1 deletion napalm/nxos/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ def get_facts(self) -> models.FactsDict:
uptime += uptime_mins * 60
uptime += uptime_secs

facts["uptime"] = uptime
facts["uptime"] = float(uptime)

iface_cmd = "show interface"
interfaces_out = self._send_command(iface_cmd)
Expand Down
2 changes: 1 addition & 1 deletion napalm/nxos_ssh/nxos_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def get_facts(self):
interface_list.append(helpers.canonical_interface_name(interface))

return {
"uptime": int(uptime),
"uptime": float(uptime),
"vendor": vendor,
"os_version": str(os_version),
"serial_number": str(serial_number),
Expand Down