func SelectNodeFromRackHD(c config.Cpi, nodeID string, filter Filter) (rackhdapi.Node, error) {
	if nodeID != "" {
		node, err := rackhdapi.GetNode(c, nodeID)

		if err != nil {
			return rackhdapi.Node{}, err
		}

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

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

	node, err := randomSelectAvailableNode(c, nodes, filter)
	if err != nil || node.ID == "" {
		return rackhdapi.Node{}, err
	}

	log.Info(fmt.Sprintf("selected node %s", node.ID))
	return node, nil
}
func CreateVM(c config.Cpi, extInput bosh.MethodArguments) (string, error) {
	agentID, stemcellCID, publicKey, boshNetworks, nodeID, err := parseCreateVMInput(extInput)
	if err != nil {
		return "", err
	}

	nodeID, err = TryReservation(c, nodeID, SelectNodeFromRackHD, ReserveNodeFromRackHD)
	if err != nil {
		return "", err
	}

	var netSpec bosh.Network
	var netName string
	for k, v := range boshNetworks {
		netName = k
		netSpec = v
	}

	nodeCatalog, err := rackhdapi.GetNodeCatalog(c, nodeID)
	if err != nil {
		return "", err
	}

	if netSpec.NetworkType == bosh.ManualNetworkType {
		netSpec, err = attachMAC(nodeCatalog.Data.NetworkData.Networks, netSpec)
		if err != nil {
			return "", err
		}
	}

	node, err := rackhdapi.GetNode(c, nodeID)
	if err != nil {
		return "", err
	}

	var diskCID string
	if node.PersistentDisk.DiskCID == "" {
		diskCID = fmt.Sprintf("%s-%s", nodeID, c.RequestID)

		container := rackhdapi.PersistentDiskSettingsContainer{
			PersistentDisk: rackhdapi.PersistentDiskSettings{
				PregeneratedDiskCID: diskCID,
			},
		}

		bodyBytes, err := json.Marshal(container)
		if err != nil {
			return "", fmt.Errorf("error marshalling persistent disk information for agent %s", agentID)
		}

		err = rackhdapi.PatchNode(c, node.ID, bodyBytes)
		if err != nil {
			return "", err
		}
	} else {
		diskCID = node.PersistentDisk.DiskCID
	}

	persistentMetadata := map[string]interface{}{}
	if _, sdbFound := nodeCatalog.Data.BlockDevices["sdb"]; sdbFound {
		persistentMetadata = map[string]interface{}{
			diskCID: map[string]string{
				"path": "/dev/sdb",
			},
		}
	}

	env := bosh.AgentEnv{
		AgentID:   agentID,
		Blobstore: c.Agent.Blobstore,
		Disks: map[string]interface{}{
			"system":     "/dev/sda",
			"persistent": persistentMetadata,
		},
		Mbus:     c.Agent.Mbus,
		Networks: map[string]bosh.Network{netName: netSpec},
		NTP:      c.Agent.Ntp,
		VM: map[string]string{
			"id":   nodeID,
			"name": nodeID,
		},
		PublicKey: publicKey,
	}

	envBytes, err := json.Marshal(env)
	if err != nil {
		return "", fmt.Errorf("error marshalling agent env %s", err)
	}
	envReader := bytes.NewReader(envBytes)
	vmCID, err := rackhdapi.UploadFile(c, nodeID, envReader, int64(len(envBytes)))
	if err != nil {
		return "", err
	}
	defer rackhdapi.DeleteFile(c, nodeID)

	workflowName, err := workflows.PublishProvisionNodeWorkflow(c)
	if err != nil {
		return "", fmt.Errorf("error publishing provision workflow: %s", err)
	}

	wipeDisk := (nodeID == "")

	err = workflows.RunProvisionNodeWorkflow(c, nodeID, workflowName, vmCID, stemcellCID, wipeDisk)
	if err != nil {
		return "", fmt.Errorf("error running provision workflow: %s", err)
	}

	return vmCID, nil
}
		})
	})

	Describe("Getting a single node by nodeID", func() {
		It("returns node with the nodeID specified", func() {
			expectedNode := helpers.LoadNode("../spec_assets/dummy_create_vm_with_disk_response.json")
			expectedNodeData, err := json.Marshal(expectedNode)
			Expect(err).ToNot(HaveOccurred())
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", "/api/common/nodes/5665a65a0561790005b77b85"),
					ghttp.RespondWith(http.StatusOK, expectedNodeData),
				),
			)

			node, err := rackhdapi.GetNode(cpiConfig, "5665a65a0561790005b77b85")

			Expect(err).ToNot(HaveOccurred())
			Expect(node).To(Equal(expectedNode))
		})
	})

	Describe("GetOBMSettings", func() {
		It("returns a node's OBM settings", func() {
			dummyResponsePath := "../spec_assets/dummy_one_node_response.json"
			httpResponse := helpers.LoadJSON(dummyResponsePath)
			expectedResponse := helpers.LoadNode(dummyResponsePath)

			nodeID := "nodeID"
			server.AppendHandlers(
				ghttp.CombineHandlers(