use of com.microsoft.azure.management.compute.LinuxConfiguration 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.LinuxConfiguration in project azure-sdk-for-java by Azure.
the class VirtualMachineImpl method setOSProfileDefaults.
private void setOSProfileDefaults() {
if (isInUpdateMode()) {
return;
}
StorageProfile storageProfile = this.inner().storageProfile();
OSDisk osDisk = storageProfile.osDisk();
if (isOSDiskFromImage(osDisk)) {
//
if (osDisk.osType() == OperatingSystemTypes.LINUX || this.isMarketplaceLinuxImage) {
// linux image: PlatformImage | CustomImage | StoredImage
//
OSProfile osProfile = this.inner().osProfile();
if (osProfile.linuxConfiguration() == null) {
osProfile.withLinuxConfiguration(new LinuxConfiguration());
}
this.inner().osProfile().linuxConfiguration().withDisablePasswordAuthentication(osProfile.adminPassword() == null);
}
if (this.inner().osProfile().computerName() == null) {
//
if (vmName.matches("[0-9]+")) {
this.inner().osProfile().withComputerName(SdkContext.randomResourceName("vm", 15));
} else if (vmName.length() <= 15) {
this.inner().osProfile().withComputerName(vmName);
} else {
this.inner().osProfile().withComputerName(SdkContext.randomResourceName("vm", 15));
}
}
} else {
// ODDisk CreateOption: ATTACH
//
// OS Profile must be set to null when an VM's OS disk is ATTACH-ed to a managed disk or
// Specialized VHD
//
this.inner().withOsProfile(null);
}
}
use of com.microsoft.azure.management.compute.LinuxConfiguration in project azure-sdk-for-java by Azure.
the class VirtualMachineScaleSetImpl method withLinuxCustomImage.
@Override
public VirtualMachineScaleSetImpl withLinuxCustomImage(String customImageId) {
ImageReferenceInner imageReferenceInner = new ImageReferenceInner();
imageReferenceInner.withId(customImageId);
this.inner().virtualMachineProfile().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE);
this.inner().virtualMachineProfile().storageProfile().withImageReference(imageReferenceInner);
this.inner().virtualMachineProfile().osProfile().withLinuxConfiguration(new LinuxConfiguration());
this.isMarketplaceLinuxImage = true;
return this;
}
use of com.microsoft.azure.management.compute.LinuxConfiguration in project azure-sdk-for-java by Azure.
the class VirtualMachineImpl method withLinuxCustomImage.
@Override
public VirtualMachineImpl withLinuxCustomImage(String customImageId) {
ImageReferenceInner imageReferenceInner = new ImageReferenceInner();
imageReferenceInner.withId(customImageId);
this.inner().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE);
this.inner().storageProfile().withImageReference(imageReferenceInner);
this.inner().osProfile().withLinuxConfiguration(new LinuxConfiguration());
this.isMarketplaceLinuxImage = true;
return this;
}
use of com.microsoft.azure.management.compute.LinuxConfiguration in project azure-sdk-for-java by Azure.
the class VirtualMachineScaleSetImpl method withSpecificLinuxImageVersion.
@Override
public VirtualMachineScaleSetImpl withSpecificLinuxImageVersion(ImageReference imageReference) {
this.inner().virtualMachineProfile().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE);
this.inner().virtualMachineProfile().storageProfile().withImageReference(imageReference.inner());
this.inner().virtualMachineProfile().osProfile().withLinuxConfiguration(new LinuxConfiguration());
this.isMarketplaceLinuxImage = true;
return this;
}
Aggregations