def __init__(self, url, bind_username=None, bind_password=None, max_age=200): assert isinstance(url, basestring) assert bind_username == None or isinstance(bind_username, basestring) assert bind_password == None or isinstance(bind_password, basestring) assert max_age > 0 url_parsed = urlparse.urlparse(url) if url_parsed.scheme != "ldap" or url_parsed.netloc == "": raise ValueError("%s: malformed LDAP URL?" % url) self.url = commonl.url_remove_user_pwd(url_parsed) if bind_username == None: self.bind_username = url_parsed.username else: self.bind_username = bind_username if bind_password == None: self.bind_password = url_parsed.password else: self.bind_password = bind_password self.bind_password = commonl.password_get(self.url, self.bind_username, self.bind_password) # dictionary of [ field_lookup, field_report ] = { # VALUE: ( TIMESTAMP, REPORTED_FIELD ), # } self._cache = collections.defaultdict(dict) self.conn = None #: maximum number of seconds an entry will live in the cache #: before it is considered old and refetched from the servers. self.max_age = max_age
def __init__(self, bmc_url, verify=True, **kwargs): assert isinstance(bmc_url, basestring) assert isinstance(verify, bool) ttbl.power.impl_c.__init__(self, paranoid=True, **kwargs) self.power_on_recovery = False self.paranoid_get_samples = 0 url = urlparse.urlparse(bmc_url) self.username = url.username self.password = commonl.password_get(url.hostname, self.username, url.password) self.url = commonl.url_remove_user_pwd(url) self.verify = verify