Example #1
0
File: config.py Project: flug/gonzo
 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)
Example #2
0
File: config.py Project: flug/gonzo
 def CLOUDS(self):
     """ returns a configuration dict """
     config_module = get_config_module()
     try:
         return config_module.CLOUDS
     except AttributeError as ex:
         raise ConfigurationError(ex)
Example #3
0
File: config.py Project: flug/gonzo
 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))
Example #4
0
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))
Example #5
0
File: config.py Project: flug/gonzo
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
Example #6
0
 def __getitem__(self, key):
     if key == "spam":
         return "ham"
     else:
         raise ConfigurationError()
Example #7
0
File: config.py Project: flug/gonzo
 def _raise(self, key):
     raise ConfigurationError('{} not specified'.format(key))
Example #8
0
 def test_missing(self, clouds):
     clouds.side_effect = ConfigurationError()
     assert available_clouds() is None
Example #9
0
 def test_error(self, project, region, cloud):
     project.side_effect = ConfigurationError()
     args = Mock()
     main(args)