func PublishReserveNodeWorkflow(c config.Cpi) (string, error) { tasks, workflow, err := generateReserveNodeWorkflow(c.RequestID) if err != nil { return "", err } for i := range tasks { err = rackhdapi.PublishTask(c, tasks[i]) if err != nil { return "", err } } w := reserveNodeWorkflow{} err = json.Unmarshal(workflow, &w) if err != nil { return "", fmt.Errorf("error umarshalling workflow: %s", err) } err = rackhdapi.PublishWorkflow(c, workflow) if err != nil { return "", err } return w.Name, nil }
func PublishProvisionNodeWorkflow(c config.Cpi) (string, error) { tasks, workflow, err := generateProvisionNodeWorkflow(c.RequestID) if err != nil { return "", err } for i := range tasks { err = rackhdapi.PublishTask(c, tasks[i]) if err != nil { return "", err } } w := provisionNodeWorkflow{} err = json.Unmarshal(workflow, &w) if err != nil { log.Error(fmt.Sprintf("error umarshalling workflow: %s", err)) return "", err } err = rackhdapi.PublishWorkflow(c, workflow) if err != nil { return "", err } return w.Name, nil }
func PublishDeprovisionNodeWorkflow(c config.Cpi, uuid string) (string, error) { tasks, workflow, err := generateDeprovisionNodeWorkflow(uuid) if err != nil { return "", err } for i := range tasks { err = rackhdapi.PublishTask(c, tasks[i]) if err != nil { return "", err } } w := deprovisionNodeWorkflow{} err = json.Unmarshal(workflow, &w) if err != nil { return "", fmt.Errorf("error umarshalling workflow: %s", err) } err = rackhdapi.PublishWorkflow(c, workflow) if err != nil { return "", err } return w.Name, nil }
fakeTaskStub := rackhdapi.TaskStub{ Name: fmt.Sprintf("Task.CF.Fake.%s", uuid), UnusedName: rackhdapi.DefaultUnusedName, } fakeTask := struct { *rackhdapi.TaskStub *rackhdapi.OptionContainer }{ TaskStub: &fakeTaskStub, OptionContainer: &rackhdapi.OptionContainer{}, } fakeTaskBytes, err := json.Marshal(fakeTask) Expect(err).ToNot(HaveOccurred()) err = rackhdapi.PublishTask(cpiConfig, fakeTaskBytes) Expect(err).ToNot(HaveOccurred()) taskLibraryBytes, err := rackhdapi.RetrieveTasks(cpiConfig) Expect(err).ToNot(HaveOccurred()) taskLibrary := []rackhdapi.TaskStub{} err = json.Unmarshal(taskLibraryBytes, &taskLibrary) Expect(err).ToNot(HaveOccurred()) Expect(taskLibrary).To(ContainElement(fakeTaskStub)) }) }) })