• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java NetworkPeering类的典型用法和代码示例

java 6次浏览

本文整理汇总了Java中com.microsoft.azure.management.network.NetworkPeering的典型用法代码示例。如果您正苦于以下问题:Java NetworkPeering类的具体用法?Java NetworkPeering怎么用?Java NetworkPeering使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

NetworkPeering类属于com.microsoft.azure.management.network包,在下文中一共展示了NetworkPeering类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getByRemoteNetworkAsync

点赞 3

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public Observable<NetworkPeering> getByRemoteNetworkAsync(final String remoteNetworkResourceId) {
    if (remoteNetworkResourceId == null) {
        return Observable.just(null);
    } else {
        return this.listAsync().filter(new Func1<NetworkPeering, Boolean>() {
            @Override
            public Boolean call(NetworkPeering peering) {
                if (peering == null) {
                    return false;
                } else {
                    return remoteNetworkResourceId.equalsIgnoreCase(peering.remoteNetworkId());
                }
            }
        });
    }
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:18,
代码来源:NetworkPeeringsImpl.java

示例2: checkAccessBetweenNetworks

点赞 3

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public boolean checkAccessBetweenNetworks() {
    if (!Utils.toPrimitiveBoolean(this.inner().allowVirtualNetworkAccess())) {
        // If network access is disabled on this peering, then it's disabled for both networks, regardless of what the remote peering says
        return false;
    }

    // Check the access setting on the remote peering
    NetworkPeering remotePeering = this.getRemotePeering();
    if (remotePeering == null) {
        return false;
    } else {
        // Access is enabled on local peering, so up to the remote peering to determine whether it's enabled or disabled overall
        return Utils.toPrimitiveBoolean(remotePeering.inner().allowVirtualNetworkAccess());
    }
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:17,
代码来源:NetworkPeeringImpl.java

示例3: print

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
/**
 * Print network info.
 *
 * @param resource a network
 * @throws CloudException Cloud errors
 */
public static void print(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());

        // Output associated NSG
        NetworkSecurityGroup subnetNsg = subnet.getNetworkSecurityGroup();
        if (subnetNsg != null) {
            info.append("\n\t\tNetwork security group ID: ").append(subnetNsg.id());
        }

        // Output associated route table
        RouteTable routeTable = subnet.getRouteTable();
        if (routeTable != null) {
            info.append("\n\tRoute table ID: ").append(routeTable.id());
        }
    }

    // Output peerings
    for (NetworkPeering peering : resource.peerings().list()) {
        info.append("\n\tPeering: ").append(peering.name())
                .append("\n\t\tRemote network ID: ").append(peering.remoteNetworkId())
                .append("\n\t\tPeering state: ").append(peering.state())
                .append("\n\t\tIs traffic forwarded from remote network allowed? ").append(peering.isTrafficForwardingFromRemoteNetworkAllowed())
                .append("\n\t\tGateway use: ").append(peering.gatewayUse());
    }
    System.out.println(info.toString());
}
 

开发者ID:Azure-Samples,
项目名称:acr-java-manage-azure-container-registry,
代码行数:45,
代码来源:Utils.java

示例4: getByRemoteNetwork

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public NetworkPeering getByRemoteNetwork(String remoteNetworkResourceId) {
    if (remoteNetworkResourceId != null) {
        for (NetworkPeering peering : this.list()) {
            if (peering.remoteNetworkId().equalsIgnoreCase(remoteNetworkResourceId)) {
                return peering;
            }
        }
    }
    return null;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:12,
代码来源:NetworkPeeringsImpl.java

示例5: getRemotePeeringAsync

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public Observable<NetworkPeering> getRemotePeeringAsync() {
    final NetworkPeeringImpl self = this;
    return this.getRemoteNetworkAsync()
        .flatMap(new Func1<Network, Observable<NetworkPeering>>() {
            @Override
            public Observable<NetworkPeering> call(Network remoteNetwork) {
                if (remoteNetwork == null) {
                    return Observable.just(null);
                } else {
                    return remoteNetwork.peerings().getByRemoteNetworkAsync(self.networkId());
                }
            }
        });
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:16,
代码来源:NetworkPeeringImpl.java

示例6: createResource

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public Network createResource(Networks networks) throws Exception {
    Region region = Region.US_EAST;
    String groupName = "rg" + this.testId;

    String networkName = SdkContext.randomResourceName("net", 15);
    String networkName2 = SdkContext.randomResourceName("net", 15);

    Creatable<Network> remoteNetworkDefinition = networks.define(networkName2)
            .withRegion(region)
            .withNewResourceGroup(groupName)
            .withAddressSpace("10.1.0.0/27")
            .withSubnet("subnet3", "10.1.0.0/27");

    Creatable<Network> localNetworkDefinition = networks.define(networkName)
            .withRegion(region)
            .withNewResourceGroup(groupName)
            .withAddressSpace("10.0.0.0/27")
            .withSubnet("subnet1", "10.0.0.0/28")
            .withSubnet("subnet2", "10.0.0.16/28");

    CreatedResources<Network> createdNetworks = networks.create(Arrays.asList(remoteNetworkDefinition, localNetworkDefinition));
    Network localNetwork = createdNetworks.get(localNetworkDefinition.key());
    Network remoteNetwork = createdNetworks.get(remoteNetworkDefinition.key());
    Assert.assertNotNull(localNetwork);
    Assert.assertNotNull(remoteNetwork);

    // Create peering
    NetworkPeering localPeering = localNetwork.peerings().define("peer0")
        .withRemoteNetwork(remoteNetwork)

        // Optionals
        .withTrafficForwardingBetweenBothNetworks()
        .withoutAccessFromEitherNetwork()
        .withGatewayUseByRemoteNetworkAllowed()
        .create();

    // Verify local peering
    Assert.assertNotNull(localNetwork.peerings());
    Assert.assertEquals(1,  localNetwork.peerings().list().size());
    localPeering = localNetwork.peerings().list().get(0);
    Assert.assertNotNull(localPeering);
    Assert.assertTrue(localPeering.name().equalsIgnoreCase("peer0"));
    Assert.assertEquals(VirtualNetworkPeeringState.CONNECTED, localPeering.state());
    Assert.assertTrue(localPeering.isTrafficForwardingFromRemoteNetworkAllowed());
    Assert.assertFalse(localPeering.checkAccessBetweenNetworks());
    Assert.assertEquals(NetworkPeeringGatewayUse.BY_REMOTE_NETWORK, localPeering.gatewayUse());

    // Verify remote peering
    Assert.assertNotNull(remoteNetwork.peerings());
    Assert.assertEquals(1, remoteNetwork.peerings().list().size());
    NetworkPeering remotePeering = localPeering.getRemotePeering();
    Assert.assertNotNull(remotePeering);
    Assert.assertTrue(remotePeering.remoteNetworkId().equalsIgnoreCase(localNetwork.id()));
    Assert.assertEquals(VirtualNetworkPeeringState.CONNECTED, remotePeering.state());
    Assert.assertTrue(remotePeering.isTrafficForwardingFromRemoteNetworkAllowed());
    Assert.assertFalse(remotePeering.checkAccessBetweenNetworks());
    Assert.assertEquals(NetworkPeeringGatewayUse.NONE, remotePeering.gatewayUse());

    return localNetwork;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:62,
代码来源:TestNetwork.java

示例7: updateResource

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public Network updateResource(Network resource) throws Exception {
    NetworkPeering localPeering = resource.peerings().list().get(0);

    // Verify remote IP invisibility to local network before peering
    Network remoteNetwork = localPeering.getRemoteNetwork();
    Assert.assertNotNull(remoteNetwork);
    Subnet remoteSubnet = remoteNetwork.subnets().get("subnet3");
    Assert.assertNotNull(remoteSubnet);
    Set<String> remoteAvailableIPs = remoteSubnet.listAvailablePrivateIPAddresses();
    Assert.assertNotNull(remoteAvailableIPs);
    Assert.assertFalse(remoteAvailableIPs.isEmpty());
    String remoteTestIP = remoteAvailableIPs.iterator().next();
    Assert.assertFalse(resource.isPrivateIPAddressAvailable(remoteTestIP));

    localPeering.update()
        .withoutTrafficForwardingFromEitherNetwork()
        .withAccessBetweenBothNetworks()
        .withoutAnyGatewayUse()
        .apply();

    // Verify local peering changes
    Assert.assertFalse(localPeering.isTrafficForwardingFromRemoteNetworkAllowed());
    Assert.assertTrue(localPeering.checkAccessBetweenNetworks());
    Assert.assertEquals(NetworkPeeringGatewayUse.NONE, localPeering.gatewayUse());

    // Verify remote peering changes
    NetworkPeering remotePeering = localPeering.getRemotePeering();
    Assert.assertNotNull(remotePeering);
    Assert.assertFalse(remotePeering.isTrafficForwardingFromRemoteNetworkAllowed());
    Assert.assertTrue(remotePeering.checkAccessBetweenNetworks());
    Assert.assertEquals(NetworkPeeringGatewayUse.NONE, remotePeering.gatewayUse());

    // Delete the peering
    resource.peerings().deleteById(remotePeering.id());

    // Verify deletion
    Assert.assertEquals(0, resource.peerings().list().size());
    Assert.assertEquals(0, remoteNetwork.peerings().list().size());

    return resource;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:43,
代码来源:TestNetwork.java

示例8: printNetwork

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
/**
 * 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
        NetworkSecurityGroup nsg = subnet.getNetworkSecurityGroup();
        if (nsg != null) {
            info.append("\n\tNetwork security group ID: ").append(nsg.id());
        }

        // Show associated route table
        RouteTable routeTable = subnet.getRouteTable();
        if (routeTable != null) {
            info.append("\n\tRoute table ID: ").append(routeTable.id());
        }
    }

    // Output peerings
    for (NetworkPeering peering : resource.peerings().list()) {
        info.append("\n\tPeering: ").append(peering.name())
            .append("\n\t\tRemote network ID: ").append(peering.remoteNetworkId())
            .append("\n\t\tPeering state: ").append(peering.state())
            .append("\n\t\tIs traffic forwarded from remote network allowed? ").append(peering.isTrafficForwardingFromRemoteNetworkAllowed())
            //TODO .append("\n\t\tIs access from remote network allowed? ").append(peering.isAccessBetweenNetworksAllowed())
            .append("\n\t\tGateway use: ").append(peering.gatewayUse());
    }

    System.out.println(info.toString());
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:45,
代码来源:TestNetwork.java

示例9: deleteByParentAsync

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public Completable deleteByParentAsync(String groupName, String parentName, final String name) {
    return this.manager().networks()
        // Get the parent network of the peering to delete
        .getByResourceGroupAsync(groupName, parentName)

        // Then find the local peering to delete
        .flatMap(new Func1<Network, Observable<NetworkPeering>>() {
            @Override
            public Observable<NetworkPeering> call(Network localNetwork) {
                if (localNetwork == null) {
                    return Observable.just(null); // Missing local network, so nothing else to do
                } else {
                    String peeringId = localNetwork.id() + "/peerings/" + name;
                    return localNetwork.peerings().getByIdAsync(peeringId);
                }
            }
        })

        // Then get the remote peering if available and possible to delete
        .flatMap(new Func1<NetworkPeering, Observable<NetworkPeering>>() {
            @Override
            public Observable<NetworkPeering> call(NetworkPeering localPeering) {
                if (localPeering == null) {
                    return Observable.just(localPeering);
                } else if (!localPeering.isSameSubscription()) {
                    return Observable.just(localPeering);
                } else {
                    return Observable.just(localPeering).concatWith(localPeering.getRemotePeeringAsync());
                }
            }
        })

        // Then delete each peering (this will be called for each of the peerings, so at least once for the local peering, and second time for the remote one if any
        .flatMap(new Func1<NetworkPeering, Observable<Void>>() {
            @Override
            public Observable<Void> call(NetworkPeering peering) {
                if (peering == null) {
                    return Observable.just(null);
                } else {
                    String networkName = ResourceUtils.nameFromResourceId(peering.networkId());
                    return peering.manager().inner().virtualNetworkPeerings().deleteAsync(
                            peering.resourceGroupName(),
                            networkName,
                            peering.name());
                }
            }
        })

        // Then continue till the last peering is deleted
        .last()
        .toCompletable();
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:54,
代码来源:NetworkPeeringsImpl.java

示例10: listByParent

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public PagedList<NetworkPeering> listByParent(String resourceGroupName, String parentName) {
    return wrapList(this.inner().list(resourceGroupName, parentName));
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:5,
代码来源:NetworkPeeringsImpl.java

示例11: list

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public PagedList<NetworkPeering> list() {
    return this.wrapList(this.inner().list(this.network.resourceGroupName(), this.network.name()));
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:5,
代码来源:NetworkPeeringsImpl.java

示例12: listAsync

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public Observable<NetworkPeering> listAsync() {
    return this.wrapPageAsync(this.inner().listAsync(this.network.resourceGroupName(), this.network.name()));
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:5,
代码来源:NetworkPeeringsImpl.java

示例13: getRemotePeering

点赞 2

import com.microsoft.azure.management.network.NetworkPeering; //导入依赖的package包/类
@Override
public NetworkPeering getRemotePeering() {
    Network network = this.getRemoteNetwork();
    return (network != null) ? network.peerings().getByRemoteNetwork(this.networkId()) : null;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:6,
代码来源:NetworkPeeringImpl.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)