Search in sources :

Example 1 with LoadBalancerHttpProbe

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

the class TestLoadBalancer method printLB.

// Print LB info
static void printLB(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 (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) 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)

Example 2 with LoadBalancerHttpProbe

use of com.microsoft.azure.management.network.LoadBalancerHttpProbe 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

LoadBalancerBackend (com.microsoft.azure.management.network.LoadBalancerBackend)2 LoadBalancerFrontend (com.microsoft.azure.management.network.LoadBalancerFrontend)2 LoadBalancerHttpProbe (com.microsoft.azure.management.network.LoadBalancerHttpProbe)2 LoadBalancerInboundNatPool (com.microsoft.azure.management.network.LoadBalancerInboundNatPool)2 LoadBalancerInboundNatRule (com.microsoft.azure.management.network.LoadBalancerInboundNatRule)2 LoadBalancerProbe (com.microsoft.azure.management.network.LoadBalancerProbe)2 LoadBalancerTcpProbe (com.microsoft.azure.management.network.LoadBalancerTcpProbe)2 LoadBalancingRule (com.microsoft.azure.management.network.LoadBalancingRule)2 ConnectionString (com.microsoft.azure.management.appservice.ConnectionString)1 Map (java.util.Map)1