Search in sources :

Example 6 with VirtualMachineInner

use of com.microsoft.azure.management.compute.implementation.VirtualMachineInner in project photon-model by vmware.

the class TestAzureLongRunningEnumeration method tagAzureResources.

/**
 * Add tags, that later should be discovered as part of first enumeration cycle.
 */
private void tagAzureResources() throws Exception {
    for (int i = 0; i < numOfVMsToTest; i++) {
        // tag v-Net
        VirtualNetworkInner vmNetwUpdate = getAzureVirtualNetwork(this.networkManagementClient, azureVMNames.get(i), nicSpecs.get(i).network.name);
        Map<String, String> vmNetwTags = new HashMap<>();
        vmNetwTags.put(NETWORK_TAG_KEY_PREFIX + azureVMNames.get(i), NETWORK_TAG_VALUE);
        vmNetwUpdate.withTags(vmNetwTags);
        updateAzureVirtualNetwork(this.networkManagementClient, azureVMNames.get(i), nicSpecs.get(i).network.name, vmNetwUpdate);
        // tag VM
        VirtualMachineInner vmUpdate = getAzureVirtualMachine(this.computeManagementClient, azureVMNames.get(i), azureVMNames.get(i));
        Map<String, String> vmTags = new HashMap<>();
        String timeStamp = String.valueOf(Utils.getNowMicrosUtc());
        vmTags.put(VM_TAG_KEY_PREFIX + azureVMNames.get(i), VM_TAG_VALUE);
        vmTags.put(TIME_STAMP_TAG_KEY, timeStamp);
        vmUpdate.withTags(vmTags);
        updateAzureVirtualMachine(this.computeManagementClient, azureVMNames.get(i), azureVMNames.get(i), vmUpdate);
        // tag Security Group
        NetworkSecurityGroupInner sgUpdate = getAzureSecurityGroup(this.networkManagementClient, azureVMNames.get(i), AZURE_SECURITY_GROUP_NAME + "-" + azureVMNames.get(i));
        Map<String, String> sgTags = new HashMap<>();
        sgTags.put(SG_TAG_KEY_PREFIX + azureVMNames.get(i), SG_TAG_VALUE);
        sgUpdate.withTags(sgTags);
        sgUpdate.withLocation(AzureTestUtil.AZURE_RESOURCE_GROUP_LOCATION);
        updateAzureSecurityGroup(this.networkManagementClient, azureVMNames.get(i), AZURE_SECURITY_GROUP_NAME, sgUpdate);
    }
}
Also used : VirtualNetworkInner(com.microsoft.azure.management.network.implementation.VirtualNetworkInner) NetworkSecurityGroupInner(com.microsoft.azure.management.network.implementation.NetworkSecurityGroupInner) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner) AzureTestUtil.randomString(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.randomString)

Example 7 with VirtualMachineInner

use of com.microsoft.azure.management.compute.implementation.VirtualMachineInner in project photon-model by vmware.

the class AzureInstanceService method createVM.

private void createVM(AzureInstanceContext ctx, AzureInstanceStage nextStage) {
    ComputeDescriptionService.ComputeDescription description = ctx.child.description;
    Map<String, String> customProperties = description.customProperties;
    if (customProperties == null) {
        handleError(ctx, new IllegalStateException("Custom properties not specified"));
        return;
    }
    // DiskService.DiskStateExpanded bootDisk = ctx.bootDiskState;
    if (ctx.bootDiskState == null) {
        handleError(ctx, new IllegalStateException("Azure bootDisk not specified"));
        return;
    }
    String cloudConfig = null;
    if (ctx.bootDiskState.bootConfig != null && ctx.bootDiskState.bootConfig.files.length > CLOUD_CONFIG_DEFAULT_FILE_INDEX) {
        cloudConfig = ctx.bootDiskState.bootConfig.files[CLOUD_CONFIG_DEFAULT_FILE_INDEX].contents;
    }
    VirtualMachineInner request = new VirtualMachineInner();
    request.withLocation(ctx.resourceGroup.location());
    SubResource availabilitySetSubResource = new SubResource().withId(ctx.availabilitySet.id());
    request.withAvailabilitySet(availabilitySetSubResource);
    // Set OS profile.
    OSProfile osProfile = new OSProfile();
    osProfile.withComputerName(ctx.vmName);
    if (ctx.childAuth != null) {
        osProfile.withAdminUsername(ctx.childAuth.userEmail);
        osProfile.withAdminPassword(EncryptionUtils.decrypt(ctx.childAuth.privateKey));
    }
    if (cloudConfig != null) {
        try {
            osProfile.withCustomData(Base64.getEncoder().encodeToString(cloudConfig.getBytes(Utils.CHARSET)));
        } catch (UnsupportedEncodingException e) {
            logWarning(() -> "Error encoding user data");
            return;
        }
    }
    request.withOsProfile(osProfile);
    // Set hardware profile.
    HardwareProfile hardwareProfile = new HardwareProfile();
    hardwareProfile.withVmSize(description.instanceType != null ? VirtualMachineSizeTypes.fromString(description.instanceType) : VirtualMachineSizeTypes.BASIC_A0);
    request.withHardwareProfile(hardwareProfile);
    // Set storage profile.
    // Create destination OS VHD
    final OSDisk osDisk = newAzureOsDisk(ctx);
    final StorageProfile storageProfile = new StorageProfile();
    storageProfile.withOsDisk(osDisk);
    List<DataDisk> dataDisks = new ArrayList<>();
    List<Integer> LUNsOnImage = new ArrayList<>();
    storageProfile.withImageReference(ctx.imageSource.asImageReferenceInner());
    if (ctx.imageSource.type == ImageSource.Type.PRIVATE_IMAGE) {
        // set LUNs of data disks present on the custom image.
        final ImageState imageState = ctx.imageSource.asImageState();
        if (imageState != null && imageState.diskConfigs != null) {
            for (DiskConfiguration diskConfig : imageState.diskConfigs) {
                if (diskConfig.properties != null && diskConfig.properties.containsKey(AzureConstants.AZURE_DISK_LUN)) {
                    DataDisk imageDataDisk = new DataDisk();
                    int lun = Integer.parseInt(diskConfig.properties.get(AzureConstants.AZURE_DISK_LUN));
                    LUNsOnImage.add(lun);
                    imageDataDisk.withLun(lun);
                    imageDataDisk.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE);
                    dataDisks.add(imageDataDisk);
                }
            }
        }
        String dataDiskCaching = ctx.bootDiskState.customProperties.get(AZURE_DATA_DISK_CACHING);
        if (dataDiskCaching != null) {
            dataDisks.stream().forEach(dataDisk -> dataDisk.withCaching(CachingTypes.fromString(dataDiskCaching)));
        }
        String diskType = ctx.bootDiskState.customProperties.get(AZURE_MANAGED_DISK_TYPE);
        if (diskType != null) {
            ManagedDiskParametersInner managedDiskParams = new ManagedDiskParametersInner();
            managedDiskParams.withStorageAccountType(StorageAccountTypes.fromString(diskType));
            dataDisks.stream().forEach(dataDisk -> dataDisk.withManagedDisk(managedDiskParams));
        }
    }
    // choose LUN greater than the one specified in case of custom image. Else start from zero.
    int LUNForAdditionalDisk = LUNsOnImage.size() == 0 ? 0 : Collections.max(LUNsOnImage) + 1;
    dataDisks.addAll(newAzureDataDisks(ctx, LUNForAdditionalDisk));
    storageProfile.withDataDisks(dataDisks);
    request.withStorageProfile(storageProfile);
    // Set network profile {{
    NetworkProfile networkProfile = new NetworkProfile();
    networkProfile.withNetworkInterfaces(new ArrayList<>());
    for (AzureNicContext nicCtx : ctx.nics) {
        NetworkInterfaceReferenceInner nicRef = new NetworkInterfaceReferenceInner();
        nicRef.withId(nicCtx.nic.id());
        // NOTE: First NIC is marked as Primary.
        nicRef.withPrimary(networkProfile.networkInterfaces().isEmpty());
        networkProfile.networkInterfaces().add(nicRef);
    }
    request.withNetworkProfile(networkProfile);
    logFine(() -> String.format("Creating virtual machine with name [%s]", ctx.vmName));
    AzureAsyncCallback<VirtualMachineInner> callback = new AzureAsyncCallback<VirtualMachineInner>() {

        @Override
        public void onError(Throwable e) {
            // exception and try again with a shorter name
            if (isIncorrectNameLength(e)) {
                request.osProfile().withComputerName(generateWindowsComputerName(ctx.vmName));
                getComputeManagementClientImpl(ctx).virtualMachines().createOrUpdateAsync(ctx.resourceGroup.name(), ctx.vmName, request, this);
                return;
            }
            handleCloudError(String.format("Provisioning VM %s: FAILED. Details:", ctx.vmName), ctx, COMPUTE_NAMESPACE, e);
        }

        // Cannot tell for sure, but these checks should be enough
        private boolean isIncorrectNameLength(Throwable e) {
            if (e instanceof CloudException) {
                CloudException ce = (CloudException) e;
                CloudError body = ce.body();
                if (body != null) {
                    String code = body.code();
                    String target = body.target();
                    return INVALID_PARAMETER.equals(code) && COMPUTER_NAME.equals(target) && request.osProfile().computerName().length() > WINDOWS_COMPUTER_NAME_MAX_LENGTH && body.message().toLowerCase().contains("windows");
                }
            }
            return false;
        }

        private String generateWindowsComputerName(String vmName) {
            String computerName = vmName;
            if (vmName.length() > WINDOWS_COMPUTER_NAME_MAX_LENGTH) {
                // Take the first 12 and the last 3 chars of the generated VM name
                computerName = vmName.substring(0, 12) + vmName.substring(vmName.length() - 3, vmName.length());
            }
            return computerName;
        }

        @Override
        public void onSuccess(VirtualMachineInner result) {
            logFine(() -> String.format("Successfully created vm [%s]", result.name()));
            ctx.provisionedVm = result;
            ComputeState cs = new ComputeState();
            // Azure for some case changes the case of the vm id.
            ctx.vmId = result.id().toLowerCase();
            cs.id = ctx.vmId;
            cs.type = ComputeType.VM_GUEST;
            cs.environmentName = ComputeDescription.ENVIRONMENT_NAME_AZURE;
            cs.lifecycleState = LifecycleState.READY;
            if (ctx.child.customProperties == null) {
                cs.customProperties = new HashMap<>();
            } else {
                cs.customProperties = ctx.child.customProperties;
            }
            cs.customProperties.put(RESOURCE_GROUP_NAME, ctx.resourceGroup.name());
            Operation.CompletionHandler completionHandler = (ox, exc) -> {
                if (exc != null) {
                    handleError(ctx, exc);
                    return;
                }
                handleAllocation(ctx, nextStage);
            };
            sendRequest(Operation.createPatch(ctx.computeRequest.resourceReference).setBody(cs).setCompletion(completionHandler));
        }
    };
    getComputeManagementClientImpl(ctx).virtualMachines().createOrUpdateAsync(ctx.resourceGroup.name(), ctx.vmName, request, callback);
}
Also used : AzureNicContext(com.vmware.photon.controller.model.adapters.azure.instance.AzureInstanceContext.AzureNicContext) VirtualMachine(com.microsoft.azure.management.compute.VirtualMachine) NetworkManagementClientImpl(com.microsoft.azure.management.network.implementation.NetworkManagementClientImpl) PROVISIONING_STATE_SUCCEEDED(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.PROVISIONING_STATE_SUCCEEDED) ComputeManager(com.microsoft.azure.management.compute.implementation.ComputeManager) IpAssignment(com.vmware.photon.controller.model.resources.NetworkInterfaceDescriptionService.IpAssignment) VirtualNetworkInner(com.microsoft.azure.management.network.implementation.VirtualNetworkInner) LifecycleState(com.vmware.photon.controller.model.resources.ComputeService.LifecycleState) COMPUTE_NAMESPACE(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.COMPUTE_NAMESPACE) DISK_CONTROLLER_NUMBER(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.DISK_CONTROLLER_NUMBER) StorageManagementClientImpl(com.microsoft.azure.management.storage.implementation.StorageManagementClientImpl) AzureDiagnosticSettings(com.vmware.photon.controller.model.adapters.azure.model.diagnostics.AzureDiagnosticSettings) INVALID_RESOURCE_GROUP(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.INVALID_RESOURCE_GROUP) Utils(com.vmware.xenon.common.Utils) Map(java.util.Map) StorageDescription(com.vmware.photon.controller.model.resources.StorageDescriptionService.StorageDescription) ProvisioningState(com.microsoft.azure.management.storage.ProvisioningState) OSDisk(com.microsoft.azure.management.compute.OSDisk) AZURE_STORAGE_ACCOUNT_KEY1(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_STORAGE_ACCOUNT_KEY1) ProviderInner(com.microsoft.azure.management.resources.implementation.ProviderInner) CachingTypes(com.microsoft.azure.management.compute.CachingTypes) Indexable(com.microsoft.azure.management.resources.fluentcore.model.Indexable) StorageAccountListKeysResultInner(com.microsoft.azure.management.storage.implementation.StorageAccountListKeysResultInner) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) StatelessService(com.vmware.xenon.common.StatelessService) AZURE_STORAGE_ACCOUNT_DEFAULT_RG_NAME(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_STORAGE_ACCOUNT_DEFAULT_RG_NAME) Disk(com.microsoft.azure.management.compute.Disk) AzureProvisioningCallback(com.vmware.photon.controller.model.adapters.azure.utils.AzureProvisioningCallback) CompletionStage(java.util.concurrent.CompletionStage) AzureSecurityGroupUtils(com.vmware.photon.controller.model.adapters.azure.utils.AzureSecurityGroupUtils) StorageAccountTypes(com.microsoft.azure.management.compute.StorageAccountTypes) SkuInner(com.microsoft.azure.management.storage.implementation.SkuInner) StorageDescriptionService(com.vmware.photon.controller.model.resources.StorageDescriptionService) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) STATUS_CODE_UNAUTHORIZED(com.vmware.xenon.common.Operation.STATUS_CODE_UNAUTHORIZED) InvalidKeyException(java.security.InvalidKeyException) StorageAccountCreateParametersInner(com.microsoft.azure.management.storage.implementation.StorageAccountCreateParametersInner) DiskCreateOptionTypes(com.microsoft.azure.management.compute.DiskCreateOptionTypes) ResourceGroupsInner(com.microsoft.azure.management.resources.implementation.ResourceGroupsInner) AzureProvisioningCallbackWithRetry(com.vmware.photon.controller.model.adapters.azure.utils.AzureProvisioningCallbackWithRetry) AZURE_DATA_DISK_CACHING(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_DATA_DISK_CACHING) INVALID_PARAMETER(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.INVALID_PARAMETER) STORAGE_ACCOUNT_ALREADY_EXIST(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.STORAGE_ACCOUNT_ALREADY_EXIST) VirtualNetworksInner(com.microsoft.azure.management.network.implementation.VirtualNetworksInner) ImageReferenceInner(com.microsoft.azure.management.compute.implementation.ImageReferenceInner) OperationContext(com.vmware.xenon.common.OperationContext) PROVISIONING_STATE_FAILED_NO_SUBNET(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.PROVISIONING_STATE_FAILED_NO_SUBNET) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) ArrayList(java.util.ArrayList) OSProfile(com.microsoft.azure.management.compute.OSProfile) ComputeInstanceRequest(com.vmware.photon.controller.model.adapterapi.ComputeInstanceRequest) SecurityGroupState(com.vmware.photon.controller.model.resources.SecurityGroupService.SecurityGroupState) StorageException(com.microsoft.azure.storage.StorageException) AzureAsyncCallback(com.vmware.photon.controller.model.adapters.azure.AzureAsyncCallback) AzureImageSource(com.vmware.photon.controller.model.adapters.azure.instance.AzureInstanceContext.AzureImageSource) MISSING_SUBSCRIPTION_CODE(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.MISSING_SUBSCRIPTION_CODE) StorageProfile(com.microsoft.azure.management.compute.StorageProfile) CloudBlobContainer(com.microsoft.azure.storage.blob.CloudBlobContainer) BiConsumer(java.util.function.BiConsumer) CloudPageBlob(com.microsoft.azure.storage.blob.CloudPageBlob) OperationStatusResponseInner(com.microsoft.azure.management.compute.implementation.OperationStatusResponseInner) VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner) PublicIPAddressInner(com.microsoft.azure.management.network.implementation.PublicIPAddressInner) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) ServiceErrorResponse(com.vmware.xenon.common.ServiceErrorResponse) DataDisk(com.microsoft.azure.management.compute.DataDisk) ServiceCallback(com.microsoft.rest.ServiceCallback) STORAGE_NAMESPACE(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.STORAGE_NAMESPACE) SubnetInner(com.microsoft.azure.management.network.implementation.SubnetInner) ImageSource(com.vmware.photon.controller.model.adapters.util.instance.BaseComputeInstanceContext.ImageSource) File(java.io.File) ManagedDiskParametersInner(com.microsoft.azure.management.compute.implementation.ManagedDiskParametersInner) NETWORK_NAMESPACE(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.NETWORK_NAMESPACE) AzureUtils.getStorageAccountKeyName(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.getStorageAccountKeyName) ApplicationTokenCredentials(com.microsoft.azure.credentials.ApplicationTokenCredentials) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) IPAllocationMethod(com.microsoft.azure.management.network.IPAllocationMethod) CloudError(com.microsoft.azure.CloudError) HardwareProfile(com.microsoft.azure.management.compute.HardwareProfile) AzureNicContext(com.vmware.photon.controller.model.adapters.azure.instance.AzureInstanceContext.AzureNicContext) URISyntaxException(java.net.URISyntaxException) NetworkProfile(com.microsoft.azure.management.compute.NetworkProfile) VirtualMachineImageResourceInner(com.microsoft.azure.management.compute.implementation.VirtualMachineImageResourceInner) AzureUriPaths(com.vmware.photon.controller.model.adapters.azure.AzureUriPaths) SubscriptionInner(com.microsoft.azure.management.resources.implementation.SubscriptionInner) AZURE_MANAGED_DISK_TYPE(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_MANAGED_DISK_TYPE) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) Creatable(com.microsoft.azure.management.resources.fluentcore.model.Creatable) AzureSdkClients(com.vmware.photon.controller.model.adapters.azure.utils.AzureSdkClients) ResourceManagementClientImpl(com.microsoft.azure.management.resources.implementation.ResourceManagementClientImpl) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) URI(java.net.URI) AzureConstants(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants) AvailabilitySet(com.microsoft.azure.management.compute.AvailabilitySet) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) SkuName(com.microsoft.azure.management.storage.SkuName) AddressSpace(com.microsoft.azure.management.network.AddressSpace) COMPUTER_NAME(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.COMPUTER_NAME) Predicate(java.util.function.Predicate) Collection(java.util.Collection) DiskConfiguration(com.vmware.photon.controller.model.resources.ImageService.ImageState.DiskConfiguration) AvailabilitySetInner(com.microsoft.azure.management.compute.implementation.AvailabilitySetInner) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) InstanceRequestType(com.vmware.photon.controller.model.adapterapi.ComputeInstanceRequest.InstanceRequestType) Collectors(java.util.stream.Collectors) Base64(java.util.Base64) List(java.util.List) VirtualHardDisk(com.microsoft.azure.management.compute.VirtualHardDisk) AzureUtils(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils) NetworkSecurityGroupsInner(com.microsoft.azure.management.network.implementation.NetworkSecurityGroupsInner) NetworkInterfacesInner(com.microsoft.azure.management.network.implementation.NetworkInterfacesInner) Optional(java.util.Optional) NetworkSecurityGroupInner(com.microsoft.azure.management.network.implementation.NetworkSecurityGroupInner) DiskService(com.vmware.photon.controller.model.resources.DiskService) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Default(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback.Default) SubResource(com.microsoft.azure.SubResource) AZURE_OSDISK_CACHING(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_OSDISK_CACHING) ResourceGroupInner(com.microsoft.azure.management.resources.implementation.ResourceGroupInner) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) AzureDeferredResultServiceCallbackWithRetry(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallbackWithRetry) VirtualMachineSizeTypes(com.microsoft.azure.management.compute.VirtualMachineSizeTypes) SubscriptionClientImpl(com.microsoft.azure.management.resources.implementation.SubscriptionClientImpl) Kind(com.microsoft.azure.management.storage.Kind) Level(java.util.logging.Level) FileUtils(com.vmware.xenon.common.FileUtils) AZURE_STORAGE_ACCOUNT_RG_NAME(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_STORAGE_ACCOUNT_RG_NAME) AuthCredentialsService(com.vmware.xenon.services.common.AuthCredentialsService) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) PublicIPAddressesInner(com.microsoft.azure.management.network.implementation.PublicIPAddressesInner) STORAGE_CONNECTION_STRING(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.STORAGE_CONNECTION_STRING) AzureDecommissionCallback(com.vmware.photon.controller.model.adapters.azure.utils.AzureDecommissionCallback) ComputeManagementClientImpl(com.microsoft.azure.management.compute.implementation.ComputeManagementClientImpl) NetworkInterfaceIPConfigurationInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner) EncryptionUtils(com.vmware.photon.controller.model.security.util.EncryptionUtils) CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient) Operation(com.vmware.xenon.common.Operation) AvailabilitySetSkuTypes(com.microsoft.azure.management.compute.AvailabilitySetSkuTypes) StorageAccountKey(com.microsoft.azure.management.storage.StorageAccountKey) BaseAdapterStage(com.vmware.photon.controller.model.adapters.util.BaseAdapterContext.BaseAdapterStage) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) NetworkInterfaceReferenceInner(com.microsoft.azure.management.compute.implementation.NetworkInterfaceReferenceInner) AzureDeferredResultServiceCallback(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback) AZURE_STORAGE_ACCOUNT_NAME(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_STORAGE_ACCOUNT_NAME) CloudException(com.microsoft.azure.CloudException) ImageState(com.vmware.photon.controller.model.resources.ImageService.ImageState) StorageAccountInner(com.microsoft.azure.management.storage.implementation.StorageAccountInner) NetworkInterfaceDescription(com.vmware.photon.controller.model.resources.NetworkInterfaceDescriptionService.NetworkInterfaceDescription) NetworkInterfaceInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceInner) CLOUD_CONFIG_DEFAULT_FILE_INDEX(com.vmware.photon.controller.model.constants.PhotonModelConstants.CLOUD_CONFIG_DEFAULT_FILE_INDEX) Collections(java.util.Collections) OperationJoin(com.vmware.xenon.common.OperationJoin) RESOURCE_GROUP_NAME(com.vmware.photon.controller.model.ComputeProperties.RESOURCE_GROUP_NAME) PROVIDER_REGISTRED_STATE(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.PROVIDER_REGISTRED_STATE) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) OSProfile(com.microsoft.azure.management.compute.OSProfile) ArrayList(java.util.ArrayList) Operation(com.vmware.xenon.common.Operation) StorageProfile(com.microsoft.azure.management.compute.StorageProfile) VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner) AzureAsyncCallback(com.vmware.photon.controller.model.adapters.azure.AzureAsyncCallback) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) ManagedDiskParametersInner(com.microsoft.azure.management.compute.implementation.ManagedDiskParametersInner) SubResource(com.microsoft.azure.SubResource) OSDisk(com.microsoft.azure.management.compute.OSDisk) NetworkInterfaceReferenceInner(com.microsoft.azure.management.compute.implementation.NetworkInterfaceReferenceInner) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CloudError(com.microsoft.azure.CloudError) CloudException(com.microsoft.azure.CloudException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DiskConfiguration(com.vmware.photon.controller.model.resources.ImageService.ImageState.DiskConfiguration) DataDisk(com.microsoft.azure.management.compute.DataDisk) NetworkProfile(com.microsoft.azure.management.compute.NetworkProfile) HardwareProfile(com.microsoft.azure.management.compute.HardwareProfile) ImageState(com.vmware.photon.controller.model.resources.ImageService.ImageState)

Example 8 with VirtualMachineInner

use of com.microsoft.azure.management.compute.implementation.VirtualMachineInner in project photon-model by vmware.

the class AzureTestUtil method getAzureVMCount.

public static int getAzureVMCount(ComputeManagementClientImpl computeManagementClient) throws Exception {
    List<VirtualMachineInner> response = computeManagementClient.virtualMachines().list();
    int count = 0;
    for (VirtualMachineInner virtualMachine : response) {
        if (AzureComputeEnumerationAdapterService.AZURE_VM_TERMINATION_STATES.contains(virtualMachine.provisioningState())) {
            continue;
        }
        count++;
    }
    return count;
}
Also used : VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner)

Example 9 with VirtualMachineInner

use of com.microsoft.azure.management.compute.implementation.VirtualMachineInner in project photon-model by vmware.

the class TestAzureProvisionTask method assertConfigurationOfDisks.

private void assertConfigurationOfDisks(int numberOfAdditionalDisks, int numberOfDataDisksOnImage) {
    ComputeState vm = getHost().getServiceState(null, ComputeState.class, UriUtils.buildUri(getHost(), this.vmState.documentSelfLink));
    List<DiskState> diskStates = vm.diskLinks.stream().map(diskLink -> getHost().getServiceState(null, DiskState.class, UriUtils.buildUri(getHost(), diskLink))).collect(Collectors.toList());
    if (numberOfDataDisksOnImage == 0) {
        for (DiskState diskState : diskStates) {
            if (diskState.bootOrder == 1) {
                assertEquals("OS Disk size does not match", AzureTestUtil.AZURE_CUSTOM_OSDISK_SIZE, diskState.capacityMBytes);
            } else {
                assertEquals("Data Disk size does not match", AzureTestUtil.AZURE_CUSTOM_DATA_DISK_SIZE, diskState.capacityMBytes);
                assertNotNull(diskState.customProperties);
                assertNotNull(diskState.customProperties.get(DISK_CONTROLLER_NUMBER));
            }
        }
    }
    if (this.isMock) {
        // return. Nothing to check on Azure.
        return;
    }
    final String vmRGName = vm.customProperties.get(ComputeProperties.RESOURCE_GROUP_NAME);
    VirtualMachineInner provisionedVM = null;
    try {
        provisionedVM = AzureTestUtil.getAzureVirtualMachine(getAzureSdkClients().getComputeManagementClientImpl(), vmRGName, this.vmState.name.replace('_', '-'));
    } catch (Exception e) {
        fail("Unable to get Azure VM details: " + e.getMessage());
    }
    final Function<String, Optional<DiskState>> findDiskStateByName = diskName -> diskStates.stream().filter(dS -> diskName.equals(dS.name)).findFirst();
    // Validate boot DiskState against Azure osDisk
    {
        final OSDisk azureOsDisk = provisionedVM.storageProfile().osDisk();
        Optional<DiskState> bootDiskOpt = findDiskStateByName.apply(azureOsDisk.name());
        if (bootDiskOpt.isPresent()) {
            final DiskState bootDiskState = bootDiskOpt.get();
            assertNotNull("Azure OS Disk with name '" + azureOsDisk.name() + "' does not match any DiskState by name", bootDiskState);
            if (bootDiskState.customProperties != null && bootDiskState.customProperties.containsKey(AzureConstants.AZURE_MANAGED_DISK_TYPE)) {
                assertEquals("Boot DiskState.id does not match Azure managed disk id", azureOsDisk.managedDisk().id(), bootDiskState.id);
            } else {
                assertEquals("Boot DiskState.id does not match Azure.osDisk.vhd.uri", AzureUtils.canonizeId(azureOsDisk.vhd().uri()), bootDiskState.id);
            }
            assertEquals("OS Disk size of the VM in azure does not match with the intended size", AzureTestUtil.AZURE_CUSTOM_OSDISK_SIZE, azureOsDisk.diskSizeGB() * 1024);
        } else {
            fail("Mismatch in boot disk name.");
        }
    }
    for (DataDisk azureDataDisk : provisionedVM.storageProfile().dataDisks()) {
        Optional<DiskState> dataDiskOpt = findDiskStateByName.apply(azureDataDisk.name());
        if (dataDiskOpt.isPresent()) {
            DiskState dataDiskState = dataDiskOpt.get();
            assertNotNull("Azure Data Disk with name '" + azureDataDisk.name() + "' does not match any DiskState by name", dataDiskState);
            if (dataDiskState.customProperties != null && dataDiskState.customProperties.containsKey(AzureConstants.AZURE_MANAGED_DISK_TYPE)) {
                assertEquals("Data Disk State id does not match Azure managed disk id.", azureDataDisk.managedDisk().id(), dataDiskState.id);
            } else {
                assertEquals("Data Disk State id does not match Azure DataDisk.vhd.uri", AzureUtils.canonizeId(azureDataDisk.vhd().uri()), dataDiskState.id);
            }
            // assert size of each of the attached disks only in case of public image
            if (numberOfDataDisksOnImage == 0) {
                assertEquals("Mismatch in intended size of data disks " + azureDataDisk.name(), AZURE_CUSTOM_DATA_DISK_SIZE, azureDataDisk.diskSizeGB().longValue() * 1024);
            }
            assertEquals("LUN of DiskState does not match Azure.dataDisk.lun", String.valueOf(azureDataDisk.lun()), dataDiskState.customProperties.get(DISK_CONTROLLER_NUMBER));
        } else {
            fail("Data Disks not found.");
        }
    }
    assertEquals("Mismatch in number of data disks found on VM in azure", numberOfAdditionalDisks + numberOfDataDisksOnImage, provisionedVM.storageProfile().dataDisks().size());
}
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) OSDisk(com.microsoft.azure.management.compute.OSDisk) DataDisk(com.microsoft.azure.management.compute.DataDisk) Optional(java.util.Optional) VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState)

Example 10 with VirtualMachineInner

use of com.microsoft.azure.management.compute.implementation.VirtualMachineInner in project photon-model by vmware.

the class AzureComputeEnumerationAdapterService method createComputeDescriptions.

/**
 * Creates relevant resources for given VMs.
 */
private void createComputeDescriptions(EnumerationContext ctx, ComputeEnumerationSubStages next) {
    if (ctx.virtualMachines.size() == 0 && ctx.regions.isEmpty()) {
        // nothing to create
        if (ctx.enumNextPageLink != null) {
            ctx.subStage = ComputeEnumerationSubStages.LISTVMS;
            handleSubStage(ctx);
            return;
        }
        logFine(() -> "No virtual machine found for creation.");
        ctx.subStage = ComputeEnumerationSubStages.PATCH_ADDITIONAL_FIELDS;
        handleSubStage(ctx);
        return;
    }
    logFine(() -> String.format("%d compute description with states to be created", ctx.virtualMachines.size()));
    Iterator<Entry<String, VirtualMachineInner>> iterator = ctx.virtualMachines.entrySet().iterator();
    Collection<Operation> opCollection = new ArrayList<>();
    while (iterator.hasNext()) {
        Entry<String, VirtualMachineInner> vmEntry = iterator.next();
        VirtualMachineInner virtualMachine = vmEntry.getValue();
        AuthCredentialsServiceState auth = new AuthCredentialsServiceState();
        if (virtualMachine.osProfile() != null) {
            auth.userEmail = virtualMachine.osProfile().adminUsername();
            auth.privateKey = virtualMachine.osProfile().adminPassword();
        }
        auth.documentSelfLink = UUID.randomUUID().toString();
        auth.tenantLinks = ctx.parentCompute.tenantLinks;
        auth.customProperties = new HashMap<>();
        if (ctx.request.endpointLink != null) {
            auth.customProperties.put(CUSTOM_PROP_ENDPOINT_LINK, ctx.request.endpointLink);
        }
        String authLink = UriUtils.buildUriPath(AuthCredentialsService.FACTORY_LINK, auth.documentSelfLink);
        Operation authOp = Operation.createPost(createInventoryUri(getHost(), AuthCredentialsService.FACTORY_LINK)).setBody(auth);
        opCollection.add(authOp);
        // TODO VSYM-631: Match existing descriptions for new VMs discovered on Azure
        ComputeDescription computeDescription = new ComputeDescription();
        computeDescription.id = UUID.randomUUID().toString();
        computeDescription.name = virtualMachine.name();
        computeDescription.regionId = virtualMachine.location();
        computeDescription.authCredentialsLink = authLink;
        computeDescription.endpointLink = ctx.request.endpointLink;
        AdapterUtils.addToEndpointLinks(computeDescription, ctx.request.endpointLink);
        computeDescription.documentSelfLink = computeDescription.id;
        computeDescription.environmentName = ENVIRONMENT_NAME_AZURE;
        if (virtualMachine.hardwareProfile() != null && virtualMachine.hardwareProfile().vmSize() != null) {
            computeDescription.instanceType = virtualMachine.hardwareProfile().vmSize().toString();
        }
        computeDescription.instanceAdapterReference = ctx.parentCompute.description.instanceAdapterReference;
        computeDescription.statsAdapterReference = ctx.parentCompute.description.statsAdapterReference;
        computeDescription.diskAdapterReference = ctx.parentCompute.description.diskAdapterReference;
        computeDescription.computeHostLink = ctx.parentCompute.documentSelfLink;
        computeDescription.customProperties = new HashMap<>();
        computeDescription.customProperties.put(SOURCE_TASK_LINK, ResourceEnumerationTaskService.FACTORY_LINK);
        // TODO: https://jira-hzn.eng.vmware.com/browse/VSYM-1268
        String resourceGroupName = getResourceGroupName(virtualMachine.id());
        computeDescription.customProperties.put(AZURE_RESOURCE_GROUP_NAME, resourceGroupName);
        computeDescription.tenantLinks = ctx.parentCompute.tenantLinks;
        Operation compDescOp = Operation.createPost(getHost(), ComputeDescriptionService.FACTORY_LINK).setBody(computeDescription);
        ctx.computeDescriptionIds.put(virtualMachine.name(), computeDescription.id);
        opCollection.add(compDescOp);
    }
    for (RegionInfo region : ctx.regions.values()) {
        ComputeDescription computeDescriptionForRegion = createComputeDescriptionForRegion(ctx, region);
        Operation compDescOp = Operation.createPost(getHost(), ComputeDescriptionService.FACTORY_LINK).setBody(computeDescriptionForRegion);
        ctx.computeDescriptionIds.put(region.regionId, computeDescriptionForRegion.id);
        opCollection.add(compDescOp);
    }
    OperationJoin.create(opCollection).setCompletion((ops, exs) -> {
        if (exs != null) {
            exs.values().forEach(ex -> logWarning(() -> String.format("Error: %s", ex.getMessage())));
        }
        logFine(() -> "Continue on to updating disks.");
        ctx.subStage = next;
        handleSubStage(ctx);
    }).sendWith(this);
}
Also used : PowerState(com.vmware.photon.controller.model.resources.ComputeService.PowerState) Arrays(java.util.Arrays) ComputeEnumerateResourceRequest(com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) LifecycleState(com.vmware.photon.controller.model.resources.ComputeService.LifecycleState) DISK_CONTROLLER_NUMBER(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.DISK_CONTROLLER_NUMBER) Action1(rx.functions.Action1) StringUtils(org.apache.commons.lang3.StringUtils) Azure(com.microsoft.azure.management.Azure) Utils(com.vmware.xenon.common.Utils) Pair(org.apache.commons.lang3.tuple.Pair) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) Map(java.util.Map) StorageDescription(com.vmware.photon.controller.model.resources.StorageDescriptionService.StorageDescription) OSDisk(com.microsoft.azure.management.compute.OSDisk) ResourceEnumerationTaskService(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) StatelessService(com.vmware.xenon.common.StatelessService) Set(java.util.Set) NetworkInterfaceService(com.vmware.photon.controller.model.resources.NetworkInterfaceService) StorageAccountTypes(com.microsoft.azure.management.compute.StorageAccountTypes) TagService(com.vmware.photon.controller.model.resources.TagService) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) SOURCE_TASK_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.SOURCE_TASK_LINK) InstanceViewStatus(com.microsoft.azure.management.compute.InstanceViewStatus) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) NumericRange(com.vmware.xenon.services.common.QueryTask.NumericRange) AZURE_DATA_DISK_CACHING(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_DATA_DISK_CACHING) ImageReferenceInner(com.microsoft.azure.management.compute.implementation.ImageReferenceInner) VirtualMachinesInner(com.microsoft.azure.management.compute.implementation.VirtualMachinesInner) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) PhotonModelUtils(com.vmware.photon.controller.model.resources.util.PhotonModelUtils) RegionInfo(com.vmware.photon.controller.model.adapterapi.RegionEnumerationResponse.RegionInfo) TagsUtil(com.vmware.photon.controller.model.adapters.util.TagsUtil) ArrayList(java.util.ArrayList) TagState(com.vmware.photon.controller.model.resources.TagService.TagState) ServiceStateCollectionUpdateRequest(com.vmware.xenon.common.ServiceStateCollectionUpdateRequest) Query(com.vmware.xenon.services.common.QueryTask.Query) EnumerationStages(com.vmware.photon.controller.model.adapters.util.enums.EnumerationStages) OperatingSystemTypes(com.microsoft.azure.management.compute.OperatingSystemTypes) BiConsumer(java.util.function.BiConsumer) AZURE_DIAGNOSTIC_STORAGE_ACCOUNT_LINK(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_DIAGNOSTIC_STORAGE_ACCOUNT_LINK) AZURE_STORAGE_ACCOUNT_URI(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_STORAGE_ACCOUNT_URI) VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) DataDisk(com.microsoft.azure.management.compute.DataDisk) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) ENVIRONMENT_NAME_AZURE(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ENVIRONMENT_NAME_AZURE) QueryTop(com.vmware.photon.controller.model.query.QueryUtils.QueryTop) CUSTOM_OS_TYPE(com.vmware.photon.controller.model.ComputeProperties.CUSTOM_OS_TYPE) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) PhotonModelConstants(com.vmware.photon.controller.model.constants.PhotonModelConstants) ComputeEnumerateAdapterRequest(com.vmware.photon.controller.model.adapters.util.ComputeEnumerateAdapterRequest) RegionEnumerationResponse(com.vmware.photon.controller.model.adapterapi.RegionEnumerationResponse) QuerySpecification(com.vmware.xenon.services.common.QueryTask.QuerySpecification) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) QueryTask(com.vmware.xenon.services.common.QueryTask) AZURE_RESOURCE_GROUP_NAME(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_RESOURCE_GROUP_NAME) OSType(com.vmware.photon.controller.model.ComputeProperties.OSType) AzureUriPaths(com.vmware.photon.controller.model.adapters.azure.AzureUriPaths) AZURE_MANAGED_DISK_TYPE(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_MANAGED_DISK_TYPE) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) AzureSdkClients(com.vmware.photon.controller.model.adapters.azure.utils.AzureSdkClients) AzureUtils.injectOperationContext(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.injectOperationContext) CUSTOM_PROP_ENDPOINT_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.CUSTOM_PROP_ENDPOINT_LINK) URI(java.net.URI) TagsUtil.newTagState(com.vmware.photon.controller.model.adapters.util.TagsUtil.newTagState) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) AzureConstants(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants) AzureConstants.getQueryResultLimit(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.getQueryResultLimit) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) Occurance(com.vmware.xenon.services.common.QueryTask.Query.Occurance) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) List(java.util.List) AzureUtils(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils) AzureUtils.getResourceGroupName(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.getResourceGroupName) TAG_KEY_TYPE(com.vmware.photon.controller.model.constants.PhotonModelConstants.TAG_KEY_TYPE) Entry(java.util.Map.Entry) NetworkInterfacesInner(com.microsoft.azure.management.network.implementation.NetworkInterfacesInner) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) InstanceViewTypes(com.microsoft.azure.management.compute.InstanceViewTypes) TagsUtil.setTagLinksToResourceState(com.vmware.photon.controller.model.adapters.util.TagsUtil.setTagLinksToResourceState) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder) DiskService(com.vmware.photon.controller.model.resources.DiskService) AzureUtils.isDiskManaged(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.isDiskManaged) Default(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback.Default) QueryByPages(com.vmware.photon.controller.model.query.QueryUtils.QueryByPages) AZURE_OSDISK_CACHING(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_OSDISK_CACHING) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress) HashMap(java.util.HashMap) HashSet(java.util.HashSet) AuthCredentialsService(com.vmware.xenon.services.common.AuthCredentialsService) TagsUtil.updateLocalTagStates(com.vmware.photon.controller.model.adapters.util.TagsUtil.updateLocalTagStates) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) EnumerationAction(com.vmware.photon.controller.model.adapterapi.EnumerationAction) AzureResourceType(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AzureResourceType) ExecutorService(java.util.concurrent.ExecutorService) Iterator(java.util.Iterator) NetworkInterfaceIPConfigurationInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner) Operation(com.vmware.xenon.common.Operation) Page(com.microsoft.azure.Page) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) NetworkInterfaceReferenceInner(com.microsoft.azure.management.compute.implementation.NetworkInterfaceReferenceInner) AzureDeferredResultServiceCallback(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback) NetworkInterfaceInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceInner) Collections(java.util.Collections) OperationJoin(com.vmware.xenon.common.OperationJoin) RESOURCE_GROUP_NAME(com.vmware.photon.controller.model.ComputeProperties.RESOURCE_GROUP_NAME) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) ArrayList(java.util.ArrayList) RegionInfo(com.vmware.photon.controller.model.adapterapi.RegionEnumerationResponse.RegionInfo) Operation(com.vmware.xenon.common.Operation) Entry(java.util.Map.Entry) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner)

Aggregations

VirtualMachineInner (com.microsoft.azure.management.compute.implementation.VirtualMachineInner)10 DiskState (com.vmware.photon.controller.model.resources.DiskService.DiskState)5 DataDisk (com.microsoft.azure.management.compute.DataDisk)4 OSDisk (com.microsoft.azure.management.compute.OSDisk)4 AzureUriPaths (com.vmware.photon.controller.model.adapters.azure.AzureUriPaths)4 AzureConstants (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants)4 Default (com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback.Default)4 InstanceViewStatus (com.microsoft.azure.management.compute.InstanceViewStatus)3 StorageAccountTypes (com.microsoft.azure.management.compute.StorageAccountTypes)3 ImageReferenceInner (com.microsoft.azure.management.compute.implementation.ImageReferenceInner)3 NetworkInterfaceReferenceInner (com.microsoft.azure.management.compute.implementation.NetworkInterfaceReferenceInner)3 NetworkInterfaceIPConfigurationInner (com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner)3 NetworkInterfaceInner (com.microsoft.azure.management.network.implementation.NetworkInterfaceInner)3 NetworkInterfacesInner (com.microsoft.azure.management.network.implementation.NetworkInterfacesInner)3 NetworkSecurityGroupInner (com.microsoft.azure.management.network.implementation.NetworkSecurityGroupInner)3 VirtualNetworkInner (com.microsoft.azure.management.network.implementation.VirtualNetworkInner)3 RESOURCE_GROUP_NAME (com.vmware.photon.controller.model.ComputeProperties.RESOURCE_GROUP_NAME)3 EnumerationAction (com.vmware.photon.controller.model.adapterapi.EnumerationAction)3 AZURE_DATA_DISK_CACHING (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_DATA_DISK_CACHING)3 AZURE_MANAGED_DISK_TYPE (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_MANAGED_DISK_TYPE)3