Beispiel #1
0
def deletesnapshot(dClusterId, tag=None):
    images = docker.images()
    for image in images:
        if image.repository.startswith(dClusterId) and tag is None:
            cmdutil.execute(["docker", "rmi", image.repository + ":" + image.tag])
        elif image.repository.startswith(dClusterId + "/") and tag == image.tag:
            cmdutil.execute(["docker", "rmi", image.repository + ":" + image.tag])
Beispiel #2
0
def _flattenDockerfile(conf):
    for node in conf["nodes"]:
        if "Dockerfile" in node:
            tempImageName = conf["id"] + "/" + node["hostname"].replace("[", "_").replace("]", "_")
            cmdutil.execute(["docker", "build", "-t", tempImageName, node["Dockerfile"]])
            node["imageName"] = tempImageName
    return conf
Beispiel #3
0
def _flattenDockerfile(conf):
    for node in conf["nodes"]:
        if "Dockerfile" in node:
            tempImageName = conf["id"] + "/" + node["hostname"].replace("[", "_").replace("]", "_")
            cmdutil.execute(["docker", "build", "-t", tempImageName, node["Dockerfile"]])
            node["imageName"] = tempImageName
    return conf
Beispiel #4
0
def deletesnapshot(dClusterId, tag=None):
    images = docker.images()
    for image in images:
        if image.repository.startswith(dClusterId) and tag is None:
            cmdutil.execute(["docker", "rmi", image.repository + ":" + image.tag])
        elif image.repository.startswith(dClusterId + "/") and tag == image.tag:
            cmdutil.execute(["docker", "rmi", image.repository + ":" + image.tag])
Beispiel #5
0
def getContainer(containerName):
    result = Container()
    result.name = containerName
    _retcode, stdout = cmdutil.execute(["docker", "inspect", '--format="{{.NetworkSettings.IPAddress}}"', containerName])
    result.ip = stdout.strip("\n").strip('"')
    _retcode, stdout = cmdutil.execute(["docker", "inspect", '--format="{{.Config.Hostname}}"', containerName])
    result.hostname = stdout.strip("\n").strip('"')
    _retcode, stdout = cmdutil.execute(["docker", "inspect", '--format="{{.Config.Domainname}}"', containerName])
    result.fqdn = result.hostname + "." + stdout.strip("\n").strip('"')
    return result
Beispiel #6
0
def getContainer(containerName):
    result = Container()
    result.name = containerName
    _retcode, stdout = cmdutil.execute([
        "docker", "inspect", '--format="{{.NetworkSettings.IPAddress}}"',
        containerName
    ])
    result.ip = stdout.strip("\n").strip('"')
    _retcode, stdout = cmdutil.execute([
        "docker", "inspect", '--format="{{.Config.Hostname}}"', containerName
    ])
    result.hostname = stdout.strip("\n").strip('"')
    _retcode, stdout = cmdutil.execute([
        "docker", "inspect", '--format="{{.Config.Domainname}}"', containerName
    ])
    result.fqdn = result.hostname + "." + stdout.strip("\n").strip('"')
    return result
Beispiel #7
0
def ps():
    '''
root@jaoki-ubuntu:/home/jaoki/coding/phd-docker# docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
f61811577af2        phd:base            bash -c cp /tmp/phd-   9 minutes ago       Up 9 minutes                            mycluster2-node3
079ed8874604        phd:base            bash -c cp /tmp/phd-   9 minutes ago       Up 9 minutes                            mycluster2-node2
845fda0ffb74        phd:installed       bash -c /tmp/phd-doc   9 minutes ago       Up 9 minutes                            mycluster2-node1
5f7434e4b690        phd:base            bash -c cp /tmp/phd-   9 minutes ago       Up 9 minutes                            mycluster1-node3
e677692a7022        phd:base            bash -c cp /tmp/phd-   9 minutes ago       Up 9 minutes                            mycluster1-node2
e2481e18d7a8        phd:installed       bash -c /tmp/phd-doc   9 minutes ago       Up 9 minutes                            mycluster1-node1
    '''
    # lines = subprocess.check_output(["docker", "ps", "-a"]).split("\n")
    _retcode, stdout = cmdutil.execute(["docker", "ps", "-a"])
    return _parsePsResult(stdout.split("\n"))
Beispiel #8
0
def ps():
    '''
root@jaoki-ubuntu:/home/jaoki/coding/phd-docker# docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
f61811577af2        phd:base            bash -c cp /tmp/phd-   9 minutes ago       Up 9 minutes                            mycluster2-node3
079ed8874604        phd:base            bash -c cp /tmp/phd-   9 minutes ago       Up 9 minutes                            mycluster2-node2
845fda0ffb74        phd:installed       bash -c /tmp/phd-doc   9 minutes ago       Up 9 minutes                            mycluster2-node1
5f7434e4b690        phd:base            bash -c cp /tmp/phd-   9 minutes ago       Up 9 minutes                            mycluster1-node3
e677692a7022        phd:base            bash -c cp /tmp/phd-   9 minutes ago       Up 9 minutes                            mycluster1-node2
e2481e18d7a8        phd:installed       bash -c /tmp/phd-doc   9 minutes ago       Up 9 minutes                            mycluster1-node1
    '''
    # lines = subprocess.check_output(["docker", "ps", "-a"]).split("\n")
    _retcode, stdout = cmdutil.execute(["docker", "ps", "-a"])
    return _parsePsResult(stdout.split("\n"))
Beispiel #9
0
def getLatestDockerConatinerId():
    _retcode, stdout = cmdutil.execute(["docker", "ps", "-l", "-q"])
    # return subprocess.check_output(["docker", "ps", "-l", "-q"]).strip("\n")
    return stdout.strip("\n")
Beispiel #10
0
def images():
    _retcode, stdout = cmdutil.execute(["docker", "images"])
    return _parseImageResult(stdout.split("\n"))
Beispiel #11
0
def installed():
    retcode, _stdout = cmdutil.execute(["which", "docker"])
    if retcode == 0:
        return True

    return False
Beispiel #12
0
def getLatestDockerConatinerId():
    _retcode, stdout = cmdutil.execute(["docker", "ps", "-l", "-q"])
    # return subprocess.check_output(["docker", "ps", "-l", "-q"]).strip("\n")
    return stdout.strip("\n")
Beispiel #13
0
def images():
    _retcode, stdout = cmdutil.execute(["docker", "images"])
    return _parseImageResult(stdout.split("\n"))
Beispiel #14
0
def installed():
    retcode, _stdout = cmdutil.execute(["which", "docker"])
    if retcode == 0:
        return True

    return False
Beispiel #15
0
def getContainerIpAddress(containerName):
    _retcode, stdout = cmdutil.execute([
        "docker", "inspect", '--format="{{.NetworkSettings.IPAddress}}"',
        containerName
    ])
    return stdout.strip("\n").strip('"')