Search in sources :

Example 1 with IPAllocationMethod

use of com.microsoft.azure.management.network.IPAllocationMethod in project photon-model by vmware.

the class AzureInstanceService method newAzureNetworkInterface.

/**
 * Converts Photon model constructs to underlying Azure NetworkInterface model.
 */
private NetworkInterfaceInner newAzureNetworkInterface(AzureInstanceContext ctx, AzureNicContext nicCtx) {
    NetworkInterfaceDescription description = nicCtx.nicStateWithDesc.description;
    NetworkInterfaceIPConfigurationInner ipConfig = new NetworkInterfaceIPConfigurationInner();
    ipConfig.withName(AzureUtils.generateClusterCommonName(NICCONFIG_NAME_PREFIX, ctx));
    ipConfig.withSubnet(nicCtx.subnet);
    if (nicCtx.publicIP != null) {
        // Public IP is not auto-assigned so check for existence
        ipConfig.withPublicIPAddress(new SubResource().withId(nicCtx.publicIP.id()));
    }
    ipConfig.withPrivateIPAllocationMethod(new IPAllocationMethod(description.assignment.name()));
    if (description.assignment == IpAssignment.STATIC) {
        ipConfig.withPrivateIPAddress(description.address);
    }
    NetworkInterfaceInner nic = new NetworkInterfaceInner();
    nic.withLocation(ctx.resourceGroup.location());
    // Azure's custom serializers don't handle well collections constructed with
    // Collections.singletonList(), so initialize an ArrayList
    List<NetworkInterfaceIPConfigurationInner> ipConfigs = new ArrayList<>();
    ipConfigs.add(ipConfig);
    nic.withIpConfigurations(ipConfigs);
    if (nicCtx.securityGroup != null) {
        // Security group is optional so check for existence
        nic.withNetworkSecurityGroup(new SubResource().withId(nicCtx.securityGroup.id()));
    }
    return nic;
}
Also used : NetworkInterfaceDescription(com.vmware.photon.controller.model.resources.NetworkInterfaceDescriptionService.NetworkInterfaceDescription) IPAllocationMethod(com.microsoft.azure.management.network.IPAllocationMethod) SubResource(com.microsoft.azure.SubResource) NetworkInterfaceIPConfigurationInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner) ArrayList(java.util.ArrayList) NetworkInterfaceInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceInner)

Example 2 with IPAllocationMethod

use of com.microsoft.azure.management.network.IPAllocationMethod in project photon-model by vmware.

the class AzureInstanceService method newAzurePublicIPAddress.

/**
 * Converts Photon model constructs to underlying Azure PublicIPAddress model.
 */
private PublicIPAddressInner newAzurePublicIPAddress(AzureInstanceContext ctx, AzureNicContext nicCtx) {
    PublicIPAddressInner publicIPAddress = new PublicIPAddressInner();
    publicIPAddress.withLocation(ctx.resourceGroup.location());
    publicIPAddress.withPublicIPAllocationMethod(new IPAllocationMethod(nicCtx.nicStateWithDesc.description.assignment.name()));
    return publicIPAddress;
}
Also used : IPAllocationMethod(com.microsoft.azure.management.network.IPAllocationMethod) PublicIPAddressInner(com.microsoft.azure.management.network.implementation.PublicIPAddressInner)

Aggregations

IPAllocationMethod (com.microsoft.azure.management.network.IPAllocationMethod)2 SubResource (com.microsoft.azure.SubResource)1 NetworkInterfaceIPConfigurationInner (com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner)1 NetworkInterfaceInner (com.microsoft.azure.management.network.implementation.NetworkInterfaceInner)1 PublicIPAddressInner (com.microsoft.azure.management.network.implementation.PublicIPAddressInner)1 NetworkInterfaceDescription (com.vmware.photon.controller.model.resources.NetworkInterfaceDescriptionService.NetworkInterfaceDescription)1 ArrayList (java.util.ArrayList)1