コード例 #1
0
    def envListLogs(self, parts=[], pattern=None):

        if not pattern:
            pattern = "%s*.log" % ('-'.join(parts))

        cmds = CommandList()
        cmd = "ls -1 \"logs/%s\" | xargs -n1 basename" % pattern

        cmds.append('subenv run %s' % cmd)
        return self.readLink() \
            .bind(Link.runCommand, cmds.logicAnd(), stream=True, capture=False, sudo=False)
コード例 #2
0
    def envRecreate(self, time=10, containers=[]):
        cmds = CommandList()

        if len(containers) > 0:
            self.logAdapter.info("Recreating %s containers" %
                                 (' '.join(containers)))
            cmds.append(self.orchestrate('recreate', containers, time))
        else:
            self.logAdapter.info("Recreating all containers...")
            cmds.append(self.orchestrate('recreateAll', time))

        return self.readLink() \
            .bind(Link.runCommand, cmds.logicAnd(), stream=True, sudo=False)
コード例 #3
0
    def envLogs(self, parts=[], pattern=None, follow=True, lines=None):

        if not pattern:
            pattern = "%s*.log" % ('-'.join(parts))

        cmds = CommandList()
        cmd = "tail"
        if follow:
            cmd += " -f"
        if lines:
            cmd += " -n %s" % int(lines)

        cmd += " \"logs/%s\"" % pattern

        cmds.append('subenv run %s' % cmd)
        return self.readLink() \
            .bind(Link.runCommand, cmds.logicAnd(), stream=True, capture=False, sudo=False)
コード例 #4
0
    def envStart(self, reset=False, containers=[]):
        cmds = CommandList()

        if reset:
            cmds.append(self.getOrchestratorCommand('resetAll'))

        if len(containers) > 0:
            self.logAdapter.info("Starting %s container(s)" %
                                 (' '.join(containers)))
            cmds.append(self.orchestrate('start', containers))
        else:
            self.logAdapter.info("Starting all containers...")
            cmds.append(self.orchestrate('startAll'))

        return self.readLink() \
            .bind(Link.runCommand, cmds.logicAnd(), stream=True, sudo=False)
コード例 #5
0
    def envSwitch(self, subenvName, restart=False):
        self.logAdapter.info("Switch engine '%s' to subenv '%s'" %
                             (self.name, subenvName))

        self.currentEnv = subenvName
        self.loadSubenvConfigFile()

        cmds = CommandList([
            "subenv init '/substance/devroot/%s'" % (subenvName),
            "subenv use '%s'" % (subenvName),
        ])

        if restart:
            cmds.append(self.orchestrate('resetAll'))
            cmds.append(self.orchestrate('login'))
            cmds.append(self.orchestrate('startAll'))

        return self.readLink() \
            .bind(Link.runCommand, cmds.logicAnd(), stream=True, sudo=False) \
            .then(self.envRegister)
コード例 #6
0
 def envCleanup(self):
     cmds = CommandList()
     cmds.append('docker system prune -a')
     return self.readLink() \
         .bind(Link.runCommand, cmds.logicAnd(), interactive=True, stream=True, shell=False, capture=False)