Search in sources :

Example 46 with DiskState

use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.

the class TestVSphereDiskService method createDiskWithDatastore.

private DiskState createDiskWithDatastore(String alias, DiskService.DiskType type, long capacityMBytes, HashMap<String, String> customProperties) throws Throwable {
    DiskState diskState = constructDiskState(alias, type, 0, null, capacityMBytes, customProperties);
    diskState.storageDescriptionLink = createStorageDescriptionState().documentSelfLink;
    return postDiskStateWithDetails(diskState);
}
Also used : DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState)

Example 47 with DiskState

use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.

the class TestVSphereDiskService method testDiskCreateAndDeleteWithStoragePolicy.

@Test
public void testDiskCreateAndDeleteWithStoragePolicy() throws Throwable {
    prepareEnvironment();
    DiskState diskState = createDiskWithStoragePolicy("AdditionalDisk1", DiskService.DiskType.HDD, ADDITIONAL_DISK_SIZE, buildCustomProperties());
    testDiskCreateAndDelete(diskState);
}
Also used : DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) Test(org.junit.Test)

Example 48 with DiskState

use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.

the class TestVSphereDiskService method testDiskCreateAndDelete.

private void testDiskCreateAndDelete(DiskState diskState) throws Throwable {
    // start provision task to do the actual disk creation
    String documentSelfLink = performDiskRequest(diskState, SubStage.CREATING_DISK);
    this.host.waitForFinishedTask(ProvisionDiskTaskService.ProvisionDiskTaskState.class, documentSelfLink);
    // check that the disk has been created
    ServiceDocumentQueryResult result = ProvisioningUtils.queryDiskInstances(this.host, 1);
    if (!isMock()) {
        DiskState disk = Utils.fromJson(result.documents.get(diskState.documentSelfLink), DiskState.class);
        assertNotNull(disk.customProperties);
        assertNotNull(disk.customProperties.get(DISK_FULL_PATH));
        assertEquals(DiskService.DiskStatus.AVAILABLE, disk.status);
        assertNotNull(disk.customProperties.get(DISK_PARENT_DIRECTORY));
        assertNotNull(disk.customProperties.get(DISK_DATASTORE_NAME));
        assertTrue(disk.id.startsWith(diskState.name));
    }
    // start provision task to do the disk deletion
    documentSelfLink = performDiskRequest(diskState, SubStage.DELETING_DISK);
    this.host.waitForFinishedTask(ProvisionDiskTaskService.ProvisionDiskTaskState.class, documentSelfLink);
    // check that the disk has been deleted
    ProvisioningUtils.queryDiskInstances(this.host, 0);
}
Also used : DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) ProvisionDiskTaskService(com.vmware.photon.controller.model.tasks.ProvisionDiskTaskService) ServiceDocumentQueryResult(com.vmware.xenon.common.ServiceDocumentQueryResult)

Example 49 with DiskState

use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.

the class TestVSphereDiskService method testDiskCreateAndDeleteWithCustomPropsDataStore.

@Test
public void testDiskCreateAndDeleteWithCustomPropsDataStore() throws Throwable {
    prepareEnvironment();
    DiskState diskState = createDiskWithCustomPropsDataStore("AdditionalDisk1", DiskService.DiskType.HDD, ADDITIONAL_DISK_SIZE, buildCustomProperties());
    testDiskCreateAndDelete(diskState);
}
Also used : DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) Test(org.junit.Test)

Example 50 with DiskState

use of com.vmware.photon.controller.model.resources.DiskService.DiskState in project photon-model by vmware.

the class TestVSphereDiskService method createDiskWithStoragePolicy.

private DiskState createDiskWithStoragePolicy(String alias, DiskService.DiskType type, long capacityMBytes, HashMap<String, String> customProperties) throws Throwable {
    DiskState diskState = constructDiskState(alias, type, 0, null, capacityMBytes, customProperties);
    diskState.groupLinks = new HashSet<>();
    if (isMock()) {
        diskState.groupLinks.add(createResourceGroupState().documentSelfLink);
    } else {
        diskState.groupLinks.add(getStoragePolicyLink());
    }
    return postDiskStateWithDetails(diskState);
}
Also used : DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState)

Aggregations

DiskState (com.vmware.photon.controller.model.resources.DiskService.DiskState)77 ArrayList (java.util.ArrayList)24 Operation (com.vmware.xenon.common.Operation)23 DiskService (com.vmware.photon.controller.model.resources.DiskService)18 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)16 List (java.util.List)15 EnumerationAction (com.vmware.photon.controller.model.adapterapi.EnumerationAction)13 UriUtils (com.vmware.xenon.common.UriUtils)13 Utils (com.vmware.xenon.common.Utils)13 HashMap (java.util.HashMap)13 TimeUnit (java.util.concurrent.TimeUnit)13 QueryTask (com.vmware.xenon.services.common.QueryTask)12 Query (com.vmware.xenon.services.common.QueryTask.Query)12 HashSet (java.util.HashSet)12 Test (org.junit.Test)11 AzureConstants (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants)10 PhotonModelUriUtils.createInventoryUri (com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri)10 ServiceDocumentQueryResult (com.vmware.xenon.common.ServiceDocumentQueryResult)10 AuthCredentialsService (com.vmware.xenon.services.common.AuthCredentialsService)10 Map (java.util.Map)10