Search in sources :

Example 1 with ProvisioningUtils

use of com.vmware.photon.controller.model.tasks.ProvisioningUtils in project photon-model by vmware.

the class TestAzureProvisionTask method assertStorageDescription.

/**
 * Ensure that after provisioning, there is one (but only one) StorageDescription created for
 * the shared storage account. This test does not use shared SA, thus provisioning should create
 * a StorageDescription.
 */
private void assertStorageDescription() {
    if (this.isMock) {
        // return. Nothing provisioned on Azure so nothing to check
        return;
    }
    try {
        ComputeState vm = getHost().getServiceState(null, ComputeState.class, UriUtils.buildUri(getHost(), this.vmState.documentSelfLink));
        String sharedSAName = vm.customProperties.get(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME);
        if (sharedSAName != null && !sharedSAName.isEmpty()) {
            Map<String, StorageDescription> storageDescriptionsMap = ProvisioningUtils.<StorageDescription>getResourceStates(getHost(), StorageDescriptionService.FACTORY_LINK, StorageDescription.class);
            assertTrue(!storageDescriptionsMap.isEmpty());
            List<StorageDescription> storageDescriptions = storageDescriptionsMap.values().stream().filter(name -> name.equals(sharedSAName)).collect(Collectors.toList());
            assertEquals("More than one storage description was created for the provisinoed storage account.", storageDescriptions.size(), 1);
        }
    } catch (Throwable t) {
        fail("Unable to verify Storage Description documents");
        t.printStackTrace();
    }
}
Also used : NicSpec(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs.NicSpec) NetworkManagementClientImpl(com.microsoft.azure.management.network.implementation.NetworkManagementClientImpl) ProvisionComputeTaskService(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService) IpAssignment(com.vmware.photon.controller.model.resources.NetworkInterfaceDescriptionService.IpAssignment) AzureTestUtil.deleteVMs(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.deleteVMs) SHARED_NETWORK_NIC_SPEC(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.SHARED_NETWORK_NIC_SPEC) VirtualNetworkInner(com.microsoft.azure.management.network.implementation.VirtualNetworkInner) DISK_CONTROLLER_NUMBER(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.DISK_CONTROLLER_NUMBER) AzureUriPaths(com.vmware.photon.controller.model.adapters.azure.AzureUriPaths) NetworkInterfaceStateWithDescription(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceStateWithDescription) ResourceGroupState(com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState) Map(java.util.Map) After(org.junit.After) StorageDescription(com.vmware.photon.controller.model.resources.StorageDescriptionService.StorageDescription) Assert.fail(org.junit.Assert.fail) ServiceDocumentQueryResult(com.vmware.xenon.common.ServiceDocumentQueryResult) ProvisioningUtils(com.vmware.photon.controller.model.tasks.ProvisioningUtils) OSDisk(com.microsoft.azure.management.compute.OSDisk) EnumSet(java.util.EnumSet) ResourceEnumerationTaskService(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService) AzureConstants(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants) DEFAULT_NIC_SPEC(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.DEFAULT_NIC_SPEC) ComputeStatsResponse(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse) ComputeStatsRequest(com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) StatelessService(com.vmware.xenon.common.StatelessService) VMResourceSpec(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.VMResourceSpec) TestUtils(com.vmware.photon.controller.model.tasks.TestUtils) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) UUID(java.util.UUID) AzureTestUtil.createPrivateImageSource(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createPrivateImageSource) AzureTestUtil.createVMResourceFromSpec(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createVMResourceFromSpec) Collectors(java.util.stream.Collectors) NO_PUBLIC_IP_NIC_SPEC(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.NO_PUBLIC_IP_NIC_SPEC) List(java.util.List) AzureUtils(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils) AzureTestUtil.createImageSource(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createImageSource) StorageDescriptionService(com.vmware.photon.controller.model.resources.StorageDescriptionService) UriUtils(com.vmware.xenon.common.UriUtils) Optional(java.util.Optional) NetworkSecurityGroupInner(com.microsoft.azure.management.network.implementation.NetworkSecurityGroupInner) AzureEnumerationAdapterService(com.vmware.photon.controller.model.adapters.azure.enumeration.AzureEnumerationAdapterService) TaskOption(com.vmware.photon.controller.model.tasks.TaskOption) DiskService(com.vmware.photon.controller.model.resources.DiskService) AzureTestUtil.createDefaultResourceGroupState(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createDefaultResourceGroupState) ComputeProperties(com.vmware.photon.controller.model.ComputeProperties) ResourceGroupStateType(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.ResourceGroupStateType) ResourceGroupInner(com.microsoft.azure.management.resources.implementation.ResourceGroupInner) PhotonModelMetricServices(com.vmware.photon.controller.model.PhotonModelMetricServices) Function(java.util.function.Function) AzureBaseTest(com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest) ProvisionComputeTaskState(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState) AzureTestUtil.createDefaultVMResource(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createDefaultVMResource) Level(java.util.logging.Level) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) EnumerationAction(com.vmware.photon.controller.model.adapterapi.EnumerationAction) Assume(org.junit.Assume) IMAGE_REFERENCE(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.IMAGE_REFERENCE) VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner) AzureNicSpecs(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs) PRIVATE_IP_NIC_SPEC(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.PRIVATE_IP_NIC_SPEC) DataDisk(com.microsoft.azure.management.compute.DataDisk) Assert.assertNotNull(org.junit.Assert.assertNotNull) Operation(com.vmware.xenon.common.Operation) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ImageSource(com.vmware.photon.controller.model.adapters.util.instance.BaseComputeInstanceContext.ImageSource) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) AZURE_CUSTOM_DATA_DISK_SIZE(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AZURE_CUSTOM_DATA_DISK_SIZE) Assert.assertNull(org.junit.Assert.assertNull) Ignore(org.junit.Ignore) AzureTestUtil.generateName(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.generateName) Assert.assertEquals(org.junit.Assert.assertEquals) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) StorageDescription(com.vmware.photon.controller.model.resources.StorageDescriptionService.StorageDescription)

Aggregations

DataDisk (com.microsoft.azure.management.compute.DataDisk)1 OSDisk (com.microsoft.azure.management.compute.OSDisk)1 VirtualMachineInner (com.microsoft.azure.management.compute.implementation.VirtualMachineInner)1 NetworkManagementClientImpl (com.microsoft.azure.management.network.implementation.NetworkManagementClientImpl)1 NetworkSecurityGroupInner (com.microsoft.azure.management.network.implementation.NetworkSecurityGroupInner)1 VirtualNetworkInner (com.microsoft.azure.management.network.implementation.VirtualNetworkInner)1 ResourceGroupInner (com.microsoft.azure.management.resources.implementation.ResourceGroupInner)1 ComputeProperties (com.vmware.photon.controller.model.ComputeProperties)1 PhotonModelMetricServices (com.vmware.photon.controller.model.PhotonModelMetricServices)1 ComputeStatsRequest (com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest)1 ComputeStatsResponse (com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse)1 EnumerationAction (com.vmware.photon.controller.model.adapterapi.EnumerationAction)1 AzureUriPaths (com.vmware.photon.controller.model.adapters.azure.AzureUriPaths)1 AzureBaseTest (com.vmware.photon.controller.model.adapters.azure.base.AzureBaseTest)1 AzureConstants (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants)1 DISK_CONTROLLER_NUMBER (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.DISK_CONTROLLER_NUMBER)1 ResourceGroupStateType (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.ResourceGroupStateType)1 AzureEnumerationAdapterService (com.vmware.photon.controller.model.adapters.azure.enumeration.AzureEnumerationAdapterService)1 AZURE_CUSTOM_DATA_DISK_SIZE (com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AZURE_CUSTOM_DATA_DISK_SIZE)1 AzureNicSpecs (com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs)1