Example #1
0
 def test_rget(self):
     c = ComposerConfig()
     c['a'] = 1
     c = c.new_child()
     c['a'] = 99
     c['b'] = "alpha"
     self.assertEqual(c.get('a'), 99)
     self.assertEqual(c.get('b'), "alpha")
     self.assertEqual(c.rget('a'), [99, 1])
Example #2
0
class Configable(object):
    CONFIG_FILE = None

    def __init__(self):
        self._config = ComposerConfig()
        self.config_file = None

    @property
    def config(self):
        if self._config.configured:
            return self._config
        if self.config_file and self.config_file.exists():
            self._config.configure(self.config_file)
        return self._config

    @property
    def configured(self):
        return bool(self.config is not None and self.config.configured)
Example #3
0
    def plan_layers(self, layers, output_files):
        config = ComposerConfig()
        config = config.add_config(
            layers["layers"][0] / ComposerConfig.DEFAULT_FILE, True)

        layers["layers"][-1].url = self.name

        for i, layer in enumerate(layers["layers"]):
            log.info("Processing layer: %s", layer.url)
            if i + 1 < len(layers["layers"]):
                next_layer = layers["layers"][i + 1]
                config = config.add_config(
                    next_layer / ComposerConfig.DEFAULT_FILE, True)
            list(e for e in utils.walk(layer.directory,
                                       self.build_tactics,
                                       current=layer,
                                       config=config,
                                       output_files=output_files))
        plan = [t for t in output_files.values() if t]
        return plan
Example #4
0
 def test_tactics(self):
     # configure from empty and a layer with tactics
     c = ComposerConfig()
     c._tactics = ['a', 'b', 'c']
     c = c.new_child()
     c._tactics = ['d', 'c']
     self.assertEqual(c.tactics()[:5], ['d', 'c', 'a', 'b', 'c'])
Example #5
0
 def __init__(self):
     self._config = ComposerConfig()
     self.config_file = None
Example #6
0
 def __init__(self):
     self.config = ComposerConfig()
     self.force = False
     self._name = None
     self._charm = None