/usr/share/pyshared/juju/environment/environment.py is in juju-0.7 0.7-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | from juju.lib.loader import get_callable
class Environment(object):
"""An environment where machines can be run on."""
def __init__(self, name, environment_config):
self._name = name
self._environment_config = environment_config
self._machine_provider = None
@property
def name(self):
"""The name of this environment."""
return self._name
def get_serialization_data(self):
provider = self.get_machine_provider()
data = {self.name: provider.get_serialization_data()}
return data
@property
def type(self):
"""The type of the environment."""
return self._environment_config["type"]
def get_machine_provider(self):
"""Return a MachineProvider instance for the given provider name.
The returned instance will be retrieved from the module named
after the type of the given machine provider.
"""
if self._machine_provider is None:
provider_type = self._environment_config["type"]
MachineProvider = get_callable(
"juju.providers.%s.MachineProvider" % provider_type)
self._machine_provider = MachineProvider(
self._name, self._environment_config)
return self._machine_provider
@property
def placement(self):
"""The name of the default placement policy.
If the environment doesn't have a default unit placement
policy None is returned
"""
return self._environment_config.get("placement")
@property
def default_series(self):
"""The Ubuntu series to run on machines in this environment."""
return self._environment_config.get("default-series")
@property
def origin(self):
"""Returns the origin of the code."""
return self._environment_config.get("juju-origin", "distro")
|