Esempio n. 1
0
//	Filter nodes by conditional service and tag
func (et *EventTask) filterNodes(nodes []*api.Node) []*api.Node {
	var results []*api.Node
	for _, node := range nodes {
		r, err := getNodeTaskResult(et.ID, et.No, node.Node)
		if err == nil && r != nil || util.HasCatalogRecord(node.Node, et.Service, et.Tag) {
			results = append(results, node)
		}
	}
	return results
}
Esempio n. 2
0
func (et *EventTask) Runnable(node string) bool {
	//	Target node doesn't have conditional service or tag
	if !util.HasCatalogRecord(node, et.Service, et.Tag) {
		return false
	}

	//	Skip task when task had executed already
	nodeResult, err := getNodeTaskResult(et.ID, et.No, node)
	if err != nil {
		return false
	}
	if nodeResult != nil && nodeResult.IsFinished() {
		return false
	}
	return true
}