Search in sources :

Example 1 with VirtualMachineScaleSetOSProfile

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);
    }
}
Also used : VirtualMachineScaleSetOSDisk(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk) UpgradePolicy(com.microsoft.azure.management.compute.UpgradePolicy) LinuxConfiguration(com.microsoft.azure.management.compute.LinuxConfiguration) VirtualMachineScaleSetOSProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile)

Example 2 with VirtualMachineScaleSetOSProfile

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

Example 3 with VirtualMachineScaleSetOSProfile

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);
}
Also used : VirtualMachineScaleSetNetworkProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetNetworkProfile) VirtualMachineScaleSetVMProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetVMProfile) VirtualMachineScaleSetOSProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile) VirtualMachineScaleSetOSDisk(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk) VirtualMachineScaleSetStorageProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile)

Aggregations

VirtualMachineScaleSetOSProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile)3 VirtualMachineScaleSetOSDisk (com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk)2 LinuxConfiguration (com.microsoft.azure.management.compute.LinuxConfiguration)1 SshConfiguration (com.microsoft.azure.management.compute.SshConfiguration)1 SshPublicKey (com.microsoft.azure.management.compute.SshPublicKey)1 UpgradePolicy (com.microsoft.azure.management.compute.UpgradePolicy)1 VirtualMachineScaleSetNetworkProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetNetworkProfile)1 VirtualMachineScaleSetStorageProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile)1 VirtualMachineScaleSetVMProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetVMProfile)1