~gz/juju-ci-tools/jes_no_upload

« back to all changes in this revision

Viewing changes to jujupy.py

  • Committer: Aaron Bentley
  • Date: 2015-08-11 13:48:41 UTC
  • mfrom: (1050.2.9 copy-cache)
  • Revision ID: aaron.bentley@canonical.com-20150811134841-780kgxioxll2ublp
SupportĀ archivingĀ cache.yaml

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
            juju_path = 'juju'
178
178
        return subprocess.check_output((juju_path, '--version')).strip()
179
179
 
 
180
    def is_jes_enabled(self):
 
181
        commands = self.get_juju_output('help', 'commands', include_e=False)
 
182
        for line in commands.splitlines():
 
183
            if line.startswith('system'):
 
184
                return True
 
185
        return False
 
186
 
180
187
    @classmethod
181
188
    def get_full_path(cls):
182
189
        if sys.platform == 'win32':
661
668
        super(EnvJujuClient25, self).__init__(*args, **kwargs)
662
669
        self._use_jes = False
663
670
 
664
 
    def _supports_jes(self):
665
 
        commands = self.get_juju_output('help', 'commands', include_e=False)
666
 
        for line in commands.splitlines():
667
 
            if line.startswith('system'):
668
 
                return True
669
 
        return False
670
 
 
671
671
    def enable_jes(self):
672
672
        if self._use_jes:
673
673
            return
674
 
        if self._supports_jes():
 
674
        if self.is_jes_enabled():
675
675
            raise JESByDefault()
676
676
        self._use_jes = True
677
 
        if not self._supports_jes():
 
677
        if not self.is_jes_enabled():
678
678
            self._use_jes = False
679
679
            raise JESNotSupported()
680
680
 
775
775
    return os.path.join(juju_home, 'jes-homes', dir_name)
776
776
 
777
777
 
 
778
def get_cache_path(juju_home):
 
779
    return os.path.join(juju_home, 'environments', 'cache.yaml')
 
780
 
 
781
 
778
782
@contextmanager
779
783
def make_jes_home(juju_home, dir_name, config):
780
784
    home_path = jes_home_path(juju_home, dir_name)