def fetch(cls): # Create own requests session and disable all environment variables, # so that we can bypass any proxy set via env var for this request. session = requests.Session() session.trust_env = False try: resp = session.get(cls.METADATA_URL, timeout=cls.TIMEOUT, headers=cls.HEADERS) resp.raise_for_status() except Exception as e: resp = None _logger.debug('Unable to fetch %s data from %r: %r', cls.VENDOR_NAME, cls.METADATA_URL, e) return resp
def fetch(self, path): if self.skip_metadata_check: return None # Create own requests session and disable all environment variables, # so that we can bypass any proxy set via env var for this request. session = requests.Session() session.trust_env = False url = self.metadata_url(path) try: resp = session.get(url, timeout=self.timeout) except Exception as e: self.skip_metadata_check = True _logger.debug('Error fetching AWS data for %r: %r', path, e) result = None else: result = resp.text return result