use of com.vmware.photon.controller.model.tasks.ResourceRemovalTaskService.ResourceRemovalTaskState in project photon-model by vmware.
the class ResourceRemovalTaskServiceTest method buildValidStartState.
private static ResourceRemovalTaskState buildValidStartState() {
ResourceRemovalTaskState startState = new ResourceRemovalTaskState();
startState.resourceQuerySpec = new QueryTask.QuerySpecification();
QueryTask.Query kindClause = new QueryTask.Query().setTermPropertyName(ServiceDocument.FIELD_NAME_KIND).setTermMatchValue(Utils.buildKind(ComputeService.ComputeState.class));
startState.resourceQuerySpec.query.addBooleanClause(kindClause);
startState.isMockRequest = true;
return startState;
}
use of com.vmware.photon.controller.model.tasks.ResourceRemovalTaskService.ResourceRemovalTaskState in project photon-model by vmware.
the class AWSPowerServiceTest method tearDown.
@After
public void tearDown() throws Throwable {
Query resourceQuery = Query.Builder.create().addKindFieldClause(ComputeState.class).addInClause(ComputeState.FIELD_NAME_SELF_LINK, this.computesToRemove).build();
QuerySpecification qSpec = new QuerySpecification();
qSpec.query = resourceQuery;
ResourceRemovalTaskState state = new ResourceRemovalTaskState();
state.isMockRequest = this.isMock;
state.resourceQuerySpec = qSpec;
ResourceRemovalTaskState removalTaskState = TestUtils.doPost(this.host, state, ResourceRemovalTaskState.class, UriUtils.buildUri(this.host, ResourceRemovalTaskService.FACTORY_LINK));
this.host.waitForFinishedTask(ResourceRemovalTaskState.class, removalTaskState.documentSelfLink);
if (this.deleteResourcesFlag) {
this.awsTestContext.put(TestAWSSetupUtils.DELETE_RESOURCES_KEY, TestAWSSetupUtils.DELETE_RESOURCES_KEY);
}
tearDownTestVpc(this.client, this.host, this.awsTestContext, this.isMock);
this.client.shutdown();
}
use of com.vmware.photon.controller.model.tasks.ResourceRemovalTaskService.ResourceRemovalTaskState in project photon-model by vmware.
the class BaseVSphereAdapterTest method deleteVmAndWait.
protected void deleteVmAndWait(ComputeState vm) {
try {
ResourceRemovalTaskState deletionState = new ResourceRemovalTaskState();
deletionState.isMockRequest = isMock();
QuerySpecification resourceQuerySpec = new QuerySpecification();
resourceQuerySpec.query.setTermPropertyName(ServiceDocument.FIELD_NAME_SELF_LINK).setTermMatchValue(vm.documentSelfLink);
deletionState.resourceQuerySpec = resourceQuerySpec;
ResourceRemovalTaskState outDelete = TestUtils.doPost(this.host, deletionState, ResourceRemovalTaskState.class, UriUtils.buildUri(this.host, ResourceRemovalTaskService.FACTORY_LINK));
awaitTaskEnd(outDelete);
} catch (Throwable e) {
this.host.log("Error deleting VM %s", e.getMessage());
}
}
use of com.vmware.photon.controller.model.tasks.ResourceRemovalTaskService.ResourceRemovalTaskState in project photon-model by vmware.
the class AzureLoadBalancerServiceTest method deleteVirtualMachines.
private void deleteVirtualMachines() {
List<ResourceRemovalTaskState> removeTaskStates = this.vmStates.stream().map(vmState -> {
getHost().log(Level.INFO, "%s: Deleting [%s] VM", this.currentTestName.getMethodName(), vmState.name);
try {
QuerySpecification resourceQuerySpec = new QuerySpecification();
resourceQuerySpec.query.setTermPropertyName(ServiceDocument.FIELD_NAME_SELF_LINK).setTermMatchValue(vmState.documentSelfLink);
ResourceRemovalTaskState deletionState = new ResourceRemovalTaskState();
deletionState.resourceQuerySpec = resourceQuerySpec;
deletionState.isMockRequest = isMock;
// Post/Start the ResourceRemovalTaskState...
deletionState = TestUtils.doPost(host, deletionState, ResourceRemovalTaskState.class, UriUtils.buildUri(host, ResourceRemovalTaskService.FACTORY_LINK));
return deletionState;
} catch (Throwable deleteExc) {
// just log and move on
getHost().log(Level.WARNING, "%s: Deleting [%s] VM: FAILED. Details: %s", this.currentTestName.getMethodName(), vmState.name, deleteExc.getMessage());
return null;
}
}).collect(Collectors.toList());
removeTaskStates.forEach(deletionState -> {
if (deletionState != null) {
getHost().waitForFinishedTask(ResourceRemovalTaskState.class, deletionState.documentSelfLink);
}
});
}
use of com.vmware.photon.controller.model.tasks.ResourceRemovalTaskService.ResourceRemovalTaskState in project photon-model by vmware.
the class AzureTestUtil method deleteVMs.
public static void deleteVMs(VerificationHost host, String documentSelfLink, boolean isMock, int numberOfRemainingVMs) throws Throwable {
// query VM doc to delete
QuerySpecification resourceQuerySpec = new QuerySpecification();
resourceQuerySpec.query.setTermPropertyName(ServiceDocument.FIELD_NAME_SELF_LINK).setTermMatchValue(documentSelfLink);
ResourceRemovalTaskState deletionState = new ResourceRemovalTaskState();
deletionState.resourceQuerySpec = resourceQuerySpec;
deletionState.isMockRequest = isMock;
// Post/Start the ResourceRemovalTaskState...
deletionState = TestUtils.doPost(host, deletionState, ResourceRemovalTaskState.class, UriUtils.buildUri(host, ResourceRemovalTaskService.FACTORY_LINK));
// ...and wait for the task to complete
host.waitForFinishedTask(ResourceRemovalTaskState.class, deletionState.documentSelfLink);
ProvisioningUtils.queryDocumentsAndAssertExpectedCount(host, numberOfRemainingVMs, ComputeService.FACTORY_LINK, false);
}
Aggregations