@Override public VirtualMachineImpl withExistingPrimaryNetwork(Network network) { this.nicDefinitionWithSubnet = this.preparePrimaryNetworkInterface(this.namer.randomName("nic", 20)) .withExistingPrimaryNetwork(network); return this; }
/** * Gets a random name. * * @param prefix the prefix to be used if possible * @param maxLen the maximum length for the random generated name * @return the random name */ public static String randomResourceName(String prefix, int maxLen) { ResourceNamer resourceNamer = SdkContext.getResourceNamerFactory().createResourceNamer(""); return resourceNamer.randomName(prefix, maxLen); }
@Override public VirtualMachineImpl withNewPrimaryNetwork(String addressSpace) { this.nicDefinitionWithPrivateIp = this.preparePrimaryNetworkInterface(this.namer.randomName("nic", 20)) .withNewPrimaryNetwork(addressSpace); return this; }
/** * Gets a random name. * * @param prefix the prefix to be used if possible * @param maxLen the maximum length for the random generated name * @return the random name */ public static String randomResourceName(String prefix, int maxLen) { ResourceNamer resourceNamer = SdkContext.getResourceNamerFactory().createResourceNamer(""); return resourceNamer.randomName(prefix, maxLen); }
@Override public VirtualMachineImpl withNewPrimaryNetwork(Creatable<Network> creatable) { this.nicDefinitionWithPrivateIp = this.preparePrimaryNetworkInterface(this.namer.randomName("nic", 20)) .withNewPrimaryNetwork(creatable); return this; }
@Override public VirtualMachineImpl withNewPrimaryNetwork(String addressSpace) { this.nicDefinitionWithPrivateIp = this.preparePrimaryNetworkInterface(this.namer.randomName("nic", 20)) .withNewPrimaryNetwork(addressSpace); return this; }
@Override public VirtualMachineImpl withNewPrimaryNetwork(Creatable<Network> creatable) { this.nicDefinitionWithPrivateIp = this.preparePrimaryNetworkInterface(this.namer.randomName("nic", 20)) .withNewPrimaryNetwork(creatable); return this; }
@Override public VirtualMachineImpl withExistingPrimaryNetwork(Network network) { this.nicDefinitionWithSubnet = this.preparePrimaryNetworkInterface(this.namer.randomName("nic", 20)) .withExistingPrimaryNetwork(network); return this; }
@Override public NicIPConfigurationImpl withNewNetwork(String addressSpaceCidr) { return withNewNetwork(this.parent().namer.randomName("vnet", 20), addressSpaceCidr); }
/** * Generates the specified number of random resource names with the same prefix. * @param prefix the prefix to be used if possible * @param maxLen the maximum length for the random generated name * @param count the number of names to generate * @return random names */ public static String[] randomResourceNames(String prefix, int maxLen, int count) { String[] names = new String[count]; ResourceNamer resourceNamer = SdkContext.getResourceNamerFactory().createResourceNamer(""); for (int i = 0; i < count; i++) { names[i] = resourceNamer.randomName(prefix, maxLen); } return names; }
@Override public NicIPConfigurationImpl withNewNetwork(String addressSpaceCidr) { return withNewNetwork(this.parent().namer.randomName("vnet", 20), addressSpaceCidr); }
/** * Generates the specified number of random resource names with the same prefix. * @param prefix the prefix to be used if possible * @param maxLen the maximum length for the random generated name * @param count the number of names to generate * @return random names */ public static String[] randomResourceNames(String prefix, int maxLen, int count) { String[] names = new String[count]; ResourceNamer resourceNamer = SdkContext.getResourceNamerFactory().createResourceNamer(""); for (int i = 0; i < count; i++) { names[i] = resourceNamer.randomName(prefix, maxLen); } return names; }
@Override public NicIPConfigurationImpl withNewPublicIPAddress() { String name = this.parent().namer.randomName("pip", 15); return withNewPublicIPAddress(prepareCreatablePublicIP(name, name)); }
@Override public NicIPConfigurationImpl withNewPublicIPAddress() { String name = this.parent().namer.randomName("pip", 15); return withNewPublicIPAddress(prepareCreatablePublicIP(name, name)); }
@Override public NicIPConfigurationImpl withNewPublicIPAddress(String leafDnsLabel) { return withNewPublicIPAddress(prepareCreatablePublicIP(this.parent().namer.randomName("pip", 15), leafDnsLabel)); }
@Override public NicIPConfigurationImpl withNewPublicIPAddress(String leafDnsLabel) { return withNewPublicIPAddress(prepareCreatablePublicIP(this.parent().namer.randomName("pip", 15), leafDnsLabel)); }
@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(); }
/** * Gets a random name. * * @param prefix the prefix to be used if possible * @param maxLen the max length for the random generated name * @return the random name */ @Override public String randomName(String prefix, int maxLen) { if (interceptorManager.isPlaybackMode()) { return interceptorManager.popVariable(); } String randomName = super.randomName(prefix, maxLen); interceptorManager.pushVariable(randomName); return randomName; }
@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 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; }