use of com.microsoft.azure.management.network.implementation.LoadBalancersInner in project photon-model by vmware.
the class AzureLoadBalancerService method createOrUpdateLoadBalancer.
/**
* Create or update load balancer in Azure
*
* @param context Azure load balancer context
* @param msg message to log
* @return DeferredResult
*/
private DeferredResult<LoadBalancerInner> createOrUpdateLoadBalancer(AzureLoadBalancerContext context, String msg) {
LoadBalancersInner azureLoadBalancerClient = context.azureSdkClients.getNetworkManagementClientImpl().loadBalancers();
logInfo(() -> msg);
AzureProvisioningCallback<LoadBalancerInner> handler = new AzureProvisioningCallback<LoadBalancerInner>(this, msg) {
@Override
protected DeferredResult<LoadBalancerInner> consumeProvisioningSuccess(LoadBalancerInner loadBalancer) {
// Populate the load balancer id with Azure Load Balancer ID
context.loadBalancerStateExpanded.id = loadBalancer.id();
return DeferredResult.completed(loadBalancer);
}
@Override
protected String getProvisioningState(LoadBalancerInner loadBalancer) {
return loadBalancer.provisioningState();
}
@Override
protected Runnable checkProvisioningStateCall(ServiceCallback<LoadBalancerInner> checkProvisioningStateCallback) {
return () -> azureLoadBalancerClient.getByResourceGroupAsync(context.resourceGroupName, context.loadBalancerAzure.name(), null, /* expand */
checkProvisioningStateCallback);
}
};
azureLoadBalancerClient.createOrUpdateAsync(context.resourceGroupName, context.loadBalancerStateExpanded.name, context.loadBalancerAzure, handler);
return handler.toDeferredResult();
}
use of com.microsoft.azure.management.network.implementation.LoadBalancersInner in project photon-model by vmware.
the class AzureLoadBalancerService method deleteLoadBalancer.
/**
* Delete load balancer from Azure
*
* @param context Azure load balancer context
* @return DeferredResult
*/
private DeferredResult<AzureLoadBalancerContext> deleteLoadBalancer(AzureLoadBalancerContext context) {
String rgName = context.resourceGroupName;
String loadBalancerName = context.loadBalancerStateExpanded.name;
LoadBalancersInner azureLoadBalancerClient = context.azureSdkClients.getNetworkManagementClientImpl().loadBalancers();
final String msg = String.format("Deleting Azure load balancer [%s] in resource group [%s].", loadBalancerName, rgName);
AzureDeferredResultServiceCallback<Void> handler = createDeleteHandler(msg);
azureLoadBalancerClient.deleteAsync(rgName, loadBalancerName, handler);
return handler.toDeferredResult().thenApply(ignore -> context);
}
Aggregations