示例#1
0
文件: controls.go 项目: rnd-ua/scope
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)
	}
}
示例#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))
}
示例#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))
}
示例#4
0
文件: mapping.go 项目: webwurst/scope
// 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}
}