use of com.microsoft.azure.management.compute.OSProfile in project azure-sdk-for-java by Azure.
the class VirtualMachinesImpl method wrapModel.
// Helper methods
@Override
protected VirtualMachineImpl wrapModel(String name) {
VirtualMachineInner inner = new VirtualMachineInner();
inner.withStorageProfile(new StorageProfile().withOsDisk(new OSDisk()).withDataDisks(new ArrayList<DataDisk>()));
inner.withOsProfile(new OSProfile());
inner.withHardwareProfile(new HardwareProfile());
inner.withNetworkProfile(new NetworkProfile().withNetworkInterfaces(new ArrayList<NetworkInterfaceReferenceInner>()));
return new VirtualMachineImpl(name, inner, this.manager(), this.storageManager, this.networkManager);
}
use of com.microsoft.azure.management.compute.OSProfile 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.OSProfile in project azure-sdk-for-java by Azure.
the class VirtualMachineImpl method withSsh.
// Virtual machine optional fluent methods
//
@Override
public VirtualMachineImpl withSsh(String publicKeyData) {
OSProfile osProfile = this.inner().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;
}
Aggregations