public static ServiceFunctionKey getSFKey(PortPair portPair) { return new ServiceFunctionKey(new SfName(portPair.getName())); } }
SfcProviderTopologyNode firstHopNode; while (maxTries > 0) { sfcProviderTopologyNodeName = new SfName(sftServiceFunctionNameList.get(start).getName()); firstHopNode = sfcProviderGraph.getNode(sfcProviderTopologyNodeName.getValue()); if (firstHopNode != null) { break; SfcProviderTopologyNode preSfcProviderTopologyNode = sfcProviderGraph.getNode(preSfName.getValue()); sfcProviderTopologyNodeName = null; for (SftServiceFunctionName sftServiceFunctionName : sftServiceFunctionNameList) { SfName curSfName = new SfName(sftServiceFunctionName.getName()); SfcProviderTopologyNode curSfcProviderTopologyNode = sfcProviderGraph.getNode(curSfName.getValue()); if (curSfcProviderTopologyNode == null) { sfcProviderGraph.getShortestPath(preSfName.getValue(), curSfName.getValue()); length = sfcProviderTopologyNodeList.size(); if (length <= 1) {
public IpAddress getSfIpAddress(String sfname) { ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(SfName.getDefaultInstance(sfname)); if (serviceFunction == null) { LOG.info("Failed to read ServiceFunction: {}", sfname); return null; } return getSfIpAddress(serviceFunction); }
@Override public String exportJsonNameOnly(DataObject dataObject) { String ret = null; if (dataObject instanceof ServiceFunction) { ServiceFunction obj = (ServiceFunction) dataObject; ObjectNode node = mapper.createObjectNode(); node.put(_NAME, obj.getName().getValue()); ArrayNode sfArray = mapper.createArrayNode(); sfArray.add(node); ret = "{\"" + _SERVICE_FUNCTION + "\":" + sfArray.toString() + "}"; } else { throw new IllegalArgumentException("Argument is not an instance of ServiceFunction"); } return ret; }
.hasNext();) { ServiceFunctionDictionary sfd = sfdItr.next(); if (sfd.getName().equals(sfdBuilder.getName())) { LOG.info("Existing SF dictionary {} found in SFF {}, removing the SF dictionary", sfd.getName(), sffBuilder.getName());
private ObjectNode getSfDictionaryObjectNode(ServiceFunctionDictionary serviceFunctionDictionary) { if (serviceFunctionDictionary == null) { return null; } ObjectNode sfObjectNode = mapper.createObjectNode(); sfObjectNode.put(_NAME, serviceFunctionDictionary.getName().getValue()); ObjectNode sffSfDataPlaneLocatorNode = ExporterUtil.getSffSfDataPlaneLocatorObjectNode(serviceFunctionDictionary.getSffSfDataPlaneLocator()); if (sffSfDataPlaneLocatorNode != null) { sfObjectNode.put(_SFF_SF_DATA_PLANE_LOCATOR, sffSfDataPlaneLocatorNode); } else { ObjectNode emptySffSfDataPlaneLocatorNode = mapper.createObjectNode(); sfObjectNode.put(_SFF_SF_DATA_PLANE_LOCATOR, emptySffSfDataPlaneLocatorNode); } return sfObjectNode; }
ServiceFunctionDictionary matchingSfd = null; for (ServiceFunctionDictionary sfd : sfDictionary) { if (sfd.getName().equals(sfKey.getName())) { matchingSfd = sfd; break;
/** * Function for JMX testing. * Creates a new sfService function with fixed parameters. * * @return Boolean */ @Override public Boolean testAPutSf() { // printTraceStart(LOG); return putSf(new SfName("firewall-test"), new SftTypeName("firewall"), "10.0.0.2", "192.168.0.2", 5050); }
/** * This method reads a Service function Type entry from a Service * Function. * * @param serviceFunction Service Function Object * @return Nothing. */ public static SftServiceFunctionName readServiceFunctionTypeEntry(ServiceFunction serviceFunction) { printTraceStart(LOG); ServiceFunctionTypeKey serviceFunctionTypeKey = new ServiceFunctionTypeKey(serviceFunction.getType()); // Build the instance identifier all the way down to the bottom child // TODO as part of typedef refactoring not messing with SFTs SfName sfName = new SfName(serviceFunction.getName().getValue()); SftServiceFunctionNameKey sftServiceFunctionNameKey = new SftServiceFunctionNameKey(sfName); InstanceIdentifier<SftServiceFunctionName> sftentryIID; sftentryIID = InstanceIdentifier.builder(ServiceFunctionTypes.class) .child(ServiceFunctionType.class, serviceFunctionTypeKey) .child(SftServiceFunctionName.class, sftServiceFunctionNameKey) .build(); printTraceStop(LOG); return (SfcDataStoreAPI.readTransactionAPI(sftentryIID, LogicalDatastoreType.CONFIGURATION)); } }
@Override public String exportJsonNameOnly(DataObject dataObject) { String ret = null; if (dataObject instanceof ServiceFunctionState) { ServiceFunctionState obj = (ServiceFunctionState) dataObject; ObjectNode node = mapper.createObjectNode(); if (obj.getName() != null) { node.put(_NAME, obj.getName().getValue()); } ArrayNode sfstateArray = mapper.createArrayNode(); sfstateArray.add(node); ret = "{\"" + _SERVICE_FUNCTION_STATE + "\":" + sfstateArray.toString() + "}"; } else { throw new IllegalArgumentException("Argument is not an instance of ServiceFunctionState"); } return ret; }
public InstanceIdentifier<ServiceFunction> getSfId(String sfName) { return InstanceIdentifier.builder(ServiceFunctions.class) .child(ServiceFunction.class, new ServiceFunctionKey(SfName.getDefaultInstance(sfName))).build(); }
/** * Function for JMX testing. * Creates multiple Service Functions with fixed parameters. * * @return Boolean */ @Override public Boolean testBPutSfs() { // printTraceStart(LOG); Boolean res = putSf(new SfName("firewall-testB"), new SftTypeName("firewall"), "10.0.0.101", "192.168.0.101", 5050); res = putSf(new SfName("dpi-testB"), new SftTypeName("dpi"), "10.0.0.102", "192.168.0.102", 5050) && res; res = putSf(new SfName("napt44-testB"), new SftTypeName("napt44"), "10.0.0.103", "192.168.0.102", 5050) && res; return res; }
@Override protected void setRestUriList(DataObject dataObject) { ServiceFunction obj = (ServiceFunction) dataObject; if (obj.getRestUri() != null) { SfName sfName = obj.getName(); if (sfName != null) { String restUri = obj.getRestUri().getValue() + SF_REST_URI + sfName.getValue(); this.restUriList = new ArrayList<>(); this.restUriList.add(restUri); LOG.info("SF will be send to REST URI {}", restUri); } } else { this.restUriList = null; } } }
private SfName getServiceFunctionByType(ServiceFunctionType serviceFunctionType) { List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName(); int countRoundRobin = 0; if (mapCountRoundRobin.size() != 0) { for (SftTypeName sfType : mapCountRoundRobin.keySet()) { if (sfType.equals(serviceFunctionType.getType())) { countRoundRobin = mapCountRoundRobin.get(sfType); LOG.debug("countRoundRobin: {}", countRoundRobin); break; } } } SftServiceFunctionName sftServiceFunctionName = sftServiceFunctionNameList.get(countRoundRobin); countRoundRobin = (countRoundRobin + 1) % sftServiceFunctionNameList.size(); mapCountRoundRobin.put(serviceFunctionType.getType(), countRoundRobin); return new SfName(sftServiceFunctionName.getName()); }
private SfName getServiceFunctionByType(ServiceFunctionType serviceFunctionType) { List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName(); int maxTries = sftServiceFunctionNameList.size(); Random rad = new Random(); ServiceFunction serviceFunction = null; SfName serviceFunctionName = null; int start = rad.nextInt(sftServiceFunctionNameList.size()); while (maxTries > 0) { serviceFunctionName = new SfName(sftServiceFunctionNameList.get(start).getName()); serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(serviceFunctionName); if (serviceFunction != null) { break; } else { LOG.debug("ServiceFunction {} doesn't exist", serviceFunctionName); maxTries--; serviceFunctionName = null; start = (start + 1) % sftServiceFunctionNameList.size(); } } if (serviceFunctionName == null) { LOG.error("Could not find an existing ServiceFunction for {}", serviceFunctionType.getType()); } return serviceFunctionName; }
for (SfcServiceFunction entry : sfg.getSfcServiceFunction()) { ObjectNode o = mapper.createObjectNode(); o.put(_NAME, entry.getName().getValue()); sfArray.add(o);
@Override public void run() { while (true) { printTraceStart(LOG); MonitoringInfo monInfo = SfcNetconfServiceFunctionAPI.getServiceFunctionMonitor(nodeName); if (monInfo != null) { SfName sfNodeName = new SfName(nodeName); SfcNetconfServiceFunctionAPI.putServiceFunctionMonitor(monInfo, sfNodeName); } try { Thread.sleep(5000); } catch (InterruptedException e) { LOG.warn("failed to ....", e); } printTraceStop(LOG); } } }