~dooferlad/juju-ci-tools/juju-ci-tools-addressable-containers

« back to all changes in this revision

Viewing changes to jujupy.py

  • Committer: Aaron Bentley
  • Date: 2015-09-02 16:25:47 UTC
  • mto: (997.1.84 trunk)
  • mto: This revision was merged to the branch mainline in revision 1004.
  • Revision ID: aaron.bentley@canonical.com-20150902162547-xmw26uwqasn7ui47
Remove JujuClientDevel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
        super(CannotConnectEnv, self).__init__(e.returncode, e.cmd, e.output)
110
110
 
111
111
 
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
116
 
    # deleted.
117
 
 
118
 
    def __init__(self, version, full_path):
119
 
        self.version = version
120
 
        self.full_path = full_path
121
 
        self.debug = False
122
 
 
123
 
    @classmethod
124
 
    def get_version(cls):
125
 
        return EnvJujuClient.get_version()
126
 
 
127
 
    @classmethod
128
 
    def get_full_path(cls):
129
 
        return EnvJujuClient.get_full_path()
130
 
 
131
 
    @classmethod
132
 
    def by_version(cls):
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)
137
 
        else:
138
 
            return JujuClientDevel(version, full_path)
139
 
 
140
 
    def get_env_client(self, environment):
141
 
        return EnvJujuClient(environment, self.version, self.full_path, None,
142
 
                             self.debug)
143
 
 
144
 
    def bootstrap(self, environment):
145
 
        """Bootstrap, using sudo if necessary."""
146
 
        return self.get_env_client(environment).bootstrap()
147
 
 
148
 
    def destroy_environment(self, environment):
149
 
        return self.get_env_client(environment).destroy_environment()
150
 
 
151
 
    def get_juju_output(self, environment, command, *args, **kwargs):
152
 
        return self.get_env_client(environment).get_juju_output(
153
 
            command, *args, **kwargs)
154
 
 
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)
158
 
 
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)
162
 
 
163
 
    def quickstart(self, environment, bundle):
164
 
        return self.get_env_client(environment).quickstart(bundle)
165
 
 
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)
169
 
 
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)
174
 
 
175
 
 
176
112
class AgentsNotStarted(Exception):
177
113
 
178
114
    def __init__(self, environment, status):