Ejemplo n.º 1
0
def destroy(dClusterId):
    psResult = dockerDriver.ps()
    for item in psResult:
        dclusterName, _nodeName = _parseContainerName(item.name)
        if dclusterName == dClusterId:
            subprocess.call(["docker", "kill", item.containerId])
            dockerDriver.rm(item.containerId, True)
Ejemplo n.º 2
0
def getContainers(dClusterId):
    psResult = dockerDriver.ps()
    result = []
    for container in psResult:
        clusterId, nodeName = _parseContainerName(container.name)
        if clusterId == dClusterId:
            result.append(container)
            
    return result
Ejemplo n.º 3
0
def hostsfile(dclusterId, outputfile):
    hosts = ""
    psResult = dockerDriver.ps()
    for container in psResult:
        clusterName, _ = _parseContainerName(container.name)
        if clusterName == dclusterId:
            container = dockerDriver.getContainer(container.name)
            hosts += container.ip + " " + container.fqdn + " " + container.hostname + "\n"
    with open(outputfile, "w") as text_file:
        text_file.write(hosts)
    print hosts


    print 0
Ejemplo n.º 4
0
def listClusterInfo(dClusterId=None):
    psResult = dockerDriver.ps()
    if dClusterId is None:
        clusterIds = []
        for container in psResult:
            clusterName, _ = _parseContainerName(container.name)
            if clusterName is not None and clusterName not in clusterIds:
                clusterIds.append(clusterName)
        print "cluster Ids"
        print "\n".join(clusterIds)
        return

    for container in psResult:
        clusterName, _ = _parseContainerName(container.name)
        if clusterName == dClusterId:
            ip = dockerDriver.getContainerIpAddress(container.name)
            print ip