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


Java SubnetService类代码示例

本文整理汇总了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);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:SubnetCreateCommand.java

示例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);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:SubnetUpdateCommand.java

示例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();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:SubnetWebResource.java

示例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();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:SubnetWebResource.java

示例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();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:SubnetWebResource.java

示例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();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:SubnetWebResource.java

示例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);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:SubnetRemoveCommand.java

示例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);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:VirtualPortExGwUpdateCommand.java

示例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();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:SubnetWebResource.java


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