Search in sources :

Example 1 with BootDevice

use of com.vmware.photon.controller.model.resources.ComputeService.BootDevice in project photon-model by vmware.

the class ProvisionComputeTaskService method processNextSubStage.

private void processNextSubStage(ProvisionComputeTaskState updatedState) {
    ProvisionComputeTaskState.SubStage newStage = updatedState.taskSubStage;
    switch(newStage) {
        case CREATING_HOST:
            ProvisionComputeTaskState.SubStage nextStageOnSuccess = ProvisionComputeTaskState.SubStage.BOOTING_FROM_ANY;
            // case.
            if (updatedState.bootAdapterReference == null) {
                nextStageOnSuccess = ProvisionComputeTaskState.SubStage.VALIDATE_COMPUTE_HOST;
            }
            // the first reboot needs to be from the network, and the bare metal
            // services
            // will provide the image reference (retrieved from the computeReference)
            doSubStageCreateHost(updatedState, nextStageOnSuccess);
            return;
        case BOOTING_FROM_NETWORK:
            doSubStageBootHost(updatedState, BootDevice.NETWORK, ProvisionComputeTaskState.SubStage.VALIDATE_COMPUTE_HOST);
            return;
        case BOOTING_FROM_CDROM:
            doSubStageBootHost(updatedState, BootDevice.CDROM, ProvisionComputeTaskState.SubStage.VALIDATE_COMPUTE_HOST);
            return;
        case BOOTING_FROM_ANY:
            BootDevice[] bootDevices = new BootDevice[] { BootDevice.DISK, BootDevice.CDROM, BootDevice.NETWORK };
            doSubStageBootHost(updatedState, bootDevices, ProvisionComputeTaskState.SubStage.VALIDATE_COMPUTE_HOST);
            return;
        case VALIDATE_COMPUTE_HOST:
            doSubStageValidateComputeHostState(updatedState);
            return;
        case DONE:
            sendSelfPatch(TaskStage.FINISHED, ProvisionComputeTaskState.SubStage.DONE, null);
            break;
        default:
            break;
    }
}
Also used : SubStage(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState.SubStage) BootDevice(com.vmware.photon.controller.model.resources.ComputeService.BootDevice)

Example 2 with BootDevice

use of com.vmware.photon.controller.model.resources.ComputeService.BootDevice in project photon-model by vmware.

the class ProvisionComputeTaskService method doSubStageBootHost.

private void doSubStageBootHost(ProvisionComputeTaskState updatedState, BootDevice[] bootDevices, ProvisionComputeTaskState.SubStage nextStage) {
    CompletionHandler c = (o, e) -> {
        if (e != null) {
            failTask(e);
            return;
        }
        ComputeBootRequest br = new ComputeBootRequest();
        br.resourceReference = UriUtils.extendUri(ClusterUtil.getClusterUri(getHost(), ServiceTypeCluster.INVENTORY_SERVICE), updatedState.computeLink);
        for (BootDevice bootDevice : bootDevices) {
            br.bootDeviceOrder.add(bootDevice);
        }
        ServiceDocument subTask = o.getBody(ServiceDocument.class);
        br.taskReference = UriUtils.buildUri(this.getHost(), subTask.documentSelfLink);
        br.isMockRequest = updatedState.isMockRequest;
        sendHostServiceRequest(br, updatedState.bootAdapterReference);
    };
    // After setting boot order and rebooting, we want the sub-task
    // to patch the main task to the "next" state.
    createSubTask(c, nextStage, updatedState);
}
Also used : ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) ComputeBootRequest(com.vmware.photon.controller.model.adapterapi.ComputeBootRequest) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) Operation(com.vmware.xenon.common.Operation) ServiceDocument(com.vmware.xenon.common.ServiceDocument) InstanceRequestType(com.vmware.photon.controller.model.adapterapi.ComputeInstanceRequest.InstanceRequestType) BootDevice(com.vmware.photon.controller.model.resources.ComputeService.BootDevice) TaskStage(com.vmware.xenon.common.TaskState.TaskStage) ComputeInstanceRequest(com.vmware.photon.controller.model.adapterapi.ComputeInstanceRequest) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Utils(com.vmware.xenon.common.Utils) UriPaths(com.vmware.photon.controller.model.UriPaths) ClusterUtil(com.vmware.photon.controller.model.util.ClusterUtil) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) InetAddressValidator(org.apache.commons.validator.routines.InetAddressValidator) UriUtils(com.vmware.xenon.common.UriUtils) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) TaskState(com.vmware.xenon.common.TaskState) URI(java.net.URI) TaskService(com.vmware.xenon.services.common.TaskService) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) SubStage(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState.SubStage) BootDevice(com.vmware.photon.controller.model.resources.ComputeService.BootDevice) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) ServiceDocument(com.vmware.xenon.common.ServiceDocument) ComputeBootRequest(com.vmware.photon.controller.model.adapterapi.ComputeBootRequest)

Aggregations

BootDevice (com.vmware.photon.controller.model.resources.ComputeService.BootDevice)2 SubStage (com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState.SubStage)2 UriPaths (com.vmware.photon.controller.model.UriPaths)1 ComputeBootRequest (com.vmware.photon.controller.model.adapterapi.ComputeBootRequest)1 ComputeInstanceRequest (com.vmware.photon.controller.model.adapterapi.ComputeInstanceRequest)1 InstanceRequestType (com.vmware.photon.controller.model.adapterapi.ComputeInstanceRequest.InstanceRequestType)1 ComputeDescription (com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)1 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)1 ClusterUtil (com.vmware.photon.controller.model.util.ClusterUtil)1 ServiceTypeCluster (com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster)1 PhotonModelUriUtils.createInventoryUri (com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri)1 Operation (com.vmware.xenon.common.Operation)1 CompletionHandler (com.vmware.xenon.common.Operation.CompletionHandler)1 ServiceDocument (com.vmware.xenon.common.ServiceDocument)1 TaskState (com.vmware.xenon.common.TaskState)1 TaskStage (com.vmware.xenon.common.TaskState.TaskStage)1 UriUtils (com.vmware.xenon.common.UriUtils)1 Utils (com.vmware.xenon.common.Utils)1 TaskService (com.vmware.xenon.services.common.TaskService)1 URI (java.net.URI)1