How to use the pyeapi.client.load_config 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 / 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_connect_return_node_enablepwd(self):
        transport = Mock()
        with patch.dict(pyeapi.client.TRANSPORTS, {'https': transport}):
            conf = get_fixture('eapi.conf')
            pyeapi.client.load_config(filename=conf)
            node = pyeapi.client.connect(host='192.168.1.16', username='eapi',
                                         password='password', port=None,
                                         timeout=60, enablepwd='enablepwd',
                                         return_node=True)
            kwargs = dict(host='192.168.1.16', username='eapi',
                          password='password', port=None, key_file=None,
                          cert_file=None, ca_file=None, timeout=60)
            transport.assert_called_once_with(**kwargs)
            self.assertEqual(node._enablepwd, 'enablepwd')
github arista-eosplus / pyeapi / test / unit / test_client.py View on Github external
def test_load_config_yaml(self):
        conf = get_fixture('eapi.conf.yaml')
        pyeapi.client.load_config(filename=conf)
        conns = pyeapi.client.config.connections
        self.assertEqual(conns, ['localhost'])
github arista-eosplus / pyeapi / test / unit / test_client.py View on Github external
def test_connect_return_node(self):
        transport = Mock()
        with patch.dict(pyeapi.client.TRANSPORTS, {'https': transport}):
            conf = get_fixture('eapi.conf')
            pyeapi.client.load_config(filename=conf)
            node = pyeapi.client.connect(host='192.168.1.16', username='eapi',
                                         password='password', port=None,
                                         timeout=60, return_node=True)
            kwargs = dict(host='192.168.1.16', username='eapi',
                          password='password', port=None, key_file=None,
                          cert_file=None, ca_file=None, timeout=60)
            transport.assert_called_once_with(**kwargs)
            self.assertIsNone(node._enablepwd)
github arista-eosplus / pyeapi / test / unit / test_client.py View on Github external
def test_config_always_has_default_connection(self):
        conf = '/invalid.conf'
        pyeapi.client.load_config(conf)
        self.assertEqual(len(pyeapi.client.config.sections()), 1)
        name = 'connection:localhost'
        self.assertIn(name, pyeapi.client.config.sections())
github arista-eosplus / pyeapi / test / unit / test_client.py View on Github external
def test_load_config(self):
        conf = get_fixture('eapi.conf')
        pyeapi.client.load_config(conf)
        self.assertEqual(len(pyeapi.client.config.sections()), 3)
        for name in ['localhost', 'test1', 'test2']:
            name = 'connection:%s' % name
            self.assertIn(name, pyeapi.client.config.sections())
github arista-eosplus / pyeapi / test / unit / test_client.py View on Github external
def test_load_config_for_connection_with_env(self):
        os.environ['EAPI_CONF'] = get_fixture('eapi.conf')
        pyeapi.client.load_config(random_string())
        cfg = pyeapi.client.config.get_connection('test1')
        self.assertEqual(cfg['host'], '192.168.1.16')
        self.assertEqual(cfg['username'], 'eapi')
        self.assertEqual(cfg['password'], 'password')
        self.assertEqual(cfg['enablepwd'], 'enablepwd')
github arista-eosplus / pyeapi / test / unit / test_client.py View on Github external
def test_load_config_empty_conf(self):
        conf = get_fixture('empty.conf')
        pyeapi.client.load_config(filename=conf)
        conns = pyeapi.client.config.connections
        self.assertEqual(conns, ['localhost'])