本文整理汇总了Java中org.onosproject.vtnrsc.subnet.SubnetService类的典型用法代码示例。如果您正苦于以下问题:Java SubnetService类的具体用法?Java SubnetService怎么用?Java SubnetService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubnetService类属于org.onosproject.vtnrsc.subnet包,在下文中一共展示了SubnetService类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.onosproject.vtnrsc.subnet.SubnetService; //导入依赖的package包/类
@Override
protected void execute() {
SubnetService service = get(SubnetService.class);
if (id == null || networkId == null || tenantId == null) {
print("id,networkId,tenantId can not be null");
return;
}
Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
TenantNetworkId.networkId(networkId),
TenantId.tenantId(tenantId), ipVersion,
cidr == null ? null : IpPrefix.valueOf(cidr),
gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
dhcpEnabled, shared, hostRoutes,
ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
allocationPools);
Set<Subnet> subnetsSet = Sets.newHashSet(subnet);
service.createSubnets(subnetsSet);
}
示例2: execute
import org.onosproject.vtnrsc.subnet.SubnetService; //导入依赖的package包/类
@Override
protected void execute() {
SubnetService service = get(SubnetService.class);
if (id == null || networkId == null || tenantId == null) {
print("id,networkId,tenantId can not be null");
return;
}
Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
TenantNetworkId.networkId(networkId),
TenantId.tenantId(tenantId), ipVersion,
cidr == null ? null : IpPrefix.valueOf(cidr),
gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
dhcpEnabled, shared, hostRoutes,
ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
allocationPools);
Set<Subnet> subnetsSet = Sets.newHashSet();
subnetsSet.add(subnet);
service.updateSubnets(subnetsSet);
}
示例3: getSubnet
import org.onosproject.vtnrsc.subnet.SubnetService; //导入依赖的package包/类
@GET
@Path("{subnetUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getSubnet(@PathParam("subnetUUID") String id) {
if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {
return Response.status(NOT_FOUND)
.entity(SUBNET_NOT_FOUND).build();
}
Subnet sub = nullIsNotFound(get(SubnetService.class)
.getSubnet(SubnetId.subnetId(id)),
SUBNET_NOT_FOUND);
ObjectNode result = new ObjectMapper().createObjectNode();
result.set("subnet", new SubnetCodec().encode(sub, this));
return ok(result.toString()).build();
}
示例4: createSubnet
import org.onosproject.vtnrsc.subnet.SubnetService; //导入依赖的package包/类
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response createSubnet(final InputStream input) {
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode subnode = mapper.readTree(input);
Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
Boolean result = nullIsNotFound((get(SubnetService.class)
.createSubnets(subnets)),
SUBNET_NOT_CREATED);
if (!result) {
return Response.status(INTERNAL_SERVER_ERROR)
.entity(SUBNET_NOT_CREATED).build();
}
return Response.status(202).entity(result.toString()).build();
} catch (Exception e) {
return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
.build();
}
}
示例5: updateSubnet
import org.onosproject.vtnrsc.subnet.SubnetService; //导入依赖的package包/类
@PUT
@Path("{subnetUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response updateSubnet(@PathParam("id") String id,
final InputStream input) {
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode subnode = mapper.readTree(input);
Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
Boolean result = nullIsNotFound(get(SubnetService.class)
.updateSubnets(subnets), SUBNET_NOT_FOUND);
if (!result) {
return Response.status(INTERNAL_SERVER_ERROR)
.entity(SUBNET_NOT_FOUND).build();
}
return Response.status(203).entity(result.toString()).build();
} catch (Exception e) {
return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
.build();
}
}
示例6: deleteSingleSubnet
import org.onosproject.vtnrsc.subnet.SubnetService; //导入依赖的package包/类
@DELETE
@Path("{subnetUUID}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteSingleSubnet(@PathParam("subnetUUID") String id)
throws IOException {
try {
SubnetId subId = SubnetId.subnetId(id);
Set<SubnetId> subIds = new HashSet<>();
subIds.add(subId);
get(SubnetService.class).removeSubnets(subIds);
return Response.noContent().entity("SUCCESS").build();
} catch (Exception e) {
return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
.build();
}
}
示例7: execute
import org.onosproject.vtnrsc.subnet.SubnetService; //导入依赖的package包/类
@Override
protected void execute() {
SubnetService service = get(SubnetService.class);
Set<SubnetId> subnetsSet = Sets.newHashSet();
subnetsSet.add(SubnetId.subnetId(id));
service.removeSubnets(subnetsSet);
}
示例8: execute
import org.onosproject.vtnrsc.subnet.SubnetService; //导入依赖的package包/类
@Override
protected void execute() {
VirtualPortService service = get(VirtualPortService.class);
SubnetService subnetService = get(SubnetService.class);
TenantNetworkService tenantNetworkService = get(TenantNetworkService.class);
Iterable<TenantNetwork> networks = tenantNetworkService.getNetworks();
if (networks != null) {
for (TenantNetwork network : networks) {
if (network.routerExternal()) {
Iterable<Subnet> subnets = subnetService.getSubnets();
if (subnets != null) {
for (Subnet subnet : subnets) {
if (network.id().networkId().equals(subnet.networkId().networkId())) {
IpAddress exgwip = subnet.gatewayIp();
FixedIp fixedGwIp = FixedIp.fixedIp(subnet.id(), exgwip);
VirtualPort exgwPort = service.getPort(fixedGwIp);
if (exgwPort == null) {
createExGwPort(network, subnet, fixedGwIp);
} else {
updateExGwPort(exgwPort);
}
}
}
}
}
}
}
}
示例9: listSubnets
import org.onosproject.vtnrsc.subnet.SubnetService; //导入依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response listSubnets() {
Iterable<Subnet> subnets = get(SubnetService.class).getSubnets();
ObjectNode result = new ObjectMapper().createObjectNode();
result.set("subnets", new SubnetCodec().encode(subnets, this));
return ok(result.toString()).build();
}