@Test public void testGetServicePath() throws Exception { final String sfcNameValue = "123"; final ServiceFunctionPath sfcPath = createSfp(sfcNameValue); final ServiceFunctionPaths sfcPaths = new ServiceFunctionPathsBuilder() .setServiceFunctionPath(Collections.singletonList(sfcPath)) .build(); stub(method(SfcProviderServicePathAPI.class, "readAllServiceFunctionPaths")).toReturn(sfcPaths); final ServiceFunctionPath servicePath = ServiceChainingUtil.findServicePathFromParameterValues(Lists.newArrayList( createParameterValue(sfcNameValue) )); assertEquals(sfcPath, servicePath); }
@Nullable static ServiceFunctionPath findServicePathFromParameterValues(final List<ParameterValue> params) { if (params == null || params.isEmpty()) { LOG.error("Cannot found service path, parameter value is null"); return null; } final Map<String, Object> paramsMap = new HashMap<>(); for (ParameterValue value : params) { if (value.getName() == null) continue; if (value.getIntValue() != null) { paramsMap.put(value.getName().getValue(), value.getIntValue()); } else if (value.getStringValue() != null) { paramsMap.put(value.getName().getValue(), value.getStringValue()); } } String chainName = null; for (String name : paramsMap.keySet()) { if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) { chainName = (String) paramsMap.get(name); } } if (chainName == null) { LOG.error("Cannot found service path, chain name is null"); return null; } final ServiceFunctionPath serviceFunctionPath = findServiceFunctionPathFromServiceChainName(new SfcName(chainName)); if (serviceFunctionPath == null) { LOG.error("Service function path not found for name {}", chainName); return null; } return serviceFunctionPath; }
ServiceChainingUtil { @Nullable static ServiceFunctionPath findServicePathFromParameterValues(final List<ParameterValue> params) { if (params == null || params.isEmpty()) { LOG.error("Cannot found service path, parameter value is null"); return null; } final Map<String, Object> paramsMap = new HashMap<>(); for (ParameterValue value : params) { if (value.getName() == null) continue; if (value.getIntValue() != null) { paramsMap.put(value.getName().getValue(), value.getIntValue()); } else if (value.getStringValue() != null) { paramsMap.put(value.getName().getValue(), value.getStringValue()); } } String chainName = null; for (String name : paramsMap.keySet()) { if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) { chainName = (String) paramsMap.get(name); } } if (chainName == null) { LOG.error("Cannot found service path, chain name is null"); return null; } final ServiceFunctionPath serviceFunctionPath = findServiceFunctionPathFromServiceChainName(new SfcName(chainName)); if (serviceFunctionPath == null) { LOG.error("Service function path not found for name {}", chainName); return null; } return serviceFunctionPath; } }
ServiceChainingUtil { @Nullable static ServiceFunctionPath findServicePathFromParameterValues(final List<ParameterValue> params) { if (params == null || params.isEmpty()) { LOG.error("Cannot found service path, parameter value is null"); return null; } final Map<String, Object> paramsMap = new HashMap<>(); for (ParameterValue value : params) { if (value.getName() == null) continue; if (value.getIntValue() != null) { paramsMap.put(value.getName().getValue(), value.getIntValue()); } else if (value.getStringValue() != null) { paramsMap.put(value.getName().getValue(), value.getStringValue()); } } String chainName = null; for (String name : paramsMap.keySet()) { if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) { chainName = (String) paramsMap.get(name); } } if (chainName == null) { LOG.error("Cannot found service path, chain name is null"); return null; } final ServiceFunctionPath serviceFunctionPath = findServiceFunctionPathFromServiceChainName(new SfcName(chainName)); if (serviceFunctionPath == null) { LOG.error("Service function path not found for name {}", chainName); return null; } return serviceFunctionPath; } private  ServiceChainingUtil(); }
ServiceChainingUtil { @Nullable static ServiceFunctionPath findServicePathFromParameterValues(final List<ParameterValue> params) { if (params == null || params.isEmpty()) { LOG.error("Cannot found service path, parameter value is null"); return null; } final Map<String, Object> paramsMap = new HashMap<>(); for (ParameterValue value : params) { if (value.getName() == null) continue; if (value.getIntValue() != null) { paramsMap.put(value.getName().getValue(), value.getIntValue()); } else if (value.getStringValue() != null) { paramsMap.put(value.getName().getValue(), value.getStringValue()); } } String chainName = null; for (String name : paramsMap.keySet()) { if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) { chainName = (String) paramsMap.get(name); } } if (chainName == null) { LOG.error("Cannot found service path, chain name is null"); return null; } final ServiceFunctionPath serviceFunctionPath = findServiceFunctionPathFromServiceChainName(new SfcName(chainName)); if (serviceFunctionPath == null) { LOG.error("Service function path not found for name {}", chainName); return null; } return serviceFunctionPath; } private  ServiceChainingUtil(); static boolean resolveRemoteSfcComponents(final RenderedServicePath renderedServicePath,
                                                      final PolicyConfigurationContext context); static RenderedServicePath resolveReversedRenderedServicePath(final ServiceFunctionPath sfp, final TenantId tenantId,
                                                                          final DataBroker dataBroker, final Sgt sourceSgt,
                                                                          final Sgt destinationSgt, final PolicyConfigurationContext context); @VisibleForTesting static void setTimeout(long value); }
ServiceChainingUtil { @Nullable static ServiceFunctionPath findServicePathFromParameterValues(final List<ParameterValue> params) { if (params == null || params.isEmpty()) { LOG.error("Cannot found service path, parameter value is null"); return null; } final Map<String, Object> paramsMap = new HashMap<>(); for (ParameterValue value : params) { if (value.getName() == null) continue; if (value.getIntValue() != null) { paramsMap.put(value.getName().getValue(), value.getIntValue()); } else if (value.getStringValue() != null) { paramsMap.put(value.getName().getValue(), value.getStringValue()); } } String chainName = null; for (String name : paramsMap.keySet()) { if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) { chainName = (String) paramsMap.get(name); } } if (chainName == null) { LOG.error("Cannot found service path, chain name is null"); return null; } final ServiceFunctionPath serviceFunctionPath = findServiceFunctionPathFromServiceChainName(new SfcName(chainName)); if (serviceFunctionPath == null) { LOG.error("Service function path not found for name {}", chainName); return null; } return serviceFunctionPath; } private  ServiceChainingUtil(); static boolean resolveRemoteSfcComponents(final RenderedServicePath renderedServicePath,
                                                      final PolicyConfigurationContext context); static RenderedServicePath resolveReversedRenderedServicePath(final ServiceFunctionPath sfp, final TenantId tenantId,
                                                                          final DataBroker dataBroker, final Sgt sourceSgt,
                                                                          final Sgt destinationSgt, final PolicyConfigurationContext context); @VisibleForTesting static void setTimeout(long value);  }