109
109
super(CannotConnectEnv, self).__init__(e.returncode, e.cmd, e.output)
112
class JujuClientDevel:
113
# This client is meant to work with the latest version of juju.
114
# Subclasses will retain support for older versions of juju, so that the
115
# latest version is easy to read, and older versions can be trivially
118
def __init__(self, version, full_path):
119
self.version = version
120
self.full_path = full_path
124
def get_version(cls):
125
return EnvJujuClient.get_version()
128
def get_full_path(cls):
129
return EnvJujuClient.get_full_path()
133
version = cls.get_version()
134
full_path = cls.get_full_path()
135
if version.startswith('1.16'):
136
raise Exception('Unsupported juju: %s' % version)
138
return JujuClientDevel(version, full_path)
140
def get_env_client(self, environment):
141
return EnvJujuClient(environment, self.version, self.full_path, None,
144
def bootstrap(self, environment):
145
"""Bootstrap, using sudo if necessary."""
146
return self.get_env_client(environment).bootstrap()
148
def destroy_environment(self, environment):
149
return self.get_env_client(environment).destroy_environment()
151
def get_juju_output(self, environment, command, *args, **kwargs):
152
return self.get_env_client(environment).get_juju_output(
153
command, *args, **kwargs)
155
def get_status(self, environment, timeout=60, raw=False, *args):
156
"""Get the current status as a dict."""
157
return self.get_env_client(environment).get_status(timeout, raw, *args)
159
def get_env_option(self, environment, option):
160
"""Return the value of the environment's configured option."""
161
return self.get_env_client(environment).get_env_option(option)
163
def quickstart(self, environment, bundle):
164
return self.get_env_client(environment).quickstart(bundle)
166
def set_env_option(self, environment, option, value):
167
"""Set the value of the option in the environment."""
168
return self.get_env_client(environment).set_env_option(option, value)
170
def juju(self, environment, command, args, sudo=False, check=True):
171
"""Run a command under juju for the current environment."""
172
return self.get_env_client(environment).juju(
173
command, args, sudo, check)
176
112
class AgentsNotStarted(Exception):
178
114
def __init__(self, environment, status):