use of com.vmware.photon.controller.model.resources.ComputeService.ComputeState in project photon-model by vmware.
the class AWSResetService method updateComputeState.
private void updateComputeState(DefaultAdapterContext c) {
ComputeState state = new ComputeState();
state.powerState = ComputeService.PowerState.ON;
Operation.createPatch(c.resourceReference).setBody(state).setCompletion((o, e) -> {
if (e != null) {
c.taskManager.patchTaskToFailure(e);
return;
}
c.taskManager.finishTask();
}).sendWith(this);
}
use of com.vmware.photon.controller.model.resources.ComputeService.ComputeState in project photon-model by vmware.
the class ResourceOperationSpecServiceTest method testGetByResourceStateAndOperation.
@Test
public void testGetByResourceStateAndOperation() throws Throwable {
String operation = UUID.randomUUID().toString();
ComputeState computeState = prepare(this.endpointType, "testGetByResourceStateAndOperation_1", "testGetByResourceStateAndOperation_2", operation);
DeferredResult<List<ResourceOperationSpec>> dr = ResourceOperationUtils.lookupByResourceState(super.host, super.host.getReferer(), computeState, operation, null);
List<ResourceOperationSpec> found = join(dr);
Assert.assertNotNull(found);
Assert.assertEquals(1, found.size());
ResourceOperationSpec resourceOperationSpec = found.get(0);
Assert.assertEquals(operation, resourceOperationSpec.operation);
}
use of com.vmware.photon.controller.model.resources.ComputeService.ComputeState in project photon-model by vmware.
the class ResourceOperationUtilsTest method testIsAvailable_simple_pos.
@Test
public void testIsAvailable_simple_pos() {
ResourceOperationSpec spec = createResourceOperationSpec();
spec.targetCriteria = SCRIPT_CONTEXT_RESOURCE + ".hostName.startsWith('test')" + " && " + SCRIPT_CONTEXT_RESOURCE + ".cpuCount==4";
ComputeState computeState = createComputeState("testIsAvailable_simple_pos");
boolean ret = ResourceOperationUtils.isAvailable(computeState, spec);
Assert.assertTrue(ret);
}
use of com.vmware.photon.controller.model.resources.ComputeService.ComputeState in project photon-model by vmware.
the class ResourceOperationUtilsTest method testIsAvailable_changeContextFromScript.
@Test
public void testIsAvailable_changeContextFromScript() {
ResourceOperationSpec spec = createResourceOperationSpec();
spec.targetCriteria = SCRIPT_CONTEXT_RESOURCE + ".hostName='changed'";
ComputeState computeState = createComputeState("testIsAvailable_changeContextFromScript");
String originalValue = computeState.hostName;
ResourceOperationUtils.isAvailable(computeState, spec);
Assert.assertEquals(originalValue, computeState.hostName);
}
use of com.vmware.photon.controller.model.resources.ComputeService.ComputeState in project photon-model by vmware.
the class ResourceOperationUtilsTest method testIsAvailable_custProps_neg.
@Test
public void testIsAvailable_custProps_neg() {
ResourceOperationSpec spec = createResourceOperationSpec();
spec.targetCriteria = SCRIPT_CONTEXT_RESOURCE + ".customProperties.p1=='v2'";
ComputeState computeState = createComputeState("testIsAvailable_custProps_neg");
boolean ret = ResourceOperationUtils.isAvailable(computeState, spec);
Assert.assertFalse(ret);
}
Aggregations