Exemplo n.º 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!'])
Exemplo n.º 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)
Exemplo n.º 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)))
Exemplo n.º 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)
Exemplo n.º 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)))
Exemplo n.º 6
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")))
Exemplo n.º 7
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))
Exemplo n.º 8
0
def dockerCallCommand(cmd, params=""):
    return Shell.call("%s %s %s" % (DOCKER_CLIENT, cmd, params))
Exemplo n.º 9
0
def pull(image):
    return Shell.call("%s %s %s" % (DOCKER_CLIENT, "pull", image)) \
        .catchError(ShellCommandError, defer(_pullLoginChain, image=image))