+ private Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupFor100gTpdrNode(
+ Uuid topoUuid, Uuid nodeUuid, Collection<OwnedNodeEdgePoint> onepl) {
+
+ Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePointKey,
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint>
+ nepMap = new HashMap<>();
+ for (OwnedNodeEdgePoint onep: onepl) {
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint nep =
+ new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group
+ .NodeEdgePointBuilder()
+ .setTopologyUuid(topoUuid)
+ .setNodeUuid(nodeUuid)
+ .setNodeEdgePointUuid(onep.key().getUuid())
+ .build();
+ nepMap.put(nep.key(), nep);
+ }
+ Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
+ Map<RuleKey, Rule> ruleList = new HashMap<>();
+ Rule rule = new RuleBuilder()
+ .setLocalId("forward")
+ .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP)
+ .setRuleType(RuleType.FORWARDING)
+ .build();
+ ruleList.put(rule.key(), rule);
+ NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
+ .setUuid(new Uuid(UUID.nameUUIDFromBytes(("rdm infra node rule group").getBytes(Charset.forName("UTF-8")))
+ .toString()))
+ .setRule(ruleList)
+ .setNodeEdgePoint(nepMap)
+ .build();
+ nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup);
+ return nodeRuleGroupMap;
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>>
+ getServiceInterfacePointDetails(GetServiceInterfacePointDetailsInput input) {
+ Uuid sipUuid = getUuidFromIput(input.getSipIdOrName());
+ Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips =
+ this.tapiContext.getTapiContext().getServiceInterfacePoint();
+ if (sips == null || sips.isEmpty()) {
+ return RpcResultBuilder.<GetServiceInterfacePointDetailsOutput>failed()
+ .withError(ErrorType.RPC, "No sips in datastore")
+ .buildFuture();
+ }
+ if (!sips.containsKey(new ServiceInterfacePointKey(sipUuid))) {
+ return RpcResultBuilder.<GetServiceInterfacePointDetailsOutput>failed()
+ .withError(ErrorType.RPC, "Sip doesnt exist in datastore")
+ .buildFuture();
+ }
+ org.opendaylight.yang.gen.v1.urn
+ .onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.details.output.Sip outSip =
+ new org.opendaylight.yang.gen.v1.urn
+ .onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.details.output.SipBuilder(
+ sips.get(new ServiceInterfacePointKey(sipUuid)))
+ .build();
+ return RpcResultBuilder.success(new GetServiceInterfacePointDetailsOutputBuilder().setSip(outSip).build())
+ .buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>>
+ getServiceInterfacePointList(GetServiceInterfacePointListInput input) {
+ Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips =
+ this.tapiContext.getTapiContext().getServiceInterfacePoint();
+ if (sips == null || sips.isEmpty()) {
+ return RpcResultBuilder.<GetServiceInterfacePointListOutput>failed()
+ .withError(ErrorType.RPC, "No sips in datastore")
+ .buildFuture();
+ }
+ Map<SipKey, Sip> outSipMap = new HashMap<>();
+ for (ServiceInterfacePoint sip : sips.values()) {
+ Sip si = new SipBuilder(sip).build();
+ outSipMap.put(si.key(), si);
+ }
+ return RpcResultBuilder.success(new GetServiceInterfacePointListOutputBuilder().setSip(outSipMap).build())
+ .buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<UpdateServiceInterfacePointOutput>>
+ updateServiceInterfacePoint(UpdateServiceInterfacePointInput input) {
+ // TODO --> not yet implemented
+ return null;
+ }
+
+ private Uuid getUuidFromIput(String serviceIdOrName) {
+ try {
+ UUID.fromString(serviceIdOrName);
+ LOG.info("Given attribute {} is a UUID", serviceIdOrName);
+ return new Uuid(serviceIdOrName);
+ } catch (IllegalArgumentException e) {
+ LOG.info("Given attribute {} is not a UUID", serviceIdOrName);
+ return new Uuid(UUID.nameUUIDFromBytes(serviceIdOrName.getBytes(StandardCharsets.UTF_8)).toString());
+ }
+ }