本文整理汇总了Python中freenasUI.common.freenasldap.FreeNAS_ActiveDirectory.get_ldap_servers方法的典型用法代码示例。如果您正苦于以下问题:Python FreeNAS_ActiveDirectory.get_ldap_servers方法的具体用法?Python FreeNAS_ActiveDirectory.get_ldap_servers怎么用?Python FreeNAS_ActiveDirectory.get_ldap_servers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freenasUI.common.freenasldap.FreeNAS_ActiveDirectory
的用法示例。
在下文中一共展示了FreeNAS_ActiveDirectory.get_ldap_servers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tryConnect
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import get_ldap_servers [as 别名]
def tryConnect(self, host, port):
max_tries = 3
connected = False
sm_timeout = _fs().middlewared.plugins.service_monitor.socket_timeout
host_list = []
if self.name == 'activedirectory':
for i in range(0, max_tries):
# Make max_tries attempts to get SRV records from DNS
host_list = FreeNAS_ActiveDirectory.get_ldap_servers(host)
if host_list:
break
else:
self.logger.debug(f'[ServiceMonitorThread] Attempt {i} to query SRV records failed')
if not host_list:
self.logger.debug(f'[ServiceMonitorThread] Query for SRV records for {host} failed')
return False
for h in host_list:
port_is_listening = FreeNAS_ActiveDirectory.port_is_listening(str(h.target), h.port, errors=[], timeout=sm_timeout)
if port_is_listening:
return True
else:
self.logger.debug(f'[ServiceMonitorThread] Cannot connect: {h.target}:{h.port}')
connected = False
return connected
else:
self.logger.debug(f'[ServiceMonitorThread] no monitoring has been written for {self.name}')
return False