use of com.microsoft.azure.management.resources.implementation.ResourceGroupInner in project photon-model by vmware.
the class AzureTestUtil method createResourceGroup.
public static ResourceGroupInner createResourceGroup(ResourceManagementClientImpl resourceManagementClient, String name) {
ResourceGroupInner rgParams = new ResourceGroupInner();
rgParams.withName(name);
rgParams.withLocation(AzureTestUtil.AZURE_RESOURCE_GROUP_LOCATION);
ResourceGroupInner resourceGroup = resourceManagementClient.resourceGroups().createOrUpdate(rgParams.name(), rgParams);
return resourceGroup;
}
use of com.microsoft.azure.management.resources.implementation.ResourceGroupInner in project photon-model by vmware.
the class AzureInstanceService method createResourceGroup.
private void createResourceGroup(AzureInstanceContext ctx, AzureInstanceStage nextStage) {
String resourceGroupName = AzureUtils.getResourceGroupName(ctx);
ResourceGroupInner resourceGroup = new ResourceGroupInner();
resourceGroup.withLocation(ctx.child.description.regionId);
String msg = "Creating Azure Resource Group [" + resourceGroupName + "] for [" + ctx.vmName + "] VM";
getResourceManagementClientImpl(ctx).resourceGroups().createOrUpdateAsync(resourceGroupName, resourceGroup, new TransitionToCallback<ResourceGroupInner>(ctx, nextStage, msg) {
@Override
CompletionStage<ResourceGroupInner> handleSuccess(ResourceGroupInner rg) {
this.ctx.resourceGroup = rg;
return CompletableFuture.completedFuture(rg);
}
});
}
use of com.microsoft.azure.management.resources.implementation.ResourceGroupInner in project photon-model by vmware.
the class AzureInstanceService method createStorageAccountRG.
/**
* Init storage account name and resource group, using the following approach:
* <table border=1>
* <tr>
* <th>AZURE_STORAGE_ACCOUNT_NAME</th>
* <th>AZURE_STORAGE_ACCOUNT_RG_NAME</th>
* <th>Used Parameter</th>
* </tr>
* <tr>
* <td>provided</td>
* <td>provided</td>
* <td>SA name = AZURE_STORAGE_ACCOUNT_NAME<br>
* SA RG name = AZURE_STORAGE_ACCOUNT_RG_NAME</td>
* </tr>
* <tr>
* <td>provided</td>
* <td>not provided</td>
* <td>SA name = AZURE_STORAGE_ACCOUNT_NAME<br>
* SA RG name = AZURE_STORAGE_ACCOUNT_DEFAULT_RG_NAME</td>
* </tr>
* <tr>
* <td>not provided</td>
* <td>provided</td>
* <td>SA name = generated name<br>
* SA RG name = ctx.resourceGroup.getName()</td>
* </tr>
* <tr>
* <td>not provided</td>
* <td>not provided</td>
* <td>SA name = generated name<br>
* SA RG name = ctx.resourceGroup.getName()</td>
* </tr>
* </table>
*/
private DeferredResult<AzureInstanceContext> createStorageAccountRG(AzureInstanceContext ctx) {
// Either we are reusing an existing storage account or using managed disks.
if (ctx.reuseExistingStorageAccount() || ctx.useManagedDisks()) {
return DeferredResult.completed(ctx);
} else {
ctx.storageAccountName = ctx.bootDiskState.customProperties.get(AZURE_STORAGE_ACCOUNT_NAME);
}
ctx.storageAccountRGName = ctx.bootDiskState.customProperties.getOrDefault(AZURE_STORAGE_ACCOUNT_RG_NAME, AZURE_STORAGE_ACCOUNT_DEFAULT_RG_NAME);
if (ctx.storageAccountName == null) {
// In case SA is not provided in the request, use request VA resource group
ctx.storageAccountName = String.valueOf(System.currentTimeMillis()) + "st";
ctx.storageAccountRGName = ctx.resourceGroup.name();
return DeferredResult.completed(ctx);
}
String msg = "Create/Update SA Resource Group [" + ctx.storageAccountRGName + "] for [" + ctx.vmName + "] VM";
AzureDeferredResultServiceCallback<ResourceGroupInner> handler = new Default<>(this, msg);
// Use shared RG. In case not provided in the bootDisk properties, use the default one
final ResourceGroupInner sharedSARG = new ResourceGroupInner();
sharedSARG.withLocation(ctx.child.description.regionId);
getResourceManagementClientImpl(ctx).resourceGroups().createOrUpdateAsync(ctx.storageAccountRGName, sharedSARG, handler);
return handler.toDeferredResult().thenApply(ignore -> ctx);
}
Aggregations