本文整理汇总了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;
}
示例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";
}
示例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());
}
}
}
示例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());
}
}
}
示例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());
}
}
}