コード例 #1
0
ファイル: EoMPLSService.java プロジェクト: modulexcite/oscars
  private PSSAction processActionForDevice(PSSAction action, String deviceId) throws PSSException {
    String errorMessage = null;
    OSCARSFaultReport faultReport = new OSCARSFaultReport();
    faultReport.setDomainId(PathTools.getLocalDomainId());
    ResDetails res = null;

    try {
      res = ActionUtils.getReservation(action);
    } catch (PSSException e) {
      log.error(e);
      errorMessage = "Could not locate ResDetails for device " + deviceId + "\n" + e.getMessage();
      action.setStatus(ActionStatus.FAIL);
      faultReport.setErrorMsg(errorMessage);
      faultReport.setErrorType(ErrorReport.SYSTEM);
      faultReport.setErrorCode(ErrorCodes.CONFIG_ERROR);
      action.setFaultReport(faultReport);
      ClassFactory.getInstance().getWorkflow().update(action);
      throw new PSSException(e);
    }

    DeviceConfigGenerator cg;
    try {
      cg = ConnectorUtils.getDeviceConfigGenerator(deviceId, SVC_ID);
    } catch (PSSException e) {
      log.error(e);
      errorMessage =
          "Could not locate config generator for device " + deviceId + "\n" + e.getMessage();
      action.setStatus(ActionStatus.FAIL);
      faultReport.setErrorMsg(errorMessage);
      faultReport.setGri(res.getGlobalReservationId());
      faultReport.setErrorType(ErrorReport.SYSTEM);
      faultReport.setErrorCode(ErrorCodes.CONFIG_ERROR);
      action.setFaultReport(faultReport);
      ClassFactory.getInstance().getWorkflow().update(action);
      throw new PSSException(e);
    }

    String deviceCommand = cg.getConfig(action, deviceId);
    String deviceAddress = ConnectorUtils.getDeviceAddress(deviceId);

    Connector conn =
        ClassFactory.getInstance().getDeviceConnectorMap().getDeviceConnector(deviceId);
    log.debug("connector for " + deviceId + " is: " + conn.getClass());

    if (ConfigHolder.getInstance().getBaseConfig().getCircuitService().isStub()) {
      log.debug("stub mode! connector will not send commands");
    }

    PSSCommand comm = new PSSCommand();
    comm.setDeviceCommand(deviceCommand);
    comm.setDeviceAddress(deviceAddress);
    try {
      conn.sendCommand(comm);
    } catch (PSSException e) {
      log.error(e.getMessage());
      action.setStatus(ActionStatus.FAIL);
      faultReport.setErrorMsg(errorMessage);
      faultReport.setGri(res.getGlobalReservationId());
      faultReport.setErrorType(ErrorReport.SYSTEM);
      if (action.getActionType().equals(ActionType.MODIFY)) {
        faultReport.setErrorCode(ErrorCodes.PATH_MODIFY_FAILED);
      } else if (action.getActionType().equals(ActionType.SETUP)) {
        faultReport.setErrorCode(ErrorCodes.PATH_SETUP_FAILED);
      } else if (action.getActionType().equals(ActionType.STATUS)) {
        faultReport.setErrorCode(ErrorCodes.UNKNOWN);
      } else if (action.getActionType().equals(ActionType.TEARDOWN)) {
        faultReport.setErrorCode(ErrorCodes.PATH_TEARDOWN_FAILED);
      }
      action.setFaultReport(faultReport);

      ClassFactory.getInstance().getWorkflow().update(action);
      throw e;
    }
    log.info("sent command!");
    return action;
  }
コード例 #2
0
ファイル: EoMPLSService.java プロジェクト: modulexcite/oscars
  public void prepareAction(PSSAction action, ResDetails res) throws PSSException {
    ActionType actionType = action.getActionType();
    switch (actionType) {
      case SETUP:
        break;
      case TEARDOWN:
        break;
      case MODIFY:
        return;
      case STATUS:
        return;
    }

    List<String> deviceIds = new ArrayList<String>();
    String srcDeviceId = EoMPLSUtils.getDeviceId(res, false);
    String dstDeviceId = EoMPLSUtils.getDeviceId(res, true);
    deviceIds.add(srcDeviceId);
    if (!srcDeviceId.equals(dstDeviceId)) deviceIds.add(dstDeviceId);

    String gri = res.getGlobalReservationId();
    HashMap<String, VplsImplementation> implMap =
        VPLS_RequestParams.getImplementationMap(deviceIds);

    boolean all_supported = true;
    boolean one_supported = false;
    boolean one_alu = false;
    boolean may_need_secondary_vpls_id = false;

    for (String deviceId : deviceIds) {
      log.debug(deviceId + " implementation: " + implMap.get(deviceId));
      if (implMap.get(deviceId).equals(VplsImplementation.UNSUPPORTED)) {
        all_supported = false;
      } else {
        one_supported = true;
      }
      if (implMap.get(deviceId).equals(VplsImplementation.ALU)) {
        one_alu = true;
      }
    }
    if (one_supported && !all_supported) {
      throw new PSSException("VPLS implementation mismatch");
    }
    if (!all_supported) return;

    if (one_alu) {
      may_need_secondary_vpls_id = true;
    }

    VPLS_RequestParamHolder holder = VPLS_RequestParamHolder.getInstance();
    VPLS_RequestParams rp = new VPLS_RequestParams();
    switch (actionType) {
      case SETUP:
        rp.reserve(res, may_need_secondary_vpls_id);
        break;
      case TEARDOWN:
        rp.release(res);
        break;
    }

    holder.getRequestParams().put(gri, rp);
  }