def _setup_static(self): """Configure CloudStack tests for use with static configuration.""" parser = configparser.RawConfigParser() parser.read(self.config_static_path) self.endpoint = parser.get('cloudstack', 'endpoint') parts = urlparse(self.endpoint) self.host = parts.hostname if not self.host: raise ApplicationError( 'Could not determine host from endpoint: %s' % self.endpoint) if parts.port: self.port = parts.port elif parts.scheme == 'http': self.port = 80 elif parts.scheme == 'https': self.port = 443 else: raise ApplicationError( 'Could not determine port from endpoint: %s' % self.endpoint) display.info('Read cs host "%s" and port %d from config: %s' % (self.host, self.port, self.config_static_path), verbosity=1) self._wait_for_service()
def _setup_static(self): """Configure CloudStack tests for use with static configuration.""" parser = configparser.RawConfigParser() parser.read(self.config_static_path) self.endpoint = parser.get('cloudstack', 'endpoint') parts = urlparse(self.endpoint) self.host = parts.hostname if not self.host: raise ApplicationError('Could not determine host from endpoint: %s' % self.endpoint) if parts.port: self.port = parts.port elif parts.scheme == 'http': self.port = 80 elif parts.scheme == 'https': self.port = 443 else: raise ApplicationError('Could not determine port from endpoint: %s' % self.endpoint) display.info('Read cs host "%s" and port %d from config: %s' % (self.host, self.port, self.config_static_path), verbosity=1) self._wait_for_service()
def _setup_dynamic(self): """Request Azure credentials through Sherlock.""" display.info('Provisioning %s cloud environment.' % self.platform, verbosity=1) config = self._read_config_template() response = {} if os.path.isfile(self.SHERLOCK_CONFIG_PATH): with open(self.SHERLOCK_CONFIG_PATH, 'r') as sherlock_fd: sherlock_uri = sherlock_fd.readline().strip() + '&rgcount=2' parts = urlparse(sherlock_uri) query_string = parse_qs(parts.query) base_uri = urlunparse(parts[:4] + ('', '')) if 'code' not in query_string: example_uri = 'https://example.azurewebsites.net/api/sandbox-provisioning' raise ApplicationError( 'The Sherlock URI must include the API key in the query string. Example: %s?code=xxx' % example_uri) display.info('Initializing azure/sherlock from: %s' % base_uri, verbosity=1) http = HttpClient(self.args) result = http.get(sherlock_uri) display.info('Started azure/sherlock from: %s' % base_uri, verbosity=1) if not self.args.explain: response = result.json() else: aci = self._create_ansible_core_ci() aci_result = aci.start() if not self.args.explain: response = aci_result['azure'] self.aci = aci if not self.args.explain: values = dict( AZURE_CLIENT_ID=response['clientId'], AZURE_SECRET=response['clientSecret'], AZURE_SUBSCRIPTION_ID=response['subscriptionId'], AZURE_TENANT=response['tenantId'], RESOURCE_GROUP=response['resourceGroupNames'][0], RESOURCE_GROUP_SECONDARY=response['resourceGroupNames'][1], ) display.sensitive.add(values['AZURE_SECRET']) config = '\n'.join('%s: %s' % (key, values[key]) for key in sorted(values)) config = '[default]\n' + config self._write_config(config)
def _setup_dynamic(self): """Request Azure credentials through Sherlock.""" display.info('Provisioning %s cloud environment.' % self.platform, verbosity=1) config = self._read_config_template() response = {} if os.path.isfile(self.SHERLOCK_CONFIG_PATH): with open(self.SHERLOCK_CONFIG_PATH, 'r') as sherlock_fd: sherlock_uri = sherlock_fd.readline().strip() + '&rgcount=2' parts = urlparse(sherlock_uri) query_string = parse_qs(parts.query) base_uri = urlunparse(parts[:4] + ('', '')) if 'code' not in query_string: example_uri = 'https://example.azurewebsites.net/api/sandbox-provisioning' raise ApplicationError('The Sherlock URI must include the API key in the query string. Example: %s?code=xxx' % example_uri) display.info('Initializing azure/sherlock from: %s' % base_uri, verbosity=1) http = HttpClient(self.args) result = http.get(sherlock_uri) display.info('Started azure/sherlock from: %s' % base_uri, verbosity=1) if not self.args.explain: response = result.json() else: aci = self._create_ansible_core_ci() aci_result = aci.start() if not self.args.explain: response = aci_result['azure'] self.aci = aci if not self.args.explain: values = dict( AZURE_CLIENT_ID=response['clientId'], AZURE_SECRET=response['clientSecret'], AZURE_SUBSCRIPTION_ID=response['subscriptionId'], AZURE_TENANT=response['tenantId'], RESOURCE_GROUP=response['resourceGroupNames'][0], RESOURCE_GROUP_SECONDARY=response['resourceGroupNames'][1], ) config = '\n'.join('%s: %s' % (key, values[key]) for key in sorted(values)) self._write_config(config)