- // get the PCMM gate parameters from the ccapId/appId/subId/gateId path in the Maps entry (if new gate)
- for (final Map.Entry<InstanceIdentifier<Gates>, Gates> entry : thisData.gateIidMap.entrySet()) {
- message = null;
- final Gates gate = entry.getValue();
- final String gateId = gate.getGateId();
- final String gatePathStr = thisData.gatePath + "/" + gateId ;
- final InetAddress subId = getInetAddress(thisData.subId);
- if (subId != null) {
- final Ccaps thisCcap = findCcapForSubscriberId(subId);
- if (thisCcap != null) {
- final String ccapId = thisCcap.getCcapId();
- // verify SCN exists on CCAP and force gateSpec.Direction to align with SCN direction
- final ServiceClassName scn = gate.getTrafficProfile().getServiceClassName();
- if (scn != null) {
- final ServiceFlowDirection scnDir = findScnOnCcap(scn, thisCcap);
- if (scnDir != null) {
- if (pcmmServiceMap.get(thisCcap.getCcapId()) != null) {
- message = pcmmServiceMap.get(thisCcap.getCcapId()).sendGateSet(gatePathStr, subId, gate, scnDir);
- gateMap.put(gatePathStr, gate);
- gateCcapMap.put(gatePathStr, thisCcap.getCcapId());
-
- if (message.contains("200 OK")) {
- logger.info("Created QoS gate {} for {}/{}/{} - {}",
- gateId, ccapId, gatePathStr, gate, message);
- logger.info("Created QoS gate {} for {}/{} - {}",
- gateId, ccapId, gatePathStr, message);
- } else {
- logger.info("Unable to create QoS gate {} for {}/{}/{} - {}",
- gateId, ccapId, gatePathStr, gate, message);
- logger.error("Unable to create QoS gate {} for {}/{} - {}",
- gateId, ccapId, gatePathStr, message);
- }
- } else {
- logger.error("Unable to locate PCMM Service for CCAP - " + thisCcap);
- break;
- }
- } else {
- logger.error("PCMMService: sendGateSet(): SCN {} not found on CCAP {} for {}/{}",
- scn.getValue(), thisCcap, gatePathStr, gate);
- message = String.format("404 Not Found - SCN %s not found on CCAP %s for %s",
- scn.getValue(), thisCcap.getCcapId(), gatePathStr);
- }
+ //pcmmService is null, do not poll
+ response = ccapId + ": CCAP connection null; no poll performed";
+ }
+
+ DateAndTime rpcDateAndTime = getNowTimeStamp();
+
+ org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.ccap.poll.connection.output.CcapBuilder ccapRpcOutput =
+ new org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.ccap.poll.connection.output.CcapBuilder().setCcapId(
+ ccapId).setConnection(connectionRpcOutput.build());
+
+ CcapPollConnectionOutputBuilder outputBuilder =
+ new CcapPollConnectionOutputBuilder().setCcap(ccapRpcOutput.build())
+ .setResponse(response)
+ .setTimestamp(rpcDateAndTime);
+
+ return Futures.immediateFuture(RpcResultBuilder.success(outputBuilder.build()).build());
+ }
+
+
+
+ private App readAppFromOperationalDatastore(InstanceIdentifier<App> appIid) {
+ Optional<App> optionalApp = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, appIid);
+ AppBuilder thisAppBuilder = new AppBuilder(optionalApp.get());
+ App thisApp = thisAppBuilder.build();
+ logger.info("readAppFromConfigDatastore() retrived App: " + thisApp.getAppId());
+ return thisApp;
+ }
+
+ private Gate readGateFromOperationalDatastore(InstanceIdentifier<Gate> gateIid) {
+ Optional<Gate> optionalGate = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, gateIid);
+ if (optionalGate.isPresent()) {
+ GateBuilder gateBuilder = new GateBuilder(optionalGate.get());
+ Gate thisGate = gateBuilder.build();
+ return thisGate;
+ } else {
+ return null;
+ }
+ }
+
+ private Subscriber readSubscriberFromOperationalDatastore(InstanceIdentifier<Subscriber> subscriberIid) {
+ Optional<Subscriber> optionalSubscriber = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, subscriberIid);
+ if (optionalSubscriber.isPresent()) {
+ SubscriberBuilder subscriberBuilder = new SubscriberBuilder(optionalSubscriber.get());
+ Subscriber thisSubscriber = subscriberBuilder.build();
+ return thisSubscriber;
+ } else {
+ return null;
+ }
+ }
+
+
+
+ @Override
+ public Future<RpcResult<QosPollGatesOutput>> qosPollGates(QosPollGatesInput input) {
+ // TODO refactor this method into smaller parts
+
+ InstanceIdentifier<App> appIid = (InstanceIdentifier<App>) input.getAppId();
+ //logger.info("qospollgates appIid : "+appIid.toString());
+ App app = readAppFromOperationalDatastore(appIid);
+ //logger.info("qospollgates app : "+app.toString());
+ AppKey appKey = InstanceIdentifier.keyOf(appIid);
+ String inputSubscriberId = input.getSubscriberId();
+ String inputGateId = input.getGateId();
+ List<String> gateOutputError = Collections.emptyList();
+ String subscriberId = null;
+ String gateId = null;
+ String ccapId = null;
+ String gatePathStr = null;
+ String opsCopsGateId = null;
+ Gate opsGate = null;
+
+ String rpcResponse = null;
+
+ org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.qos.poll.gates.output.GateBuilder gateOutputBuilder =
+ new org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.qos.poll.gates.output.GateBuilder();
+
+ GateBuilder gateBuilder = new GateBuilder();
+
+ if (inputSubscriberId != null) {
+ if (inputGateId != null) {
+ //Subscriber Id and Gate Id provided, only one gate to be poolled
+
+ //generate the gateiid
+ InstanceIdentifier<Gate> gateIid = appIid.builder()
+ .child(Subscribers.class)
+ .child(Subscriber.class, new SubscriberKey(inputSubscriberId))
+ .child(Gates.class)
+ .child(Gate.class, new GateKey(inputGateId))
+ .build();
+
+
+ opsGate = readGateFromOperationalDatastore(gateIid);
+
+ //does the gate exists in the Operational DS?
+ if (opsGate == null) {
+ gatePathStr = appKey.getAppId() + "/" + inputSubscriberId + "/" + inputGateId;
+ rpcResponse = gatePathStr + ": gate does not exist in the system; gate poll not performed";
+ } else {
+ opsCopsGateId = opsGate.getCopsGateId();
+ gatePathStr = opsGate.getGatePath();
+
+ if ((!Objects.equals(opsCopsGateId, "")) && (!Objects.equals(opsCopsGateId, null))) {
+ ccapId = findCcapForSubscriberId(getInetAddress(inputSubscriberId)).getCcapId();
+ PCMMService pcmmService = pcmmServiceMap.get(ccapId);
+ //is the CCAP socket open?
+ if (!pcmmService.getPcmmPdpSocket() && pcmmService.getPcmmCcapClientIsConnected()) {
+ PCMMService.GateSendStatus status = pcmmService.sendGateInfo(gatePathStr);
+ DateAndTime gateDateAndTime = getNowTimeStamp();
+ //logger.info("qospollgates Gate Status : GateID/"+status.getCopsGateId());
+ //logger.info("qospollgates Gate Status : Message/"+status.getMessage());
+ //logger.info("qospollgates Gate Status : DidSucceed/"+status.didSucceed());
+ gateOutputError = Collections.singletonList(status.getMessage());
+
+ gateOutputBuilder.setGatePath(gatePathStr)
+ .setCcapId(ccapId)
+ .setCopsGateState(status.getCopsGateState() + "/" + status.getCopsGateStateReason())
+ .setCopsGateTimeInfo(status.getCopsGateTimeInfo())
+ .setCopsGateUsageInfo(status.getCopsGateUsageInfo())
+ .setCopsGateId(status.getCopsGateId())
+ .setError(gateOutputError)
+ .setTimestamp(gateDateAndTime);
+
+ gateBuilder.setGateId(inputGateId)
+ .setGatePath(gatePathStr)
+ .setCcapId(ccapId)
+ .setCopsGateState(status.getCopsGateState() + "/" + status.getCopsGateStateReason())
+ .setCopsGateTimeInfo(status.getCopsGateTimeInfo())
+ .setCopsGateUsageInfo(status.getCopsGateUsageInfo())
+ .setCopsGateId(status.getCopsGateId())
+ .setError(gateOutputError)
+ .setTimestamp(gateDateAndTime);
+
+ mdsalUtils.put(LogicalDatastoreType.OPERATIONAL, gateIid, gateBuilder.build());
+ rpcResponse = gatePathStr + ": gate poll complete";
+ } else {
+ rpcResponse =
+ ccapId + ": CCAP socket is down or client disconnected; gate poll not performed";