func UpdateNodeStatus(nodeData provision.NodeStatusData) ([]UpdateUnitsResult, error) {
	node, findNodeErr := findNodeForNodeData(nodeData)
	var nodeAddresses []string
	if findNodeErr == nil {
		nodeAddresses = []string{node.Address()}
	} else {
		nodeAddresses = nodeData.Addrs
	}
	if healer.HealerInstance != nil {
		err := healer.HealerInstance.UpdateNodeData(nodeAddresses, nodeData.Checks)
		if err != nil {
			log.Errorf("[update node status] unable to set node status in healer: %s", err)
		}
	}
	if findNodeErr == provision.ErrNodeNotFound {
		counterNodesNotFound.Inc()
		log.Errorf("[update node status] node not found with nodedata: %#v", nodeData)
		result := make([]UpdateUnitsResult, len(nodeData.Units))
		for i, unitData := range nodeData.Units {
			result[i] = UpdateUnitsResult{ID: unitData.ID, Found: false}
		}
		return result, nil
	}
	if findNodeErr != nil {
		return nil, findNodeErr
	}
	unitProv, ok := node.Provisioner().(provision.UnitStatusProvisioner)
	if !ok {
		return []UpdateUnitsResult{}, nil
	}
	result := make([]UpdateUnitsResult, len(nodeData.Units))
	for i, unitData := range nodeData.Units {
		unit := provision.Unit{ID: unitData.ID, Name: unitData.Name}
		err := unitProv.SetUnitStatus(unit, unitData.Status)
		_, isNotFound := err.(*provision.UnitNotFoundError)
		if err != nil && !isNotFound {
			return nil, err
		}
		result[i] = UpdateUnitsResult{ID: unitData.ID, Found: !isNotFound}
	}
	return result, nil
}
func UpdateNodeStatus(nodeData provision.NodeStatusData) ([]UpdateUnitsResult, error) {
	node, findNodeErr := findNodeForNodeData(nodeData)
	var nodeAddresses []string
	if findNodeErr == nil {
		nodeAddresses = []string{node.Address()}
	} else {
		nodeAddresses = nodeData.Addrs
	}
	if healer.HealerInstance != nil {
		err := healer.HealerInstance.UpdateNodeData(nodeAddresses, nodeData.Checks)
		if err != nil {
			log.Errorf("[update node status] unable to set node status in healer: %s", err)
		}
	}
	if findNodeErr == provision.ErrNodeNotFound {
		counterNodesNotFound.Inc()
		log.Errorf("[update node status] node not found with nodedata: %#v", nodeData)
		result := make([]UpdateUnitsResult, len(nodeData.Units))
		for i, unitData := range nodeData.Units {
			result[i] = UpdateUnitsResult{ID: unitData.ID, Found: false}
		}
		return result, nil
	}
	if findNodeErr != nil {
		return nil, findNodeErr
	}
	unitProv, ok := node.Provisioner().(provision.UnitStatusProvisioner)
	if !ok {
		return []UpdateUnitsResult{}, nil
	}
	result := make([]UpdateUnitsResult, len(nodeData.Units))
	for i, unitData := range nodeData.Units {
		unit := provision.Unit{ID: unitData.ID, Name: unitData.Name}
		err := unitProv.SetUnitStatus(unit, unitData.Status)
		_, isNotFound := err.(*provision.UnitNotFoundError)
		if err != nil && !isNotFound {
			return nil, err
		}
		result[i] = UpdateUnitsResult{ID: unitData.ID, Found: !isNotFound}
	}
	return result, nil
}
func UpdateNodeStatus ( nodeData provision . NodeStatusData ) ( [ ] UpdateUnitsResult , error ) { node , findNodeErr := findNodeForNodeData ( nodeData ) var nodeAddresses [ ] string if findNodeErr == nil { nodeAddresses = [ ] string { node . Address ( ) } } else { nodeAddresses = nodeData . Addrs } if healer . HealerInstance != nil { err := healer . HealerInstance . UpdateNodeData ( nodeAddresses , nodeData . Checks ) if err != nil { log . Errorf ( " " , err ) } } if findNodeErr == provision . ErrNodeNotFound { counterNodesNotFound . Inc ( ) log . Errorf ( " " , nodeData ) result := make ( [ ] UpdateUnitsResult , len ( nodeData . Units ) ) for i , unitData := range nodeData . Units { result [ i ] = UpdateUnitsResult { ID : unitData . ID , Found : false } } return result , nil } if findNodeErr != nil { return nil , findNodeErr } unitProv , ok := node . Provisioner ( ) . ( provision . UnitStatusProvisioner ) if ! ok { return [ ] UpdateUnitsResult { } , nil } result := make ( [ ] UpdateUnitsResult , len ( nodeData . Units ) ) for i , unitData := range nodeData . Units { unit := provision . Unit { ID : unitData . ID , Name : unitData . Name } err := unitProv . SetUnitStatus ( unit , unitData . Status ) _ , isNotFound := err . ( * provision . UnitNotFoundError ) if err != nil && ! isNotFound { return nil , err } result [ i ] = UpdateUnitsResult { ID : unitData . ID , Found : ! isNotFound } } return result , nil }
// UpdateNodeStatus updates the status of the given node and its units,
// returning a map which units were found during the update.
UpdateNodeStatus updates the status of the given node and its units returning a map which units were found during the update .