Search in sources :

Example 1 with VirtualMachineScaleSetStorageProfile

use of com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile in project azure-sdk-for-java by Azure.

the class VirtualMachineScaleSetImpl method handleOSDiskContainersAsync.

private Observable<Void> handleOSDiskContainersAsync() {
    final VirtualMachineScaleSetStorageProfile storageProfile = inner().virtualMachineProfile().storageProfile();
    if (isManagedDiskEnabled()) {
        storageProfile.osDisk().withVhdContainers(null);
        return Observable.just(null);
    }
    if (isOSDiskFromStoredImage(storageProfile)) {
        // There is a restriction currently that virtual machine's disk cannot be stored in multiple storage
        // accounts if scale set is based on stored image. Remove this check once azure start supporting it.
        //
        storageProfile.osDisk().vhdContainers().clear();
        return Observable.just(null);
    }
    if (this.isInCreateMode() && this.creatableStorageAccountKeys.isEmpty() && this.existingStorageAccountsToAssociate.isEmpty()) {
        //
        return Utils.<StorageAccount>rootResource(this.storageManager.storageAccounts().define(this.namer.randomName("stg", 24).replace("-", "")).withRegion(this.regionName()).withExistingResourceGroup(this.resourceGroupName()).createAsync()).map(new Func1<StorageAccount, Void>() {

            @Override
            public Void call(StorageAccount storageAccount) {
                String containerName = vhdContainerName;
                if (containerName == null) {
                    containerName = "vhds";
                }
                storageProfile.osDisk().vhdContainers().add(mergePath(storageAccount.endPoints().primary().blob(), containerName));
                vhdContainerName = null;
                creatableStorageAccountKeys.clear();
                existingStorageAccountsToAssociate.clear();
                return null;
            }
        });
    } else {
        String containerName = this.vhdContainerName;
        if (containerName == null) {
            for (String containerUrl : storageProfile.osDisk().vhdContainers()) {
                containerName = containerUrl.substring(containerUrl.lastIndexOf("/") + 1);
                break;
            }
        }
        if (containerName == null) {
            containerName = "vhds";
        }
        for (String storageAccountKey : this.creatableStorageAccountKeys) {
            StorageAccount storageAccount = (StorageAccount) createdResource(storageAccountKey);
            storageProfile.osDisk().vhdContainers().add(mergePath(storageAccount.endPoints().primary().blob(), containerName));
        }
        for (StorageAccount storageAccount : this.existingStorageAccountsToAssociate) {
            storageProfile.osDisk().vhdContainers().add(mergePath(storageAccount.endPoints().primary().blob(), containerName));
        }
        this.vhdContainerName = null;
        this.creatableStorageAccountKeys.clear();
        this.existingStorageAccountsToAssociate.clear();
        return Observable.just(null);
    }
}
Also used : StorageAccount(com.microsoft.azure.management.storage.StorageAccount) VirtualMachineScaleSetStorageProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile)

Example 2 with VirtualMachineScaleSetStorageProfile

use of com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile in project azure-sdk-for-java by Azure.

the class VirtualMachineScaleSetImpl method setOSDiskDefault.

private void setOSDiskDefault() {
    if (isInUpdateMode()) {
        return;
    }
    VirtualMachineScaleSetStorageProfile storageProfile = this.inner().virtualMachineProfile().storageProfile();
    VirtualMachineScaleSetOSDisk osDisk = storageProfile.osDisk();
    if (isOSDiskFromImage(osDisk)) {
        //
        if (isManagedDiskEnabled()) {
            //
            if (osDisk.managedDisk() == null) {
                osDisk.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters());
            }
            if (osDisk.managedDisk().storageAccountType() == null) {
                osDisk.managedDisk().withStorageAccountType(StorageAccountTypes.STANDARD_LRS);
            }
            osDisk.withVhdContainers(null);
        // We won't set osDisk.name() explicitly for managed disk, if it is null CRP generates unique
        // name for the disk resource within the resource group.
        } else {
            // Note:
            // Native (un-managed) disk
            //     Supported: PlatformImage and StoredImage
            //     UnSupported: CustomImage
            //
            osDisk.withManagedDisk(null);
            if (osDisk.name() == null) {
                withOSDiskName(this.name() + "-os-disk");
            }
        }
    } else {
    // NOP [ODDisk CreateOption: ATTACH, ATTACH is not supported for VMSS]
    }
    if (this.osDiskCachingType() == null) {
        withOSDiskCaching(CachingTypes.READ_WRITE);
    }
}
Also used : VirtualMachineScaleSetOSDisk(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk) VirtualMachineScaleSetStorageProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile) VirtualMachineScaleSetManagedDiskParameters(com.microsoft.azure.management.compute.VirtualMachineScaleSetManagedDiskParameters)

Example 3 with VirtualMachineScaleSetStorageProfile

use of com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile in project azure-sdk-for-java by Azure.

the class VirtualMachineScaleSetsImpl method wrapModel.

@Override
protected VirtualMachineScaleSetImpl wrapModel(String name) {
    VirtualMachineScaleSetInner inner = new VirtualMachineScaleSetInner();
    inner.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile());
    inner.virtualMachineProfile().withStorageProfile(new VirtualMachineScaleSetStorageProfile().withOsDisk(new VirtualMachineScaleSetOSDisk().withVhdContainers(new ArrayList<String>())));
    inner.virtualMachineProfile().withOsProfile(new VirtualMachineScaleSetOSProfile());
    inner.virtualMachineProfile().withNetworkProfile(new VirtualMachineScaleSetNetworkProfile());
    inner.virtualMachineProfile().networkProfile().withNetworkInterfaceConfigurations(new ArrayList<VirtualMachineScaleSetNetworkConfigurationInner>());
    VirtualMachineScaleSetNetworkConfigurationInner primaryNetworkInterfaceConfiguration = new VirtualMachineScaleSetNetworkConfigurationInner().withPrimary(true).withName("primary-nic-cfg").withIpConfigurations(new ArrayList<VirtualMachineScaleSetIPConfigurationInner>());
    primaryNetworkInterfaceConfiguration.ipConfigurations().add(new VirtualMachineScaleSetIPConfigurationInner().withName("primary-nic-ip-cfg"));
    inner.virtualMachineProfile().networkProfile().networkInterfaceConfigurations().add(primaryNetworkInterfaceConfiguration);
    return new VirtualMachineScaleSetImpl(name, inner, this.manager(), this.storageManager, this.networkManager);
}
Also used : VirtualMachineScaleSetNetworkProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetNetworkProfile) VirtualMachineScaleSetVMProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetVMProfile) VirtualMachineScaleSetOSProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile) VirtualMachineScaleSetOSDisk(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk) VirtualMachineScaleSetStorageProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile)

Aggregations

VirtualMachineScaleSetStorageProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile)3 VirtualMachineScaleSetOSDisk (com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk)2 VirtualMachineScaleSetManagedDiskParameters (com.microsoft.azure.management.compute.VirtualMachineScaleSetManagedDiskParameters)1 VirtualMachineScaleSetNetworkProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetNetworkProfile)1 VirtualMachineScaleSetOSProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile)1 VirtualMachineScaleSetVMProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetVMProfile)1 StorageAccount (com.microsoft.azure.management.storage.StorageAccount)1