def _get_from_any_instance(self, endpoint): for eureka_url in self.eureka_urls: try: r = requests.get(urljoin(eureka_url, endpoint), headers={'accept': 'application/json'}) r.raise_for_status() return json.loads(r.content) except (EurekaHTTPException, URLError) as e: pass raise EurekaGetFailedException("Failed to GET %s from all instances" % endpoint)
def get_remote_config(self): try: url = urljoin(self.config_url, "eurekaserver/expeureka01") r, res = requests.get(url, headers={'Accept': 'application/json'}) r.raise_for_status() configs = json.loads(res) eureka_urls = [] ports = [] for item in configs['propertySources']: eureka_urls.append(item['source']['eureka.client.serviceUrl.defaultZone']) ports.append(item['source']['server.port']) return eureka_urls,ports except (EurekaHTTPException, URLError): raise EurekaGetFailedException("Failed to GET from all configs" ), None, sys.exc_info()[2]