def __init__(self, proxyName='proxy1', proxy=[], groupName='group1', lbType=leastc, host='', address='', enabled=True, weight=1): if isinstance(proxy, str): proxy = [proxy] self.proxyName = proxyName self.proxyAddresses = [util.splitHostPort(x) for x in proxy] self.groupName = groupName self.lbType = lbType self.hostName = host self.hostAddress = util.splitHostPort(address) self.groupEnabled = enabled self.hostWeight = weight
def getHostByHostame(self, hostname): """ A convenience method for getting a host proxy from the group proxy, given its hostname. """ host, port = util.splitHostPort(hostname) for host in self.hosts.values(): if host.hostname == host and host.port == port: return host