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


Java RouterService类代码示例

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


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

示例1: execute

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@Override
protected void execute() {
    RouterService service = get(RouterService.class);
    try {
        List<String> routes = new ArrayList<String>();
        Router router = new DefaultRouter(
                                          RouterId.valueOf(id),
                                          routerName,
                                          adminStateUp,
                                          status == null ? Status.ACTIVE
                                                        : Status.valueOf(status),
                                          distributed,
                                          null,
                                          VirtualPortId.portId(gatewayPortId),
                                          TenantId.tenantId(tenantId),
                                          routes);
        Set<Router> routerSet = Sets.newHashSet(router);
        service.createRouters(routerSet);
    } catch (Exception e) {
        print(null, e.getMessage());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:RouterCreateCommand.java

示例2: execute

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@Override
protected void execute() {
    RouterService service = get(RouterService.class);
    RouterId routerId = RouterId.valueOf(id);
    Router router = get(RouterService.class).getRouter(routerId);
    try {
        List<String> routes = new ArrayList<String>();
        Router routerObj = new DefaultRouter(
                                             RouterId.valueOf(id),
                                             routerName == null ? router.name() : routerName,
                                             adminStateUp,
                                             status == null ? Status.ACTIVE
                                                           : Status.valueOf(status),
                                             distributed,
                                             null,
                                             gatewayPortId == null ? router.gatewayPortid()
                                                                  : VirtualPortId.portId(gatewayPortId),
                                             tenantId == null ? router.tenantId()
                                                              : TenantId.tenantId(tenantId),
                                             routes);
        Set<Router> routerSet = Sets.newHashSet(routerObj);
        service.createRouters(routerSet);
    } catch (Exception e) {
        print(null, e.getMessage());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:RouterUpdateCommand.java

示例3: getRouter

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@GET
@Path("{routerUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getRouter(@PathParam("routerUUID") String id,
                          @QueryParam("fields") List<String> fields) {

    if (!get(RouterService.class).exists(RouterId.valueOf(id))) {
        return Response.status(NOT_FOUND)
                .entity("The Router does not exists").build();
    }
    Router sub = nullIsNotFound(get(RouterService.class)
            .getRouter(RouterId.valueOf(id)), NOT_EXIST);

    ObjectNode result = new ObjectMapper().createObjectNode();
    if (fields.size() > 0) {
        result.set("router",
                   new RouterCodec().extracFields(sub, this, fields));
    } else {
        result.set("router", new RouterCodec().encode(sub, this));
    }
    return ok(result.toString()).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:RouterWebResource.java

示例4: createRouter

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response createRouter(final InputStream input) {
    try {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode subnode = mapper.readTree(input);
        Collection<Router> routers = createOrUpdateByInputStream(subnode);

        Boolean result = nullIsNotFound((get(RouterService.class)
                .createRouters(routers)), CREATE_FAIL);
        if (!result) {
            return Response.status(CONFLICT).entity(CREATE_FAIL).build();
        }
        return Response.status(CREATED).entity(result.toString()).build();

    } catch (Exception e) {
        return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:RouterWebResource.java

示例5: updateRouter

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@PUT
@Path("{routerUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response updateRouter(@PathParam("routerUUID") String id,
                             final InputStream input) {
    try {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode subnode = mapper.readTree(input);
        Collection<Router> routers = changeUpdateJsonToSub(subnode, id);
        Boolean result = nullIsNotFound(get(RouterService.class)
                .updateRouters(routers), UPDATE_FAIL);
        if (!result) {
            return Response.status(CONFLICT).entity(UPDATE_FAIL).build();
        }
        return ok(result.toString()).build();
    } catch (Exception e) {
        return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:RouterWebResource.java

示例6: getRouter

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@GET
@Path("{routerUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getRouter(@PathParam("routerUUID") String id,
                          @QueryParam("fields") List<String> fields) {

    if (!get(RouterService.class).exists(RouterId.valueOf(id))) {
        return Response.status(NOT_FOUND)
                .entity("The Router does not exists").build();
    }
    Router sub = nullIsNotFound(get(RouterService.class)
            .getRouter(RouterId.valueOf(id)), NOT_EXIST);

    ObjectNode result = new ObjectMapper().createObjectNode();
    if (!fields.isEmpty()) {
        result.set("router",
                   new RouterCodec().extracFields(sub, this, fields));
    } else {
        result.set("router", new RouterCodec().encode(sub, this));
    }
    return ok(result.toString()).build();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:RouterWebResource.java

示例7: createRouter

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response createRouter(final InputStream input) {
    try {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode subnode = mapper.readTree(input);
        Collection<Router> routers = createOrUpdateByInputStream(subnode);

        Boolean result = nullIsNotFound((get(RouterService.class)
                .createRouters(routers)), CREATE_FAIL);
        if (!result) {
            return Response.status(CONFLICT).entity(CREATE_FAIL).build();
        }
        return Response.status(CREATED).entity(result.toString()).build();

    } catch (IllegalArgumentException | IOException e) {
        return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:21,代码来源:RouterWebResource.java

示例8: execute

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@Override
protected void execute() {
    RouterService service = get(RouterService.class);
    if (id == null && routerName == null) {
        print(null, "one of id, routerName should not be null");
    }
    try {
        Set<RouterId> routerSet = Sets.newHashSet();
        if (id != null) {
            routerSet.add(RouterId.valueOf(id));
            service.removeRouters(routerSet);
        } else {
            Iterable<Router> routers = service.getRouters();
            if (routers == null) {
                return;
            }
            for (Router router : routers) {
                if (router.name().equals(routerName)) {
                    routerSet.add(router.id());
                    service.removeRouters(routerSet);
                    return;
                }
            }
        }
    } catch (Exception e) {
        print(null, e.getMessage());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:RouterRemoveCommand.java

示例9: listRouters

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response listRouters() {
    Collection<Router> routers = get(RouterService.class).getRouters();
    ObjectNode result = new ObjectMapper().createObjectNode();
    result.set("routers", new RouterCodec().encode(routers, this));
    return ok(result.toString()).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:RouterWebResource.java

示例10: deleteSingleRouter

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@DELETE
@Path("{routerUUID}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteSingleRouter(@PathParam("routerUUID") String id)
        throws IOException {
    try {
        RouterId routerId = RouterId.valueOf(id);
        Set<RouterId> routerIds = Sets.newHashSet(routerId);
        get(RouterService.class).removeRouters(routerIds);
        return Response.noContent().entity(DELETE_SUCCESS).build();
    } catch (Exception e) {
        return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:RouterWebResource.java

示例11: addRouterInterface

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@PUT
@Path("{routerUUID}/add_router_interface")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response addRouterInterface(@PathParam("routerUUID") String id,
                                   final InputStream input) {
    if (!get(RouterService.class).exists(RouterId.valueOf(id))) {
        return Response.status(NOT_FOUND).entity(NOT_EXIST).build();
    }
    try {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode subnode = mapper.readTree(input);
        if (!subnode.hasNonNull("id")) {
            throw new IllegalArgumentException("id should not be null");
        } else if (subnode.get("id").asText().isEmpty()) {
            throw new IllegalArgumentException("id should not be empty");
        }
        RouterId routerId = RouterId.valueOf(id);
        if (!subnode.hasNonNull("subnet_id")) {
            throw new IllegalArgumentException("subnet_id should not be null");
        } else if (subnode.get("subnet_id").asText().isEmpty()) {
            throw new IllegalArgumentException("subnet_id should not be empty");
        }
        SubnetId subnetId = SubnetId
                .subnetId(subnode.get("subnet_id").asText());
        if (!subnode.hasNonNull("tenant_id")) {
            throw new IllegalArgumentException("tenant_id should not be null");
        } else if (subnode.get("tenant_id").asText().isEmpty()) {
            throw new IllegalArgumentException("tenant_id should not be empty");
        }
        TenantId tenentId = TenantId
                .tenantId(subnode.get("tenant_id").asText());
        if (!subnode.hasNonNull("port_id")) {
            throw new IllegalArgumentException("port_id should not be null");
        } else if (subnode.get("port_id").asText().isEmpty()) {
            throw new IllegalArgumentException("port_id should not be empty");
        }
        VirtualPortId portId = VirtualPortId
                .portId(subnode.get("port_id").asText());
        RouterInterface routerInterface = RouterInterface
                .routerInterface(subnetId, portId, routerId, tenentId);
        get(RouterInterfaceService.class)
                .addRouterInterface(routerInterface);
        return ok(INTFACR_ADD_SUCCESS).build();
    } catch (Exception e) {
        return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:49,代码来源:RouterWebResource.java

示例12: removeRouterInterface

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
@PUT
@Path("{routerUUID}/remove_router_interface")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response removeRouterInterface(@PathParam("routerUUID") String id,
                                      final InputStream input) {
    if (!get(RouterService.class).exists(RouterId.valueOf(id))) {
        return Response.status(NOT_FOUND).entity(NOT_EXIST).build();
    }
    try {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode subnode = mapper.readTree(input);
        if (!subnode.hasNonNull("id")) {
            throw new IllegalArgumentException("id should not be null");
        } else if (subnode.get("id").asText().isEmpty()) {
            throw new IllegalArgumentException("id should not be empty");
        }
        RouterId routerId = RouterId.valueOf(id);
        if (!subnode.hasNonNull("subnet_id")) {
            throw new IllegalArgumentException("subnet_id should not be null");
        } else if (subnode.get("subnet_id").asText().isEmpty()) {
            throw new IllegalArgumentException("subnet_id should not be empty");
        }
        SubnetId subnetId = SubnetId
                .subnetId(subnode.get("subnet_id").asText());
        if (!subnode.hasNonNull("port_id")) {
            throw new IllegalArgumentException("port_id should not be null");
        } else if (subnode.get("port_id").asText().isEmpty()) {
            throw new IllegalArgumentException("port_id should not be empty");
        }
        VirtualPortId portId = VirtualPortId
                .portId(subnode.get("port_id").asText());
        if (!subnode.hasNonNull("tenant_id")) {
            throw new IllegalArgumentException("tenant_id should not be null");
        } else if (subnode.get("tenant_id").asText().isEmpty()) {
            throw new IllegalArgumentException("tenant_id should not be empty");
        }
        TenantId tenentId = TenantId
                .tenantId(subnode.get("tenant_id").asText());
        RouterInterface routerInterface = RouterInterface
                .routerInterface(subnetId, portId, routerId, tenentId);
        get(RouterInterfaceService.class)
                .removeRouterInterface(routerInterface);
        return ok(INTFACR_DEL_SUCCESS).build();
    } catch (Exception e) {
        return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:49,代码来源:RouterWebResource.java

示例13: changeUpdateJsonToSub

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
/**
 * Returns a collection of floatingIps from floatingIpNodes.
 *
 * @param subnode the router json node
 * @param routerId the router identify
 * @return routers a collection of router
 * @throws Exception when any argument is illegal
 */
public Collection<Router> changeUpdateJsonToSub(JsonNode subnode,
                                                String routerId)
                                                        throws Exception {
    checkNotNull(subnode, JSON_NOT_NULL);
    checkNotNull(routerId, "routerId should not be null");
    Map<RouterId, Router> subMap = new HashMap<RouterId, Router>();
    JsonNode routerNode = subnode.get("router");
    RouterId id = RouterId.valueOf(routerId);
    Router sub = nullIsNotFound(get(RouterService.class).getRouter(id),
                                NOT_EXIST);
    TenantId tenantId = sub.tenantId();

    VirtualPortId gwPortId = null;
    if (routerNode.hasNonNull("gw_port_id")) {
        gwPortId = VirtualPortId
                .portId(routerNode.get("gw_port_id").asText());
    }
    Status status = sub.status();

    String routerName = routerNode.get("name").asText();

    checkArgument(routerNode.get("admin_state_up").isBoolean(),
                  "admin_state_up should be boolean");
    boolean adminStateUp = routerNode.get("admin_state_up").asBoolean();

    boolean distributed = sub.distributed();
    if (routerNode.hasNonNull("distributed")) {
        distributed = routerNode.get("distributed").asBoolean();
    }
    RouterGateway gateway = sub.externalGatewayInfo();
    if (routerNode.hasNonNull("external_gateway_info")) {
        gateway = jsonNodeToGateway(routerNode
                .get("external_gateway_info"));
    }
    List<String> routes = new ArrayList<String>();
    DefaultRouter routerObj = new DefaultRouter(id, routerName,
                                                adminStateUp, status,
                                                distributed, gateway,
                                                gwPortId, tenantId, routes);
    subMap.put(id, routerObj);
    return Collections.unmodifiableCollection(subMap.values());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:51,代码来源:RouterWebResource.java

示例14: changeUpdateJsonToSub

import org.onosproject.vtnrsc.router.RouterService; //导入依赖的package包/类
/**
 * Returns a collection of floatingIps from floatingIpNodes.
 *
 * @param subnode the router json node
 * @param routerId the router identify
 * @return routers a collection of router
 */
public Collection<Router> changeUpdateJsonToSub(JsonNode subnode,
                                                String routerId) {
    checkNotNull(subnode, JSON_NOT_NULL);
    checkNotNull(routerId, "routerId should not be null");
    Map<RouterId, Router> subMap = new HashMap<RouterId, Router>();
    JsonNode routerNode = subnode.get("router");
    RouterId id = RouterId.valueOf(routerId);
    Router sub = nullIsNotFound(get(RouterService.class).getRouter(id),
                                NOT_EXIST);
    TenantId tenantId = sub.tenantId();

    VirtualPortId gwPortId = null;
    if (routerNode.hasNonNull("gw_port_id")) {
        gwPortId = VirtualPortId
                .portId(routerNode.get("gw_port_id").asText());
    }
    Status status = sub.status();

    String routerName = routerNode.get("name").asText();

    checkArgument(routerNode.get("admin_state_up").isBoolean(),
                  "admin_state_up should be boolean");
    boolean adminStateUp = routerNode.get("admin_state_up").asBoolean();

    boolean distributed = sub.distributed();
    if (routerNode.hasNonNull("distributed")) {
        distributed = routerNode.get("distributed").asBoolean();
    }
    RouterGateway gateway = sub.externalGatewayInfo();
    if (routerNode.hasNonNull("external_gateway_info")) {
        gateway = jsonNodeToGateway(routerNode
                .get("external_gateway_info"));
    }
    List<String> routes = new ArrayList<String>();
    DefaultRouter routerObj = new DefaultRouter(id, routerName,
                                                adminStateUp, status,
                                                distributed, gateway,
                                                gwPortId, tenantId, routes);
    subMap.put(id, routerObj);
    return Collections.unmodifiableCollection(subMap.values());
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:49,代码来源:RouterWebResource.java


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