~gz/juju-ci-tools/assess_jes_dump_logs

« back to all changes in this revision

Viewing changes to jujupy.py

  • Committer: Aaron Bentley
  • Date: 2015-12-15 19:34:45 UTC
  • mfrom: (1193.2.7 remove-client-home)
  • Revision ID: aaron.bentley@canonical.com-20151215193445-2267zpvl9z6oq5ja
Store EnvJujuClient.juju_home in SimpleEnvironment.

Show diffs side-by-side

added added

removed removed

Lines of Context:
237
237
        self.version = version
238
238
        self.full_path = full_path
239
239
        self.debug = debug
240
 
        if juju_home is None:
241
 
            juju_home = get_juju_home()
242
 
        self.juju_home = juju_home
 
240
        if env is not None:
 
241
            if juju_home is None:
 
242
                if env.juju_home is None:
 
243
                    env.juju_home = get_juju_home()
 
244
            else:
 
245
                env.juju_home = juju_home
243
246
        self.juju_timings = {}
244
247
        self._timeout_path = get_timeout_path()
245
248
 
252
255
        if self.full_path is not None:
253
256
            env['PATH'] = '{}{}{}'.format(os.path.dirname(self.full_path),
254
257
                                          os.pathsep, env['PATH'])
255
 
        env['JUJU_HOME'] = self.juju_home
 
258
        env['JUJU_HOME'] = self.env.juju_home
256
259
        return env
257
260
 
258
261
    def add_ssh_machines(self, machines):
307
310
            self.env.needs_sudo(), check=False, include_e=False,
308
311
            timeout=timedelta(minutes=10).total_seconds())
309
312
        if delete_jenv:
310
 
            jenv_path = get_jenv_path(self.juju_home, self.env.environment)
 
313
            jenv_path = get_jenv_path(self.env.juju_home, self.env.environment)
311
314
            ensure_deleted(jenv_path)
312
315
 
313
316
    def kill_controller(self):
934
937
    # ensure MAASAccount knows what the name will be.
935
938
    config['name'] = client.env.environment
936
939
    if config['type'] == 'local':
937
 
        config.setdefault('root-dir', get_local_root(client.juju_home,
 
940
        config.setdefault('root-dir', get_local_root(client.env.juju_home,
938
941
                          client.env))
939
942
        # MongoDB requires a lot of free disk space, and the only
940
943
        # visible error message is from "juju bootstrap":
982
985
        # Skip creating symlink where not supported (i.e. Windows).
983
986
        if not permanent and getattr(os, 'symlink', None) is not None:
984
987
            os.symlink(new_jenv_path, jenv_path)
985
 
        old_juju_home = client.juju_home
986
 
        client.juju_home = temp_juju_home
 
988
        old_juju_home = client.env.juju_home
 
989
        client.env.juju_home = temp_juju_home
987
990
        try:
988
991
            yield temp_juju_home
989
992
        finally:
1000
1003
                    except OSError as e:
1001
1004
                        if e.errno != errno.ENOENT:
1002
1005
                            raise
1003
 
                client.juju_home = old_juju_home
 
1006
                client.env.juju_home = old_juju_home
1004
1007
 
1005
1008
 
1006
1009
def get_machine_dns_name(client, machine, timeout=600):
1122
1125
 
1123
1126
class SimpleEnvironment:
1124
1127
 
1125
 
    def __init__(self, environment, config=None):
 
1128
    def __init__(self, environment, config=None, juju_home=None):
1126
1129
        self.environment = environment
1127
1130
        self.config = config
 
1131
        self.juju_home = juju_home
1128
1132
        if self.config is not None:
1129
1133
            self.local = bool(self.config.get('type') == 'local')
1130
1134
            self.kvm = (