def SIZES(self): """ returns the host group instance size map """ config_module = get_config_module() try: return config_module.SIZES except AttributeError as ex: raise ConfigurationError(ex)
def CLOUDS(self): """ returns a configuration dict """ config_module = get_config_module() try: return config_module.CLOUDS except AttributeError as ex: raise ConfigurationError(ex)
def get_cloud(self, cloud=None): if cloud is None: cloud = global_state['cloud'] clouds = self.CLOUDS try: return clouds[cloud] except KeyError: raise ConfigurationError('Invalid cloud: {}'.format(cloud))
def set_cloud(cloud): if not cloud: return global_state['cloud'] = cloud # set the default region cloud_config = config_proxy.get_cloud() try: supported_regions = cloud_config['REGIONS'] except KeyError: raise ConfigurationError( 'Cloud "{}" has no REGIONS setting'.format(cloud)) try: default_region = supported_regions[0] set_region(default_region) except (TypeError, IndexError): raise ConfigurationError( 'Cloud "{}" has no supported regions'.format(cloud))
def get_config_module(gonzo_home=GONZO_HOME): """ returns the global configuration module """ if not os.path.exists(gonzo_home): os.mkdir(gonzo_home) try: fp, pathname, description = imp.find_module('config', [gonzo_home]) except ImportError: raise ConfigurationError( "gonzo config does not exist. Please see README") config_module = imp.load_module('config', fp, pathname, description) return config_module
def __getitem__(self, key): if key == "spam": return "ham" else: raise ConfigurationError()
def _raise(self, key): raise ConfigurationError('{} not specified'.format(key))
def test_missing(self, clouds): clouds.side_effect = ConfigurationError() assert available_clouds() is None
def test_error(self, project, region, cloud): project.side_effect = ConfigurationError() args = Mock() main(args)