Пример #1
0
    def testJob(self):
        Shell.call("cp %s %s" % ("tests/dockwrkr-2.yml",
            os.path.join(self.basePath, "dockwrkr.yml")))

        with self.pushd(self.basePath):
            core = Core()
            self.assertIsInstance(core.initialize(), OK)
            core.run('hellojob', ['Executing dockwrkr job: OK!'])
Пример #2
0
    def testRes(self):
        Shell.call("cp %s %s" % ("tests/dockwrkr-2.yml",
                                 os.path.join(self.basePath, "dockwrkr.yml")))
        with self.pushd(self.basePath):
            core = Core()
            self.assertIsInstance(core.initialize(), OK)

            self.assertIsInstance(core.reset(time=0), OK)
            self.assertIsInstance(core.start(containers=['hello1']), OK)
            self.assertIsInstance(core.restart(
                containers=['hello1'], time=0), OK)
            self.assertIsInstance(core.recreate(
                containers=['hello1'], time=0), OK)
            self.assertIsInstance(core.reset(time=0), OK)
Пример #3
0
def execmd(container,
           cmd,
           tty=False,
           interactive=False,
           user=None,
           detach=None,
           privileged=None):
    opts = []
    if tty:
        opts.append('--tty')
    if interactive:
        opts.append('--interactive')
    if user:
        opts.append('--user %s' % user)
    if detach:
        opts.append('--detach')
    if privileged:
        opts.append('--privileged')

    parts = []
    parts.append(' '.join(opts))
    parts.append(container)
    parts.append(' '.join(cmd))

    return Shell.call("%s %s %s" % (DOCKER_CLIENT, "exec", ' '.join(parts)))
Пример #4
0
    def testInitialize(self):
        Shell.call("cp %s %s" % ("tests/dockwrkr-1.yml",
                                 os.path.join(self.basePath, "dockwrkr.yml")))
        with self.pushd(self.basePath):
            core = Core()
            self.assertIsInstance(core.initialize(), OK)

            self.assertIsInstance(core.reset(time=0), OK)
            self.assertIsInstance(core.start(containers=['hello1']), OK)
            self.assertIsInstance(core.start(containers=['hello2']), OK)
            self.assertIsInstance(core.start(containers=['hello3']), OK)
            self.assertIsInstance(core.stop(all=True, time=0), OK)
            self.assertIsInstance(core.start(all=True), OK)
            self.assertIsInstance(core.pull(all=True), OK)
            self.assertIsInstance(core.excmd(
                container='hello1', cmd=['ls', '-al']), OK)
            self.assertIsInstance(core.reset(time=0), OK)
Пример #5
0
def stats(containers=[]):
    opts = ['-a']

    parts = []
    parts.append(' '.join(opts))
    parts.append(' '.join(containers))

    return Shell.call("%s %s %s" % (DOCKER_CLIENT, "stats", ' '.join(parts)))
Пример #6
0
    def writePid(self, container):
        if not self.arePidsEnabled():
            return OK(None)

        dir = self.getPidsDir()
        pidfile = os.path.join(dir, "%s.pid" % (container))

        return Shell.makeDirectory(dir) \
            .then(defer(docker.readContainerPid, container=container)) \
            .bind(defer(Try.attempt, writeToFile, filename=pidfile))
Пример #7
0
    def testPids(self):
        Shell.call("cp %s %s" % ("tests/dockwrkr-2.yml",
                                 os.path.join(self.basePath, "dockwrkr.yml")))
        with self.pushd(self.basePath):
            core = Core()
            self.assertIsInstance(core.initialize(), OK)

            pdir = os.path.join(self.basePath, "pids")

            self.assertIsInstance(core.reset(time=0), OK)
            self.assertIsInstance(core.start(containers=['hello1']), OK)
            self.assertTrue(os.path.isfile(os.path.join(pdir, "hello1.pid")))
            self.assertIsInstance(core.start(containers=['hello2']), OK)
            self.assertTrue(os.path.isfile(os.path.join(pdir, "hello2.pid")))
            self.assertIsInstance(core.start(containers=['hello3']), OK)
            self.assertTrue(os.path.isfile(os.path.join(pdir, "hello3.pid")))
            self.assertIsInstance(core.stop(all=True, time=0), OK)
            self.assertFalse(os.path.isfile(os.path.join(pdir, "hello1.pid")))
            self.assertFalse(os.path.isfile(os.path.join(pdir, "hello2.pid")))
            self.assertFalse(os.path.isfile(os.path.join(pdir, "hello3.pid")))
Пример #8
0
def login(registry, username=None, password=None, email=None):
    opts = []
    if username:
        opts.append("-u %s" % username)
    if password:
        opts.append("-p %s" % password)
    if email:
        opts.append("-e %s" % email)

    return Shell.call("%s %s %s %s" %
                      (DOCKER_CLIENT, "login", ' '.join(opts), registry))
Пример #9
0
def dockerCallCommand(cmd, params=""):
    return Shell.call("%s %s %s" % (DOCKER_CLIENT, cmd, params))
Пример #10
0
def dockerReadCommand(cmd, params="", shell=False, stream=False, cwd=None):
    return Shell.command("%s %s %s" % (DOCKER_CLIENT, cmd, params), shell=False) \
      .catch(onDockerError)
Пример #11
0
 def tearDown(self):
     ''' tearDown the test '''
     if self.basePath:
         Shell.nukeDirectory(self.basePath).catch(TestCore.raiser)
Пример #12
0
def pull(image):
    return Shell.call("%s %s %s" % (DOCKER_CLIENT, "pull", image)) \
        .catchError(ShellCommandError, defer(_pullLoginChain, image=image))
Пример #13
0
 def clearTemporaryDirs(cls):
     for x in cls.tempDirs:
         Shell.nukeDirectory(x)