use of com.microsoft.azure.management.network.implementation.PublicIPAddressInner in project photon-model by vmware.
the class AzureLoadBalancerService method getPublicIPAddress.
/**
* Fetch public IP address after an address has been assigned
*/
private DeferredResult<AzureLoadBalancerContext> getPublicIPAddress(AzureLoadBalancerContext ctx) {
if (ctx.publicIPAddressInner == null) {
// No public IP address created -> do nothing.
return DeferredResult.completed(ctx);
}
NetworkManagementClientImpl client = ctx.azureSdkClients.getNetworkManagementClientImpl();
String msg = "Get public IP address for resource group [" + ctx.resourceGroupName + "] and name [" + ctx.publicIPAddressInner.name() + "].";
AzureDeferredResultServiceCallback<PublicIPAddressInner> callback = new AzureDeferredResultServiceCallback<PublicIPAddressInner>(ctx.service, msg) {
@Override
protected DeferredResult<PublicIPAddressInner> consumeSuccess(PublicIPAddressInner result) {
ctx.publicIPAddressInner = result;
ctx.loadBalancerStateExpanded.address = result.ipAddress();
return DeferredResult.completed(result);
}
};
client.publicIPAddresses().getByResourceGroupAsync(ctx.resourceGroupName, ctx.publicIPAddressInner.name(), null, callback);
return callback.toDeferredResult().thenApply(ignored -> ctx);
}
use of com.microsoft.azure.management.network.implementation.PublicIPAddressInner in project photon-model by vmware.
the class AzureTestUtil method addAzureGatewayToVirtualNetwork.
/**
* Adds Gateway to Virtual Network in Azure
*/
private static void addAzureGatewayToVirtualNetwork(String resourceGroupName, AzureNicSpecs nicSpecs, NetworkManagementClientImpl networkManagementClient) throws CloudException, IOException, InterruptedException {
// create Gateway Subnet
SubnetInner gatewaySubnetParams = new SubnetInner();
gatewaySubnetParams.withName(nicSpecs.gateway.name);
gatewaySubnetParams.withAddressPrefix(nicSpecs.gateway.cidr);
SubnetInner gatewaySubnet = networkManagementClient.subnets().createOrUpdate(resourceGroupName, nicSpecs.network.name, AzureConstants.GATEWAY_SUBNET_NAME, gatewaySubnetParams);
// create Public IP
PublicIPAddressInner publicIPAddressParams = new PublicIPAddressInner();
publicIPAddressParams.withPublicIPAllocationMethod(IPAllocationMethod.DYNAMIC);
publicIPAddressParams.withLocation(nicSpecs.gateway.zoneId);
PublicIPAddressInner publicIPAddress = networkManagementClient.publicIPAddresses().createOrUpdate(resourceGroupName, nicSpecs.gateway.publicIpName, publicIPAddressParams);
SubResource publicIPSubResource = new SubResource();
publicIPSubResource.withId(publicIPAddress.id());
// create IP Configuration
VirtualNetworkGatewayIPConfigurationInner ipConfiguration = new VirtualNetworkGatewayIPConfigurationInner();
ipConfiguration.withName(nicSpecs.gateway.ipConfigurationName);
ipConfiguration.withSubnet(gatewaySubnet);
ipConfiguration.withPrivateIPAllocationMethod(IPAllocationMethod.DYNAMIC);
ipConfiguration.withPublicIPAddress(publicIPSubResource);
// create Virtual Network Gateway
VirtualNetworkGatewayInner virtualNetworkGateway = new VirtualNetworkGatewayInner();
virtualNetworkGateway.withGatewayType(VirtualNetworkGatewayType.VPN);
virtualNetworkGateway.withVpnType(VpnType.ROUTE_BASED);
VirtualNetworkGatewaySku vNetGatewaySku = new VirtualNetworkGatewaySku();
vNetGatewaySku.withName(VirtualNetworkGatewaySkuName.STANDARD);
vNetGatewaySku.withTier(VirtualNetworkGatewaySkuTier.STANDARD);
vNetGatewaySku.withCapacity(2);
virtualNetworkGateway.withSku(vNetGatewaySku);
virtualNetworkGateway.withLocation(AZURE_RESOURCE_GROUP_LOCATION);
List<VirtualNetworkGatewayIPConfigurationInner> ipConfigurations = new ArrayList<>();
ipConfigurations.add(ipConfiguration);
virtualNetworkGateway.withIpConfigurations(ipConfigurations);
// Call the async variant because the virtual network gateway provisioning depends on
// the public IP address assignment which is time-consuming operation
networkManagementClient.virtualNetworkGateways().createOrUpdateAsync(resourceGroupName, nicSpecs.gateway.name, virtualNetworkGateway, new ServiceCallback<VirtualNetworkGatewayInner>() {
@Override
public void failure(Throwable throwable) {
throw new RuntimeException("Error creating Azure Virtual Network Gateway.", throwable);
}
@Override
public void success(VirtualNetworkGatewayInner response) {
}
});
}
Aggregations