Esempio n. 1
0
    def objects(self):
        """Get objects for a notification.

        :return: The list of objects (as :class:`Column`,
            :class:`Node` or :class:`Scalar` instances) of the notification.
        """
        child = self.node
        lindex = []
        element = _smi.smiGetFirstElement(child)
        while element != ffi.NULL:
            nelement = _smi.smiGetElementNode(element)
            if nelement == ffi.NULL:
                raise SMIException("cannot get object "
                                   "associated with {0}".format(
                                       ffi.string(self.node.name)))
            if nelement.nodekind == _smi.SMI_NODEKIND_COLUMN:
                lindex.append(Column(nelement))
            elif nelement.nodekind == _smi.SMI_NODEKIND_NODE:
                lindex.append(Node(nelement))
            elif nelement.nodekind == _smi.SMI_NODEKIND_SCALAR:
                lindex.append(Scalar(nelement))
            else:
                raise SMIException("object {0} for {1} is "
                                   "not a node".format(
                                       ffi.string(nelement.name),
                                       ffi.string(self.node.name)))
            element = _smi.smiGetNextElement(element)
        return lindex
Esempio n. 2
0
    def objects(self):
        """Get objects for a notification.

        :return: The list of objects (as :class:`Column`,
            :class:`Node` or :class:`Scalar` instances) of the notification.
        """
        child = self.node
        lindex = []
        element = _smi.smiGetFirstElement(child)
        while element != ffi.NULL:
            nelement = _smi.smiGetElementNode(element)
            if nelement == ffi.NULL:
                raise SMIException("cannot get object "
                                   "associated with {0}".format(
                                       ffi.string(self.node.name)))
            if nelement.nodekind == _smi.SMI_NODEKIND_COLUMN:
                lindex.append(Column(nelement))
            elif nelement.nodekind == _smi.SMI_NODEKIND_NODE:
                lindex.append(Node(nelement))
            elif nelement.nodekind == _smi.SMI_NODEKIND_SCALAR:
                lindex.append(Scalar(nelement))
            else:
                raise SMIException("object {0} for {1} is "
                                   "not a node".format(
                                       ffi.string(nelement.name),
                                       ffi.string(self.node.name)))
            element = _smi.smiGetNextElement(element)
        return lindex
Esempio n. 3
0
File: mib.py Progetto: W4lken/snimpy
    def index(self):
        """Get indexes for a table. The indexes are used to locate a precise
        row in a table. They are a subset of the table columns.

        :return: The list of indexes (as :class:`Column` instances) of
            the table.
        """
        child = self._row
        lindex = []
        element = _smi.smiGetFirstElement(child)
        while element != ffi.NULL:
            nelement = _smi.smiGetElementNode(element)
            if nelement == ffi.NULL:
                raise SMIException("cannot get index " "associated with {0}".format(ffi.string(self.node.name)))
            if nelement.nodekind != _smi.SMI_NODEKIND_COLUMN:
                raise SMIException(
                    "index {0} for {1} is " "not a column".format(ffi.string(nelement.name), ffi.string(self.node.name))
                )
            lindex.append(Column(nelement))
            element = _smi.smiGetNextElement(element)
        return lindex
Esempio n. 4
0
    def index(self):
        """Get indexes for a table. The indexes are used to locate a precise
        row in a table. They are a subset of the table columns.

        :return: The list of indexes (as :class:`Column` instances) of
            the table.
        """
        child = self._row
        lindex = []
        element = _smi.smiGetFirstElement(child)
        while element != ffi.NULL:
            nelement = _smi.smiGetElementNode(element)
            if nelement == ffi.NULL:
                raise SMIException("cannot get index "
                                   "associated with {0}".format(
                                       ffi.string(self.node.name)))
            if nelement.nodekind != _smi.SMI_NODEKIND_COLUMN:
                raise SMIException("index {0} for {1} is "
                                   "not a column".format(
                                       ffi.string(nelement.name),
                                       ffi.string(self.node.name)))
            lindex.append(Column(nelement))
            element = _smi.smiGetNextElement(element)
        return lindex