예제 #1
0
func SelectNodeFromRackHD(c config.Cpi, diskCID string) (string, error) {
	if diskCID != "" {
		node, err := rackhdapi.GetNodeByDiskCID(c, diskCID)

		if err != nil {
			return "", err
		}

		log.Info(fmt.Sprintf("selected node %s", node.ID))
		return node.ID, nil
	}

	nodes, err := rackhdapi.GetNodes(c)
	if err != nil {
		return "", err
	}

	nodeID, err := randomSelectAvailableNode(c, nodes)
	if err != nil || nodeID == "" {
		return "", err
	}

	log.Info(fmt.Sprintf("selected node %s", nodeID))
	return nodeID, nil
}
예제 #2
0
		})
	})

	Describe("Getting a single node by disk CID", func() {
		It("returns node with the disk specified", func() {
			expectedNodes := helpers.LoadNodes("../spec_assets/dummy_create_vm_with_disk_response.json")
			expectedNodesData, err := json.Marshal(expectedNodes)
			Expect(err).ToNot(HaveOccurred())
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", "/api/common/nodes"),
					ghttp.RespondWith(http.StatusOK, expectedNodesData),
				),
			)

			node, err := rackhdapi.GetNodeByDiskCID(cpiConfig, "disk-1234")

			Expect(err).ToNot(HaveOccurred())
			Expect(node).To(Equal(expectedNodes[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(