How to use the pyeapi.utils.debug 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_utils.py View on Github external
def test_debug(self, mock_logger):
        pyeapi.utils.islocalconnection = Mock(return_value=True)
        pyeapi.utils.debug('test')
        mock_logger.debug.assert_called_with('test_utils.test_debug: test')
github arista-eosplus / pyeapi / pyeapi / client.py View on Github external
This method will load the eapi.conf file specified by filename into
        the instance object.  It will also add the default connection localhost
        if it was not defined in the eapi.conf file

        Args:
            filename (str): The full path to the file to load
        """

        try:
            SafeConfigParser.read(self, filename)
        except SafeConfigParserError as exc:
            # Ignore file and syslog a message on SafeConfigParser errors
            msg = ("%s: parsing error in eapi conf file: %s" %
                   (type(exc).__name__, filename))
            debug(msg)

        self._add_default_connection()

        for name in self.sections():
            if name.startswith('connection:') and \
               'host' not in dict(self.items(name)):

                self.set(name, 'host', name.split(':')[1])
        self.generate_tags()
github arista-eosplus / pyeapi / pyeapi / connection.py View on Github external
Args:
            data (string): The data to be included in the body of the eAPI
                request object

        Returns:
            A decoded response.  The response object is deserialized from
                JSON and returned as a standard Python dictionary object

        Raises:
            CommandError if an eAPI failure response object is returned from
                the node.   The CommandError exception includes the error
                code and error message from the eAPI response.
        """
        header = {'Content-Type': 'application/json'}

        debug('EAPI REQ: %s' % data)
        request = urllib2.Request(self.uri, data, header)
        response = self.http(request)
        decoded = json.loads(response.read())
        debug('EAPI RESP: %s' % decoded)

        if 'error' in decoded:
            _message = decoded['error']['message']
            _code = decoded['error']['code']
            raise CommandError(_code, _message)

        return decoded
github arista-eosplus / pyeapi / pyeapi / connection.py View on Github external
Returns:
            A decoded response.  The response object is deserialized from
                JSON and returned as a standard Python dictionary object

        Raises:
            CommandError if an eAPI failure response object is returned from
                the node.   The CommandError exception includes the error
                code and error message from the eAPI response.
        """
        header = {'Content-Type': 'application/json'}

        debug('EAPI REQ: %s' % data)
        request = urllib2.Request(self.uri, data, header)
        response = self.http(request)
        decoded = json.loads(response.read())
        debug('EAPI RESP: %s' % decoded)

        if 'error' in decoded:
            _message = decoded['error']['message']
            _code = decoded['error']['code']
            raise CommandError(_code, _message)

        return decoded