use of com.microsoft.azure.management.compute.AvailabilitySetSkuTypes in project photon-model by vmware.
the class AzureInstanceService method createAvailabilitySet.
private void createAvailabilitySet(AzureInstanceContext ctx, AzureInstanceStage nextStage) {
String availabilitySetName = AzureUtils.getAvailabilitySetName(ctx);
String msg = "Creating Azure Availability Set [" + availabilitySetName + "] for [" + ctx.vmName + "] VM";
AvailabilitySetSkuTypes skuType = ctx.useManagedDisks() ? AvailabilitySetSkuTypes.MANAGED : AvailabilitySetSkuTypes.UNMANAGED;
AvailabilitySet.DefinitionStages.WithCreate availabilitySetDefinition = ctx.azureSdkClients.getComputeManager().availabilitySets().define(availabilitySetName).withRegion(ctx.child.description.regionId).withExistingResourceGroup(ctx.resourceGroup.name()).withSku(skuType);
AzureDeferredResultServiceCallbackWithRetry<AvailabilitySet> callback = new AzureDeferredResultServiceCallbackWithRetry<AvailabilitySet>(this, msg) {
@Override
protected DeferredResult<AvailabilitySet> consumeSuccess(AvailabilitySet availabilitySet) {
logInfo("Successfully created AvailabilitySet: " + availabilitySet.name());
ctx.availabilitySet = availabilitySet;
return DeferredResult.completed(availabilitySet);
}
@Override
protected Runnable retryServiceCall(ServiceCallback<AvailabilitySet> retryCallback) {
return () -> availabilitySetDefinition.createAsync(retryCallback);
}
};
availabilitySetDefinition.createAsync(callback);
callback.toDeferredResult().thenApply(ignore -> ctx).whenComplete(thenAllocation(ctx, nextStage, NETWORK_NAMESPACE));
}
Aggregations