Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_node_hasattr_connection(self):
node = pyeapi.client.Node(None)
self.assertTrue(hasattr(node, 'connection'))
def setUp(self):
self.node = Node(None)
self.node._running_config = self.config
self.mock_config = Mock(name='node.config')
self.node.config = self.mock_config
self.mock_enable = Mock(name='node.enable')
self.node.enable = self.mock_enable
self.assertIsNotNone(self.instance)
self.instance.node = self.node
def test_node_returns_version_number(self):
node = pyeapi.client.Node(None)
version = '4.17.1.1F-3512479.41711F (engineering build)'
node.enable = Mock()
node.enable.return_value = [{'result': {'version': version,
'modelName': 'vEOS'}}]
self.assertIsInstance(node.version_number, str)
self.assertIn(node.version_number, version)
def setUp(self):
self.connection = Mock()
self.node = pyeapi.client.Node(self.connection)
def main():
devices = yaml_load_devices()
password = os.getenv("PYNET_PASSWORD") if os.getenv("PYNET_PASSWORD") else getpass()
for name, device_dict in devices.items():
device_dict["password"] = password
connection = pyeapi.client.connect(**device_dict)
device = pyeapi.client.Node(connection)
output = device.enable("show ip arp")
print()
print("-" * 40)
arp_list = output[0]["result"]["ipV4Neighbors"]
for arp_entry in arp_list:
mac_address = arp_entry["hwAddress"]
ip_address = arp_entry["address"]
print("{:^15}{:^5}{:^15}".format(ip_address, "-->", mac_address))
print("-" * 40)
print()
import os
import pyeapi
from getpass import getpass
from my_funcs import yaml_load_devices
if __name__ == "__main__":
password = os.getenv("PYNET_PASSWORD") if os.getenv("PYNET_PASSWORD") else getpass()
devices = yaml_load_devices()
for name, device_dict in devices.items():
device_dict["password"] = password
connection = pyeapi.client.connect(**device_dict)
device = pyeapi.client.Node(connection)
output = device.enable("show ip route")
routes = output[0]["result"]["vrfs"]["default"]["routes"]
print()
for prefix, route_dict in routes.items():
route_type = route_dict["routeType"]
print()
print(prefix)
print("-" * 12)
print(route_type)
print(">" * 6)
print(route_dict["vias"][0]["interface"])
if route_type == "static":
print(route_dict["vias"][0]["nexthopAddr"])
print("-" * 12)