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) } }
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)) }
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)) }
// 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} }