use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec in project photon-model by vmware.
the class BaseResourceOperationTest method registerResourceOperation.
protected ResourceOperationSpec[] registerResourceOperation(ResourceOperationSpec roState) {
Operation registerOp = Operation.createPost(super.host, ResourceOperationSpecService.FACTORY_LINK).setBody(roState).setCompletion((op, ex) -> {
if (ex != null) {
this.logger.severe(Utils.toString(ex));
op.fail(ex);
} else {
op.complete();
}
});
DeferredResult<Operation> deferredResult = super.host.sendWithDeferredResult(registerOp).exceptionally(e -> {
this.logger.severe("Error: " + Utils.toString(e));
return null;
});
// TestRequestSender
join(deferredResult);
Operation response = deferredResult.getNow((Operation) null);
ResourceOperationSpec persistedState = response.getBody(ResourceOperationSpec.class);
Assert.assertNotNull(persistedState);
markForDelete(persistedState.documentSelfLink);
return new ResourceOperationSpec[] { roState, persistedState };
}
use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec in project photon-model by vmware.
the class VSphereAdapterD2PowerOpsService method getResourceOperationSpec.
private static ResourceOperationSpec getResourceOperationSpec(ResourceOperation operationType, String targetCriteria) {
ResourceOperationSpec spec = new ResourceOperationSpec();
spec.endpointType = PhotonModelConstants.EndpointType.vsphere.name();
spec.resourceType = ResourceType.COMPUTE;
spec.operation = operationType.operation;
spec.name = operationType.displayName;
spec.description = operationType.description;
spec.targetCriteria = targetCriteria;
return spec;
}
use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec in project photon-model by vmware.
the class AWSResetService method getResourceOperationSpec.
public static ResourceOperationSpec getResourceOperationSpec() {
ResourceOperationSpec spec = new ResourceOperationSpec();
spec.endpointType = EndpointType.aws.name();
spec.resourceType = ResourceType.COMPUTE;
spec.operation = ResourceOperation.RESET.operation;
spec.name = ResourceOperation.RESET.displayName;
spec.description = ResourceOperation.RESET.description;
spec.targetCriteria = ResourceOperationUtils.TargetCriteria.RESOURCE_POWER_STATE_ON.getCriteria();
return spec;
}
use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec in project photon-model by vmware.
the class ResourceOperationSpecServiceTest method testGetByEndpointType_neg.
@Test
public void testGetByEndpointType_neg() {
DeferredResult<ResourceOperationSpec> dr = ResourceOperationUtils.lookUpByEndpointType(super.host, super.host.getReferer(), UUID.randomUUID().toString(), ResourceType.COMPUTE, UUID.randomUUID().toString(), null, null);
ResourceOperationSpec found = join(dr);
Assert.assertNull(found);
}
use of com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec in project photon-model by vmware.
the class ResourceOperationSpecServiceTest method testGetByResourceState.
@Test
public void testGetByResourceState() throws Throwable {
ComputeState computeState = prepare(this.endpointType, "testGetByResourceState_1", "testGetByResourceState_2");
registerResourceOperation(this.endpointType, ResourceType.NETWORK, "testGetByResourceState_3");
DeferredResult<List<ResourceOperationSpec>> dr = ResourceOperationUtils.lookupByResourceState(super.host, super.host.getReferer(), computeState, null, null);
List<ResourceOperationSpec> found = join(dr);
Assert.assertNotNull(found);
Assert.assertEquals(2, found.size());
}
Aggregations