示例#1
0
 def _autodetect_id(self, host, **kwargs):
     logger.debug("Trying to detect objectId for %s" % host)
     adapter = get_adapter(host, **kwargs)
     id_ = oid_to_str(adapter.get_one(OID_OBJECT_ID))
     assert id_ is not None, 'empty OID returned'
     logger.debug("objectId for %s is %s" % (host, id_))
     return id_
示例#2
0
def maybe_oid_to_str(objectId):
    """Convert given OID to string if needed."""
    if objectId is None:
        return None
    elif isinstance(objectId, binary_type):
        return objectId
    elif isinstance(objectId, string_types):
        return b(objectId)
    elif isinstance(objectId, ObjectIdentifier):
        return b(objectId)
    elif isinstance(objectId, (tuple, list)):
        return oid_to_str(objectId)
    else:
        raise ValueError('Unknown OID %r' % objectId)
示例#3
0
 def autodetect_id(self, host, **kwargs):
     self.inst_logger.debug("Trying to detect objectId for %s" % host)
     adapter = get_adapter(host, **kwargs)
     id = oid_to_str(adapter.get_one(OID_OBJECT_ID))
     self.inst_logger.debug("objectId for %s is %s" % (host, id))
     return id