def do_get(self, url, top_level=False, top_level_path=""): parts = list(urllib.parse.urlparse(url)) # 2 is the path offset if top_level: parts[2] = '/' + top_level_path parts[2] = MULTIPLE_SLASH.sub('/', parts[2]) url = urllib.parse.urlunparse(parts) try: if self.disable_ssl_validation: urllib3.disable_warnings() http = urllib3.PoolManager(cert_reqs='CERT_NONE') else: http = urllib3.PoolManager() r = http.request('GET', url, headers=self.headers) except Exception as e: LOG.error("Request on service '%s' with url '%s' failed", self.s_type, url) raise e if r.status == 403: raise exceptions.Forbidden("Request on service '%s' with url '%s' " "failed with code 403" % (self.s_type, url)) if r.status >= 400: raise ServiceError("Request on service '%s' with url '%s' failed" " with code %d" % (self.s_type, url, r.status)) return r.data.decode('utf-8')
def _discover_network(self): LOG.info("No network supplied, trying auto discover for network") network_list = self.client.list_networks() for network in network_list['networks']: if network['router:external'] and network['subnets']: LOG.info("Found network, using: {0}".format(network['id'])) self._public_network_id = network['id'] self._public_network_name = network['name'] break # Couldn't find an existing external network else: LOG.error("No external networks found. " "Please note that any test that relies on external " "connectivity would most likely fail.")