当前位置: 首页>>代码示例>>Java>>正文


Java Network类代码示例

本文整理汇总了Java中org.jclouds.openstack.neutron.v2.domain.Network的典型用法代码示例。如果您正苦于以下问题:Java Network类的具体用法?Java Network怎么用?Java Network使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Network类属于org.jclouds.openstack.neutron.v2.domain包,在下文中一共展示了Network类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findNetworkByName

import org.jclouds.openstack.neutron.v2.domain.Network; //导入依赖的package包/类
public static Network findNetworkByName(NetworkApi networkApi, String networkName, boolean external) {
    for (IterableWithMarker<Network> networkIterator : networkApi.list()) {
        Optional<Network> optNet = networkIterator.firstMatch(input -> input.getName().equals(networkName) && (external == (input.getExternal() != null && input.getExternal())));
        if (optNet.isPresent()) {
            return optNet.get();
        }
    }
    return null;
}
 
开发者ID:vuminhkh,项目名称:tosca-runtime,代码行数:10,代码来源:NetworkUtil.java

示例2: getNetworkIdByName

import org.jclouds.openstack.neutron.v2.domain.Network; //导入依赖的package包/类
private String getNetworkIdByName(String networkName) {
	if(neutronApi == null){
		init();
	}
	Iterator<Network> netIterator = neutronApi.getNetworkApi(DEFAULT_REGION).list().concat().iterator();

	while(netIterator.hasNext()){
	Network net = netIterator.next();
	if(net.getName().equals(networkName)){
		return net.getId();
	}
	}
	
	return "NO NETWORK FOUND";
}
 
开发者ID:FITeagle,项目名称:adapters,代码行数:16,代码来源:OpenstackClient.java

示例3: createNetwork

import org.jclouds.openstack.neutron.v2.domain.Network; //导入依赖的package包/类
private void createNetwork() {
   NetworkApi networkApi = neutronApi.getNetworkApi(REGION);
   Network net = null;
   try {
      net = networkApi.create(Network.createBuilder("jclouds-test").build());
   } finally {
      // Cleanup
      if (net != null) {
         networkApi.delete(net.getId());
      }
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:13,代码来源:CreateNetwork.java

示例4: createSubnet

import org.jclouds.openstack.neutron.v2.domain.Network; //导入依赖的package包/类
private void createSubnet() {
   NetworkApi networkApi = neutronApi.getNetworkApi(REGION);
   SubnetApi subnetApi = neutronApi.getSubnetApi(REGION);
   Network net = null;
   Subnet subnet = null;
   try {
      // Create a network first. The subnet will be created on the network.
      net = networkApi.create(Network.createBuilder("jclouds-test").build());

      // Assigns an allocation pool to the subnet
      ImmutableSet<AllocationPool> allocationPools = ImmutableSet.of(
            AllocationPool.builder().start("a3:bc00::10").end("a3:bc00::20").build(),
            AllocationPool.builder().start("a3:bc00::50").end("a3:bc00::90").build()
      );

      // Takes care of routing
      ImmutableSet<HostRoute> hostRoutes = ImmutableSet.of(
            HostRoute.builder().destinationCidr("a3:bc00::/48").nextHop("a3:bc00::0004").build()
      );

      subnet = subnetApi.create(Subnet.createBuilder(net.getId(), "a3:bc00::/48").ipVersion(6).allocationPools(allocationPools).hostRoutes(hostRoutes).build());

   } finally {
      // Cleanup
      if (subnet != null) {
         subnetApi.delete(subnet.getId());
      }
      if (net != null) {
         networkApi.delete(net.getId());
      }
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:33,代码来源:CreateSubnet.java

示例5: createPort

import org.jclouds.openstack.neutron.v2.domain.Network; //导入依赖的package包/类
private void createPort() {
   NetworkApi networkApi = neutronApi.getNetworkApi(REGION);
   SubnetApi subnetApi = neutronApi.getSubnetApi(REGION);
   PortApi portApi = neutronApi.getPortApi(REGION);

   Network net = null;
   Subnet subnet = null;
   Port port = null;

   try {
      // Create a network first. The subnet will be created on the network.
      net = networkApi.create(Network.createBuilder("jclouds-test").build());

      subnet = subnetApi.create(
            Subnet.createBuilder(net.getId(), "192.168.0.0/30").ipVersion(4)
                  .name("JClouds-Live-IPv4-Subnet").build()
      );

      port = portApi.create(
            Port.createBuilder(net.getId()).name("JClouds-Live-IPv4-Port")
                  .fixedIps( ImmutableSet.of(IP.builder().subnetId(subnet.getId()).build() )).build()
      );

   } finally {
      // Cleanup
      if (port != null) {
         portApi.delete(port.getId());
      }
      if (subnet != null) {
         subnetApi.delete(subnet.getId());
      }
      if (net != null) {
         networkApi.delete(net.getId());
      }
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:37,代码来源:CreatePort.java


注:本文中的org.jclouds.openstack.neutron.v2.domain.Network类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。