def _setup_static(self): parser = ConfigParser() parser.read(self.config_static_path) self.endpoint = parser.get('DEFAULT', 'vcenter_hostname') self.port = parser.get('DEFAULT', 'vcenter_port') if parser.get('DEFAULT', 'vmware_validate_certs').lower() in ('no', 'false'): self.insecure = True self._wait_for_service()
def parse(path): """ :type path: str :rtype: TowerConfig """ parser = ConfigParser() parser.read(path) keys = ( 'version', 'host', 'username', 'password', ) values = dict((k, parser.get('default', k)) for k in keys) config = TowerConfig(values) missing = [k for k in keys if not values.get(k)] if missing: raise ApplicationError( 'Missing or empty Tower configuration value(s): %s' % ', '.join(missing)) return config
def _setup_static(self): """Configure CloudStack tests for use with static configuration.""" parser = ConfigParser() 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 get_environment_config(self): """ :rtype: CloudEnvironmentConfig """ parser = ConfigParser() parser.read(self.config_path) env_vars = dict(SCW_API_KEY=parser.get('default', 'key'), SCW_ORG=parser.get('default', 'org')) ansible_vars = dict(scw_org=parser.get('default', 'org'), ) return CloudEnvironmentConfig( env_vars=env_vars, ansible_vars=ansible_vars, )
def _setup_static(self): parser = ConfigParser({ 'vcenter_port': '443', 'vmware_proxy_host': '', 'vmware_proxy_port': '' }) parser.read(self.config_static_path) self.endpoint = parser.get('DEFAULT', 'vcenter_hostname') self.port = parser.get('DEFAULT', 'vcenter_port') if parser.get('DEFAULT', 'vmware_validate_certs').lower() in ('no', 'false'): self.insecure = True proxy_host = parser.get('DEFAULT', 'vmware_proxy_host') proxy_port = int(parser.get('DEFAULT', 'vmware_proxy_port')) if proxy_host and proxy_port: self.proxy = 'http://%s:%d' % (proxy_host, proxy_port) self._wait_for_service()
def configure_environment(self, env, cmd): """ :type env: dict[str, str] :type cmd: list[str] """ parser = ConfigParser() parser.read(self.config_path) changes = dict(VULTR_API_KEY=parser.get('default', 'key'), ) env.update(changes) cmd.append('-e') cmd.append('vultr_resource_prefix=%s' % self.resource_prefix)
def get_environment_config(self): """ :rtype: CloudEnvironmentConfig """ parser = ConfigParser() parser.read(self.config_path) env_vars = dict(VULTR_API_KEY=parser.get('default', 'key'), ) ansible_vars = dict(vultr_resource_prefix=self.resource_prefix, ) return CloudEnvironmentConfig( env_vars=env_vars, ansible_vars=ansible_vars, )
def configure_environment(self, env, cmd): """ :type env: dict[str, str] :type cmd: list[str] """ parser = ConfigParser() parser.read(self.config_path) changes = dict(CLOUDSCALE_API_TOKEN=parser.get( 'default', 'cloudscale_api_token'), ) env.update(changes) cmd.append('-e') cmd.append('cloudscale_resource_prefix=%s' % self.resource_prefix)
def get_environment_config(self): parser = ConfigParser() parser.read(self.config_path) env_vars = dict(HCLOUD_TOKEN=parser.get('default', 'hcloud_api_token'), ) ansible_vars = dict(hcloud_prefix=self.resource_prefix, ) ansible_vars.update( dict((key.lower(), value) for key, value in env_vars.items())) return CloudEnvironmentConfig( env_vars=env_vars, ansible_vars=ansible_vars, )
def get_environment_config(self): """ :rtype: CloudEnvironmentConfig """ parser = ConfigParser() parser.read(self.config_path) env_vars = dict(CLOUDSCALE_API_TOKEN=parser.get( 'default', 'cloudscale_api_token'), ) ansible_vars = dict(cloudscale_resource_prefix=self.resource_prefix, ) ansible_vars.update( dict((key.lower(), value) for key, value in env_vars.items())) return CloudEnvironmentConfig( env_vars=env_vars, ansible_vars=ansible_vars, )