def __init__(self, config=None, prev_config=None): """Generate a list of mixin classes that implement the backend, working through composition. 'config' is a dict which typically comes from the JSON de-serialization of config.json in JujuGUI. 'prev_config' is a dict used to compute the differences. If it is not passed, all current config values are considered new. """ if config is None: config = utils.get_config() self.config = config if prev_config is None: prev_config = {} self.prev_config = prev_config self.mixins = [SetUpMixin()] is_legacy_juju = utils.legacy_juju() if config["staging"]: if not is_legacy_juju: raise ValueError("Unable to use staging with go backend") self.mixins.append(ImprovMixin()) elif config["sandbox"]: self.mixins.append(SandboxMixin()) else: mixin = PythonMixin() if is_legacy_juju else GoMixin() self.mixins.append(mixin) # We always install and start the GUI. self.mixins.append(GuiMixin()) # TODO: eventually this option will go away, as well as haproxy and # Apache. if config.get("builtin-server", False): self.mixins.append(BuiltinServerMixin()) else: self.mixins.append(HaproxyApacheMixin())
def test_pyjuju(self): # If the agent file does not exist this is a PyJuju environment. self.assertTrue(legacy_juju())
def test_jujucore(self): # If the agent file is found this is a juju-core environment. agent_path = os.path.join(self.base_dir, 'agent.conf') open(agent_path, 'w').close() self.assertFalse(legacy_juju())