Exemple #1
0
func processEvent(a *api.API, bootID string, appID string, group string, event *omahaSpec.Event) error {
	logger.Info("processEvent", "appID", appID, "group", group, "event", event.Type+"."+event.Result, "eventError", event.ErrorCode, "previousVersion", event.PreviousVersion)
	eventType, err := strconv.Atoi(event.Type)
	if err != nil {
		return err
	}
	eventResult, err := strconv.Atoi(event.Result)
	if err != nil {
		return err
	}
	if err := a.RegisterEvent(bootID, appID, group, eventType, eventResult, event.PreviousVersion, event.ErrorCode); err != nil {
		return err
	}
	return nil
}
Exemple #2
0
func addCoreosExtraInfo(a *api.API, pkg *api.Package, m *omahaSpec.Manifest) error {
	c, err := a.GetCoreosAction(pkg.ID)
	if err != nil {
		return err
	}
	action := m.AddAction(c.Event)
	action.ChromeOSVersion = c.ChromeOSVersion
	action.Sha256 = c.Sha256
	action.NeedsAdmin = c.NeedsAdmin
	action.IsDelta = c.IsDelta
	action.DisablePayloadBackoff = c.DisablePayloadBackoff
	action.MetadataSignatureRsa = c.MetadataSignatureRsa
	action.MetadataSize = c.MetadataSize
	action.Deadline = c.Deadline
	return nil
}
Exemple #3
0
func buildOmahaResponse(a *api.API, omahaReq *omahaSpec.Request, ip string) (*omahaSpec.Response, error) {
	omahaResp := omahaSpec.NewResponse("coreroller")

	for _, reqApp := range omahaReq.Apps {

		respApp := omahaResp.AddApp(reqApp.Id)
		respApp.Status = "ok"

		// Let's add the track and version again in the response (as we got from request)
		respApp.Track = reqApp.Track
		respApp.Version = reqApp.Version

		// Get group
		group := getGroup(reqApp.Id, reqApp.Track)

		// If it has an event tag, we process it first.
		if reqApp.Events != nil {
			for _, event := range reqApp.Events {
				if err := processEvent(a, reqApp.MachineID, reqApp.Id, group, event); err != nil {
					logger.Warn("processEvent", "error", err.Error())
				}
				// Always acknowledge the event
				respEvent := respApp.AddEvent()
				respEvent.Status = "ok"
			}
		}

		// If it has an updatechek tag
		if reqApp.UpdateCheck != nil {
			appPackage, err := a.GetUpdatePackage(reqApp.MachineID, ip, reqApp.Version, reqApp.Id, group)
			if err != nil && err != api.ErrNoUpdatePackageAvailable {
				// If there is an error, we return it
				respApp.Status = getStatusMesssageFromRollerdResponse(err)
			} else {
				u := respApp.AddUpdateCheck()
				processUpdateCheck(a, appPackage, u)
			}
		}
	}

	return omahaResp, nil
}