func hasOBMSettings(c config.Cpi, nodeID string) bool {
	log.Debug(fmt.Sprintf("Getting OBM settings"))
	obmSettings, err := rackhdapi.GetOBMSettings(c, nodeID)
	if err != nil {
		log.Error(fmt.Sprintf("Error getting OBM settings on node %s: %v\n", nodeID, err))
	}
	return len(obmSettings) > 0
}
Ejemplo n.º 2
0
func nodeIsAvailable(c config.Cpi, n rackhdapi.Node) bool {
	log.Debug(fmt.Sprintf("Getting active workflow"))
	workflow, err := rackhdapi.GetActiveWorkflows(c, n.ID)
	if err != nil {
		log.Error(fmt.Sprintf("Error getting active workflow on node %s: %v\n", n.ID, err))
	}
	log.Debug(fmt.Sprintf("Getting OBM settings"))
	obmSettings, err := rackhdapi.GetOBMSettings(c, n.ID)
	if err != nil {
		log.Error(fmt.Sprintf("Error getting OBM settings on node %s: %v\n", n.ID, err))
	}

	return (n.Status == "" || n.Status == rackhdapi.Available) &&
		(n.CID == "") &&
		reflect.DeepEqual(workflow, rackhdapi.WorkflowResponse{}) &&
		(len(obmSettings) > 0) &&
		!hasPersistentDisk(n)
}
Ejemplo n.º 3
0
	Describe("GetOBMSettings", func() {
		It("returns a node's OBM settings", func() {
			dummy_response_path := "../spec_assets/dummy_one_node_response.json"
			httpResponse := helpers.LoadJSON(dummy_response_path)
			expectedResponse := helpers.LoadNode(dummy_response_path)

			nodeID := "nodeID"
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", fmt.Sprintf("/api/common/nodes/%s", nodeID)),
					ghttp.RespondWith(http.StatusOK, httpResponse),
				),
			)

			response, err := rackhdapi.GetOBMSettings(cpiConfig, nodeID)
			Expect(err).ToNot(HaveOccurred())
			Expect(server.ReceivedRequests()).To(HaveLen(1))
			Expect(response).To(Equal(expectedResponse.OBMSettings))
		})
	})

	Describe("IsAMTService", func() {
		It("returns true if the node's obm settings is amt", func() {
			dummy_response_path := "../spec_assets/dummy_one_node_response.json"
			httpResponse := helpers.LoadJSON(dummy_response_path)

			nodeID := "nodeID"
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", fmt.Sprintf("/api/common/nodes/%s", nodeID)),