~mthaddon/mojo/lp-1656985

« back to all changes in this revision

Viewing changes to mojo/contain.py

[hloeung,r=pjdc] LXCContainer.is_setup(): revert to similar behaviour as r424 but warn of breakage in future releases - LP#1697574

Show diffs side-by-side

added added

removed removed

Lines of Context:
539
539
        return os.path.exists(self.conf)
540
540
 
541
541
    def is_setup(self):
542
 
        sentinel_file = self.container_root + "/etc/init/containersetup.conf"
543
 
        # We need to check this for all releases including Xenial because
544
 
        # projects may have been set up the old/legacy way (LP#1697574).
545
 
        if os.path.exists(sentinel_file):
546
 
            return True
547
542
        if UBUNTU_RELEASES.get(self.series) >= UBUNTU_RELEASES['vivid']:
548
 
            # The new setup no longer ships containersetup.conf and instead
549
 
            # creates conf_nonet so we need to also check for this.
550
 
            return os.path.exists(self.conf_nonet)
551
 
        return False
 
543
            sentinel_file = self.conf_nonet
 
544
            # XXX: LP#1697574: Need to handle when conf_nonet doesn't exist for
 
545
            # previous set ups.
 
546
            if not os.path.exists(sentinel_file):
 
547
                logging.warn("Project doesn't seem properly set up, please fix "
 
548
                             "as project will break in future releases. {}"
 
549
                             .format(sentinel_file))
 
550
                return True
 
551
        else:
 
552
            sentinel_file = self.container_root + "/etc/init/containersetup.conf"
 
553
        return os.path.exists(sentinel_file)
552
554
 
553
555
    @needs_root
554
556
    @ensure_defined