Search in sources :

Example 1 with DataDisk

use of com.microsoft.azure.management.compute.DataDisk in project azure-sdk-for-java by Azure.

the class Utils method print.

/**
     * Print virtual machine info.
     * @param resource a virtual machine
     */
public static void print(VirtualMachine resource) {
    StringBuilder storageProfile = new StringBuilder().append("\n\tStorageProfile: ");
    if (resource.storageProfile().imageReference() != null) {
        storageProfile.append("\n\t\tImageReference:");
        storageProfile.append("\n\t\t\tPublisher: ").append(resource.storageProfile().imageReference().publisher());
        storageProfile.append("\n\t\t\tOffer: ").append(resource.storageProfile().imageReference().offer());
        storageProfile.append("\n\t\t\tSKU: ").append(resource.storageProfile().imageReference().sku());
        storageProfile.append("\n\t\t\tVersion: ").append(resource.storageProfile().imageReference().version());
    }
    if (resource.storageProfile().osDisk() != null) {
        storageProfile.append("\n\t\tOSDisk:");
        storageProfile.append("\n\t\t\tOSType: ").append(resource.storageProfile().osDisk().osType());
        storageProfile.append("\n\t\t\tName: ").append(resource.storageProfile().osDisk().name());
        storageProfile.append("\n\t\t\tCaching: ").append(resource.storageProfile().osDisk().caching());
        storageProfile.append("\n\t\t\tCreateOption: ").append(resource.storageProfile().osDisk().createOption());
        storageProfile.append("\n\t\t\tDiskSizeGB: ").append(resource.storageProfile().osDisk().diskSizeGB());
        if (resource.storageProfile().osDisk().image() != null) {
            storageProfile.append("\n\t\t\tImage Uri: ").append(resource.storageProfile().osDisk().image().uri());
        }
        if (resource.storageProfile().osDisk().vhd() != null) {
            storageProfile.append("\n\t\t\tVhd Uri: ").append(resource.storageProfile().osDisk().vhd().uri());
        }
        if (resource.storageProfile().osDisk().encryptionSettings() != null) {
            storageProfile.append("\n\t\t\tEncryptionSettings: ");
            storageProfile.append("\n\t\t\t\tEnabled: ").append(resource.storageProfile().osDisk().encryptionSettings().enabled());
            storageProfile.append("\n\t\t\t\tDiskEncryptionKey Uri: ").append(resource.storageProfile().osDisk().encryptionSettings().diskEncryptionKey().secretUrl());
            storageProfile.append("\n\t\t\t\tKeyEncryptionKey Uri: ").append(resource.storageProfile().osDisk().encryptionSettings().keyEncryptionKey().keyUrl());
        }
    }
    if (resource.storageProfile().dataDisks() != null) {
        int i = 0;
        for (DataDisk disk : resource.storageProfile().dataDisks()) {
            storageProfile.append("\n\t\tDataDisk: #").append(i++);
            storageProfile.append("\n\t\t\tName: ").append(disk.name());
            storageProfile.append("\n\t\t\tCaching: ").append(disk.caching());
            storageProfile.append("\n\t\t\tCreateOption: ").append(disk.createOption());
            storageProfile.append("\n\t\t\tDiskSizeGB: ").append(disk.diskSizeGB());
            storageProfile.append("\n\t\t\tLun: ").append(disk.lun());
            if (resource.isManagedDiskEnabled()) {
                if (disk.managedDisk() != null) {
                    storageProfile.append("\n\t\t\tManaged Disk Id: ").append(disk.managedDisk().id());
                }
            } else {
                if (disk.vhd().uri() != null) {
                    storageProfile.append("\n\t\t\tVhd Uri: ").append(disk.vhd().uri());
                }
            }
            if (disk.image() != null) {
                storageProfile.append("\n\t\t\tImage Uri: ").append(disk.image().uri());
            }
        }
    }
    StringBuilder osProfile = new StringBuilder().append("\n\tOSProfile: ");
    if (resource.osProfile() != null) {
        osProfile.append("\n\t\tComputerName:").append(resource.osProfile().computerName());
        if (resource.osProfile().windowsConfiguration() != null) {
            osProfile.append("\n\t\t\tWindowsConfiguration: ");
            osProfile.append("\n\t\t\t\tProvisionVMAgent: ").append(resource.osProfile().windowsConfiguration().provisionVMAgent());
            osProfile.append("\n\t\t\t\tEnableAutomaticUpdates: ").append(resource.osProfile().windowsConfiguration().enableAutomaticUpdates());
            osProfile.append("\n\t\t\t\tTimeZone: ").append(resource.osProfile().windowsConfiguration().timeZone());
        }
        if (resource.osProfile().linuxConfiguration() != null) {
            osProfile.append("\n\t\t\tLinuxConfiguration: ");
            osProfile.append("\n\t\t\t\tDisablePasswordAuthentication: ").append(resource.osProfile().linuxConfiguration().disablePasswordAuthentication());
        }
    } else {
        // OSProfile will be null for a VM attached to specialized VHD.
        osProfile.append("null");
    }
    StringBuilder networkProfile = new StringBuilder().append("\n\tNetworkProfile: ");
    for (String networkInterfaceId : resource.networkInterfaceIds()) {
        networkProfile.append("\n\t\tId:").append(networkInterfaceId);
    }
    StringBuilder extensions = new StringBuilder().append("\n\tExtensions: ");
    for (Map.Entry<String, VirtualMachineExtension> extensionEntry : resource.listExtensions().entrySet()) {
        VirtualMachineExtension extension = extensionEntry.getValue();
        extensions.append("\n\t\tExtension: ").append(extension.id()).append("\n\t\t\tName: ").append(extension.name()).append("\n\t\t\tTags: ").append(extension.tags()).append("\n\t\t\tProvisioningState: ").append(extension.provisioningState()).append("\n\t\t\tAuto upgrade minor version enabled: ").append(extension.autoUpgradeMinorVersionEnabled()).append("\n\t\t\tPublisher: ").append(extension.publisherName()).append("\n\t\t\tType: ").append(extension.typeName()).append("\n\t\t\tVersion: ").append(extension.versionName()).append("\n\t\t\tPublic Settings: ").append(extension.publicSettingsAsJsonString());
    }
    System.out.println(new StringBuilder().append("Virtual Machine: ").append(resource.id()).append("Name: ").append(resource.name()).append("\n\tResource group: ").append(resource.resourceGroupName()).append("\n\tRegion: ").append(resource.region()).append("\n\tTags: ").append(resource.tags()).append("\n\tHardwareProfile: ").append("\n\t\tSize: ").append(resource.size()).append(storageProfile).append(osProfile).append(networkProfile).append(extensions).toString());
}
Also used : ImageDataDisk(com.microsoft.azure.management.compute.ImageDataDisk) DataDisk(com.microsoft.azure.management.compute.DataDisk) VirtualMachineExtension(com.microsoft.azure.management.compute.VirtualMachineExtension) ConnectionString(com.microsoft.azure.management.appservice.ConnectionString) Map(java.util.Map) TrafficManagerExternalEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint) TrafficManagerNestedProfileEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint) TrafficManagerAzureEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint)

Example 2 with DataDisk

use of com.microsoft.azure.management.compute.DataDisk in project azure-sdk-for-java by Azure.

the class VirtualMachineImpl method initializeDataDisks.

private void initializeDataDisks() {
    if (this.inner().storageProfile().dataDisks() == null) {
        this.inner().storageProfile().withDataDisks(new ArrayList<DataDisk>());
    }
    this.isUnmanagedDiskSelected = false;
    this.managedDataDisks.clear();
    this.unmanagedDataDisks = new ArrayList<>();
    if (!isManagedDiskEnabled()) {
        for (DataDisk dataDiskInner : this.storageProfile().dataDisks()) {
            this.unmanagedDataDisks.add(new UnmanagedDataDiskImpl(dataDiskInner, this));
        }
    }
}
Also used : VirtualMachineUnmanagedDataDisk(com.microsoft.azure.management.compute.VirtualMachineUnmanagedDataDisk) VirtualMachineDataDisk(com.microsoft.azure.management.compute.VirtualMachineDataDisk) DataDisk(com.microsoft.azure.management.compute.DataDisk)

Example 3 with DataDisk

use of com.microsoft.azure.management.compute.DataDisk in project azure-sdk-for-java by Azure.

the class VirtualMachineImpl method withNewDataDiskFromImage.

@Override
public VirtualMachineImpl withNewDataDiskFromImage(int imageLun, int newSizeInGB, CachingTypes cachingType, StorageAccountTypes storageAccountType) {
    ManagedDiskParametersInner managedDiskParameters = new ManagedDiskParametersInner();
    managedDiskParameters.withStorageAccountType(storageAccountType);
    this.managedDataDisks.newDisksFromImage.add(new DataDisk().withLun(imageLun).withDiskSizeGB(newSizeInGB).withManagedDisk(managedDiskParameters).withCaching(cachingType));
    return this;
}
Also used : VirtualMachineUnmanagedDataDisk(com.microsoft.azure.management.compute.VirtualMachineUnmanagedDataDisk) VirtualMachineDataDisk(com.microsoft.azure.management.compute.VirtualMachineDataDisk) DataDisk(com.microsoft.azure.management.compute.DataDisk)

Example 4 with DataDisk

use of com.microsoft.azure.management.compute.DataDisk in project azure-sdk-for-java by Azure.

the class VirtualMachineImpl method withExistingDataDisk.

@Override
public VirtualMachineImpl withExistingDataDisk(Disk disk) {
    throwIfManagedDiskDisabled(ManagedUnmanagedDiskErrors.VM_BOTH_UNMANAGED_AND_MANAGED_DISK_NOT_ALLOWED);
    ManagedDiskParametersInner managedDiskParameters = new ManagedDiskParametersInner();
    managedDiskParameters.withId(disk.id());
    this.managedDataDisks.existingDisksToAttach.add(new DataDisk().withLun(-1).withManagedDisk(managedDiskParameters));
    return this;
}
Also used : VirtualMachineUnmanagedDataDisk(com.microsoft.azure.management.compute.VirtualMachineUnmanagedDataDisk) VirtualMachineDataDisk(com.microsoft.azure.management.compute.VirtualMachineDataDisk) DataDisk(com.microsoft.azure.management.compute.DataDisk)

Example 5 with DataDisk

use of com.microsoft.azure.management.compute.DataDisk in project azure-sdk-for-java by Azure.

the class VirtualMachineImpl method withNewDataDisk.

@Override
public VirtualMachineImpl withNewDataDisk(int sizeInGB) {
    throwIfManagedDiskDisabled(ManagedUnmanagedDiskErrors.VM_BOTH_UNMANAGED_AND_MANAGED_DISK_NOT_ALLOWED);
    this.managedDataDisks.implicitDisksToAssociate.add(new DataDisk().withLun(-1).withDiskSizeGB(sizeInGB));
    return this;
}
Also used : VirtualMachineUnmanagedDataDisk(com.microsoft.azure.management.compute.VirtualMachineUnmanagedDataDisk) VirtualMachineDataDisk(com.microsoft.azure.management.compute.VirtualMachineDataDisk) DataDisk(com.microsoft.azure.management.compute.DataDisk)

Aggregations

DataDisk (com.microsoft.azure.management.compute.DataDisk)17 VirtualMachineUnmanagedDataDisk (com.microsoft.azure.management.compute.VirtualMachineUnmanagedDataDisk)8 VirtualMachineDataDisk (com.microsoft.azure.management.compute.VirtualMachineDataDisk)7 DiskState (com.vmware.photon.controller.model.resources.DiskService.DiskState)5 Map (java.util.Map)5 OSDisk (com.microsoft.azure.management.compute.OSDisk)4 DiskService (com.vmware.photon.controller.model.resources.DiskService)4 Operation (com.vmware.xenon.common.Operation)4 ArrayList (java.util.ArrayList)4 Disk (com.microsoft.azure.management.compute.Disk)3 VirtualMachine (com.microsoft.azure.management.compute.VirtualMachine)3 ManagedDiskParametersInner (com.microsoft.azure.management.compute.implementation.ManagedDiskParametersInner)3 VirtualMachineInner (com.microsoft.azure.management.compute.implementation.VirtualMachineInner)3 AzureConstants (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants)3 UriUtils (com.vmware.xenon.common.UriUtils)3 Level (java.util.logging.Level)3 StorageProfile (com.microsoft.azure.management.compute.StorageProfile)2 VirtualHardDisk (com.microsoft.azure.management.compute.VirtualHardDisk)2 NetworkManagementClientImpl (com.microsoft.azure.management.network.implementation.NetworkManagementClientImpl)2 NetworkSecurityGroupInner (com.microsoft.azure.management.network.implementation.NetworkSecurityGroupInner)2