How to use pyeapi - 10 common examples

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 / lib / systestlib.py View on Github external
def setUp(self):
        pyeapi.client.load_config(filename=get_fixture('dut.conf'))
        config = pyeapi.client.config

        self.duts = list()
        for name in config.sections():
            if name.startswith('connection:') and 'localhost' not in name:
                name = name.split(':')[1]
                self.duts.append(pyeapi.client.connect_to(name))
github arista-eosplus / pyeapi / test / system / test_client.py View on Github external
def test_execute_with_autocomplete(self):
        # There are some versions of EOS before 4.17.x that have the
        # autocomplete feature available. If system tests are run on one of
        # those version of EOS this system test will fail.
        for dut in self.duts:
            version = self._dut_eos_version(dut)
            version = version.split('.')
            if int(version[0]) >= 4 and int(version[1]) >= 17:
                result = dut.connection.execute(['sh ver'], encoding='json',
                                                autoComplete=True)
                self.assertIn('version', result['result'][0])
            else:
                # Verify exception thrown for EOS version that does not
                # support autoComplete parameter with EAPI
                with self.assertRaises(pyeapi.eapilib.CommandError):
                    dut.connection.execute(['sh ver'], encoding='json',
                                           autoComplete=True)
github arista-eosplus / pyeapi / test / system / test_client.py View on Github external
def setUp(self):
        pyeapi.client.load_config(filename=get_fixture('dut.conf'))
        config = pyeapi.client.config

        self.duts = list()
        for name in config.sections():
            if name.startswith('connection:') and 'localhost' not in name:
                name = name.split(':')[1]
                dut = pyeapi.client.connect_to(name)
                self.duts.append(dut)
                if dut._enablepwd is not None:
                    # If enable password defined for dut, set the
                    # enable password on the dut and clear it on tearDown
                    dut.config("enable secret %s" % dut._enablepwd)
github internap / fake-switches / tests / arista / __init__.py View on Github external
def wrapper(self, protocol):
        api = pyeapi.connect(transport="http", host=protocol.host, port=protocol.conf["http"],
                             username=protocol.username, password=protocol.password, return_node=True)
        test(self, protocol, api)
github arista-eosplus / pyeapi / test / system / test_client.py View on Github external
def setUp(self):
        pyeapi.client.load_config(filename=get_fixture('dut.conf'))
        config = pyeapi.client.config

        self.duts = list()
        for name in config.sections():
            if name.startswith('connection:') and 'localhost' not in name:
                name = name.split(':')[1]
                self.duts.append(pyeapi.client.connect_to(name))
github arista-eosplus / pyeapi / test / system / test_client.py View on Github external
def setUp(self):
        pyeapi.client.load_config(filename=get_fixture('dut.conf'))
        config = pyeapi.client.config

        self.duts = list()
        for name in config.sections():
            if name.startswith('connection:') and 'localhost' not in name:
                name = name.split(':')[1]
                dut = pyeapi.client.connect_to(name)
                self.duts.append(dut)
                if dut._enablepwd is not None:
                    # If enable password defined for dut, set the
                    # enable password on the dut and clear it on tearDown
                    dut.config("enable secret %s" % dut._enablepwd)
github arista-eosplus / pyeapi / test / lib / systestlib.py View on Github external
def setUp(self):
        pyeapi.client.load_config(filename=get_fixture('dut.conf'))
        config = pyeapi.client.config

        self.duts = list()
        for name in config.sections():
            if name.startswith('connection:') and 'localhost' not in name:
                name = name.split(':')[1]
                self.duts.append(pyeapi.client.connect_to(name))
github arista-eosplus / pyeapi / test / system / test_client.py View on Github external
def setUp(self):
        pyeapi.client.load_config(filename=get_fixture('dut.conf'))
        config = pyeapi.client.config

        self.duts = list()
        for name in config.sections():
            if name.startswith('connection:') and 'localhost' not in name:
                name = name.split(':')[1]
                dut = pyeapi.client.connect_to(name)
                self.duts.append(dut)
                if dut._enablepwd is not None:
                    # If enable password defined for dut, set the
                    # enable password on the dut and clear it on tearDown
                    dut.config("enable secret %s" % dut._enablepwd)
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