use of com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile 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.VirtualMachineScaleSetOSProfile in project azure-sdk-for-java by Azure.
the class VirtualMachineScaleSetImpl method withSsh.
@Override
public VirtualMachineScaleSetImpl withSsh(String publicKeyData) {
VirtualMachineScaleSetOSProfile osProfile = this.inner().virtualMachineProfile().osProfile();
if (osProfile.linuxConfiguration().ssh() == null) {
SshConfiguration sshConfiguration = new SshConfiguration();
sshConfiguration.withPublicKeys(new ArrayList<SshPublicKey>());
osProfile.linuxConfiguration().withSsh(sshConfiguration);
}
SshPublicKey sshPublicKey = new SshPublicKey();
sshPublicKey.withKeyData(publicKeyData);
sshPublicKey.withPath("/home/" + osProfile.adminUsername() + "/.ssh/authorized_keys");
osProfile.linuxConfiguration().ssh().publicKeys().add(sshPublicKey);
return this;
}
use of com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile 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