use of com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk in project azure-sdk-for-java by Azure.
the class VirtualMachineScaleSetImpl method setOSProfileDefaults.
private void setOSProfileDefaults() {
if (isInUpdateMode()) {
return;
}
if (this.inner().sku().capacity() == null) {
this.withCapacity(2);
}
if (this.inner().upgradePolicy() == null || this.inner().upgradePolicy().mode() == null) {
this.inner().withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.AUTOMATIC));
}
VirtualMachineScaleSetOSProfile osProfile = this.inner().virtualMachineProfile().osProfile();
VirtualMachineScaleSetOSDisk osDisk = this.inner().virtualMachineProfile().storageProfile().osDisk();
if (isOSDiskFromImage(osDisk)) {
//
if (this.osType() == OperatingSystemTypes.LINUX || this.isMarketplaceLinuxImage) {
if (osProfile.linuxConfiguration() == null) {
osProfile.withLinuxConfiguration(new LinuxConfiguration());
}
osProfile.linuxConfiguration().withDisablePasswordAuthentication(osProfile.adminPassword() == null);
}
if (this.computerNamePrefix() == null) {
// VM name cannot contain only numeric values and cannot exceed 15 chars
if (this.name().matches("[0-9]+")) {
withComputerNamePrefix(this.namer.randomName("vmss-vm", 12));
} else if (this.name().length() <= 12) {
withComputerNamePrefix(this.name() + "-vm");
} else {
withComputerNamePrefix(this.namer.randomName("vmss-vm", 12));
}
}
} else {
// NOP [ODDisk CreateOption: ATTACH, ATTACH is not supported for VMSS]
this.inner().virtualMachineProfile().withOsProfile(null);
}
}
use of com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk 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);
}
}
use of com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk 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);
}
Aggregations