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


Java RestMessages类代码示例

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


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

示例1: handleNodeAvailability

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
private Node handleNodeAvailability(String containerName, String nodeType,
        String nodeId) {

    Node node = Node.fromString(nodeType, nodeId);
    if (node == null) {
        throw new ResourceNotFoundException(nodeId + " : "
                + RestMessages.NONODE.toString());
    }

    ISwitchManager sm = (ISwitchManager) ServiceHelper.getInstance(
            ISwitchManager.class, containerName, this);

    if (sm == null) {
        throw new ServiceUnavailableException("Switch Manager "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    if (!sm.getNodes().contains(node)) {
        throw new ResourceNotFoundException(node.toString() + " : "
                + RestMessages.NONODE.toString());
    }
    return node;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:24,代码来源:SwitchNorthbound.java

示例2: handleNodeConnectorAvailability

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
private void handleNodeConnectorAvailability(String containerName,
        Node node, String nodeConnectorType, String nodeConnectorId) {

    NodeConnector nc = NodeConnector.fromStringNoNode(nodeConnectorType,
            nodeConnectorId, node);
    if (nc == null) {
        throw new ResourceNotFoundException(nc + " : "
                + RestMessages.NORESOURCE.toString());
    }

    ISwitchManager sm = (ISwitchManager) ServiceHelper.getInstance(
            ISwitchManager.class, containerName, this);

    if (sm == null) {
        throw new ServiceUnavailableException("Switch Manager "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    if (!sm.getNodeConnectors(node).contains(nc)) {
        throw new ResourceNotFoundException(nc.toString() + " : "
                + RestMessages.NORESOURCE.toString());
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:24,代码来源:SwitchNorthbound.java

示例3: getStaticRoutesInternal

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
private List<StaticRoute> getStaticRoutesInternal(String containerName) {

        IForwardingStaticRouting staticRouting = (IForwardingStaticRouting) ServiceHelper
                .getInstance(IForwardingStaticRouting.class, containerName,
                        this);

        if (staticRouting == null) {
            throw new ResourceNotFoundException(RestMessages.NOCONTAINER
                    .toString());
        }

        List<StaticRoute> routes = new ArrayList<StaticRoute>();

        for (StaticRouteConfig conf : staticRouting.getStaticRouteConfigs()
                .values()) {
            StaticRoute route = new StaticRoute(conf.getName(), conf
                    .getStaticRoute(), conf.getNextHop());
            routes.add(route);
        }
        return routes;
    }
 
开发者ID:lbchen,项目名称:ODL,代码行数:22,代码来源:StaticRoutingNorthbound.java

示例4: getActiveHosts

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
/**
 * Returns a list of all Hosts : both configured via PUT API and dynamically
 * learnt on the network.
 *
 * @param containerName
 *            Name of the Container. The Container name for the base
 *            controller is "default".
 * @return List of Active Hosts.
 */
@Path("/{containerName}")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(Hosts.class)
@StatusCodes({
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "The containerName is not found"),
        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public Hosts getActiveHosts(@PathParam("containerName") String containerName) {

    if (!NorthboundUtils.isAuthorized(
            getUserName(), containerName, Privilege.READ, this)) {
        throw new UnauthorizedException(
                "User is not authorized to perform this operation on container "
                        + containerName);
    }
    IfIptoHost hostTracker = getIfIpToHostService(containerName);
    if (hostTracker == null) {
        throw new ServiceUnavailableException("Host Tracker "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return new Hosts(hostTracker.getAllHosts());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:34,代码来源:HostTrackerNorthbound.java

示例5: getInactiveHosts

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
/**
 * Returns a list of Hosts that are statically configured and are connected
 * to a NodeConnector that is down.
 *
 * @param containerName
 *            Name of the Container. The Container name for the base
 *            controller is "default".
 * @return List of inactive Hosts.
 */
@Path("/{containerName}/inactive")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(Hosts.class)
@StatusCodes({
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "The containerName is not found"),
        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public Hosts getInactiveHosts(
        @PathParam("containerName") String containerName) {
    if (!NorthboundUtils.isAuthorized(
            getUserName(), containerName, Privilege.READ, this)) {
        throw new UnauthorizedException(
                "User is not authorized to perform this operation on container "
                        + containerName);
    }
    IfIptoHost hostTracker = getIfIpToHostService(containerName);
    if (hostTracker == null) {
        throw new ServiceUnavailableException("Host Tracker "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return new Hosts(hostTracker.getInactiveStaticHosts());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:34,代码来源:HostTrackerNorthbound.java

示例6: getAllPools

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
@Path("/{containerName}")
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(Pools.class)
@StatusCodes( {
    @ResponseCode(code = 200, condition = "Operation successful"),
    @ResponseCode(code = 404, condition = "The containerName is not found"),
    @ResponseCode(code = 503, condition = "Load balancer service is unavailable") })
public Pools getAllPools(
        @PathParam("containerName") String containerName) {

    IConfigManager configManager = getConfigManagerService(containerName);
    if (configManager == null) {
        throw new ServiceUnavailableException("Load Balancer "
                                                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return new Pools(configManager.getAllPools());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:20,代码来源:LoadBalancerNorthbound.java

示例7: getAllVIPs

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
@Path("/{containerName}/vips")
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(VIPs.class)
@StatusCodes( {
    @ResponseCode(code = 200, condition = "Operation successful"),
    @ResponseCode(code = 404, condition = "The containerName is not found"),
    @ResponseCode(code = 503, condition = "Load balancer service is unavailable") })
public VIPs getAllVIPs(
        @PathParam("containerName") String containerName) {

    IConfigManager configManager = getConfigManagerService(containerName);
    if (configManager == null) {
        throw new ServiceUnavailableException("Load Balancer "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return new VIPs(configManager.getAllVIPs());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:20,代码来源:LoadBalancerNorthbound.java

示例8: getIfSwitchManagerService

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
private ISwitchManager getIfSwitchManagerService(String containerName) {
    IContainerManager containerManager = (IContainerManager) ServiceHelper
            .getGlobalInstance(IContainerManager.class, this);
    if (containerManager == null) {
        throw new ServiceUnavailableException("Container "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    boolean found = false;
    List<String> containerNames = containerManager.getContainerNames();
    for (String cName : containerNames) {
        if (cName.trim().equalsIgnoreCase(containerName.trim())) {
            found = true;
            break;
        }
    }

    if (found == false) {
        throw new ResourceNotFoundException(containerName + " "
                + RestMessages.NOCONTAINER.toString());
    }

    ISwitchManager switchManager = (ISwitchManager) ServiceHelper
            .getInstance(ISwitchManager.class, containerName, this);

    if (switchManager == null) {
        throw new ServiceUnavailableException("Switch Manager "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return switchManager;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:33,代码来源:SwitchNorthbound.java

示例9: deleteNodeProperty

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
/**
 * Delete a property of a node
 *
 * @param containerName
 *            Name of the Container
 * @param nodeType
 *            Type of the node being programmed
 * @param nodeId
 *            Node Identifier as specified by
 *            {@link org.opendaylight.controller.sal.core.Node}
 * @param propertyName
 *            Name of the Property specified by
 *            {@link org.opendaylight.controller.sal.core.Property} and its
 *            extended classes
 * @return Response as dictated by the HTTP Response Status code
 */

@Path("/{containerName}/node/{nodeType}/{nodeId}/property/{propertyName}")
@DELETE
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"),
        @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
public Response deleteNodeProperty(
        @PathParam("containerName") String containerName,
        @PathParam("nodeType") String nodeType,
        @PathParam("nodeId") String nodeId,
        @PathParam("propertyName") String propertyName) {

    if (!NorthboundUtils.isAuthorized(
            getUserName(), containerName, Privilege.WRITE, this)) {
        throw new UnauthorizedException(
                "User is not authorized to perform this operation on container "
                        + containerName);
    }
    handleDefaultDisabled(containerName);

    ISwitchManager switchManager = getIfSwitchManagerService(containerName);
    if (switchManager == null) {
        throw new ServiceUnavailableException("Switch Manager "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    handleNodeAvailability(containerName, nodeType, nodeId);
    Node node = Node.fromString(nodeType, nodeId);
    Status ret = switchManager.removeNodeProp(node, propertyName);
    if (ret.isSuccess()) {
        return Response.ok().build();
    }
    throw new ResourceNotFoundException(ret.getDescription());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:53,代码来源:SwitchNorthbound.java

示例10: saveSwitchConfig

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
/**
 * Save the current switch configurations
 *
 * @param containerName
 *            Name of the Container
 * @return Response as dictated by the HTTP Response Status code
 */
@Path("/{containerName}/switch-config")
@POST
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "The containerName is not found"),
        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public Response saveSwitchConfig(
        @PathParam("containerName") String containerName) {

    if (!NorthboundUtils.isAuthorized(
            getUserName(), containerName, Privilege.WRITE, this)) {
        throw new UnauthorizedException(
                "User is not authorized to perform this operation on container "
                        + containerName);
    }
    ISwitchManager switchManager = getIfSwitchManagerService(containerName);
    if (switchManager == null) {
        throw new ServiceUnavailableException("Switch Manager "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    Status ret = switchManager.saveSwitchConfig();
    if (ret.isSuccess()) {
        return Response.ok().build();
    }
    throw new InternalServerErrorException(ret.getDescription());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:36,代码来源:SwitchNorthbound.java

示例11: handleDefaultDisabled

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
private void handleDefaultDisabled(String containerName) {
    IContainerManager containerManager = (IContainerManager) ServiceHelper
            .getGlobalInstance(IContainerManager.class, this);
    if (containerManager == null) {
        throw new InternalServerErrorException(
                RestMessages.INTERNALERROR.toString());
    }
    if (containerName.equals(GlobalConstants.DEFAULT.toString())
            && containerManager.hasNonDefaultContainer()) {
        throw new ResourceConflictException(
                RestMessages.DEFAULTDISABLED.toString());
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:14,代码来源:SwitchNorthbound.java

示例12: getStaticRoute

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
/**
 * Returns the static route for the provided configuration name on a given container
 *
 * @param containerName Name of the Container. The Container name for the base controller is "default".
 * @param name Name of the Static Route configuration
 * @return Static route configured with the supplied Name.
 */
@Path("/{containerName}/{name}")
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(StaticRoute.class)
@StatusCodes( {
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "The Container Name or Static Route Configuration name passed was not found") })
public StaticRoute getStaticRoute(
        @PathParam("containerName") String containerName,
        @PathParam("name") String name) {

    if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
            Privilege.WRITE, this)){
        throw new
            UnauthorizedException("User is not authorized to perform this operation on container "
                        + containerName);
    }
    List<StaticRoute> routes = this.getStaticRoutesInternal(containerName);
    for (StaticRoute route : routes) {
        if (route.getName().equalsIgnoreCase(name)) {
            return route;
        }
    }

    throw new ResourceNotFoundException(RestMessages.NOSTATICROUTE
            .toString());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:35,代码来源:StaticRoutingNorthbound.java

示例13: removeStaticRoute

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
/**
 *
 * Delete a Static Route
 *
 * @param containerName Name of the Container. The Container name for the base controller is "default".
 * @param name Name of the Static Route configuration to be removed
 *
 * @return Response as dictated by the HTTP Response code
 */

@Path("/{containerName}/{name}")
@DELETE
@StatusCodes( {
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "Container Name or Configuration Name not found"),
        @ResponseCode(code = 406, condition = "Cannot operate on Default Container when other Containers are active") })
public Response removeStaticRoute(
        @PathParam(value = "containerName") String containerName,
        @PathParam(value = "name") String name) {

    if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
            Privilege.WRITE, this)){
        throw new
            UnauthorizedException("User is not authorized to perform this operation on container "
                        + containerName);
    }
    handleDefaultDisabled(containerName);

    IForwardingStaticRouting staticRouting = (IForwardingStaticRouting) ServiceHelper
            .getInstance(IForwardingStaticRouting.class, containerName,
                    this);

    if (staticRouting == null) {
        throw new ResourceNotFoundException(RestMessages.NOCONTAINER
                .toString());
    }

    Status status = staticRouting.removeStaticRoute(name);
    if (status.isSuccess()) {
        return Response.ok().build();
    }
    throw new ResourceNotFoundException(status.getDescription());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:44,代码来源:StaticRoutingNorthbound.java

示例14: handleDefaultDisabled

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
private void handleDefaultDisabled(String containerName) {
    IContainerManager containerManager = (IContainerManager) ServiceHelper
            .getGlobalInstance(IContainerManager.class, this);
    if (containerManager == null) {
        throw new InternalServerErrorException(RestMessages.INTERNALERROR
                .toString());
    }
    if (containerName.equals(GlobalConstants.DEFAULT.toString())
            && containerManager.hasNonDefaultContainer()) {
        throw new NotAcceptableException(RestMessages.DEFAULTDISABLED
                .toString());
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:14,代码来源:StaticRoutingNorthbound.java

示例15: getForwardingRulesManagerService

import org.opendaylight.controller.northbound.commons.RestMessages; //导入依赖的package包/类
private IForwardingRulesManager getForwardingRulesManagerService(
        String containerName) {
    IContainerManager containerManager = (IContainerManager) ServiceHelper
            .getGlobalInstance(IContainerManager.class, this);
    if (containerManager == null) {
        throw new ServiceUnavailableException("Container "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    boolean found = false;
    List<String> containerNames = containerManager.getContainerNames();
    for (String cName : containerNames) {
        if (cName.trim().equalsIgnoreCase(containerName.trim())) {
            found = true;
        }
    }

    if (found == false) {
        throw new ResourceNotFoundException(containerName + " "
                + RestMessages.NOCONTAINER.toString());
    }

    IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper
            .getInstance(IForwardingRulesManager.class, containerName, this);

    if (frm == null) {
        throw new ServiceUnavailableException("Flow Programmer "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return frm;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:33,代码来源:FlowProgrammerNorthbound.java


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