Search in sources :

Example 1 with RouteTable

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

the class TestNetwork method printNetwork.

/**
	 * Outputs info about a network
	 * @param resource a network
	 */
public static void printNetwork(Network resource) {
    StringBuilder info = new StringBuilder();
    info.append("Network: ").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\tAddress spaces: ").append(resource.addressSpaces()).append("\n\tDNS server IPs: ").append(resource.dnsServerIPs());
    // Output subnets
    for (Subnet subnet : resource.subnets().values()) {
        info.append("\n\tSubnet: ").append(subnet.name()).append("\n\t\tAddress prefix: ").append(subnet.addressPrefix());
        // Show associated NSG
        info.append("\n\tAssociated NSG: ");
        NetworkSecurityGroup nsg;
        try {
            nsg = subnet.getNetworkSecurityGroup();
        } catch (Exception e) {
            nsg = null;
        }
        info.append((null == nsg) ? "(None)" : nsg.resourceGroupName() + "/" + nsg.name());
        // Show associated route table
        info.append("\n\tAssociated route table: ");
        RouteTable routeTable;
        try {
            routeTable = subnet.getRouteTable();
        } catch (Exception e) {
            routeTable = null;
        }
        info.append((null == routeTable) ? "(None)" : routeTable.resourceGroupName() + "/" + routeTable.name());
    }
    System.out.println(info.toString());
}
Also used : RouteTable(com.microsoft.azure.management.network.RouteTable) NetworkSecurityGroup(com.microsoft.azure.management.network.NetworkSecurityGroup) Subnet(com.microsoft.azure.management.network.Subnet)

Aggregations

NetworkSecurityGroup (com.microsoft.azure.management.network.NetworkSecurityGroup)1 RouteTable (com.microsoft.azure.management.network.RouteTable)1 Subnet (com.microsoft.azure.management.network.Subnet)1