Ejemplo n.º 1
0
func captureContainerID(f func(string, xfer.Request) xfer.Response) func(xfer.Request) xfer.Response {
	return func(req xfer.Request) xfer.Response {
		containerID, ok := report.ParseContainerNodeID(req.NodeID)
		if !ok {
			return xfer.ResponseErrorf("Invalid ID: %s", req.NodeID)
		}
		return f(containerID, req)
	}
}
Ejemplo n.º 2
0
func (r *registry) unpauseContainer(req xfer.Request) xfer.Response {
	log.Printf("Unpausing container %s", req.NodeID)

	_, containerID, ok := report.ParseContainerNodeID(req.NodeID)
	if !ok {
		return xfer.ResponseErrorf("Invalid ID: %s", req.NodeID)
	}

	return xfer.ResponseError(r.client.UnpauseContainer(containerID))
}
Ejemplo n.º 3
0
func (r *registry) stopContainer(req xfer.Request) xfer.Response {
	log.Printf("Stopping container %s", req.NodeID)

	_, containerID, ok := report.ParseContainerNodeID(req.NodeID)
	if !ok {
		return xfer.ResponseErrorf("Invalid ID: %s", req.NodeID)
	}

	return xfer.ResponseError(r.client.StopContainer(containerID, waitTime))
}
Ejemplo n.º 4
0
// MapContainerIdentity maps a container topology node to a container
// renderable node. As it is only ever run on container topology nodes, we
// expect that certain keys are present.
func MapContainerIdentity(m RenderableNode, _ report.Networks) RenderableNodes {
	id, ok := m.Metadata[docker.ContainerID]
	if !ok {
		return RenderableNodes{}
	}

	var (
		major, _ = GetRenderableContainerName(m.Node)
		minor    = report.ExtractHostID(m.Node)
		rank     = m.Metadata[docker.ImageID]
	)

	node := NewRenderableNodeWith(id, major, minor, rank, m)
	if imageID, ok := m.Metadata[docker.ImageID]; ok {
		hostID, _, _ := report.ParseContainerNodeID(m.ID)
		node.Origins = node.Origins.Add(report.MakeContainerNodeID(hostID, imageID))
	}
	return RenderableNodes{id: node}
}