Search in sources :

Example 1 with LoadBalancersInner

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();
}
Also used : LoadBalancerInner(com.microsoft.azure.management.network.implementation.LoadBalancerInner) ServiceCallback(com.microsoft.rest.ServiceCallback) AzureDeferredResultServiceCallback(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback) LoadBalancersInner(com.microsoft.azure.management.network.implementation.LoadBalancersInner) AzureProvisioningCallback(com.vmware.photon.controller.model.adapters.azure.utils.AzureProvisioningCallback)

Example 2 with LoadBalancersInner

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);
}
Also used : LoadBalancersInner(com.microsoft.azure.management.network.implementation.LoadBalancersInner)

Aggregations

LoadBalancersInner (com.microsoft.azure.management.network.implementation.LoadBalancersInner)2 LoadBalancerInner (com.microsoft.azure.management.network.implementation.LoadBalancerInner)1 ServiceCallback (com.microsoft.rest.ServiceCallback)1 AzureDeferredResultServiceCallback (com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback)1 AzureProvisioningCallback (com.vmware.photon.controller.model.adapters.azure.utils.AzureProvisioningCallback)1