Example #1
0
def destroy(dClusterId):
    psResult = docker.ps()
    for item in psResult:
        dclusterName, _nodeName = _parseContainerName(item.name)
        if dclusterName == dClusterId:
            subprocess.call(["docker", "kill", item.containerId])
            docker.rm(item.containerId, True)
Example #2
0
def destroy(dClusterId):
    psResult = docker.ps()
    for item in psResult:
        dclusterName, _nodeName = _parseContainerName(item.name)
        if dclusterName == dClusterId:
            subprocess.call(["docker", "kill", item.containerId])
            docker.rm(item.containerId, True)
Example #3
0
def getContainers(dClusterId):
    psResult = docker.ps()
    result = []
    for container in psResult:
        clusterId, nodeName = _parseContainerName(container.name)
        if clusterId == dClusterId:
            result.append(container)
            
    return result
Example #4
0
def snapshot(dClusterId, tag=None):
    psResult = docker.ps()
    for container in psResult:
        clusterId, nodeName = _parseContainerName(container.name)
        if clusterId == dClusterId:
            if tag is None:
                subprocess.call(["docker", "commit", container.name, clusterId + "/" + nodeName])
            else:
                subprocess.call(["docker", "commit", container.name, clusterId + "/" + nodeName + ":" + tag])
Example #5
0
def getContainers(dClusterId):
    psResult = docker.ps()
    result = []
    for container in psResult:
        clusterId, nodeName = _parseContainerName(container.name)
        if clusterId == dClusterId:
            result.append(container)

    return result
Example #6
0
def snapshot(dClusterId, tag=None):
    psResult = docker.ps()
    for container in psResult:
        clusterId, nodeName = _parseContainerName(container.name)
        if clusterId == dClusterId:
            if tag is None:
                subprocess.call(["docker", "commit", container.name, clusterId + "/" + nodeName])
            else:
                subprocess.call(["docker", "commit", container.name, clusterId + "/" + nodeName + ":" + tag])
Example #7
0
def hostsfile(dclusterId, outputfile):
    hosts = ""
    psResult = docker.ps()
    for container in psResult:
        clusterName, _ = _parseContainerName(container.name)
        if clusterName == dclusterId:
            container = docker.getContainer(container.name)
            hosts += container.ip + " " + container.fqdn + " " + container.hostname + "\n"
    with open(outputfile, "w") as text_file:
        text_file.write(hosts)

    print 0
Example #8
0
def hostsfile(dclusterId, outputfile):
    hosts = ""
    psResult = docker.ps()
    for container in psResult:
        clusterName, _ = _parseContainerName(container.name)
        if clusterName == dclusterId:
            container = docker.getContainer(container.name)
            hosts += container.ip + " " + container.fqdn + " " + container.hostname + "\n"
    with open(outputfile, "w") as text_file:
        text_file.write(hosts)

    print 0
Example #9
0
def listClusterInfo(dClusterId=None):
    psResult = docker.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 = docker.getContainerIpAddress(container.name)
            print ip
Example #10
0
def listClusterInfo(dClusterId=None):
    psResult = docker.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 = docker.getContainerIpAddress(container.name)
            print ip
Example #11
0
def build_menu(env, log_on, logfile):
    log_csv = lambda fn: log_decorator(fn, logfile)

    # fmt: off
    top_menu = [
        MenuOption(
            name="Calibrate",
            closure=calibrate_controller,
            kwargs={
                "env": env,
                "pid_fn": pid_controller(),
                "calibration_file": "bot.json",
            },
            is_controller=False,
        ),
        MenuOption(
            name="Joystick",
            closure=joystick_controller,
            kwargs={},
            decorators=[squash_small_angles, log_csv]
            if log_on else [squash_small_angles],
        ),
        MenuOption(
            name="PID",
            closure=pid_controller,
            kwargs={},
            decorators=[log_csv] if log_on else None,
        ),
    ]
    # fmt: on

    # Parse the docker-compose.yml file for a list of brains
    middle_menu = []
    # Parse brains from docker ps and add to middle_menu
    # parse the list
    for brain_image in docker.ps():
        m = MenuOption(
            name=brain_image.short_name,
            closure=brain_controller,
            kwargs={
                "port": brain_image.port,
                "alert_fn": alert_callback
            },
            decorators=[log_csv] if log_on else None,
        )
        middle_menu.append(m)

    bottom_menu = [
        MenuOption(
            name="Hue Info",
            closure=info_config_controller,
            kwargs={"env": env},
            is_controller=False,
            require_servos=False,
        ),
        MenuOption(
            name="Bot Info",
            closure=info_screen_controller,
            kwargs={"env": env},
            is_controller=False,
            require_servos=False,
        ),
    ]

    return top_menu + middle_menu + bottom_menu
Example #12
0
def admin_home():
    images = sorted(docker.images(), key=lambda i: i['repository'])
    processes = sorted(docker.ps(), key=lambda p: p['image'])
    return render_template('admin.html', images=images, processes=processes, current_tab='admin')