Search in sources :

Example 1 with Operation

use of com.vmware.xenon.common.Operation in project photon-model by vmware.

the class TestAWSEnumerationDocumentCountInLongRun method storeDocumentLinksFromComputeStates.

/**
 * Gets and stores resource pool links and network interface links by querying
 * given instance IDs.
 * @param instanceIdList List of instance IDs provisioned by the test
 */
private void storeDocumentLinksFromComputeStates(List<String> instanceIdList) {
    // Query to get all compute state documents associated with list of instance IDs.
    QueryTask.Query computeStateQuery = QueryTask.Query.Builder.create().addKindFieldClause(ComputeState.class).addInClause(ComputeState.FIELD_NAME_ID, instanceIdList).build();
    QueryTask q = QueryTask.Builder.createDirectTask().setQuery(computeStateQuery).addOption(QueryTask.QuerySpecification.QueryOption.EXPAND_CONTENT).build();
    Operation queryComputeState = QueryUtils.createQueryTaskOperation(this.host, q, ServiceTypeCluster.INVENTORY_SERVICE).setReferer(this.host.getUri());
    Operation queryResponse = this.host.waitForResponse(queryComputeState);
    Assert.assertTrue("Error retrieving compute states", queryResponse.getStatusCode() == 200);
    QueryTask qt = queryResponse.getBody(QueryTask.class);
    // Store all compute links
    this.computeStateLinks.addAll(qt.results.documentLinks);
    // Store resource pool links and network links from all compute states.
    for (String documentLink : this.computeStateLinks) {
        ComputeState cs = Utils.fromJson(qt.results.documents.get(documentLink), ComputeState.class);
        this.resourcePoolLinks.add(cs.resourcePoolLink);
        this.networkInterfaceLinks.addAll(cs.networkInterfaceLinks);
    }
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) QueryTask(com.vmware.xenon.services.common.QueryTask) Operation(com.vmware.xenon.common.Operation)

Example 2 with Operation

use of com.vmware.xenon.common.Operation in project photon-model by vmware.

the class AWSComputeStateCreationAdapterService method createTags.

/**
 * POSTs all tags for newly discovered instances. Even if some tags already exist we rely on
 * IDEMPOTENT_POST behaviour and POST them again. All tags that got created successfully are
 * stored in createdExternalTags list.
 */
private void createTags(AWSComputeStateCreationContext context, AWSComputeStateCreationStage next) {
    // Get all tags from the instances to be created
    Set<Tag> create = context.request.instancesToBeCreated.stream().flatMap(i -> i.getTags().stream()).collect(Collectors.toSet());
    // Put them in a set to remove the duplicates
    Set<Tag> allTags = new HashSet<>();
    allTags.addAll(create);
    // POST each of the tags. If a tag exists it won't be created again. We don't want the name
    // tags, so filter them out
    List<Operation> operations = new ArrayList<>();
    Map<Long, Tag> tagsCreationOperationIdsMap = new ConcurrentHashMap<>();
    allTags.stream().filter(t -> !AWSConstants.AWS_TAG_NAME.equals(t.getKey())).forEach(t -> {
        TagState tagState = newTagState(t.getKey(), t.getValue(), true, context.request.tenantLinks);
        Operation op = Operation.createPost(this, TagService.FACTORY_LINK).setBody(tagState);
        operations.add(op);
        tagsCreationOperationIdsMap.put(op.getId(), t);
    });
    if (operations.isEmpty()) {
        context.creationStage = next;
        handleComputeStateCreateOrUpdate(context);
    } else {
        OperationJoin.create(operations).setCompletion((ops, exs) -> {
            if (exs != null && !exs.isEmpty()) {
                logSevere(() -> String.format("Error creating %s external tags for compute" + "states: %s", exs.size(), Utils.toString(exs.get(0))));
            }
            ops.values().stream().filter(operation -> operation.getStatusCode() == Operation.STATUS_CODE_OK || operation.getStatusCode() == Operation.STATUS_CODE_NOT_MODIFIED).forEach(operation -> {
                if (tagsCreationOperationIdsMap.containsKey(operation.getId())) {
                    context.createdExternalTags.add(tagsCreationOperationIdsMap.get(operation.getId()));
                }
            });
            context.creationStage = next;
            handleComputeStateCreateOrUpdate(context);
        }).sendWith(this);
    }
}
Also used : AdapterUtils.createDeleteOperation(com.vmware.photon.controller.model.adapters.util.AdapterUtils.createDeleteOperation) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) Arrays(java.util.Arrays) QueryTask(com.vmware.xenon.services.common.QueryTask) InstanceDescKey(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.InstanceDescKey) AWSEnumerationUtils(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils) StringUtils(org.apache.commons.lang3.StringUtils) AWSEnumerationUtils.getKeyForComputeDescriptionFromCD(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.getKeyForComputeDescriptionFromCD) Utils(com.vmware.xenon.common.Utils) Map(java.util.Map) GroupIdentifier(com.amazonaws.services.ec2.model.GroupIdentifier) AdapterUtils.createPatchOperation(com.vmware.photon.controller.model.adapters.util.AdapterUtils.createPatchOperation) URI(java.net.URI) TagsUtil.newTagState(com.vmware.photon.controller.model.adapters.util.TagsUtil.newTagState) AWSClientManager(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManager) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) StatelessService(com.vmware.xenon.common.StatelessService) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) UUID(java.util.UUID) AdapterUtils.getDeletionState(com.vmware.photon.controller.model.adapters.util.AdapterUtils.getDeletionState) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) NetworkInterfaceService(com.vmware.photon.controller.model.resources.NetworkInterfaceService) TagService(com.vmware.photon.controller.model.resources.TagService) Tag(com.amazonaws.services.ec2.model.Tag) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) TAG_KEY_TYPE(com.vmware.photon.controller.model.constants.PhotonModelConstants.TAG_KEY_TYPE) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) AWSEnumerationUtils.mapInstanceToComputeState(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.mapInstanceToComputeState) ZoneData(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.ZoneData) InstanceNetworkInterface(com.amazonaws.services.ec2.model.InstanceNetworkInterface) AWSResourceType.ec2_instance(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSResourceType.ec2_instance) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AWSConstants(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants) TagState(com.vmware.photon.controller.model.resources.TagService.TagState) AWSResourceType.ec2_net_interface(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSResourceType.ec2_net_interface) ServiceStateCollectionUpdateRequest(com.vmware.xenon.common.ServiceStateCollectionUpdateRequest) Query(com.vmware.xenon.services.common.QueryTask.Query) TagsUtil.updateLocalTagStates(com.vmware.photon.controller.model.adapters.util.TagsUtil.updateLocalTagStates) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) AdapterUtils.createPostOperation(com.vmware.photon.controller.model.adapters.util.AdapterUtils.createPostOperation) AWSEnumerationUtils.getRepresentativeListOfCDsFromInstanceList(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.getRepresentativeListOfCDsFromInstanceList) BiConsumer(java.util.function.BiConsumer) Instance(com.amazonaws.services.ec2.model.Instance) AWSSecurityGroupEnumerationResponse(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSSecurityGroupEnumerationAdapterService.AWSSecurityGroupEnumerationResponse) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) Operation(com.vmware.xenon.common.Operation) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) AWSNetworkEnumerationResponse(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSNetworkStateEnumerationAdapterService.AWSNetworkEnumerationResponse) TimeUnit(java.util.concurrent.TimeUnit) AWSEnumerationUtils.getCDsRepresentingVMsInLocalSystemCreatedByEnumerationQuery(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.getCDsRepresentingVMsInLocalSystemCreatedByEnumerationQuery) AWSClientManagerFactory(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManagerFactory) Collections(java.util.Collections) AWSUriPaths(com.vmware.photon.controller.model.adapters.awsadapter.AWSUriPaths) OperationJoin(com.vmware.xenon.common.OperationJoin) ArrayList(java.util.ArrayList) Tag(com.amazonaws.services.ec2.model.Tag) AdapterUtils.createDeleteOperation(com.vmware.photon.controller.model.adapters.util.AdapterUtils.createDeleteOperation) AdapterUtils.createPatchOperation(com.vmware.photon.controller.model.adapters.util.AdapterUtils.createPatchOperation) AdapterUtils.createPostOperation(com.vmware.photon.controller.model.adapters.util.AdapterUtils.createPostOperation) Operation(com.vmware.xenon.common.Operation) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TagsUtil.newTagState(com.vmware.photon.controller.model.adapters.util.TagsUtil.newTagState) TagState(com.vmware.photon.controller.model.resources.TagService.TagState) HashSet(java.util.HashSet)

Example 3 with Operation

use of com.vmware.xenon.common.Operation in project photon-model by vmware.

the class AWSComputeStateCreationAdapterService method addUpdateOrRemoveNICStates.

/**
 * From the previously calculated NICs delta (based on whether the local state correspond to
 * existing AWS object, the AWS object was deleted, or a new AWS object was added): 1) Create,
 * update or delete NICState objects 2) Update the CS's references to the added or removed
 * NetworkInterfaceStates
 */
private Map<String, Map<String, Collection<Object>>> addUpdateOrRemoveNICStates(AWSComputeStateCreationContext context, Instance instance, Map<String, List<Integer>> nicsDeviceIndexDeltaMap, String existingEndpointLink, Set<String> endpointLinks) {
    List<NetworkInterfaceState> existingNicStates = context.request.nicStatesToBeUpdated.get(instance.getInstanceId());
    // Generate operation for adding NIC state and description, and retain its link to add to
    // the CS
    List<Integer> deviceIndexesToAdd = nicsDeviceIndexDeltaMap.get(ADD_NIC_STATES);
    Collection<Object> networkInterfaceLinksToBeAdded = instance.getNetworkInterfaces().stream().filter(awsNic -> deviceIndexesToAdd.contains(awsNic.getAttachment().getDeviceIndex()) && context.request.enumeratedNetworks != null && context.request.enumeratedNetworks.subnets != null && context.request.enumeratedNetworks.subnets.containsKey(awsNic.getSubnetId())).map(awsNic -> createNICStateAndDescription(context, awsNic, existingEndpointLink, endpointLinks)).map(addedNicState -> UriUtils.buildUriPath(NetworkInterfaceService.FACTORY_LINK, addedNicState.documentSelfLink)).collect(Collectors.toList());
    // Generate operation for removing NIC states, and retain its link to remove from the CS {{
    List<Integer> deviceIndexesToRemove = nicsDeviceIndexDeltaMap.get(REMOVE_NIC_STATES);
    Collection<Object> networkInterfaceLinksToBeRemoved = deviceIndexesToRemove.stream().map(deviceIndexToRemove -> {
        NetworkInterfaceState stateToDelete = existingNicStates.stream().filter(existNicState -> existNicState.deviceIndex == deviceIndexToRemove).findFirst().orElse(null);
        return stateToDelete;
    }).filter(existingNicState -> existingNicState != null).map(existingNicState -> deleteNICState(context, existingNicState)).map(existingNicState -> existingNicState.documentSelfLink).collect(Collectors.toList());
    // Generate operation for updating NIC states, no links should be updated on CS in this case
    List<Integer> deviceIndexesToUpdate = nicsDeviceIndexDeltaMap.get(UPDATE_NIC_STATES);
    deviceIndexesToUpdate.stream().map(deviceIndexToUpdate -> existingNicStates.stream().filter(existNicState -> existNicState.deviceIndex == deviceIndexToUpdate).findFirst().orElse(null)).filter(existingNicState -> existingNicState != null).forEach(existingNicState -> updateNICState(context, instance, existingNicState));
    if (context.request.nicStatesToBeDeleted.size() > 0 && context.request.nicStatesToBeDeleted.get(instance.getInstanceId()) != null) {
        this.logInfo(() -> String.format("Compute %s failed to discover %d nics", instance.getInstanceId(), context.request.nicStatesToBeDeleted.get(instance.getInstanceId()).size()));
        networkInterfaceLinksToBeRemoved.addAll(context.request.nicStatesToBeDeleted.get(instance.getInstanceId()));
    }
    Map<String, Map<String, Collection<Object>>> nicsDeltaMap = new HashMap<>();
    // only add the collections to the delta map in case there is something to add/remove
    if (!networkInterfaceLinksToBeRemoved.isEmpty()) {
        Map<String, Collection<Object>> collectionsToRemoveMap = new HashMap<>();
        collectionsToRemoveMap.put(ComputeState.FIELD_NAME_NETWORK_INTERFACE_LINKS, networkInterfaceLinksToBeRemoved);
        nicsDeltaMap.put(REMOVE_NIC_STATES, collectionsToRemoveMap);
    }
    if (!networkInterfaceLinksToBeAdded.isEmpty()) {
        Map<String, Collection<Object>> collectionsToAddMap = new HashMap<>();
        collectionsToAddMap.put(ComputeState.FIELD_NAME_NETWORK_INTERFACE_LINKS, networkInterfaceLinksToBeAdded);
        nicsDeltaMap.put(ADD_NIC_STATES, collectionsToAddMap);
    }
    return nicsDeltaMap;
}
Also used : AdapterUtils.createDeleteOperation(com.vmware.photon.controller.model.adapters.util.AdapterUtils.createDeleteOperation) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) Arrays(java.util.Arrays) QueryTask(com.vmware.xenon.services.common.QueryTask) InstanceDescKey(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.InstanceDescKey) AWSEnumerationUtils(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils) StringUtils(org.apache.commons.lang3.StringUtils) AWSEnumerationUtils.getKeyForComputeDescriptionFromCD(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.getKeyForComputeDescriptionFromCD) Utils(com.vmware.xenon.common.Utils) Map(java.util.Map) GroupIdentifier(com.amazonaws.services.ec2.model.GroupIdentifier) AdapterUtils.createPatchOperation(com.vmware.photon.controller.model.adapters.util.AdapterUtils.createPatchOperation) URI(java.net.URI) TagsUtil.newTagState(com.vmware.photon.controller.model.adapters.util.TagsUtil.newTagState) AWSClientManager(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManager) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) StatelessService(com.vmware.xenon.common.StatelessService) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) UUID(java.util.UUID) AdapterUtils.getDeletionState(com.vmware.photon.controller.model.adapters.util.AdapterUtils.getDeletionState) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) NetworkInterfaceService(com.vmware.photon.controller.model.resources.NetworkInterfaceService) TagService(com.vmware.photon.controller.model.resources.TagService) Tag(com.amazonaws.services.ec2.model.Tag) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) TAG_KEY_TYPE(com.vmware.photon.controller.model.constants.PhotonModelConstants.TAG_KEY_TYPE) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) AWSEnumerationUtils.mapInstanceToComputeState(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.mapInstanceToComputeState) ZoneData(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.ZoneData) InstanceNetworkInterface(com.amazonaws.services.ec2.model.InstanceNetworkInterface) AWSResourceType.ec2_instance(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSResourceType.ec2_instance) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AWSConstants(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants) TagState(com.vmware.photon.controller.model.resources.TagService.TagState) AWSResourceType.ec2_net_interface(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSResourceType.ec2_net_interface) ServiceStateCollectionUpdateRequest(com.vmware.xenon.common.ServiceStateCollectionUpdateRequest) Query(com.vmware.xenon.services.common.QueryTask.Query) TagsUtil.updateLocalTagStates(com.vmware.photon.controller.model.adapters.util.TagsUtil.updateLocalTagStates) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) AdapterUtils.createPostOperation(com.vmware.photon.controller.model.adapters.util.AdapterUtils.createPostOperation) AWSEnumerationUtils.getRepresentativeListOfCDsFromInstanceList(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.getRepresentativeListOfCDsFromInstanceList) BiConsumer(java.util.function.BiConsumer) Instance(com.amazonaws.services.ec2.model.Instance) AWSSecurityGroupEnumerationResponse(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSSecurityGroupEnumerationAdapterService.AWSSecurityGroupEnumerationResponse) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) Operation(com.vmware.xenon.common.Operation) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) AWSNetworkEnumerationResponse(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSNetworkStateEnumerationAdapterService.AWSNetworkEnumerationResponse) TimeUnit(java.util.concurrent.TimeUnit) AWSEnumerationUtils.getCDsRepresentingVMsInLocalSystemCreatedByEnumerationQuery(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSEnumerationUtils.getCDsRepresentingVMsInLocalSystemCreatedByEnumerationQuery) AWSClientManagerFactory(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManagerFactory) Collections(java.util.Collections) AWSUriPaths(com.vmware.photon.controller.model.adapters.awsadapter.AWSUriPaths) OperationJoin(com.vmware.xenon.common.OperationJoin) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Collection(java.util.Collection) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Example 4 with Operation

use of com.vmware.xenon.common.Operation in project photon-model by vmware.

the class AWSEnumerationAdapterService method kickOffEnumerationWorkFlows.

/**
 * Kicks off the enumeration flows for creation and deletion.
 */
public void kickOffEnumerationWorkFlows(EnumerationContext context, AWSEnumerationStages next) {
    List<List<Operation>> enumOperations = new ArrayList<>();
    if (!AWSUtils.isAwsClientMock()) {
        ComputeEnumerateAdapterRequest awsS3EnumerationRequest = new ComputeEnumerateAdapterRequest(context.request, context.endpointAuth, context.parent, Regions.DEFAULT_REGION.getName());
        Operation patchAWSS3StorageAdapterService = Operation.createPatch(this, AWSS3StorageEnumerationAdapterService.SELF_LINK).setBody(awsS3EnumerationRequest).setReferer(getHost().getUri());
        enumOperations.add(Collections.singletonList(patchAWSS3StorageAdapterService));
    }
    for (String regionId : context.regions) {
        List<Operation> enumOperationsForRegion = new ArrayList<>();
        ComputeEnumerateAdapterRequest awsEnumerationRequest = new ComputeEnumerateAdapterRequest(context.request, context.endpointAuth, context.parent, regionId);
        Operation patchAWSCreationAdapterService = Operation.createPatch(this, AWSEnumerationAndCreationAdapterService.SELF_LINK).setBody(awsEnumerationRequest).setReferer(this.getHost().getUri());
        Operation patchAWSDeletionAdapterService = Operation.createPatch(this, AWSEnumerationAndDeletionAdapterService.SELF_LINK).setBody(awsEnumerationRequest).setReferer(getHost().getUri());
        Operation patchAWSEBSStorageAdapterService = Operation.createPatch(this, AWSEBSStorageEnumerationAdapterService.SELF_LINK).setBody(awsEnumerationRequest).setReferer(getHost().getUri());
        enumOperationsForRegion.add(patchAWSCreationAdapterService);
        enumOperationsForRegion.add(patchAWSDeletionAdapterService);
        enumOperationsForRegion.add(patchAWSEBSStorageAdapterService);
        enumOperations.add(enumOperationsForRegion);
    }
    if (enumOperations.size() == 0) {
        logFine(() -> "No enumeration tasks to run");
        context.stage = next;
        handleEnumerationRequest(context);
        return;
    }
    OperationJoin.JoinedCompletionHandler joinCompletion = (ox, exc) -> {
        if (exc != null) {
            logSevere(() -> String.format("Error starting the enumeration workflows for AWS: %s", Utils.toString(exc)));
            context.taskManager.patchTaskToFailure(exc.values().iterator().next());
            return;
        }
        logInfo(() -> "Completed creation and deletion enumeration for compute and storage" + " states");
        context.stage = next;
        handleEnumerationRequest(context);
    };
    OperationSequence enumOp = OperationSequence.create(OperationJoin.create(enumOperations.get(0)));
    for (int i = 1; i < enumOperations.size(); i++) {
        enumOp = enumOp.next(OperationJoin.create(enumOperations.get(i)));
    }
    enumOp.setCompletion(joinCompletion);
    enumOp.sendWith(getHost());
    logFine(() -> "Started creation and deletion enumeration for AWS computes and storage");
}
Also used : AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) Arrays(java.util.Arrays) ComputeEnumerateResourceRequest(com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest) StatelessService(com.vmware.xenon.common.StatelessService) Operation(com.vmware.xenon.common.Operation) BaseAdapterStage(com.vmware.photon.controller.model.adapters.util.BaseAdapterContext.BaseAdapterStage) BaseAdapterContext(com.vmware.photon.controller.model.adapters.util.BaseAdapterContext) AWSUtils(com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Regions(com.amazonaws.regions.Regions) List(java.util.List) Utils(com.vmware.xenon.common.Utils) GET_REGIONS(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSEnumerationAdapterService.AWSEnumerationStages.GET_REGIONS) ComputeEnumerateAdapterRequest(com.vmware.photon.controller.model.adapters.util.ComputeEnumerateAdapterRequest) KICKOFF_ENUMERATION(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSEnumerationAdapterService.AWSEnumerationStages.KICKOFF_ENUMERATION) OperationSequence(com.vmware.xenon.common.OperationSequence) Collections(java.util.Collections) AWSUriPaths(com.vmware.photon.controller.model.adapters.awsadapter.AWSUriPaths) OperationJoin(com.vmware.xenon.common.OperationJoin) PATCH_COMPLETION(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSEnumerationAdapterService.AWSEnumerationStages.PATCH_COMPLETION) OperationSequence(com.vmware.xenon.common.OperationSequence) ComputeEnumerateAdapterRequest(com.vmware.photon.controller.model.adapters.util.ComputeEnumerateAdapterRequest) OperationJoin(com.vmware.xenon.common.OperationJoin) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Operation(com.vmware.xenon.common.Operation)

Example 5 with Operation

use of com.vmware.xenon.common.Operation in project photon-model by vmware.

the class AWSEnumerationAdapterService method startHelperServices.

/**
 * Starts the related services for the Enumeration Service
 */
public void startHelperServices(Operation startPost) {
    Operation patchAWSEnumerationCreationService = Operation.createPatch(getHost(), AWSEnumerationAndCreationAdapterService.SELF_LINK).setReferer(getUri());
    Operation patchAWSEnumerationDeletionService = Operation.createPatch(getHost(), AWSEnumerationAndDeletionAdapterService.SELF_LINK).setReferer(getUri());
    Operation patchAWSEBSStorageEnumerationService = Operation.createPatch(getHost(), AWSEBSStorageEnumerationAdapterService.SELF_LINK).setReferer(getUri());
    Operation patchAWSS3StorageEnumerationService = Operation.createPatch(getHost(), AWSS3StorageEnumerationAdapterService.SELF_LINK).setReferer(getUri());
    getHost().startService(patchAWSEnumerationCreationService, new AWSEnumerationAndCreationAdapterService());
    getHost().startService(patchAWSEnumerationDeletionService, new AWSEnumerationAndDeletionAdapterService());
    getHost().startService(patchAWSEBSStorageEnumerationService, new AWSEBSStorageEnumerationAdapterService());
    getHost().startService(patchAWSS3StorageEnumerationService, new AWSS3StorageEnumerationAdapterService());
    getHost().startService(new AWSVolumeTypeDiscoveryService());
    AdapterUtils.registerForServiceAvailability(getHost(), operation -> startPost.complete(), startPost::fail, LINKS);
}
Also used : Operation(com.vmware.xenon.common.Operation)

Aggregations

Operation (com.vmware.xenon.common.Operation)391 URI (java.net.URI)142 ArrayList (java.util.ArrayList)132 QueryTask (com.vmware.xenon.services.common.QueryTask)118 List (java.util.List)118 Utils (com.vmware.xenon.common.Utils)111 StatelessService (com.vmware.xenon.common.StatelessService)108 UriUtils (com.vmware.xenon.common.UriUtils)106 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)98 Map (java.util.Map)92 HashMap (java.util.HashMap)90 OperationJoin (com.vmware.xenon.common.OperationJoin)86 Query (com.vmware.xenon.services.common.QueryTask.Query)86 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)82 Collectors (java.util.stream.Collectors)79 HashSet (java.util.HashSet)78 AuthCredentialsServiceState (com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState)73 AdapterUtils (com.vmware.photon.controller.model.adapters.util.AdapterUtils)70 DeferredResult (com.vmware.xenon.common.DeferredResult)69 Consumer (java.util.function.Consumer)69