How to use the pyeapi.client.Node function in pyeapi

To help you get started, we’ve selected a few pyeapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arista-eosplus / pyeapi / test / unit / test_client.py View on Github external
def test_node_hasattr_connection(self):
        node = pyeapi.client.Node(None)
        self.assertTrue(hasattr(node, 'connection'))
github arista-eosplus / pyeapi / test / lib / testlib.py View on Github external
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
github arista-eosplus / pyeapi / test / unit / test_client.py View on Github external
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)
github arista-eosplus / pyeapi / test / unit / test_client.py View on Github external
def setUp(self):
        self.connection = Mock()
        self.node = pyeapi.client.Node(self.connection)
github ktbyers / pyplus_course / class6 / exercises / ex2a_yaml_inventory.py View on Github external
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()
github ktbyers / pyplus_course / class6 / exercises / ex3_show_routes.py View on Github external
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)