Search in sources :

Example 1 with ENDPOINT_REMOVAL_REQUEST_REFERRER_VALUE

use of com.vmware.photon.controller.model.resources.EndpointService.ENDPOINT_REMOVAL_REQUEST_REFERRER_VALUE in project photon-model by vmware.

the class EndpointRemovalTaskService method doInstanceDelete.

/**
 * Delete endpoint
 */
private void doInstanceDelete(EndpointRemovalTaskState currentState, SubStage next) {
    EndpointState endpoint = currentState.endpoint;
    Operation crdOp = Operation.createDelete(createInventoryUri(this.getHost(), endpoint.authCredentialsLink));
    Operation epOp = Operation.createDelete(createInventoryUri(this.getHost(), endpoint.documentSelfLink));
    // custom header identifier for endpoint service to validate before deleting endpoint
    epOp.addRequestHeader(ENDPOINT_REMOVAL_REQUEST_REFERRER_NAME, ENDPOINT_REMOVAL_REQUEST_REFERRER_VALUE);
    OperationJoin.create(crdOp, epOp).setCompletion((ops, exc) -> {
        if (exc != null) {
            // failing to delete the endpoint itself is considered a critical error
            Throwable endpointRemovalException = exc.get(epOp.getId());
            if (endpointRemovalException != null) {
                sendFailureSelfPatch(endpointRemovalException);
                return;
            }
            // other removal exceptions are just warnings
            logFine(() -> String.format("Failed delete some of the associated resources," + " reason %s", Utils.toString(exc)));
        }
        // Endpoint and AuthCredentials are deleted; mark the operation as complete
        sendSelfPatch(TaskStage.STARTED, next);
    }).sendWith(this);
}
Also used : EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) LINK(com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.LINK) Service(com.vmware.xenon.common.Service) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) Arrays(java.util.Arrays) QueryTask(com.vmware.xenon.services.common.QueryTask) SnapshotState(com.vmware.photon.controller.model.resources.SnapshotService.SnapshotState) ServiceDocument(com.vmware.xenon.common.ServiceDocument) ResourceGroupState(com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState) Utils(com.vmware.xenon.common.Utils) RouterState(com.vmware.photon.controller.model.resources.RouterService.RouterState) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) StorageDescription(com.vmware.photon.controller.model.resources.StorageDescriptionService.StorageDescription) SINGLE_ASSIGNMENT(com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.SINGLE_ASSIGNMENT) EnumSet(java.util.EnumSet) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) SEPARATOR(com.vmware.photon.controller.model.tasks.monitoring.StatsUtil.SEPARATOR) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) Collection(java.util.Collection) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) UUID(java.util.UUID) ServiceHost(com.vmware.xenon.common.ServiceHost) ENDPOINT_LINK_EXPLICIT_SUPPORT(com.vmware.photon.controller.model.resources.util.PhotonModelUtils.ENDPOINT_LINK_EXPLICIT_SUPPORT) OPTIONAL(com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.OPTIONAL) List(java.util.List) UriUtils(com.vmware.xenon.common.UriUtils) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) TaskState(com.vmware.xenon.common.TaskState) TaskService(com.vmware.xenon.services.common.TaskService) STORE_ONLY(com.vmware.xenon.common.ServiceDocumentDescription.PropertyIndexingOption.STORE_ONLY) ResourcePoolState(com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState) PhotonModelUtils(com.vmware.photon.controller.model.resources.util.PhotonModelUtils) JoinedCompletionHandler(com.vmware.xenon.common.OperationJoin.JoinedCompletionHandler) ArrayList(java.util.ArrayList) SecurityGroupState(com.vmware.photon.controller.model.resources.SecurityGroupService.SecurityGroupState) HashSet(java.util.HashSet) Query(com.vmware.xenon.services.common.QueryTask.Query) UriPaths(com.vmware.photon.controller.model.UriPaths) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) ENDPOINT_REMOVAL_REQUEST_REFERRER_VALUE(com.vmware.photon.controller.model.resources.EndpointService.ENDPOINT_REMOVAL_REQUEST_REFERRER_VALUE) ENDPOINT_REMOVAL_REQUEST_REFERRER_NAME(com.vmware.photon.controller.model.resources.EndpointService.ENDPOINT_REMOVAL_REQUEST_REFERRER_NAME) SERVICE_USE(com.vmware.xenon.common.ServiceDocumentDescription.PropertyUsageOption.SERVICE_USE) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) Operation(com.vmware.xenon.common.Operation) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) TaskStage(com.vmware.xenon.common.TaskState.TaskStage) TimeUnit(java.util.concurrent.TimeUnit) PropertyIndexingOption(com.vmware.xenon.common.ServiceDocumentDescription.PropertyIndexingOption) ImageState(com.vmware.photon.controller.model.resources.ImageService.ImageState) NetworkInterfaceDescription(com.vmware.photon.controller.model.resources.NetworkInterfaceDescriptionService.NetworkInterfaceDescription) NetworkState(com.vmware.photon.controller.model.resources.NetworkService.NetworkState) Collections(java.util.Collections) OperationJoin(com.vmware.xenon.common.OperationJoin) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) Operation(com.vmware.xenon.common.Operation)

Aggregations

UriPaths (com.vmware.photon.controller.model.UriPaths)1 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)1 ComputeDescription (com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)1 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)1 DiskState (com.vmware.photon.controller.model.resources.DiskService.DiskState)1 ENDPOINT_REMOVAL_REQUEST_REFERRER_NAME (com.vmware.photon.controller.model.resources.EndpointService.ENDPOINT_REMOVAL_REQUEST_REFERRER_NAME)1 ENDPOINT_REMOVAL_REQUEST_REFERRER_VALUE (com.vmware.photon.controller.model.resources.EndpointService.ENDPOINT_REMOVAL_REQUEST_REFERRER_VALUE)1 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)1 ImageState (com.vmware.photon.controller.model.resources.ImageService.ImageState)1 NetworkInterfaceDescription (com.vmware.photon.controller.model.resources.NetworkInterfaceDescriptionService.NetworkInterfaceDescription)1 NetworkInterfaceState (com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState)1 NetworkState (com.vmware.photon.controller.model.resources.NetworkService.NetworkState)1 ResourceGroupState (com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState)1 ResourcePoolState (com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState)1 ResourceState (com.vmware.photon.controller.model.resources.ResourceState)1 RouterState (com.vmware.photon.controller.model.resources.RouterService.RouterState)1 SecurityGroupState (com.vmware.photon.controller.model.resources.SecurityGroupService.SecurityGroupState)1 SnapshotState (com.vmware.photon.controller.model.resources.SnapshotService.SnapshotState)1 StorageDescription (com.vmware.photon.controller.model.resources.StorageDescriptionService.StorageDescription)1 SubnetState (com.vmware.photon.controller.model.resources.SubnetService.SubnetState)1