コード例 #1
0
  @Override
  public JSONRPC2Response process(Map<String, Object> params) {
    JSONRPC2Response resp = null;

    try {
      Integer id = HandlerUtils.<Number>fetchField(FSID, params, true, null).intValue();

      String status = FVConfigurationController.instance().flowSpaceStatus(id);
      resp = new JSONRPC2Response(status, 0);
    } catch (ClassCastException e) {
      resp =
          new JSONRPC2Response(
              new JSONRPC2Error(
                  JSONRPC2Error.INVALID_PARAMS.getCode(), cmdName() + ": " + e.getMessage()),
              0);
    } catch (MissingRequiredField e) {
      resp =
          new JSONRPC2Response(
              new JSONRPC2Error(
                  JSONRPC2Error.INVALID_PARAMS.getCode(), cmdName() + ": " + e.getMessage()),
              0);
    } catch (NullPointerException e) {
      e.printStackTrace();
    }
    return resp;
  }
コード例 #2
0
  @Override
  public JSONRPC2Response process(final Map<String, Object> params) {
    try {

      final Number tid =
          HandlerUtils.<Number>fetchField(MonitoringHandler.TENANT, params, true, null);
      final Number dpid =
          HandlerUtils.<Number>fetchField(MonitoringHandler.VDPID, params, false, -1);
      final OVXMap map = OVXMap.getInstance();
      final LinkedList<Map<String, Object>> flows = new LinkedList<Map<String, Object>>();
      if (dpid.longValue() == -1) {
        HashMap<String, Object> res = new HashMap<String, Object>();
        for (OVXSwitch vsw : map.getVirtualNetwork(tid.intValue()).getSwitches()) {
          flows.clear();
          final Collection<OVXFlowMod> fms = vsw.getFlowTable().getFlowTable();
          for (final OVXFlowMod flow : fms) {
            final Map<String, Object> entry = flow.toMap();
            flows.add(entry);
          }
          res.put(vsw.getSwitchName(), flows.clone());
        }
        this.resp = new JSONRPC2Response(res, 0);
      } else {

        final OVXSwitch vsw = map.getVirtualNetwork(tid.intValue()).getSwitch(dpid.longValue());
        final Collection<OVXFlowMod> fms = vsw.getFlowTable().getFlowTable();
        for (final OVXFlowMod flow : fms) {
          final Map<String, Object> entry = flow.toMap();
          flows.add(entry);
        }
        this.resp = new JSONRPC2Response(flows, 0);
      }

    } catch (ClassCastException | MissingRequiredField e) {
      this.resp =
          new JSONRPC2Response(
              new JSONRPC2Error(
                  JSONRPC2Error.INVALID_PARAMS.getCode(),
                  this.cmdName() + ": Unable to fetch virtual topology : " + e.getMessage()),
              0);
    } catch (final InvalidDPIDException e) {
      this.resp =
          new JSONRPC2Response(
              new JSONRPC2Error(
                  JSONRPC2Error.INVALID_PARAMS.getCode(),
                  this.cmdName() + ": Unable to fetch virtual topology : " + e.getMessage()),
              0);
    } catch (NetworkMappingException e) {
      this.resp =
          new JSONRPC2Response(
              new JSONRPC2Error(
                  JSONRPC2Error.INVALID_PARAMS.getCode(),
                  this.cmdName() + ": Unable to fetch virtual topology : " + e.getMessage()),
              0);
    }

    return this.resp;
  }