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

    DeviceConfigGenerator cg;
    try {
      cg = ConnectorUtils.getDeviceConfigGenerator(deviceId, SVC_ID);
    } catch (PSSException e) {
      log.error(e);
      return;
    }
    PostCommitConfigGen pcg;
    if (cg instanceof PostCommitConfigGen) {
      pcg = (PostCommitConfigGen) cg;
    } else {
      return;
    }

    String deviceCommand = pcg.getPostCommitConfig(action, deviceId);
    String deviceAddress = null;
    Connector conn = null;
    try {
      deviceAddress = ConnectorUtils.getDeviceAddress(deviceId);
      conn = ClassFactory.getInstance().getDeviceConnectorMap().getDeviceConnector(deviceId);
    } catch (PSSException ex) {
      log.error(ex.getMessage(), ex);
      return;
    }
    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("post-commit command failed");
    }
    log.info("sent post-commit command!");
  }
コード例 #2
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;
  }