Beispiel #1
0
  @Override
  public void parseResponse(Object response, Object model) throws CommandException {

    if (!(model instanceof ProteusOpticalSwitch)) {
      throw new IllegalArgumentException(
          "Given model is not a ProteusOpticalSwitchCard. It is of type: " + model.getClass());
    }

    WonesysResponse commandResponse = (WonesysResponse) response;

    if (commandResponse.getStatus().equals(Response.Status.ERROR)) {
      if (commandResponse.getErrors().size() > 0)
        throw new CommandException(commandResponse.getErrors().get(0));
      else throw new CommandException("Command Failed");
    }

    ProteusOpticalSwitchCard relatedCard = ((ProteusOpticalSwitch) model).getCard(chassis, slot);
    FiberChannelPlan channelPlan = relatedCard.getChannelPlan();

    String responseData = commandResponse.getInformation();

    int channelCount = responseData.length() / 2;
    log.info("Port supports " + channelCount + " channels");
    for (int i = 0; i < channelCount; i++) {
      String sport = responseData.substring(i * 2, (i * 2) + 2);
      int port = Integer.parseInt(sport, 16);

      int dwdmChannel = channelPlan.getFirstChannel() + (channelPlan.getChannelGap() * i);

      if (port != 0) {
        log.info("Channel " + dwdmChannel + " mapped to port " + port);

        NetworkPort portInModel = relatedCard.getPort(port);
        if (portInModel == null) {
          log.error(
              "Mapped port is not in model. Skipping this mapping although channel is in use");
          continue;
        }

      } else {
        // if (port == 0) --> channel is not associated with any port
        // log.trace("Channel " + dwdmChannel + " not in use");
      }
      SetChannel.setChannelInModel(relatedCard, dwdmChannel, port, (ProteusOpticalSwitch) model);
    }
  }
  private FiberConnection newMakeConnectionParams(ProteusOpticalSwitch proteus) throws Exception {

    FiberConnection fiberConnection = new FiberConnection();

    // PSROADM DROP card
    int dropChasis = 0;
    int dropSlot = 1;
    ProteusOpticalSwitchCard dropCard = proteus.getCard(dropChasis, dropSlot);
    FCPort srcPort = (FCPort) dropCard.getPort(0);

    DWDMChannel srcFiberChannel =
        (DWDMChannel)
            ((WDMChannelPlan) dropCard.getChannelPlan())
                .getChannel(dropCard.getChannelPlan().getFirstChannel());

    double srcLambda = srcFiberChannel.getLambda();

    fiberConnection.setSrcCard(dropCard);
    fiberConnection.setSrcPort(srcPort);
    fiberConnection.setSrcFiberChannel(srcFiberChannel);

    // PSROADM ADD card
    int addChasis = 0;
    int addSlot = 17;
    ProteusOpticalSwitchCard addCard = proteus.getCard(addChasis, addSlot);
    FCPort dstPort = ((WonesysPassiveAddCard) addCard).getCommonPort();

    DWDMChannel dstFiberChannel =
        (DWDMChannel)
            ((WDMChannelPlan) addCard.getChannelPlan())
                .getChannel(
                    ((WDMChannelPlan) addCard.getChannelPlan())
                        .getChannelNumberFromLambda(srcLambda));

    fiberConnection.setDstCard(addCard);
    fiberConnection.setDstPort(dstPort);
    fiberConnection.setDstFiberChannel(dstFiberChannel);

    return fiberConnection;
  }