Search in sources :

Example 1 with NetSpec

use of com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs.NetSpec in project photon-model by vmware.

the class AzureTestUtil method initializeNicSpecs.

public static AzureNicSpecs initializeNicSpecs(String prefix, boolean assignGateway, boolean assignPublicIpAddress, boolean assignPrivateIpAddress) {
    String networkName = (prefix != null ? prefix + "-" : "") + AZURE_NETWORK_NAME;
    NetSpec network = new NetSpec(networkName, AZURE_NETWORK_CIDR, AZURE_RESOURCE_GROUP_LOCATION);
    List<NetSpec> subnets = new ArrayList<>();
    for (int i = 0; i < AZURE_SUBNET_CIDR.length; i++) {
        String subnetName = (prefix != null ? prefix + "-" : "") + AZURE_SUBNET_NAME + i;
        subnets.add(new NetSpec(subnetName, AZURE_SUBNET_CIDR[i], AZURE_RESOURCE_GROUP_LOCATION));
    }
    GatewaySpec gateway = assignGateway ? new GatewaySpec(AZURE_GATEWAY_NAME, AZURE_GATEWAY_CIDR, AZURE_RESOURCE_GROUP_LOCATION, AZURE_GATEWAY_IP_CONFIGURATION_NAME, AZURE_GATEWAY_PUBLIC_IP_NAME, IPAllocationMethod.DYNAMIC, VirtualNetworkGatewaySkuName.STANDARD, VirtualNetworkGatewaySkuTier.STANDARD, VirtualNetworkGatewayType.VPN, VpnType.ROUTE_BASED) : null;
    List<NicSpec> nicSpecs = new ArrayList<>();
    for (int i = 0; i < subnets.size(); i++) {
        NicSpec nicSpec = null;
        if (i == 0 && assignPrivateIpAddress) {
            nicSpec = NicSpec.createStatic(subnets.get(i));
        } else {
            nicSpec = NicSpec.createDynamic(subnets.get(i));
        }
        nicSpecs.add(nicSpec);
    }
    return new AzureNicSpecs(network, gateway, nicSpecs, assignPublicIpAddress);
}
Also used : NetSpec(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs.NetSpec) ArrayList(java.util.ArrayList) GatewaySpec(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs.GatewaySpec) NicSpec(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs.NicSpec)

Aggregations

GatewaySpec (com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs.GatewaySpec)1 NetSpec (com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs.NetSpec)1 NicSpec (com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.AzureNicSpecs.NicSpec)1 ArrayList (java.util.ArrayList)1