Search in sources :

Example 1 with OSProfile

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);
}
Also used : StorageProfile(com.microsoft.azure.management.compute.StorageProfile) OSDisk(com.microsoft.azure.management.compute.OSDisk) NetworkProfile(com.microsoft.azure.management.compute.NetworkProfile) OSProfile(com.microsoft.azure.management.compute.OSProfile) HardwareProfile(com.microsoft.azure.management.compute.HardwareProfile) ArrayList(java.util.ArrayList)

Example 2 with OSProfile

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);
    }
}
Also used : StorageProfile(com.microsoft.azure.management.compute.StorageProfile) OSDisk(com.microsoft.azure.management.compute.OSDisk) OSProfile(com.microsoft.azure.management.compute.OSProfile) LinuxConfiguration(com.microsoft.azure.management.compute.LinuxConfiguration)

Example 3 with OSProfile

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;
}
Also used : OSProfile(com.microsoft.azure.management.compute.OSProfile) SshPublicKey(com.microsoft.azure.management.compute.SshPublicKey) SshConfiguration(com.microsoft.azure.management.compute.SshConfiguration)

Aggregations

OSProfile (com.microsoft.azure.management.compute.OSProfile)3 OSDisk (com.microsoft.azure.management.compute.OSDisk)2 StorageProfile (com.microsoft.azure.management.compute.StorageProfile)2 HardwareProfile (com.microsoft.azure.management.compute.HardwareProfile)1 LinuxConfiguration (com.microsoft.azure.management.compute.LinuxConfiguration)1 NetworkProfile (com.microsoft.azure.management.compute.NetworkProfile)1 SshConfiguration (com.microsoft.azure.management.compute.SshConfiguration)1 SshPublicKey (com.microsoft.azure.management.compute.SshPublicKey)1 ArrayList (java.util.ArrayList)1