@Override public VirtualMachineImpl withoutPrimaryPublicIPAddress() { Creatable<NetworkInterface> nicCreatable = this.nicDefinitionWithCreate; this.creatablePrimaryNetworkInterfaceKey = this.addDependency(nicCreatable); return this; }
private void reset(VirtualMachineInner inner) { this.setInner(inner); clearCachedRelatedResources(); initializeDataDisks(); virtualMachineMsiHandler.clear(); }
@Override public void beforeGroupCreateOrUpdate() { // [1]. StorageProfile: If implicit storage account creation is required then add Creatable<StorageAccount>. // if (creatableStorageAccountKey == null && existingStorageAccountToAssociate == null) { if (osDiskRequiresImplicitStorageAccountCreation() || dataDisksRequiresImplicitStorageAccountCreation()) { Creatable<StorageAccount> storageAccountCreatable = null; if (this.creatableGroup != null) { storageAccountCreatable = this.storageManager.storageAccounts() .define(this.namer.randomName("stg", 24).replace("-", "")) .withRegion(this.regionName()) .withNewResourceGroup(this.creatableGroup); } else { storageAccountCreatable = this.storageManager.storageAccounts() .define(this.namer.randomName("stg", 24).replace("-", "")) .withRegion(this.regionName()) .withExistingResourceGroup(this.resourceGroupName()); } this.creatableStorageAccountKey = this.addDependency(storageAccountCreatable); } } // [2]. BootDiagnosticsProfile: If any implicit resource creation is required then add Creatable<?>. // this.bootDiagnosticsHandler.prepare(); }
@Override public VirtualMachineImpl withNewPrimaryPublicIPAddress(String leafDnsLabel) { PublicIPAddress.DefinitionStages.WithGroup definitionWithGroup = this.networkManager.publicIPAddresses() .define(this.namer.randomName("pip", 15)) .withRegion(this.regionName()); PublicIPAddress.DefinitionStages.WithCreate definitionAfterGroup; if (this.creatableGroup != null) { definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.creatableGroup); } else { definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.resourceGroupName()); } this.implicitPipCreatable = definitionAfterGroup.withLeafDomainLabel(leafDnsLabel); // Create NIC with creatable PIP // Creatable<NetworkInterface> nicCreatable = this.nicDefinitionWithCreate .withNewPrimaryPublicIPAddress(this.implicitPipCreatable); this.creatablePrimaryNetworkInterfaceKey = this.addDependency(nicCreatable); return this; }
@Override public VirtualMachineImpl withExistingUnmanagedDataDisk(String storageAccountName, String containerName, String vhdName) { throwIfManagedDiskEnabled(ManagedUnmanagedDiskErrors.VM_BOTH_MANAGED_AND_UNMANAGED_DISK_NOT_ALLOWED); return defineUnmanagedDataDisk(null) .withExistingVhd(storageAccountName, containerName, vhdName) .attach(); }
@Override public VirtualMachineImpl withNewDataDisk(Creatable<Disk> creatable) { throwIfManagedDiskDisabled(ManagedUnmanagedDiskErrors.VM_BOTH_UNMANAGED_AND_MANAGED_DISK_NOT_ALLOWED); this.managedDataDisks.newDisksToAttach.put(this.addDependency(creatable), new DataDisk().withLun(-1)); return this; }
@Override public ServiceFuture<Void> deallocateAsync(ServiceCallback<Void> callback) { return ServiceFuture.fromBody(this.deallocateAsync(), callback); }
@Override public ServiceFuture<Void> generalizeAsync(ServiceCallback<Void> callback) { return ServiceFuture.fromBody(this.generalizeAsync(), callback); }
@Override protected VirtualMachineImpl wrapModel(VirtualMachineInner virtualMachineInner) { if (virtualMachineInner == null) { return null; } return new VirtualMachineImpl(virtualMachineInner.name(), virtualMachineInner, this.manager(), this.storageManager, this.networkManager, this.rbacManager); } }
@Override public ServiceFuture<String> captureAsync(String containerName, String vhdPrefix, boolean overwriteVhd, ServiceCallback<String> callback) { return ServiceFuture.fromBody(this.captureAsync(containerName, vhdPrefix, overwriteVhd), callback); }
private String blobUrl(String storageAccountName, String containerName, String blobName) { AzureEnvironment azureEnvironment = this.parent().environment(); return "https://" + storageAccountName + ".blob" + azureEnvironment.storageEndpointSuffix() + "/" + containerName + "/" + blobName; } }
@Override public ServiceFuture<Void> convertToManagedAsync(ServiceCallback<Void> callback) { return ServiceFuture.fromBody(this.convertToManagedAsync(), callback); }
@Override public void beforeGroupCreateOrUpdate() { // [1]. StorageProfile: If implicit storage account creation is required then add Creatable<StorageAccount>. // if (creatableStorageAccountKey == null && existingStorageAccountToAssociate == null) { if (osDiskRequiresImplicitStorageAccountCreation() || dataDisksRequiresImplicitStorageAccountCreation()) { Creatable<StorageAccount> storageAccountCreatable = null; if (this.creatableGroup != null) { storageAccountCreatable = this.storageManager.storageAccounts() .define(this.namer.randomName("stg", 24).replace("-", "")) .withRegion(this.regionName()) .withNewResourceGroup(this.creatableGroup); } else { storageAccountCreatable = this.storageManager.storageAccounts() .define(this.namer.randomName("stg", 24).replace("-", "")) .withRegion(this.regionName()) .withExistingResourceGroup(this.resourceGroupName()); } this.creatableStorageAccountKey = this.addDependency(storageAccountCreatable); } } // [2]. BootDiagnosticsProfile: If any implicit resource creation is required then add Creatable<?>. // this.bootDiagnosticsHandler.prepare(); }
@Override public VirtualMachineImpl withNewPrimaryPublicIPAddress(String leafDnsLabel) { PublicIPAddress.DefinitionStages.WithGroup definitionWithGroup = this.networkManager.publicIPAddresses() .define(this.namer.randomName("pip", 15)) .withRegion(this.regionName()); PublicIPAddress.DefinitionStages.WithCreate definitionAfterGroup; if (this.creatableGroup != null) { definitionAfterGroup = definitionWithGroup.withNewResourceGroup(this.creatableGroup); } else { definitionAfterGroup = definitionWithGroup.withExistingResourceGroup(this.resourceGroupName()); } this.implicitPipCreatable = definitionAfterGroup.withLeafDomainLabel(leafDnsLabel); // Create NIC with creatable PIP // Creatable<NetworkInterface> nicCreatable = this.nicDefinitionWithCreate .withNewPrimaryPublicIPAddress(this.implicitPipCreatable); this.creatablePrimaryNetworkInterfaceKey = this.addDependency(nicCreatable); return this; }
@Override public VirtualMachineImpl withNewUnmanagedDataDisk(Integer sizeInGB) { throwIfManagedDiskEnabled(ManagedUnmanagedDiskErrors.VM_BOTH_MANAGED_AND_UNMANAGED_DISK_NOT_ALLOWED); return defineUnmanagedDataDisk(null) .withNewVhd(sizeInGB) .attach(); }
@Override public VirtualMachineImpl withNewDataDisk(Creatable<Disk> creatable) { throwIfManagedDiskDisabled(ManagedUnmanagedDiskErrors.VM_BOTH_UNMANAGED_AND_MANAGED_DISK_NOT_ALLOWED); this.managedDataDisks.newDisksToAttach.put(this.addDependency(creatable), new DataDisk().withLun(-1)); return this; }
@Override public void deallocate() { this.deallocateAsync().await(); }
@Override public void generalize() { this.generalizeAsync().await(); }
@Override protected VirtualMachineImpl wrapModel(VirtualMachineInner virtualMachineInner) { if (virtualMachineInner == null) { return null; } return new VirtualMachineImpl(virtualMachineInner.name(), virtualMachineInner, this.manager(), this.storageManager, this.networkManager, this.rbacManager); } }
@Override public String capture(String containerName, String vhdPrefix, boolean overwriteVhd) { return this.captureAsync(containerName, vhdPrefix, overwriteVhd).toBlocking().last(); }