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_
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)
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