Search in sources :

Example 1 with LoadBalancerInboundNatPool

use of com.microsoft.azure.management.network.LoadBalancerInboundNatPool in project azure-sdk-for-java by Azure.

the class LoadBalancerImpl method beforeCreating.

@Override
protected void beforeCreating() {
    // Account for the newly created public IPs
    for (Entry<String, String> pipFrontendAssociation : this.creatablePIPKeys.entrySet()) {
        PublicIPAddress pip = (PublicIPAddress) this.createdResource(pipFrontendAssociation.getKey());
        if (pip != null) {
            withExistingPublicIPAddress(pip.id(), pipFrontendAssociation.getValue());
        }
    }
    this.creatablePIPKeys.clear();
    // Reset and update probes
    List<ProbeInner> innerProbes = innersFromWrappers(this.httpProbes.values());
    innerProbes = innersFromWrappers(this.tcpProbes.values(), innerProbes);
    if (innerProbes == null) {
        innerProbes = new ArrayList<>();
    }
    this.inner().withProbes(innerProbes);
    // Reset and update backends
    List<BackendAddressPoolInner> innerBackends = innersFromWrappers(this.backends.values());
    if (null == innerBackends) {
        innerBackends = new ArrayList<>();
    }
    this.inner().withBackendAddressPools(innerBackends);
    // Reset and update frontends
    List<FrontendIPConfigurationInner> innerFrontends = innersFromWrappers(this.frontends.values());
    if (null == innerFrontends) {
        innerFrontends = new ArrayList<>();
    }
    this.inner().withFrontendIPConfigurations(innerFrontends);
    // Reset and update inbound NAT rules
    List<InboundNatRuleInner> innerNatRules = innersFromWrappers(this.inboundNatRules.values());
    if (null == innerNatRules) {
        innerNatRules = new ArrayList<>();
    }
    this.inner().withInboundNatRules(innerNatRules);
    for (LoadBalancerInboundNatRule natRule : this.inboundNatRules.values()) {
        // Clear deleted frontend references
        SubResource ref = natRule.inner().frontendIPConfiguration();
        if (ref != null && !this.frontends().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            natRule.inner().withFrontendIPConfiguration(null);
        }
    }
    // Reset and update inbound NAT pools
    List<InboundNatPoolInner> innerNatPools = innersFromWrappers(this.inboundNatPools.values());
    if (null == innerNatPools) {
        innerNatPools = new ArrayList<>();
    }
    this.inner().withInboundNatPools(innerNatPools);
    for (LoadBalancerInboundNatPool natPool : this.inboundNatPools.values()) {
        // Clear deleted frontend references
        SubResource ref = natPool.inner().frontendIPConfiguration();
        if (ref != null && !this.frontends().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            natPool.inner().withFrontendIPConfiguration(null);
        }
    }
    // Reset and update load balancing rules
    List<LoadBalancingRuleInner> innerRules = innersFromWrappers(this.loadBalancingRules.values());
    if (innerRules == null) {
        innerRules = new ArrayList<>();
    }
    this.inner().withLoadBalancingRules(innerRules);
    for (LoadBalancingRule lbRule : this.loadBalancingRules.values()) {
        SubResource ref;
        // Clear deleted frontend references
        ref = lbRule.inner().frontendIPConfiguration();
        if (ref != null && !this.frontends().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            lbRule.inner().withFrontendIPConfiguration(null);
        }
        // Clear deleted backend references
        ref = lbRule.inner().backendAddressPool();
        if (ref != null && !this.backends().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            lbRule.inner().withBackendAddressPool(null);
        }
        // Clear deleted probe references
        ref = lbRule.inner().probe();
        if (ref != null && !this.httpProbes().containsKey(ResourceUtils.nameFromResourceId(ref.id())) && !this.tcpProbes().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            lbRule.inner().withProbe(null);
        }
    }
}
Also used : SubResource(com.microsoft.azure.SubResource) LoadBalancingRule(com.microsoft.azure.management.network.LoadBalancingRule) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress) LoadBalancerInboundNatPool(com.microsoft.azure.management.network.LoadBalancerInboundNatPool) LoadBalancerInboundNatRule(com.microsoft.azure.management.network.LoadBalancerInboundNatRule)

Example 2 with LoadBalancerInboundNatPool

use of com.microsoft.azure.management.network.LoadBalancerInboundNatPool in project azure-sdk-for-java by Azure.

the class LoadBalancerFrontendImpl method inboundNatPools.

@Override
public Map<String, LoadBalancerInboundNatPool> inboundNatPools() {
    final Map<String, LoadBalancerInboundNatPool> pools = new TreeMap<>();
    if (this.inner().inboundNatPools() != null) {
        for (SubResource innerRef : this.inner().inboundNatPools()) {
            String name = ResourceUtils.nameFromResourceId(innerRef.id());
            LoadBalancerInboundNatPool pool = this.parent().inboundNatPools().get(name);
            if (pool != null) {
                pools.put(name, pool);
            }
        }
    }
    return Collections.unmodifiableMap(pools);
}
Also used : SubResource(com.microsoft.azure.SubResource) TreeMap(java.util.TreeMap) LoadBalancerInboundNatPool(com.microsoft.azure.management.network.LoadBalancerInboundNatPool)

Example 3 with LoadBalancerInboundNatPool

use of com.microsoft.azure.management.network.LoadBalancerInboundNatPool in project azure-sdk-for-java by Azure.

the class VirtualMachineScaleSetImpl method associateLoadBalancerToIpConfiguration.

private static void associateLoadBalancerToIpConfiguration(LoadBalancer loadBalancer, VirtualMachineScaleSetIPConfigurationInner ipConfig) {
    Collection<LoadBalancerBackend> backends = loadBalancer.backends().values();
    String[] backendNames = new String[backends.size()];
    int i = 0;
    for (LoadBalancerBackend backend : backends) {
        backendNames[i] = backend.name();
        i++;
    }
    associateBackEndsToIpConfiguration(loadBalancer.id(), ipConfig, backendNames);
    Collection<LoadBalancerInboundNatPool> inboundNatPools = loadBalancer.inboundNatPools().values();
    String[] natPoolNames = new String[inboundNatPools.size()];
    i = 0;
    for (LoadBalancerInboundNatPool inboundNatPool : inboundNatPools) {
        natPoolNames[i] = inboundNatPool.name();
        i++;
    }
    associateInboundNATPoolsToIpConfiguration(loadBalancer.id(), ipConfig, natPoolNames);
}
Also used : LoadBalancerInboundNatPool(com.microsoft.azure.management.network.LoadBalancerInboundNatPool) LoadBalancerBackend(com.microsoft.azure.management.network.LoadBalancerBackend)

Example 4 with LoadBalancerInboundNatPool

use of com.microsoft.azure.management.network.LoadBalancerInboundNatPool in project azure-sdk-for-java by Azure.

the class VirtualMachineScaleSetImpl method getInboundNatPoolsAssociatedWithIpConfiguration.

private static Map<String, LoadBalancerInboundNatPool> getInboundNatPoolsAssociatedWithIpConfiguration(LoadBalancer loadBalancer, VirtualMachineScaleSetIPConfigurationInner ipConfig) {
    String loadBalancerId = loadBalancer.id();
    Map<String, LoadBalancerInboundNatPool> attachedInboundNatPools = new HashMap<>();
    Map<String, LoadBalancerInboundNatPool> lbInboundNatPools = loadBalancer.inboundNatPools();
    for (LoadBalancerInboundNatPool lbInboundNatPool : lbInboundNatPools.values()) {
        String inboundNatPoolId = mergePath(loadBalancerId, "inboundNatPools", lbInboundNatPool.name());
        for (SubResource subResource : ipConfig.loadBalancerInboundNatPools()) {
            if (subResource.id().equalsIgnoreCase(inboundNatPoolId)) {
                attachedInboundNatPools.put(lbInboundNatPool.name(), lbInboundNatPool);
            }
        }
    }
    return attachedInboundNatPools;
}
Also used : SubResource(com.microsoft.azure.SubResource) HashMap(java.util.HashMap) LoadBalancerInboundNatPool(com.microsoft.azure.management.network.LoadBalancerInboundNatPool)

Example 5 with LoadBalancerInboundNatPool

use of com.microsoft.azure.management.network.LoadBalancerInboundNatPool in project azure-sdk-for-java by Azure.

the class Utils method print.

/**
     * Print load balancer.
     * @param resource a load balancer
     */
public static void print(LoadBalancer resource) {
    StringBuilder info = new StringBuilder();
    info.append("Load balancer: ").append(resource.id()).append("Name: ").append(resource.name()).append("\n\tResource group: ").append(resource.resourceGroupName()).append("\n\tRegion: ").append(resource.region()).append("\n\tTags: ").append(resource.tags()).append("\n\tBackends: ").append(resource.backends().keySet().toString());
    // Show public IP addresses
    info.append("\n\tPublic IP address IDs: ").append(resource.publicIPAddressIds().size());
    for (String pipId : resource.publicIPAddressIds()) {
        info.append("\n\t\tPIP id: ").append(pipId);
    }
    // Show TCP probes
    info.append("\n\tTCP probes: ").append(resource.tcpProbes().size());
    for (LoadBalancerTcpProbe probe : resource.tcpProbes().values()) {
        info.append("\n\t\tProbe name: ").append(probe.name()).append("\n\t\t\tPort: ").append(probe.port()).append("\n\t\t\tInterval in seconds: ").append(probe.intervalInSeconds()).append("\n\t\t\tRetries before unhealthy: ").append(probe.numberOfProbes());
        // Show associated load balancing rules
        info.append("\n\t\t\tReferenced from load balancing rules: ").append(probe.loadBalancingRules().size());
        for (LoadBalancingRule rule : probe.loadBalancingRules().values()) {
            info.append("\n\t\t\t\tName: ").append(rule.name());
        }
    }
    // Show HTTP probes
    info.append("\n\tHTTP probes: ").append(resource.httpProbes().size());
    for (LoadBalancerHttpProbe probe : resource.httpProbes().values()) {
        info.append("\n\t\tProbe name: ").append(probe.name()).append("\n\t\t\tPort: ").append(probe.port()).append("\n\t\t\tInterval in seconds: ").append(probe.intervalInSeconds()).append("\n\t\t\tRetries before unhealthy: ").append(probe.numberOfProbes()).append("\n\t\t\tHTTP request path: ").append(probe.requestPath());
        // Show associated load balancing rules
        info.append("\n\t\t\tReferenced from load balancing rules: ").append(probe.loadBalancingRules().size());
        for (LoadBalancingRule rule : probe.loadBalancingRules().values()) {
            info.append("\n\t\t\t\tName: ").append(rule.name());
        }
    }
    // Show load balancing rules
    info.append("\n\tLoad balancing rules: ").append(resource.loadBalancingRules().size());
    for (LoadBalancingRule rule : resource.loadBalancingRules().values()) {
        info.append("\n\t\tLB rule name: ").append(rule.name()).append("\n\t\t\tProtocol: ").append(rule.protocol()).append("\n\t\t\tFloating IP enabled? ").append(rule.floatingIPEnabled()).append("\n\t\t\tIdle timeout in minutes: ").append(rule.idleTimeoutInMinutes()).append("\n\t\t\tLoad distribution method: ").append(rule.loadDistribution().toString());
        LoadBalancerFrontend frontend = rule.frontend();
        info.append("\n\t\t\tFrontend: ");
        if (frontend != null) {
            info.append(frontend.name());
        } else {
            info.append("(None)");
        }
        info.append("\n\t\t\tFrontend port: ").append(rule.frontendPort());
        LoadBalancerBackend backend = rule.backend();
        info.append("\n\t\t\tBackend: ");
        if (backend != null) {
            info.append(backend.name());
        } else {
            info.append("(None)");
        }
        info.append("\n\t\t\tBackend port: ").append(rule.backendPort());
        LoadBalancerProbe probe = rule.probe();
        info.append("\n\t\t\tProbe: ");
        if (probe == null) {
            info.append("(None)");
        } else {
            info.append(probe.name()).append(" [").append(probe.protocol().toString()).append("]");
        }
    }
    // Show frontends
    info.append("\n\tFrontends: ").append(resource.frontends().size());
    for (LoadBalancerFrontend frontend : resource.frontends().values()) {
        info.append("\n\t\tFrontend name: ").append(frontend.name()).append("\n\t\t\tInternet facing: ").append(frontend.isPublic());
        if (frontend.isPublic()) {
            info.append("\n\t\t\tPublic IP Address ID: ").append(((LoadBalancerPublicFrontend) frontend).publicIPAddressId());
        } else {
            info.append("\n\t\t\tVirtual network ID: ").append(((LoadBalancerPrivateFrontend) frontend).networkId()).append("\n\t\t\tSubnet name: ").append(((LoadBalancerPrivateFrontend) frontend).subnetName()).append("\n\t\t\tPrivate IP address: ").append(((LoadBalancerPrivateFrontend) frontend).privateIPAddress()).append("\n\t\t\tPrivate IP allocation method: ").append(((LoadBalancerPrivateFrontend) frontend).privateIPAllocationMethod());
        }
        // Inbound NAT pool references
        info.append("\n\t\t\tReferenced inbound NAT pools: ").append(frontend.inboundNatPools().size());
        for (LoadBalancerInboundNatPool pool : frontend.inboundNatPools().values()) {
            info.append("\n\t\t\t\tName: ").append(pool.name());
        }
        // Inbound NAT rule references
        info.append("\n\t\t\tReferenced inbound NAT rules: ").append(frontend.inboundNatRules().size());
        for (LoadBalancerInboundNatRule rule : frontend.inboundNatRules().values()) {
            info.append("\n\t\t\t\tName: ").append(rule.name());
        }
        // Load balancing rule references
        info.append("\n\t\t\tReferenced load balancing rules: ").append(frontend.loadBalancingRules().size());
        for (LoadBalancingRule rule : frontend.loadBalancingRules().values()) {
            info.append("\n\t\t\t\tName: ").append(rule.name());
        }
    }
    // Show inbound NAT rules
    info.append("\n\tInbound NAT rules: ").append(resource.inboundNatRules().size());
    for (LoadBalancerInboundNatRule natRule : resource.inboundNatRules().values()) {
        info.append("\n\t\tInbound NAT rule name: ").append(natRule.name()).append("\n\t\t\tProtocol: ").append(natRule.protocol().toString()).append("\n\t\t\tFrontend: ").append(natRule.frontend().name()).append("\n\t\t\tFrontend port: ").append(natRule.frontendPort()).append("\n\t\t\tBackend port: ").append(natRule.backendPort()).append("\n\t\t\tBackend NIC ID: ").append(natRule.backendNetworkInterfaceId()).append("\n\t\t\tBackend NIC IP config name: ").append(natRule.backendNicIPConfigurationName()).append("\n\t\t\tFloating IP? ").append(natRule.floatingIPEnabled()).append("\n\t\t\tIdle timeout in minutes: ").append(natRule.idleTimeoutInMinutes());
    }
    // Show inbound NAT pools
    info.append("\n\tInbound NAT pools: ").append(resource.inboundNatPools().size());
    for (LoadBalancerInboundNatPool natPool : resource.inboundNatPools().values()) {
        info.append("\n\t\tInbound NAT pool name: ").append(natPool.name()).append("\n\t\t\tProtocol: ").append(natPool.protocol().toString()).append("\n\t\t\tFrontend: ").append(natPool.frontend().name()).append("\n\t\t\tFrontend port range: ").append(natPool.frontendPortRangeStart()).append("-").append(natPool.frontendPortRangeEnd()).append("\n\t\t\tBackend port: ").append(natPool.backendPort());
    }
    // Show backends
    info.append("\n\tBackends: ").append(resource.backends().size());
    for (LoadBalancerBackend backend : resource.backends().values()) {
        info.append("\n\t\tBackend name: ").append(backend.name());
        // Show assigned backend NICs
        info.append("\n\t\t\tReferenced NICs: ").append(backend.backendNicIPConfigurationNames().entrySet().size());
        for (Map.Entry<String, String> entry : backend.backendNicIPConfigurationNames().entrySet()) {
            info.append("\n\t\t\t\tNIC ID: ").append(entry.getKey()).append(" - IP Config: ").append(entry.getValue());
        }
        // Show assigned virtual machines
        Set<String> vmIds = backend.getVirtualMachineIds();
        info.append("\n\t\t\tReferenced virtual machine ids: ").append(vmIds.size());
        for (String vmId : vmIds) {
            info.append("\n\t\t\t\tVM ID: ").append(vmId);
        }
        // Show assigned load balancing rules
        info.append("\n\t\t\tReferenced load balancing rules: ").append(new ArrayList<String>(backend.loadBalancingRules().keySet()));
    }
    System.out.println(info.toString());
}
Also used : LoadBalancerHttpProbe(com.microsoft.azure.management.network.LoadBalancerHttpProbe) LoadBalancingRule(com.microsoft.azure.management.network.LoadBalancingRule) LoadBalancerProbe(com.microsoft.azure.management.network.LoadBalancerProbe) LoadBalancerTcpProbe(com.microsoft.azure.management.network.LoadBalancerTcpProbe) ConnectionString(com.microsoft.azure.management.appservice.ConnectionString) LoadBalancerFrontend(com.microsoft.azure.management.network.LoadBalancerFrontend) LoadBalancerInboundNatPool(com.microsoft.azure.management.network.LoadBalancerInboundNatPool) LoadBalancerInboundNatRule(com.microsoft.azure.management.network.LoadBalancerInboundNatRule) LoadBalancerBackend(com.microsoft.azure.management.network.LoadBalancerBackend) Map(java.util.Map)

Aggregations

LoadBalancerInboundNatPool (com.microsoft.azure.management.network.LoadBalancerInboundNatPool)6 SubResource (com.microsoft.azure.SubResource)3 LoadBalancerBackend (com.microsoft.azure.management.network.LoadBalancerBackend)3 LoadBalancerInboundNatRule (com.microsoft.azure.management.network.LoadBalancerInboundNatRule)3 LoadBalancingRule (com.microsoft.azure.management.network.LoadBalancingRule)3 LoadBalancerFrontend (com.microsoft.azure.management.network.LoadBalancerFrontend)2 LoadBalancerHttpProbe (com.microsoft.azure.management.network.LoadBalancerHttpProbe)2 LoadBalancerProbe (com.microsoft.azure.management.network.LoadBalancerProbe)2 LoadBalancerTcpProbe (com.microsoft.azure.management.network.LoadBalancerTcpProbe)2 ConnectionString (com.microsoft.azure.management.appservice.ConnectionString)1 PublicIPAddress (com.microsoft.azure.management.network.PublicIPAddress)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1