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());
}
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));
}
}
}
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;
}
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;
}
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;
}
Aggregations