def app_delete_container(host, cid): try: node = Node.find(host) except ValueError: return Response("{} is not in the cluster".format(host), status=422) Container.find(node, cid).delete() return Response("", status=204)
def app_node_container_status(host, cid): try: node = Node.find(host) except ValueError: return Response("{} is not in the cluster".format(node), status=422) container = Container.find(node, cid) return json.dumps(container.status())
def app_migrate_container(host, cid): try: node = Node.find(host) except ValueError: return Response("{} is not in the cluster".format(host), status=422) container = Container.find(node, cid) nodes = Node.all() strategy = AllocationStrategy.from_name(current_app.config['strategy']) selected_node = strategy.select_node(nodes, container.service()) new_container = container.migrate(selected_node) return Response(json.dumps( {"Started": new_container, "Stopped": container}, cls=ContainerJSONEncoder), status=201)