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)
def getContainers(dClusterId): psResult = dockerDriver.ps() result = [] for container in psResult: clusterId, nodeName = _parseContainerName(container.name) if clusterId == dClusterId: result.append(container) return result
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
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