From 2b5650e4ca816afc9c20275adb551d1006c88880 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 24 Feb 2020 13:18:28 +0100 Subject: [PATCH 001/187] Update version to 0.0.2-SNAPSHOT. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4de45ef..76a8676 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.cnit.blueprint expbuilder - 0.0.1 + 0.0.2-SNAPSHOT A REST API module to compose VSD and CDs. https://github.com/TheWall89/5geve-experiment-builder docker-build From 256301402b4aeff765091a224cb01c9655d3f9a1 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 29 Feb 2020 19:54:31 +0100 Subject: [PATCH 002/187] Change REST path to plural. --- .../java/it/cnit/blueprint/expbuilder/rest/Controller.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/Controller.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/Controller.java index 55cab5e..31d07b5 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/Controller.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/rest/Controller.java @@ -14,12 +14,12 @@ public class Controller { private final NsdComposer nsdComposer; - @GetMapping("/experiment") + @GetMapping("/experiments") public OnboardExpBlueprintRequest retrieveExperiment() { return null; } - @PostMapping("/experiment") + @PostMapping("/experiments") public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest composeRequest) { try { nsdComposer.compose(composeRequest.getVsbRequest().getNsds().get(0), From 2a00cab6bc776a1a7b3ae16ab340013a02f2bbcb Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 29 Feb 2020 19:55:05 +0100 Subject: [PATCH 003/187] Rename class to ExperimentsController. --- .../rest/{Controller.java => ExperimentsController.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/it/cnit/blueprint/expbuilder/rest/{Controller.java => ExperimentsController.java} (97%) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/Controller.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/ExperimentsController.java similarity index 97% rename from src/main/java/it/cnit/blueprint/expbuilder/rest/Controller.java rename to src/main/java/it/cnit/blueprint/expbuilder/rest/ExperimentsController.java index 31d07b5..31897a7 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/Controller.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/rest/ExperimentsController.java @@ -10,7 +10,7 @@ @RestController @AllArgsConstructor -public class Controller { +public class ExperimentsController { private final NsdComposer nsdComposer; From b40a53e2b72945c883ea6b7aed5ac34d2327b425 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 4 Mar 2020 14:49:53 +0100 Subject: [PATCH 004/187] Re-adding strategies. Add a 'master' composer. --- .../master/CompositionStrategy.java | 6 +++ .../expbuilder/master/MasterComposer.java | 41 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/java/it/cnit/blueprint/expbuilder/master/CompositionStrategy.java create mode 100644 src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/CompositionStrategy.java b/src/main/java/it/cnit/blueprint/expbuilder/master/CompositionStrategy.java new file mode 100644 index 0000000..2998c79 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/CompositionStrategy.java @@ -0,0 +1,6 @@ +package it.cnit.blueprint.expbuilder.master; + +public enum CompositionStrategy { + PASS_THROUGH, + CONNECT +} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java new file mode 100644 index 0000000..9fd48db --- /dev/null +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java @@ -0,0 +1,41 @@ +package it.cnit.blueprint.expbuilder.master; + +import it.cnit.blueprint.expbuilder.nsd.compose.NsdComposer; +import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; +import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; +import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.ScopedProxyMode; +import org.springframework.stereotype.Service; +import org.springframework.web.context.WebApplicationContext; + +@Service +@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS) +@Slf4j +@AllArgsConstructor +public class MasterComposer { + + private NsdComposer nsdComposer; + // TODO vsbComposer + + // TODO Composition Strategy comes from CtxB + private static CompositionStrategy STRAT = CompositionStrategy.CONNECT; + + public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] contexts) + throws InvalidCtxComposeInfo { + for (CtxComposeInfo ctx : contexts) { + if (STRAT.equals(CompositionStrategy.CONNECT)){ + log.info("connect"); + } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)){ + log.info("pass_through"); + } else { + log.error("not supported"); + throw new InvalidCtxComposeInfo("Strategy x not supported."); + } + + } + } + +} From bea1e7ee8a61e8b25d0b147a1f7c69cf1b2007b0 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 4 Mar 2020 17:05:27 +0100 Subject: [PATCH 005/187] Start implementation for passthrough. Retrieve info for RAN VirtualLink. --- .../expbuilder/master/MasterComposer.java | 46 +++++++++++- .../expbuilder/nsd/compose/NsdComposer.java | 71 +++++++++++++++++++ 2 files changed, 114 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java index 9fd48db..eb6ce2b 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java @@ -3,7 +3,13 @@ import it.cnit.blueprint.expbuilder.nsd.compose.NsdComposer; import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; +import it.cnit.blueprint.expbuilder.rest.InvalidNsd; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Scope; @@ -24,12 +30,22 @@ public class MasterComposer { private static CompositionStrategy STRAT = CompositionStrategy.CONNECT; public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] contexts) - throws InvalidCtxComposeInfo { + throws InvalidCtxComposeInfo, InvalidNsd { + // Assumptions: + // - The Vsb has only 1 Nsd. + Nsd vsbNsd = vsbRequest.getNsds().get(0); for (CtxComposeInfo ctx : contexts) { - if (STRAT.equals(CompositionStrategy.CONNECT)){ + // - The Ctx has only 1 Nsd. + Nsd ctxNsd = ctx.getCtxBReq().getNsds().get(0); + if (STRAT.equals(CompositionStrategy.CONNECT)) { log.info("connect"); - } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)){ + } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)) { log.info("pass_through"); + // compose Nsd + Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); + NsVirtualLinkDesc ranVld = findSapVld(ranSapd, vsbNsd); + nsdComposer.composePassThrough(ranVld, vsbNsd, ctxNsd); + // compose Exp blueprint } else { log.error("not supported"); throw new InvalidCtxComposeInfo("Strategy x not supported."); @@ -38,4 +54,28 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte } } + private Sapd findRanSapd(VsBlueprint vsb, Nsd nsd) { + for (VsbEndpoint e : vsb.getEndPoints()) { + if (e.isRanConnection()) { + for (Sapd sapd : nsd.getSapd()) { + if (e.getEndPointId().equals(sapd.getCpdId())) { + return sapd; + } + } + } + } + // TODO exception + return null; + } + + private NsVirtualLinkDesc findSapVld(Sapd sapd, Nsd nsd) { + for (NsVirtualLinkDesc vld : nsd.getVirtualLinkDesc()) { + if (vld.getVirtualLinkDescId().equals(sapd.getNsVirtualLinkDescId())) { + return vld; + } + } + // TODO exception + return null; + } + } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 5eb9f2e..9675044 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -39,6 +39,7 @@ public class NsdComposer { private NsdGraphService nsdGraphService; + static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory()); private VnfProfile getVnfProfile(String vnfProfileId, NsDf nsDf) throws NotExistingEntityException { @@ -68,6 +69,23 @@ private VirtualLinkProfile getVlProfile(String vlProfileId, NsDf nsDf) return vlProfile; } + private VirtualLinkProfile getVlProfile(NsVirtualLinkDesc vld, NsDf nsDf) + throws NotExistingEntityException { + VirtualLinkProfile resultVlp; + Optional optVlp = nsDf.getVirtualLinkProfile().stream() + .filter(vlp -> vlp.getVirtualLinkDescId().equals(vld.getVirtualLinkDescId())).findFirst(); + if (optVlp.isPresent()) { + resultVlp = optVlp.get(); + } else { + String m = MessageFormatter + .format("vlProfile with VirtualLinkDescId='{}' not found in nsDf='{}'.", + vld.getVirtualLinkDescId(), nsDf.getNsDfId()) + .getMessage(); + throw new NotExistingEntityException(m); + } + return resultVlp; + } + private NsVirtualLinkConnectivity getVlConnectivity(String cpdId, VnfProfile vnfProfile) throws NotExistingEntityException { NsVirtualLinkConnectivity nsVlC; @@ -237,6 +255,23 @@ private VlWrapper retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel return new VlWrapper(vlMap, vlProfile, vlDesc); } + private VlWrapper retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLevel) + throws InvalidNsd, VlNotFoundInLvlMapping { + VirtualLinkProfile vlProfile; + try { + vlProfile = getVlProfile(vld, nsDf); + } catch (NotExistingEntityException e) { + throw new InvalidNsd(e.getMessage()); + } + VirtualLinkToLevelMapping vlMap; + try { + vlMap = getVlLvlMapping(vlProfile.getVirtualLinkProfileId(), nsLevel); + } catch (NotExistingEntityException e) { + throw new VlNotFoundInLvlMapping(e.getMessage()); + } + return new VlWrapper(vlMap, vlProfile, vld); + } + @SuppressWarnings("DuplicatedCode") @SneakyThrows(JsonProcessingException.class) public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) @@ -375,4 +410,40 @@ public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) } } + @SneakyThrows(JsonProcessingException.class) + public void composePassThrough(NsVirtualLinkDesc ranVld, Nsd vsbNsd, Nsd ctxNsd) + throws InvalidNsd { + // We assume only one NsDf for the context + NsDf ctxNsDf = ctxNsd.getNsDf().get(0); + // We assume only one NsLevel for the context + NsLevel ctxNsLvl = ctxNsDf.getNsInstantiationLevel().get(0); + // We assume only one NsDf for the vertical service + NsDf vsbNsDf = vsbNsd.getNsDf().get(0); + + log.info("Composing '{}' with <{}, {}, {}>.", + vsbNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), + ctxNsLvl.getNsLevelId()); + log.debug("Nsd BEFORE composition:\n{}", OBJECT_MAPPER.writeValueAsString(vsbNsd)); + + vsbNsd.setNsdName(vsbNsd.getNsdName() + " + " + ctxNsd.getNsdName()); + for (NsLevel vsbNsLvl : vsbNsDf.getNsInstantiationLevel()) { + log.info("Start composition for nsDf='{}' and nsLvl='{}'", + vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); + Graph g = nsdGraphService + .buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); + log.debug("Graph BEFORE composition :\n{}", nsdGraphService.export(g)); + + VlWrapper ranVlWrapper; + try { + ranVlWrapper = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); + } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + + // TODO retrieve one adjacent VNF to the ranVL. + + } + } + } From cd692a6486ec695a6bed13a6011613a2b207c880 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 5 Mar 2020 13:06:36 +0100 Subject: [PATCH 006/187] Retrieve info about a VNF connected to RAN. --- .../expbuilder/nsd/compose/NsdComposer.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 9675044..b71af5f 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -26,6 +26,7 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.jgrapht.Graph; +import org.jgrapht.Graphs; import org.slf4j.helpers.MessageFormatter; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; @@ -204,7 +205,7 @@ private void addVirtualLink(Nsd nsd, NsDf nsDf, NsLevel nsLevel, VlWrapper vlWra } private VnfWrapper retrieveVnfInfo(String vnfProfileId, String cpdId, Nsd nsd, NsDf nsDf, - NsLevel nsLevel) throws InvalidNsd, InvalidCtxComposeInfo, VnfNotFoundInLvlMapping { + NsLevel nsLevel) throws InvalidNsd, VnfNotFoundInLvlMapping { VnfToLevelMapping vnfLvlMap; try { vnfLvlMap = getVnfLvlMapping(vnfProfileId, nsLevel); @@ -221,7 +222,7 @@ private VnfWrapper retrieveVnfInfo(String vnfProfileId, String cpdId, Nsd nsd, N try { vlC = getVlConnectivity(cpdId, vnfProfile); } catch (NotExistingEntityException e) { - throw new InvalidCtxComposeInfo(e.getMessage()); + throw new InvalidNsd(e.getMessage()); } String vnfdId; try { @@ -308,7 +309,7 @@ public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) } catch (VnfNotFoundInLvlMapping e) { log.warn(e.getMessage() + " Skip."); continue; - } catch (InvalidNsd | InvalidCtxComposeInfo e) { + } catch (InvalidNsd e) { log.error(e.getMessage()); throw e; } @@ -358,7 +359,7 @@ public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) } catch (VnfNotFoundInLvlMapping e) { log.warn(e.getMessage() + " Skip."); continue; - } catch (InvalidNsd | InvalidCtxComposeInfo e) { + } catch (InvalidNsd e) { log.error(e.getMessage()); throw e; } @@ -436,12 +437,36 @@ public void composePassThrough(NsVirtualLinkDesc ranVld, Nsd vsbNsd, Nsd ctxNsd) VlWrapper ranVlWrapper; try { ranVlWrapper = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); + log.debug("Retrieved VL information for RAN vld: '{}'", ranVld.getVirtualLinkDescId()); } catch (InvalidNsd | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - // TODO retrieve one adjacent VNF to the ranVL. + ProfileVertex ranVlVertex; + Optional optVertex = g.vertexSet().stream() + .filter( + v -> v.getElementId().equals(ranVlWrapper.getVlProfile().getVirtualLinkProfileId())) + .findFirst(); + if (optVertex.isPresent()) { + ranVlVertex = optVertex.get(); + log.debug("Found ProfileVertex for RAN VL."); + } else { + throw new InvalidNsd("VL not connected to any VnfProfile"); + } + // Assumption: select the first VNF attached to the RAN VL + ProfileVertex ranVnfVertex = Graphs.neighborListOf(g, ranVlVertex).get(0); + String cpdId = g.getEdge(ranVlVertex, ranVnfVertex); + + VnfWrapper ranVnfWrapper; + try { + ranVnfWrapper = retrieveVnfInfo(ranVnfVertex.getElementId(), cpdId, vsbNsd, vsbNsDf, + vsbNsLvl); + } catch (InvalidNsd | VnfNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + } } From 11c85e6def783338dfb34a23354790f5641e28fd Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 5 Mar 2020 13:21:35 +0100 Subject: [PATCH 007/187] Moving method from master to nsd composer. --- .../expbuilder/master/MasterComposer.java | 15 ++--------- .../expbuilder/nsd/compose/NsdComposer.java | 26 ++++++++++++++++++- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java index eb6ce2b..90767b4 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java @@ -43,8 +43,7 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte log.info("pass_through"); // compose Nsd Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); - NsVirtualLinkDesc ranVld = findSapVld(ranSapd, vsbNsd); - nsdComposer.composePassThrough(ranVld, vsbNsd, ctxNsd); + nsdComposer.composePassThrough(ranSapd, vsbNsd, ctxNsd); // compose Exp blueprint } else { log.error("not supported"); @@ -64,17 +63,7 @@ private Sapd findRanSapd(VsBlueprint vsb, Nsd nsd) { } } } - // TODO exception - return null; - } - - private NsVirtualLinkDesc findSapVld(Sapd sapd, Nsd nsd) { - for (NsVirtualLinkDesc vld : nsd.getVirtualLinkDesc()) { - if (vld.getVirtualLinkDescId().equals(sapd.getNsVirtualLinkDescId())) { - return vld; - } - } - // TODO exception + // TODO exception invalid blueprint or nsd return null; } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index b71af5f..f79a125 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -17,6 +17,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; @@ -273,6 +274,21 @@ private VlWrapper retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLev return new VlWrapper(vlMap, vlProfile, vld); } + private NsVirtualLinkDesc findSapVld(Sapd sapd, Nsd nsd) throws InvalidNsd { + NsVirtualLinkDesc vld; + Optional optVld = nsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals(sapd.getNsVirtualLinkDescId())).findFirst(); + if (optVld.isPresent()) { + vld = optVld.get(); + } else { + String m = MessageFormatter + .format("Vld with id='{}' not found.", sapd.getNsVirtualLinkDescId()) + .getMessage(); + throw new InvalidNsd(m); + } + return vld; + } + @SuppressWarnings("DuplicatedCode") @SneakyThrows(JsonProcessingException.class) public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) @@ -412,8 +428,16 @@ public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) } @SneakyThrows(JsonProcessingException.class) - public void composePassThrough(NsVirtualLinkDesc ranVld, Nsd vsbNsd, Nsd ctxNsd) + public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) throws InvalidNsd { + NsVirtualLinkDesc ranVld; + try { + ranVld = findSapVld(ranSapd, vsbNsd); + } catch (InvalidNsd e) { + log.error(e.getMessage()); + throw e; + } + // We assume only one NsDf for the context NsDf ctxNsDf = ctxNsd.getNsDf().get(0); // We assume only one NsLevel for the context From 52416012e09bd6e571fd6ba4c9f7547837ddcd82 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 5 Mar 2020 13:38:00 +0100 Subject: [PATCH 008/187] Move a graph related method to NsdGraphService. --- .../expbuilder/nsd/compose/NsdComposer.java | 17 ++++++++--------- .../expbuilder/nsd/graph/NsdGraphService.java | 14 ++++++++++++++ .../graph/ProfileVertexNotFoundException.java | 8 ++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/ProfileVertexNotFoundException.java diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index f79a125..8cb7c8f 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; +import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; @@ -468,15 +469,13 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) } ProfileVertex ranVlVertex; - Optional optVertex = g.vertexSet().stream() - .filter( - v -> v.getElementId().equals(ranVlWrapper.getVlProfile().getVirtualLinkProfileId())) - .findFirst(); - if (optVertex.isPresent()) { - ranVlVertex = optVertex.get(); + try { + ranVlVertex = nsdGraphService + .getVertexById(ranVlWrapper.getVlProfile().getVirtualLinkProfileId(), g); log.debug("Found ProfileVertex for RAN VL."); - } else { - throw new InvalidNsd("VL not connected to any VnfProfile"); + } catch (ProfileVertexNotFoundException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); } // Assumption: select the first VNF attached to the RAN VL ProfileVertex ranVnfVertex = Graphs.neighborListOf(g, ranVlVertex).get(0); @@ -486,12 +485,12 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) try { ranVnfWrapper = retrieveVnfInfo(ranVnfVertex.getElementId(), cpdId, vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Retrieved VNF information for id: '{}'", ranVnfVertex.getElementId()); } catch (InvalidNsd | VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - } } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java index 29e63fa..a7bdc97 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java @@ -11,6 +11,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import lombok.AllArgsConstructor; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -118,4 +119,17 @@ public String export(Graph graph) { return graphExporter.export(graph); } + public ProfileVertex getVertexById(String vertexId, Graph g) + throws ProfileVertexNotFoundException { + Optional optVertex = g.vertexSet().stream() + .filter(v -> v.getElementId().equals(vertexId)) + .findFirst(); + if (optVertex.isPresent()) { + return optVertex.get(); + } else { + throw new ProfileVertexNotFoundException( + "ProfileVertex with id='" + vertexId + "' not found."); + } + } + } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/ProfileVertexNotFoundException.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/ProfileVertexNotFoundException.java new file mode 100644 index 0000000..ca77b6a --- /dev/null +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/ProfileVertexNotFoundException.java @@ -0,0 +1,8 @@ +package it.cnit.blueprint.expbuilder.nsd.graph; + +public class ProfileVertexNotFoundException extends Exception { + + public ProfileVertexNotFoundException(String message) { + super(message); + } +} From d74355d991ba162ba358386a9a78de696936a262 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 5 Mar 2020 15:57:31 +0100 Subject: [PATCH 009/187] Rename vsb graph variable name. --- .../expbuilder/nsd/compose/NsdComposer.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 8cb7c8f..df35dc1 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -455,9 +455,9 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) for (NsLevel vsbNsLvl : vsbNsDf.getNsInstantiationLevel()) { log.info("Start composition for nsDf='{}' and nsLvl='{}'", vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); - Graph g = nsdGraphService + Graph vsbG = nsdGraphService .buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); - log.debug("Graph BEFORE composition :\n{}", nsdGraphService.export(g)); + log.debug("Graph BEFORE composition :\n{}", nsdGraphService.export(vsbG)); VlWrapper ranVlWrapper; try { @@ -471,15 +471,15 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) ProfileVertex ranVlVertex; try { ranVlVertex = nsdGraphService - .getVertexById(ranVlWrapper.getVlProfile().getVirtualLinkProfileId(), g); + .getVertexById(ranVlWrapper.getVlProfile().getVirtualLinkProfileId(), vsbG); log.debug("Found ProfileVertex for RAN VL."); } catch (ProfileVertexNotFoundException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } // Assumption: select the first VNF attached to the RAN VL - ProfileVertex ranVnfVertex = Graphs.neighborListOf(g, ranVlVertex).get(0); - String cpdId = g.getEdge(ranVlVertex, ranVnfVertex); + ProfileVertex ranVnfVertex = Graphs.neighborListOf(vsbG, ranVlVertex).get(0); + String cpdId = vsbG.getEdge(ranVlVertex, ranVnfVertex); VnfWrapper ranVnfWrapper; try { @@ -491,6 +491,10 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) throw new InvalidNsd(e.getMessage()); } + // TODO retrieve ctx info + + // TODO clear context vnf cpd for mgmt. Handled in another method. + } } From 9d9815f2f3d1e8e795be79a32e4a2617a08c02e0 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 5 Mar 2020 16:53:10 +0100 Subject: [PATCH 010/187] Refactor input for passthrough method. --- .../expbuilder/master/MasterComposer.java | 25 ++++++-- .../expbuilder/nsd/compose/NsdComposer.java | 60 +++++++++++++++++-- 2 files changed, 75 insertions(+), 10 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java index 90767b4..dc923c2 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java @@ -4,10 +4,10 @@ import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; -import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import lombok.AllArgsConstructor; @@ -37,13 +37,22 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte for (CtxComposeInfo ctx : contexts) { // - The Ctx has only 1 Nsd. Nsd ctxNsd = ctx.getCtxBReq().getNsds().get(0); + CtxBlueprint ctxB = ctx.getCtxBReq().getCtxBlueprint(); if (STRAT.equals(CompositionStrategy.CONNECT)) { log.info("connect"); } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)) { log.info("pass_through"); // compose Nsd Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); - nsdComposer.composePassThrough(ranSapd, vsbNsd, ctxNsd); + String ctxVnfdId; + if (ctxNsd.getVnfdId().size() == 1) { + ctxVnfdId = ctxNsd.getVnfdId().get(0); + } else { + throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); + } + String ctxMgmtVldId = findMgmtVldId(ctxB, ctxNsd); + nsdComposer.composePassThrough(ranSapd, vsbNsd, ctxVnfdId, ctxMgmtVldId, ctxNsd); + // TODO prepare input for mgmt VL and cpdid // compose Exp blueprint } else { log.error("not supported"); @@ -53,8 +62,14 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte } } - private Sapd findRanSapd(VsBlueprint vsb, Nsd nsd) { - for (VsbEndpoint e : vsb.getEndPoints()) { + private String findMgmtVldId(Blueprint b, Nsd nsd) { + // TODO Visit vlDesc in nsd and check if mgmt in b. + // We need model modifications to make this work. + return ""; + } + + private Sapd findRanSapd(Blueprint b, Nsd nsd) { + for (VsbEndpoint e : b.getEndPoints()) { if (e.isRanConnection()) { for (Sapd sapd : nsd.getSapd()) { if (e.getEndPointId().equals(sapd.getCpdId())) { diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index df35dc1..3734812 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -6,6 +6,7 @@ import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; +import it.cnit.blueprint.expbuilder.nsd.graph.VirtualLinkProfileVertex; import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; @@ -22,6 +23,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; +import java.util.List; import java.util.Optional; import java.util.UUID; import lombok.AllArgsConstructor; @@ -44,7 +46,7 @@ public class NsdComposer { private NsdGraphService nsdGraphService; static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory()); - private VnfProfile getVnfProfile(String vnfProfileId, NsDf nsDf) + private VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) throws NotExistingEntityException { VnfProfile vnfProfile; try { @@ -58,6 +60,22 @@ private VnfProfile getVnfProfile(String vnfProfileId, NsDf nsDf) return vnfProfile; } + private VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) + throws NotExistingEntityException { + VnfProfile vnfProfile; + Optional optVnfP = nsDf.getVnfProfile().stream() + .filter(p -> p.getVnfdId().equals(vnfdId)).findFirst(); + if (optVnfP.isPresent()) { + vnfProfile = optVnfP.get(); + } else { + String m = MessageFormatter + .format("No VnfProfile with vnfdId='{}' found in nsDf='{}'", vnfdId, nsDf.getNsDfId()) + .getMessage(); + throw new NotExistingEntityException(m); + } + return vnfProfile; + } + private VirtualLinkProfile getVlProfile(String vlProfileId, NsDf nsDf) throws NotExistingEntityException { VirtualLinkProfile vlProfile; @@ -216,7 +234,7 @@ private VnfWrapper retrieveVnfInfo(String vnfProfileId, String cpdId, Nsd nsd, N } VnfProfile vnfProfile; try { - vnfProfile = getVnfProfile(vnfProfileId, nsDf); + vnfProfile = getVnfProfileById(vnfProfileId, nsDf); } catch (NotExistingEntityException e) { throw new InvalidNsd(e.getMessage()); } @@ -429,7 +447,8 @@ public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) } @SneakyThrows(JsonProcessingException.class) - public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) + public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, + String ctxMgmtVldId, Nsd ctxNsd) throws InvalidNsd { NsVirtualLinkDesc ranVld; try { @@ -445,6 +464,9 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) NsLevel ctxNsLvl = ctxNsDf.getNsInstantiationLevel().get(0); // We assume only one NsDf for the vertical service NsDf vsbNsDf = vsbNsd.getNsDf().get(0); + Graph ctxG = nsdGraphService + .buildGraph(ctxNsd.getSapd(), ctxNsDf, ctxNsLvl); + log.debug("ctxG graph composition :\n{}", nsdGraphService.export(ctxG)); log.info("Composing '{}' with <{}, {}, {}>.", vsbNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), @@ -457,8 +479,9 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); Graph vsbG = nsdGraphService .buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); - log.debug("Graph BEFORE composition :\n{}", nsdGraphService.export(vsbG)); + log.debug("vsbG BEFORE composition :\n{}", nsdGraphService.export(vsbG)); + // Retrieve vsb info VlWrapper ranVlWrapper; try { ranVlWrapper = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); @@ -478,6 +501,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) throw new InvalidNsd(e.getMessage()); } // Assumption: select the first VNF attached to the RAN VL + // TODO this could be a SAP! Check it ProfileVertex ranVnfVertex = Graphs.neighborListOf(vsbG, ranVlVertex).get(0); String cpdId = vsbG.getEdge(ranVlVertex, ranVnfVertex); @@ -491,7 +515,33 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, Nsd ctxNsd) throw new InvalidNsd(e.getMessage()); } - // TODO retrieve ctx info + // Retrieve ctx info + VnfProfile ctxVnfProfile; + try { + ctxVnfProfile = getVnfProfileByDescId(ctxVnfdId, ctxNsDf); + } catch (NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + + ProfileVertex ctxVnfPVertex; + try { + ctxVnfPVertex = nsdGraphService.getVertexById(ctxVnfProfile.getVnfProfileId(), ctxG); + } catch (ProfileVertexNotFoundException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + List ctxVnfNeighbors = Graphs.neighborListOf(ctxG, ctxVnfPVertex); + // Assumption: select the first VL that is NOT management + VirtualLinkProfile ctxVlProfile; + for (ProfileVertex vlp : ctxVnfNeighbors) { + if (!((VirtualLinkProfileVertex) vlp).getVlProfile().getVirtualLinkDescId() + .equals(ctxMgmtVldId)) { + ctxVlProfile = ((VirtualLinkProfileVertex) vlp).getVlProfile(); + } + } + + // TODO make connections // TODO clear context vnf cpd for mgmt. Handled in another method. From f065cf0fd50a34f75f48b3a6a85a4b41328924a1 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 5 Mar 2020 16:53:31 +0100 Subject: [PATCH 011/187] Add TODO for graph constraint. --- .../it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java index a7bdc97..57bcc64 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java @@ -132,4 +132,6 @@ public ProfileVertex getVertexById(String vertexId, Graph } } + // TODO implement constraint on coloring: no VL and Vnf directly connected. + } From 5b1f3281504d34a6c49c8ce3ba591f1850ebf84f Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 5 Mar 2020 17:04:58 +0100 Subject: [PATCH 012/187] Refactor input of graph method. Respect Jgrapht format. --- .../it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java | 4 ++-- .../cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 3734812..6b30008 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -494,7 +494,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, ProfileVertex ranVlVertex; try { ranVlVertex = nsdGraphService - .getVertexById(ranVlWrapper.getVlProfile().getVirtualLinkProfileId(), vsbG); + .getVertexById(vsbG, ranVlWrapper.getVlProfile().getVirtualLinkProfileId()); log.debug("Found ProfileVertex for RAN VL."); } catch (ProfileVertexNotFoundException e) { log.error(e.getMessage()); @@ -526,7 +526,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, ProfileVertex ctxVnfPVertex; try { - ctxVnfPVertex = nsdGraphService.getVertexById(ctxVnfProfile.getVnfProfileId(), ctxG); + ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); } catch (ProfileVertexNotFoundException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java index 57bcc64..99cbe71 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java @@ -119,7 +119,7 @@ public String export(Graph graph) { return graphExporter.export(graph); } - public ProfileVertex getVertexById(String vertexId, Graph g) + public ProfileVertex getVertexById(Graph g, String vertexId) throws ProfileVertexNotFoundException { Optional optVertex = g.vertexSet().stream() .filter(v -> v.getElementId().equals(vertexId)) From dd1ab2b3dddc3c9c2c1594f5c2af61abef7f71dc Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 5 Mar 2020 17:17:26 +0100 Subject: [PATCH 013/187] Check a possible dangerous case. --- .../expbuilder/nsd/compose/NsdComposer.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 6b30008..8e79948 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -6,6 +6,7 @@ import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; +import it.cnit.blueprint.expbuilder.nsd.graph.SapVertex; import it.cnit.blueprint.expbuilder.nsd.graph.VirtualLinkProfileVertex; import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; @@ -501,8 +502,16 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd(e.getMessage()); } // Assumption: select the first VNF attached to the RAN VL - // TODO this could be a SAP! Check it - ProfileVertex ranVnfVertex = Graphs.neighborListOf(vsbG, ranVlVertex).get(0); + List ranVlNeigh = Graphs.neighborListOf(vsbG, ranVlVertex); + ProfileVertex ranVnfVertex; + Optional optV = ranVlNeigh.stream().filter(v -> !(v instanceof SapVertex)) + .findFirst(); + if (optV.isPresent()) { + ranVnfVertex = optV.get(); + } else { + throw new InvalidNsd( + "No neighbor of type VnfProfileVertex found for '" + ranVlVertex.getVertexId() +"'."); + } String cpdId = vsbG.getEdge(ranVlVertex, ranVnfVertex); VnfWrapper ranVnfWrapper; From 6a355acdb8ed52036f5b276fae5d048dbde8a8ec Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 5 Mar 2020 17:29:30 +0100 Subject: [PATCH 014/187] Fix for wrong instance check. --- .../cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 8e79948..f2b67f6 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -6,8 +6,8 @@ import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; -import it.cnit.blueprint.expbuilder.nsd.graph.SapVertex; import it.cnit.blueprint.expbuilder.nsd.graph.VirtualLinkProfileVertex; +import it.cnit.blueprint.expbuilder.nsd.graph.VnfProfileVertex; import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; @@ -504,13 +504,13 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, // Assumption: select the first VNF attached to the RAN VL List ranVlNeigh = Graphs.neighborListOf(vsbG, ranVlVertex); ProfileVertex ranVnfVertex; - Optional optV = ranVlNeigh.stream().filter(v -> !(v instanceof SapVertex)) + Optional optV = ranVlNeigh.stream().filter(v -> v instanceof VnfProfileVertex) .findFirst(); if (optV.isPresent()) { ranVnfVertex = optV.get(); } else { throw new InvalidNsd( - "No neighbor of type VnfProfileVertex found for '" + ranVlVertex.getVertexId() +"'."); + "No neighbor of type VnfProfileVertex found for '" + ranVlVertex.getVertexId() + "'."); } String cpdId = vsbG.getEdge(ranVlVertex, ranVnfVertex); From 0a5c4917bffefb58671b08d2e7fb1a64f803c1d4 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 5 Mar 2020 17:45:16 +0100 Subject: [PATCH 015/187] Add TODO for a problem. --- .../it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index f2b67f6..c29940c 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -541,7 +541,8 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd(e.getMessage()); } List ctxVnfNeighbors = Graphs.neighborListOf(ctxG, ctxVnfPVertex); - // Assumption: select the first VL that is NOT management + // Assumption: select all the VLs that are NOT management + // TODO VirtualLinkProfile ctxVlProfile; for (ProfileVertex vlp : ctxVnfNeighbors) { if (!((VirtualLinkProfileVertex) vlp).getVlProfile().getVirtualLinkDescId() From 9c06da3805deb74f5789acfb036408ed813375ee Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 17:24:16 +0100 Subject: [PATCH 016/187] Remove cpd information on VnfWrapper. --- .../expbuilder/nsd/compose/NsdComposer.java | 347 +++++++++--------- .../expbuilder/nsd/compose/VnfWrapper.java | 6 +- .../rest/ExperimentsController.java | 7 +- 3 files changed, 173 insertions(+), 187 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index c29940c..bc5873b 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -8,11 +8,7 @@ import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; import it.cnit.blueprint.expbuilder.nsd.graph.VirtualLinkProfileVertex; import it.cnit.blueprint.expbuilder.nsd.graph.VnfProfileVertex; -import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; -import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; -import it.cnit.blueprint.expbuilder.rest.VnfConnection; -import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; @@ -26,7 +22,6 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.util.List; import java.util.Optional; -import java.util.UUID; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -225,8 +220,8 @@ private void addVirtualLink(Nsd nsd, NsDf nsDf, NsLevel nsLevel, VlWrapper vlWra } } - private VnfWrapper retrieveVnfInfo(String vnfProfileId, String cpdId, Nsd nsd, NsDf nsDf, - NsLevel nsLevel) throws InvalidNsd, VnfNotFoundInLvlMapping { + private VnfWrapper retrieveVnfInfo(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) + throws InvalidNsd, VnfNotFoundInLvlMapping { VnfToLevelMapping vnfLvlMap; try { vnfLvlMap = getVnfLvlMapping(vnfProfileId, nsLevel); @@ -239,19 +234,13 @@ private VnfWrapper retrieveVnfInfo(String vnfProfileId, String cpdId, Nsd nsd, N } catch (NotExistingEntityException e) { throw new InvalidNsd(e.getMessage()); } - NsVirtualLinkConnectivity vlC; - try { - vlC = getVlConnectivity(cpdId, vnfProfile); - } catch (NotExistingEntityException e) { - throw new InvalidNsd(e.getMessage()); - } String vnfdId; try { vnfdId = getVnfdId(vnfProfile.getVnfdId(), nsd); } catch (NotExistingEntityException e) { throw new InvalidNsd(e.getMessage()); } - return new VnfWrapper(vnfLvlMap, vnfProfile, vlC, vnfdId); + return new VnfWrapper(vnfdId, vnfProfile, vnfLvlMap); } private VlWrapper retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) @@ -309,143 +298,143 @@ private NsVirtualLinkDesc findSapVld(Sapd sapd, Nsd nsd) throws InvalidNsd { return vld; } - @SuppressWarnings("DuplicatedCode") - @SneakyThrows(JsonProcessingException.class) - public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) - throws InvalidCtxComposeInfo, InvalidNsd { - ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); - for (CtxComposeInfo ctxComposeInfo : ctxComposeInfos) { - Nsd ctxNsd = ctxComposeInfo.getCtxBReq().getNsds().get(0); - // We assume only one NsDf for the context - NsDf ctxNsDf = ctxNsd.getNsDf().get(0); - // We assume only one NsLevel for the context - NsLevel ctxNsLvl = ctxNsDf.getNsInstantiationLevel().get(0); - log.info("Composing '{}' with <{}, {}, {}>.", - vsNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), - ctxNsLvl.getNsLevelId()); - log.debug("Nsd BEFORE composition:\n{}", objectMapper.writeValueAsString(vsNsd)); - vsNsd.setNsdName(vsNsd.getNsdName() + " + " + ctxNsd.getNsdName()); - for (NsDf vsNsDf : vsNsd.getNsDf()) { - for (NsLevel vsNsLvl : vsNsDf.getNsInstantiationLevel()) { - log.info("Start composition for nsDf='{}' and nsLvl='{}'", - vsNsDf.getNsDfId(), vsNsLvl.getNsLevelId()); - Graph g = nsdGraphService - .buildGraph(vsNsd.getSapd(), vsNsDf, vsNsLvl); - log.debug("Graph BEFORE composition :\n{}", nsdGraphService.export(g)); - for (VnfConnection ctxC : ctxComposeInfo.getCtxConnections()) { - log.info("ctxConnection: {}", ctxC); - VnfWrapper vnfWrapper; - VlWrapper vlWrapper; - - // Retrieve the VNF from context Nsd - try { - vnfWrapper = retrieveVnfInfo(ctxC.getVnfProfileId(), ctxC.getCpdId(), - ctxNsd, ctxNsDf, ctxNsLvl); - log.debug("Found vnfProfile='{}' in context.", ctxC.getVnfProfileId()); - } catch (VnfNotFoundInLvlMapping e) { - log.warn(e.getMessage() + " Skip."); - continue; - } catch (InvalidNsd e) { - log.error(e.getMessage()); - throw e; - } - - // Retrieve the VirtualLink from context Nsd (and add it) - try { - vlWrapper = retrieveVlInfo(ctxC.getVlProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); - log.debug("Found vlProfile='{}' in context.", ctxC.getVlProfileId()); - addVirtualLink(vsNsd, vsNsDf, vsNsLvl, vlWrapper); - log.debug("Added vlProfile='{}' in service (if not present).", ctxC.getVlProfileId()); - } catch (VlNotFoundInLvlMapping e) { - log.debug(e.getMessage() + " Trying in service."); - // Retrieve the VirtualLink from vertical Nsd - try { - vlWrapper = retrieveVlInfo(ctxC.getVlProfileId(), vsNsd, vsNsDf, vsNsLvl); - log.debug("Found vlProfile='{}' in vertical service.", ctxC.getVlProfileId()); - } catch (VlNotFoundInLvlMapping vlNotFoundInLvlMapping) { - String m = MessageFormatter - .format("vlProfile='{}' not found neither in context or vertical service.", - ctxC.getVlProfileId()).getMessage(); - log.error(m, e); - throw new InvalidCtxComposeInfo(m); - } - } catch (InvalidNsd e) { - log.error(e.getMessage()); - throw e; - } - - // Create connection between Vnf and VL - vnfWrapper.getVlConnectivity() - .setVirtualLinkProfileId(vlWrapper.getVlProfile().getVirtualLinkProfileId()); - log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", - ctxC.getVnfProfileId(), ctxC.getVlProfileId()); - addVnf(vsNsd, vsNsDf, vsNsLvl, vnfWrapper); - log.debug("Added vnfProfile='{}' in service (if not present).", ctxC.getVnfProfileId()); - } - for (VnfConnection vsC : ctxComposeInfo.getVsConnections()) { - log.info("vsConnection: {}", vsC); - VnfWrapper vnfWrapper; - VlWrapper vlWrapper; - - // Retrieve the VNF from vertical Nsd - try { - vnfWrapper = retrieveVnfInfo(vsC.getVnfProfileId(), vsC.getCpdId(), - vsNsd, vsNsDf, vsNsLvl); - log.debug("Found vnfProfile='{}' in vertical service.", vsC.getVnfProfileId()); - } catch (VnfNotFoundInLvlMapping e) { - log.warn(e.getMessage() + " Skip."); - continue; - } catch (InvalidNsd e) { - log.error(e.getMessage()); - throw e; - } - - // Retrieve the VirtualLink from context Nsd (and add it) - try { - vlWrapper = retrieveVlInfo(vsC.getVlProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); - log.debug("Found vlProfile='{}' in context.", vsC.getVlProfileId()); - addVirtualLink(vsNsd, vsNsDf, vsNsLvl, vlWrapper); - log.info("Added vlProfile='{}' in service. (if not present).", vsC.getVlProfileId()); - } catch (VlNotFoundInLvlMapping e) { - String m = MessageFormatter - .format("vlProfile='{}' not found in context.", vsC.getVlProfileId()) - .getMessage(); - log.error(m, e); - throw new InvalidCtxComposeInfo(m); - } catch (InvalidNsd e) { - log.error(e.getMessage()); - throw e; - } - - // Create connection between Vnf and VL - vnfWrapper.getVlConnectivity() - .setVirtualLinkProfileId(vlWrapper.getVlProfile().getVirtualLinkProfileId()); - log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", - vsC.getVnfProfileId(), vsC.getVlProfileId()); - } - try { - vsNsd.isValid(); - } catch (MalformattedElementException e) { - String m = "Nsd looks not valid after composition"; - log.error(m, e); - throw new InvalidNsd(m); - } - g = nsdGraphService.buildGraph(vsNsd.getSapd(), vsNsDf, vsNsLvl); - log.debug("Graph AFTER composition with {}:\n{}", - ctxNsd.getNsdIdentifier(), nsdGraphService.export(g)); - log.info("Completed composition for nsDf='{}' and nsLvl='{}'", - vsNsDf.getNsDfId(), vsNsLvl.getNsLevelId()); - } - } - vsNsd.setNsdIdentifier(UUID.randomUUID().toString()); - vsNsd.setNsdInvariantId(UUID.randomUUID().toString()); - log.debug("Nsd AFTER composition with {}:\n{}", - ctxNsd.getNsdIdentifier(), objectMapper.writeValueAsString(vsNsd)); - log.info("Completed composition of '{}' with <{}, {}, {}>.", - vsNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), - ctxNsLvl.getNsLevelId()); - } - } +// @SuppressWarnings("DuplicatedCode") +// @SneakyThrows(JsonProcessingException.class) +// public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) +// throws InvalidCtxComposeInfo, InvalidNsd { +// ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); +// for (CtxComposeInfo ctxComposeInfo : ctxComposeInfos) { +// Nsd ctxNsd = ctxComposeInfo.getCtxBReq().getNsds().get(0); +// // We assume only one NsDf for the context +// NsDf ctxNsDf = ctxNsd.getNsDf().get(0); +// // We assume only one NsLevel for the context +// NsLevel ctxNsLvl = ctxNsDf.getNsInstantiationLevel().get(0); +// log.info("Composing '{}' with <{}, {}, {}>.", +// vsNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), +// ctxNsLvl.getNsLevelId()); +// log.debug("Nsd BEFORE composition:\n{}", objectMapper.writeValueAsString(vsNsd)); +// vsNsd.setNsdName(vsNsd.getNsdName() + " + " + ctxNsd.getNsdName()); +// for (NsDf vsNsDf : vsNsd.getNsDf()) { +// for (NsLevel vsNsLvl : vsNsDf.getNsInstantiationLevel()) { +// log.info("Start composition for nsDf='{}' and nsLvl='{}'", +// vsNsDf.getNsDfId(), vsNsLvl.getNsLevelId()); +// Graph g = nsdGraphService +// .buildGraph(vsNsd.getSapd(), vsNsDf, vsNsLvl); +// log.debug("Graph BEFORE composition :\n{}", nsdGraphService.export(g)); +// for (VnfConnection ctxC : ctxComposeInfo.getCtxConnections()) { +// log.info("ctxConnection: {}", ctxC); +// VnfWrapper vnfWrapper; +// VlWrapper vlWrapper; +// +// // Retrieve the VNF from context Nsd +// try { +// vnfWrapper = retrieveVnfInfo(ctxC.getVnfProfileId(), ctxC.getCpdId(), +// ctxNsd, ctxNsDf, ctxNsLvl); +// log.debug("Found vnfProfile='{}' in context.", ctxC.getVnfProfileId()); +// } catch (VnfNotFoundInLvlMapping e) { +// log.warn(e.getMessage() + " Skip."); +// continue; +// } catch (InvalidNsd e) { +// log.error(e.getMessage()); +// throw e; +// } +// +// // Retrieve the VirtualLink from context Nsd (and add it) +// try { +// vlWrapper = retrieveVlInfo(ctxC.getVlProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); +// log.debug("Found vlProfile='{}' in context.", ctxC.getVlProfileId()); +// addVirtualLink(vsNsd, vsNsDf, vsNsLvl, vlWrapper); +// log.debug("Added vlProfile='{}' in service (if not present).", ctxC.getVlProfileId()); +// } catch (VlNotFoundInLvlMapping e) { +// log.debug(e.getMessage() + " Trying in service."); +// // Retrieve the VirtualLink from vertical Nsd +// try { +// vlWrapper = retrieveVlInfo(ctxC.getVlProfileId(), vsNsd, vsNsDf, vsNsLvl); +// log.debug("Found vlProfile='{}' in vertical service.", ctxC.getVlProfileId()); +// } catch (VlNotFoundInLvlMapping vlNotFoundInLvlMapping) { +// String m = MessageFormatter +// .format("vlProfile='{}' not found neither in context or vertical service.", +// ctxC.getVlProfileId()).getMessage(); +// log.error(m, e); +// throw new InvalidCtxComposeInfo(m); +// } +// } catch (InvalidNsd e) { +// log.error(e.getMessage()); +// throw e; +// } +// +// // Create connection between Vnf and VL +// vnfWrapper.getVlConnectivity() +// .setVirtualLinkProfileId(vlWrapper.getVlProfile().getVirtualLinkProfileId()); +// log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", +// ctxC.getVnfProfileId(), ctxC.getVlProfileId()); +// addVnf(vsNsd, vsNsDf, vsNsLvl, vnfWrapper); +// log.debug("Added vnfProfile='{}' in service (if not present).", ctxC.getVnfProfileId()); +// } +// for (VnfConnection vsC : ctxComposeInfo.getVsConnections()) { +// log.info("vsConnection: {}", vsC); +// VnfWrapper vnfWrapper; +// VlWrapper vlWrapper; +// +// // Retrieve the VNF from vertical Nsd +// try { +// vnfWrapper = retrieveVnfInfo(vsC.getVnfProfileId(), vsC.getCpdId(), +// vsNsd, vsNsDf, vsNsLvl); +// log.debug("Found vnfProfile='{}' in vertical service.", vsC.getVnfProfileId()); +// } catch (VnfNotFoundInLvlMapping e) { +// log.warn(e.getMessage() + " Skip."); +// continue; +// } catch (InvalidNsd e) { +// log.error(e.getMessage()); +// throw e; +// } +// +// // Retrieve the VirtualLink from context Nsd (and add it) +// try { +// vlWrapper = retrieveVlInfo(vsC.getVlProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); +// log.debug("Found vlProfile='{}' in context.", vsC.getVlProfileId()); +// addVirtualLink(vsNsd, vsNsDf, vsNsLvl, vlWrapper); +// log.info("Added vlProfile='{}' in service. (if not present).", vsC.getVlProfileId()); +// } catch (VlNotFoundInLvlMapping e) { +// String m = MessageFormatter +// .format("vlProfile='{}' not found in context.", vsC.getVlProfileId()) +// .getMessage(); +// log.error(m, e); +// throw new InvalidCtxComposeInfo(m); +// } catch (InvalidNsd e) { +// log.error(e.getMessage()); +// throw e; +// } +// +// // Create connection between Vnf and VL +// vnfWrapper.getVlConnectivity() +// .setVirtualLinkProfileId(vlWrapper.getVlProfile().getVirtualLinkProfileId()); +// log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", +// vsC.getVnfProfileId(), vsC.getVlProfileId()); +// } +// try { +// vsNsd.isValid(); +// } catch (MalformattedElementException e) { +// String m = "Nsd looks not valid after composition"; +// log.error(m, e); +// throw new InvalidNsd(m); +// } +// g = nsdGraphService.buildGraph(vsNsd.getSapd(), vsNsDf, vsNsLvl); +// log.debug("Graph AFTER composition with {}:\n{}", +// ctxNsd.getNsdIdentifier(), nsdGraphService.export(g)); +// log.info("Completed composition for nsDf='{}' and nsLvl='{}'", +// vsNsDf.getNsDfId(), vsNsLvl.getNsLevelId()); +// } +// } +// vsNsd.setNsdIdentifier(UUID.randomUUID().toString()); +// vsNsd.setNsdInvariantId(UUID.randomUUID().toString()); +// log.debug("Nsd AFTER composition with {}:\n{}", +// ctxNsd.getNsdIdentifier(), objectMapper.writeValueAsString(vsNsd)); +// log.info("Completed composition of '{}' with <{}, {}, {}>.", +// vsNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), +// ctxNsLvl.getNsLevelId()); +// } +// } @SneakyThrows(JsonProcessingException.class) public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, @@ -482,6 +471,33 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, .buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); log.debug("vsbG BEFORE composition :\n{}", nsdGraphService.export(vsbG)); + // Retrieve ctx elements to insert + VnfProfile ctxVnfProfile; + try { + ctxVnfProfile = getVnfProfileByDescId(ctxVnfdId, ctxNsDf); + } catch (NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + + ProfileVertex ctxVnfPVertex; + try { + ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); + } catch (ProfileVertexNotFoundException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + List ctxVnfNeighbors = Graphs.neighborListOf(ctxG, ctxVnfPVertex); + // Assumption: select all the VLs that are NOT management + // TODO + VirtualLinkProfile ctxVlProfile; + for (ProfileVertex vlp : ctxVnfNeighbors) { + if (!((VirtualLinkProfileVertex) vlp).getVlProfile().getVirtualLinkDescId() + .equals(ctxMgmtVldId)) { + ctxVlProfile = ((VirtualLinkProfileVertex) vlp).getVlProfile(); + } + } + // Retrieve vsb info VlWrapper ranVlWrapper; try { @@ -516,7 +532,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, VnfWrapper ranVnfWrapper; try { - ranVnfWrapper = retrieveVnfInfo(ranVnfVertex.getElementId(), cpdId, vsbNsd, vsbNsDf, + ranVnfWrapper = retrieveVnfInfo(ranVnfVertex.getElementId(), vsbNsd, vsbNsDf, vsbNsLvl); log.debug("Retrieved VNF information for id: '{}'", ranVnfVertex.getElementId()); } catch (InvalidNsd | VnfNotFoundInLvlMapping e) { @@ -524,33 +540,6 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd(e.getMessage()); } - // Retrieve ctx info - VnfProfile ctxVnfProfile; - try { - ctxVnfProfile = getVnfProfileByDescId(ctxVnfdId, ctxNsDf); - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - - ProfileVertex ctxVnfPVertex; - try { - ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); - } catch (ProfileVertexNotFoundException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - List ctxVnfNeighbors = Graphs.neighborListOf(ctxG, ctxVnfPVertex); - // Assumption: select all the VLs that are NOT management - // TODO - VirtualLinkProfile ctxVlProfile; - for (ProfileVertex vlp : ctxVnfNeighbors) { - if (!((VirtualLinkProfileVertex) vlp).getVlProfile().getVirtualLinkDescId() - .equals(ctxMgmtVldId)) { - ctxVlProfile = ((VirtualLinkProfileVertex) vlp).getVlProfile(); - } - } - // TODO make connections // TODO clear context vnf cpd for mgmt. Handled in another method. diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfWrapper.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfWrapper.java index 7f7462a..d461136 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfWrapper.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfWrapper.java @@ -1,6 +1,5 @@ package it.cnit.blueprint.expbuilder.nsd.compose; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import lombok.AllArgsConstructor; @@ -10,8 +9,7 @@ @AllArgsConstructor public class VnfWrapper { - private VnfToLevelMapping vnfToLevelMapping; - private VnfProfile vnfProfile; - private NsVirtualLinkConnectivity vlConnectivity; private String vfndId; + private VnfProfile vnfProfile; + private VnfToLevelMapping vnfToLevelMapping; } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/ExperimentsController.java index 31897a7..9e4c645 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/rest/ExperimentsController.java @@ -1,6 +1,6 @@ package it.cnit.blueprint.expbuilder.rest; -import it.cnit.blueprint.expbuilder.nsd.compose.NsdComposer; +import it.cnit.blueprint.expbuilder.master.MasterComposer; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardExpBlueprintRequest; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; @@ -12,7 +12,7 @@ @AllArgsConstructor public class ExperimentsController { - private final NsdComposer nsdComposer; + private final MasterComposer masterComposer; @GetMapping("/experiments") public OnboardExpBlueprintRequest retrieveExperiment() { @@ -22,8 +22,7 @@ public OnboardExpBlueprintRequest retrieveExperiment() { @PostMapping("/experiments") public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest composeRequest) { try { - nsdComposer.compose(composeRequest.getVsbRequest().getNsds().get(0), - composeRequest.getContexts()); + masterComposer.compose(composeRequest.getVsbRequest(), composeRequest.getContexts()); } catch (InvalidCtxComposeInfo e) { //TODO create and return a 422 response. e.printStackTrace(); From be98f8977b1943e1279b60d11e747fe981f50522 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 18:00:45 +0100 Subject: [PATCH 017/187] Correctly retrieve method from context and compose with vsbNsd. --- .../expbuilder/nsd/compose/NsdComposer.java | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index bc5873b..3b119a2 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -8,6 +8,7 @@ import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; import it.cnit.blueprint.expbuilder.nsd.graph.VirtualLinkProfileVertex; import it.cnit.blueprint.expbuilder.nsd.graph.VnfProfileVertex; +import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; @@ -20,7 +21,9 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import lombok.AllArgsConstructor; import lombok.SneakyThrows; @@ -439,7 +442,7 @@ private NsVirtualLinkDesc findSapVld(Sapd sapd, Nsd nsd) throws InvalidNsd { @SneakyThrows(JsonProcessingException.class) public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, String ctxMgmtVldId, Nsd ctxNsd) - throws InvalidNsd { + throws InvalidNsd, InvalidCtxComposeInfo { NsVirtualLinkDesc ranVld; try { ranVld = findSapVld(ranSapd, vsbNsd); @@ -471,7 +474,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, .buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); log.debug("vsbG BEFORE composition :\n{}", nsdGraphService.export(vsbG)); - // Retrieve ctx elements to insert + // Retrieve ctx VNF VnfProfile ctxVnfProfile; try { ctxVnfProfile = getVnfProfileByDescId(ctxVnfdId, ctxNsDf); @@ -479,7 +482,17 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } + VnfWrapper ctxVnfWrapper; + try { + ctxVnfWrapper = retrieveVnfInfo(ctxVnfProfile.getVnfProfileId(), + ctxNsd, ctxNsDf, ctxNsLvl); + } catch (VnfNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + addVnf(vsbNsd, vsbNsDf, vsbNsLvl, ctxVnfWrapper); + // Retrieve first non-management VLs from ctx ProfileVertex ctxVnfPVertex; try { ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); @@ -488,15 +501,25 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd(e.getMessage()); } List ctxVnfNeighbors = Graphs.neighborListOf(ctxG, ctxVnfPVertex); - // Assumption: select all the VLs that are NOT management - // TODO - VirtualLinkProfile ctxVlProfile; - for (ProfileVertex vlp : ctxVnfNeighbors) { - if (!((VirtualLinkProfileVertex) vlp).getVlProfile().getVirtualLinkDescId() - .equals(ctxMgmtVldId)) { - ctxVlProfile = ((VirtualLinkProfileVertex) vlp).getVlProfile(); + Map ctxNonMgmtVls = new HashMap<>(); + try { + for (ProfileVertex vlpV : ctxVnfNeighbors) { + if (!((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() + .equals(ctxMgmtVldId)) { + VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); + ctxNonMgmtVls.put(ctxG.getEdge(ctxVnfPVertex, vlpV), + retrieveVlInfo(vlProfile.getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl)); + } } + if (ctxNonMgmtVls.isEmpty()) { + throw new InvalidNsd("Can't find a non-management VL in Ctx."); + } + } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); } + String selectedCp = ctxNonMgmtVls.keySet().iterator().next(); + addVirtualLink(vsbNsd, vsbNsDf, vsbNsLvl, ctxNonMgmtVls.get(selectedCp)); // Retrieve vsb info VlWrapper ranVlWrapper; From 93977fe74d3327d7c1f981fb6e9e0cae37bf2a14 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 18:19:28 +0100 Subject: [PATCH 018/187] get first nonMgmt VL. No Map required. --- .../expbuilder/nsd/compose/NsdComposer.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 3b119a2..3e934fb 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import javax.swing.text.html.Option; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -492,7 +493,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, } addVnf(vsbNsd, vsbNsDf, vsbNsLvl, ctxVnfWrapper); - // Retrieve first non-management VLs from ctx + // Retrieve first non-management VL from ctx ProfileVertex ctxVnfPVertex; try { ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); @@ -501,27 +502,30 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd(e.getMessage()); } List ctxVnfNeighbors = Graphs.neighborListOf(ctxG, ctxVnfPVertex); - Map ctxNonMgmtVls = new HashMap<>(); + VlWrapper ctxNonMgmtVlWrap = null; + String ctxVnfCp; try { - for (ProfileVertex vlpV : ctxVnfNeighbors) { - if (!((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() + for (ProfileVertex n : ctxVnfNeighbors) { + if (n instanceof VirtualLinkProfileVertex + && !((VirtualLinkProfileVertex) n).getVlProfile().getVirtualLinkDescId() .equals(ctxMgmtVldId)) { - VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); - ctxNonMgmtVls.put(ctxG.getEdge(ctxVnfPVertex, vlpV), - retrieveVlInfo(vlProfile.getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl)); + ctxNonMgmtVlWrap = retrieveVlInfo( + ((VirtualLinkProfileVertex) n).getVlProfile().getVirtualLinkProfileId(), + ctxNsd, ctxNsDf, ctxNsLvl); + ctxVnfCp = ctxG.getEdge(ctxVnfPVertex, n); + break; } } - if (ctxNonMgmtVls.isEmpty()) { + if (ctxNonMgmtVlWrap == null) { throw new InvalidNsd("Can't find a non-management VL in Ctx."); } } catch (InvalidNsd | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - String selectedCp = ctxNonMgmtVls.keySet().iterator().next(); - addVirtualLink(vsbNsd, vsbNsDf, vsbNsLvl, ctxNonMgmtVls.get(selectedCp)); + addVirtualLink(vsbNsd, vsbNsDf, vsbNsLvl, ctxNonMgmtVlWrap); - // Retrieve vsb info + // Retrieve VL closest to RAN from vsb VlWrapper ranVlWrapper; try { ranVlWrapper = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); From 8ce4e595df192508c176220d01204d303f9be65e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 18:26:32 +0100 Subject: [PATCH 019/187] Revert "get first nonMgmt VL. No Map required." This reverts commit 93977fe74d3327d7c1f981fb6e9e0cae37bf2a14. --- .../expbuilder/nsd/compose/NsdComposer.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 3e934fb..3b119a2 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import javax.swing.text.html.Option; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -493,7 +492,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, } addVnf(vsbNsd, vsbNsDf, vsbNsLvl, ctxVnfWrapper); - // Retrieve first non-management VL from ctx + // Retrieve first non-management VLs from ctx ProfileVertex ctxVnfPVertex; try { ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); @@ -502,30 +501,27 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd(e.getMessage()); } List ctxVnfNeighbors = Graphs.neighborListOf(ctxG, ctxVnfPVertex); - VlWrapper ctxNonMgmtVlWrap = null; - String ctxVnfCp; + Map ctxNonMgmtVls = new HashMap<>(); try { - for (ProfileVertex n : ctxVnfNeighbors) { - if (n instanceof VirtualLinkProfileVertex - && !((VirtualLinkProfileVertex) n).getVlProfile().getVirtualLinkDescId() + for (ProfileVertex vlpV : ctxVnfNeighbors) { + if (!((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() .equals(ctxMgmtVldId)) { - ctxNonMgmtVlWrap = retrieveVlInfo( - ((VirtualLinkProfileVertex) n).getVlProfile().getVirtualLinkProfileId(), - ctxNsd, ctxNsDf, ctxNsLvl); - ctxVnfCp = ctxG.getEdge(ctxVnfPVertex, n); - break; + VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); + ctxNonMgmtVls.put(ctxG.getEdge(ctxVnfPVertex, vlpV), + retrieveVlInfo(vlProfile.getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl)); } } - if (ctxNonMgmtVlWrap == null) { + if (ctxNonMgmtVls.isEmpty()) { throw new InvalidNsd("Can't find a non-management VL in Ctx."); } } catch (InvalidNsd | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - addVirtualLink(vsbNsd, vsbNsDf, vsbNsLvl, ctxNonMgmtVlWrap); + String selectedCp = ctxNonMgmtVls.keySet().iterator().next(); + addVirtualLink(vsbNsd, vsbNsDf, vsbNsLvl, ctxNonMgmtVls.get(selectedCp)); - // Retrieve VL closest to RAN from vsb + // Retrieve vsb info VlWrapper ranVlWrapper; try { ranVlWrapper = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); From 3cb78570520be0668e378e44f233b5c2e1c3d977 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 18:29:39 +0100 Subject: [PATCH 020/187] Fixes to ensure the instance of ranVnfVertex. Rename cpd variable. --- .../expbuilder/nsd/compose/NsdComposer.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 3b119a2..6bca6c6 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -518,8 +518,8 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - String selectedCp = ctxNonMgmtVls.keySet().iterator().next(); - addVirtualLink(vsbNsd, vsbNsDf, vsbNsLvl, ctxNonMgmtVls.get(selectedCp)); + String ctxVnfPrimaryCpd = ctxNonMgmtVls.keySet().iterator().next(); + addVirtualLink(vsbNsd, vsbNsDf, vsbNsLvl, ctxNonMgmtVls.get(ctxVnfPrimaryCpd)); // Retrieve vsb info VlWrapper ranVlWrapper; @@ -531,6 +531,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd(e.getMessage()); } + // Assumption: select the first VNF attached to the RAN VL ProfileVertex ranVlVertex; try { ranVlVertex = nsdGraphService @@ -540,13 +541,12 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - // Assumption: select the first VNF attached to the RAN VL List ranVlNeigh = Graphs.neighborListOf(vsbG, ranVlVertex); - ProfileVertex ranVnfVertex; + VnfProfileVertex ranVnfVertex; Optional optV = ranVlNeigh.stream().filter(v -> v instanceof VnfProfileVertex) .findFirst(); if (optV.isPresent()) { - ranVnfVertex = optV.get(); + ranVnfVertex = (VnfProfileVertex) optV.get(); } else { throw new InvalidNsd( "No neighbor of type VnfProfileVertex found for '" + ranVlVertex.getVertexId() + "'."); @@ -555,9 +555,10 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, VnfWrapper ranVnfWrapper; try { - ranVnfWrapper = retrieveVnfInfo(ranVnfVertex.getElementId(), vsbNsd, vsbNsDf, - vsbNsLvl); - log.debug("Retrieved VNF information for id: '{}'", ranVnfVertex.getElementId()); + ranVnfWrapper = retrieveVnfInfo(ranVnfVertex.getVnfProfile().getVnfProfileId(), + vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Retrieved VNF information for id: '{}'", + ranVnfVertex.getVnfProfile().getVnfProfileId()); } catch (InvalidNsd | VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); From 90dcc88d5be1568fe2849a85716ed2e6f18292e7 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 18:46:31 +0100 Subject: [PATCH 021/187] Connect ranVnf with VL coming from context. --- .../expbuilder/nsd/compose/NsdComposer.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 6bca6c6..749a48d 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -551,17 +551,20 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd( "No neighbor of type VnfProfileVertex found for '" + ranVlVertex.getVertexId() + "'."); } - String cpdId = vsbG.getEdge(ranVlVertex, ranVnfVertex); - - VnfWrapper ranVnfWrapper; - try { - ranVnfWrapper = retrieveVnfInfo(ranVnfVertex.getVnfProfile().getVnfProfileId(), - vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Retrieved VNF information for id: '{}'", - ranVnfVertex.getVnfProfile().getVnfProfileId()); - } catch (InvalidNsd | VnfNotFoundInLvlMapping e) { + String ranVnfCpd = vsbG.getEdge(ranVlVertex, ranVnfVertex); + + // Connect ranVnf to the new VL coming from ctx + Optional optVlc = ranVnfVertex.getVnfProfile() + .getNsVirtualLinkConnectivity().stream() + .filter(vlc -> vlc.getCpdId().get(0).equals(ranVnfCpd)).findFirst(); + if (optVlc.isPresent()) { + optVlc.get().setVirtualLinkProfileId( + ctxNonMgmtVls.get(ctxVnfPrimaryCpd).getVlProfile().getVirtualLinkProfileId()); + } else { + InvalidNsd e = new InvalidNsd("Could not find NsVirtualLinkConnectivity for cpdId:'" + + ranVnfCpd + "'."); log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw e; } // TODO make connections From cda5c50521e067c1ce7e940a10b9db555a5d1078 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 18:47:12 +0100 Subject: [PATCH 022/187] Use LinkedHashMap that preserves insertion order. --- .../it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 749a48d..375e336 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -22,6 +22,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -501,7 +502,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd(e.getMessage()); } List ctxVnfNeighbors = Graphs.neighborListOf(ctxG, ctxVnfPVertex); - Map ctxNonMgmtVls = new HashMap<>(); + LinkedHashMap ctxNonMgmtVls = new LinkedHashMap<>(); try { for (ProfileVertex vlpV : ctxVnfNeighbors) { if (!((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() From 68a85faa62d9e33ea90c78d2a924b59653a9c8ed Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 19:03:24 +0100 Subject: [PATCH 023/187] Small fix to get the right connections for ctxVnf. --- .../expbuilder/nsd/compose/NsdComposer.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 375e336..84621dd 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -21,10 +21,10 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; -import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; import lombok.AllArgsConstructor; import lombok.SneakyThrows; @@ -493,7 +493,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, } addVnf(vsbNsd, vsbNsDf, vsbNsLvl, ctxVnfWrapper); - // Retrieve first non-management VLs from ctx + // Retrieve non-management VLs from ctx ProfileVertex ctxVnfPVertex; try { ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); @@ -519,10 +519,11 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - String ctxVnfPrimaryCpd = ctxNonMgmtVls.keySet().iterator().next(); - addVirtualLink(vsbNsd, vsbNsDf, vsbNsLvl, ctxNonMgmtVls.get(ctxVnfPrimaryCpd)); + Iterator> ctxNonMgmtVLIter = ctxNonMgmtVls.entrySet().iterator(); + Entry ctxPrimaryConn = ctxNonMgmtVLIter.next(); + addVirtualLink(vsbNsd, vsbNsDf, vsbNsLvl, ctxPrimaryConn.getValue()); - // Retrieve vsb info + // Retrieve RAN VL information from vsb VlWrapper ranVlWrapper; try { ranVlWrapper = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); @@ -532,6 +533,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd(e.getMessage()); } + // Retrieve RAN closest VNF information from vsb // Assumption: select the first VNF attached to the RAN VL ProfileVertex ranVlVertex; try { @@ -560,7 +562,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, .filter(vlc -> vlc.getCpdId().get(0).equals(ranVnfCpd)).findFirst(); if (optVlc.isPresent()) { optVlc.get().setVirtualLinkProfileId( - ctxNonMgmtVls.get(ctxVnfPrimaryCpd).getVlProfile().getVirtualLinkProfileId()); + ctxNonMgmtVls.get(ctxPrimaryConn.getKey()).getVlProfile().getVirtualLinkProfileId()); } else { InvalidNsd e = new InvalidNsd("Could not find NsVirtualLinkConnectivity for cpdId:'" + ranVnfCpd + "'."); @@ -568,6 +570,9 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw e; } + // Connect ctxVnf with RAN VL + Entry ctxSecondaryConn = ctxNonMgmtVLIter.next(); + // TODO make connections // TODO clear context vnf cpd for mgmt. Handled in another method. From 65c558fcc472d170edfdcf793ee23333781e7072 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 20:18:03 +0100 Subject: [PATCH 024/187] Connectx ctxVnf with ranVL. --- .../expbuilder/nsd/compose/NsdComposer.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 84621dd..3288b9a 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -557,11 +557,11 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, String ranVnfCpd = vsbG.getEdge(ranVlVertex, ranVnfVertex); // Connect ranVnf to the new VL coming from ctx - Optional optVlc = ranVnfVertex.getVnfProfile() + Optional optRanVlc = ranVnfVertex.getVnfProfile() .getNsVirtualLinkConnectivity().stream() .filter(vlc -> vlc.getCpdId().get(0).equals(ranVnfCpd)).findFirst(); - if (optVlc.isPresent()) { - optVlc.get().setVirtualLinkProfileId( + if (optRanVlc.isPresent()) { + optRanVlc.get().setVirtualLinkProfileId( ctxNonMgmtVls.get(ctxPrimaryConn.getKey()).getVlProfile().getVirtualLinkProfileId()); } else { InvalidNsd e = new InvalidNsd("Could not find NsVirtualLinkConnectivity for cpdId:'" @@ -572,8 +572,18 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, // Connect ctxVnf with RAN VL Entry ctxSecondaryConn = ctxNonMgmtVLIter.next(); - - // TODO make connections + Optional optCtxVlc = ctxVnfWrapper.getVnfProfile() + .getNsVirtualLinkConnectivity().stream() + .filter(vlc -> vlc.getCpdId().get(0).equals(ctxSecondaryConn.getKey())).findFirst(); + if (optCtxVlc.isPresent()) { + optCtxVlc.get().setVirtualLinkProfileId( + ranVlWrapper.getVlProfile().getVirtualLinkProfileId()); + } else { + InvalidNsd e = new InvalidNsd("Could not find NsVirtualLinkConnectivity for cpdId:'" + + ranVnfCpd + "'."); + log.error(e.getMessage()); + throw e; + } // TODO clear context vnf cpd for mgmt. Handled in another method. From 6211bc62590435cb9684c4d6348f0b48ea403f70 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 20:32:48 +0100 Subject: [PATCH 025/187] Refactor method to create connections. --- .../expbuilder/nsd/compose/NsdComposer.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 3288b9a..5e03cc3 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -302,6 +302,21 @@ private NsVirtualLinkDesc findSapVld(Sapd sapd, Nsd nsd) throws InvalidNsd { return vld; } + private void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vlp) + throws NotExistingEntityException { + Optional optVlConn = vnfp.getNsVirtualLinkConnectivity().stream() + .filter(vlConn -> vlConn.getCpdId().get(0).equals(cpdId)).findFirst(); + if (optVlConn.isPresent()) { + optVlConn.get().setVirtualLinkProfileId(vlp.getVirtualLinkProfileId()); + } else { + String m = MessageFormatter + .format("cpdId='{}' not found in vnfProfile='{}'.", cpdId, vnfp.getVnfProfileId()) + .getMessage(); + throw new NotExistingEntityException(m); + } + + } + // @SuppressWarnings("DuplicatedCode") // @SneakyThrows(JsonProcessingException.class) // public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) @@ -557,32 +572,22 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, String ranVnfCpd = vsbG.getEdge(ranVlVertex, ranVnfVertex); // Connect ranVnf to the new VL coming from ctx - Optional optRanVlc = ranVnfVertex.getVnfProfile() - .getNsVirtualLinkConnectivity().stream() - .filter(vlc -> vlc.getCpdId().get(0).equals(ranVnfCpd)).findFirst(); - if (optRanVlc.isPresent()) { - optRanVlc.get().setVirtualLinkProfileId( - ctxNonMgmtVls.get(ctxPrimaryConn.getKey()).getVlProfile().getVirtualLinkProfileId()); - } else { - InvalidNsd e = new InvalidNsd("Could not find NsVirtualLinkConnectivity for cpdId:'" - + ranVnfCpd + "'."); + try { + connectVnfToVL(ranVnfVertex.getVnfProfile(), ranVnfCpd, + ctxPrimaryConn.getValue().getVlProfile()); + } catch (NotExistingEntityException e) { log.error(e.getMessage()); - throw e; + throw new InvalidNsd(e.getMessage()); } // Connect ctxVnf with RAN VL Entry ctxSecondaryConn = ctxNonMgmtVLIter.next(); - Optional optCtxVlc = ctxVnfWrapper.getVnfProfile() - .getNsVirtualLinkConnectivity().stream() - .filter(vlc -> vlc.getCpdId().get(0).equals(ctxSecondaryConn.getKey())).findFirst(); - if (optCtxVlc.isPresent()) { - optCtxVlc.get().setVirtualLinkProfileId( - ranVlWrapper.getVlProfile().getVirtualLinkProfileId()); - } else { - InvalidNsd e = new InvalidNsd("Could not find NsVirtualLinkConnectivity for cpdId:'" - + ranVnfCpd + "'."); + try { + connectVnfToVL(ctxVnfWrapper.getVnfProfile(), ctxSecondaryConn.getKey(), + ranVlWrapper.getVlProfile()); + } catch (NotExistingEntityException e) { log.error(e.getMessage()); - throw e; + throw new InvalidNsd(e.getMessage()); } // TODO clear context vnf cpd for mgmt. Handled in another method. From f08c1aa780eff4b93965caa4c3fccf057a615659 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Fri, 6 Mar 2020 21:13:35 +0100 Subject: [PATCH 026/187] Re-order parameters in add* methods. --- .../blueprint/expbuilder/nsd/compose/NsdComposer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 5e03cc3..5c1ffce 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -188,7 +188,7 @@ private VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel ns return vlLvlMap; } - private void addVnf(Nsd nsd, NsDf nsDf, NsLevel nsLevel, VnfWrapper vnfWrapper) { + private void addVnf(VnfWrapper vnfWrapper, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { String vnfdId = vnfWrapper.getVfndId(); if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { nsd.getVnfdId().add(vnfdId); @@ -205,7 +205,7 @@ private void addVnf(Nsd nsd, NsDf nsDf, NsLevel nsLevel, VnfWrapper vnfWrapper) } } - private void addVirtualLink(Nsd nsd, NsDf nsDf, NsLevel nsLevel, VlWrapper vlWrapper) { + private void addVirtualLink(VlWrapper vlWrapper, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { NsVirtualLinkDesc vlDesc = vlWrapper.getVlDescriptor(); if (nsd.getVirtualLinkDesc().stream() .noneMatch(nsdVld -> nsdVld.getVirtualLinkDescId().equals(vlDesc.getVirtualLinkDescId()))) { @@ -506,7 +506,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - addVnf(vsbNsd, vsbNsDf, vsbNsLvl, ctxVnfWrapper); + addVnf(ctxVnfWrapper, vsbNsd, vsbNsDf, vsbNsLvl); // Retrieve non-management VLs from ctx ProfileVertex ctxVnfPVertex; @@ -536,7 +536,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, } Iterator> ctxNonMgmtVLIter = ctxNonMgmtVls.entrySet().iterator(); Entry ctxPrimaryConn = ctxNonMgmtVLIter.next(); - addVirtualLink(vsbNsd, vsbNsDf, vsbNsLvl, ctxPrimaryConn.getValue()); + addVirtualLink(ctxPrimaryConn.getValue(), vsbNsd, vsbNsDf, vsbNsLvl); // Retrieve RAN VL information from vsb VlWrapper ranVlWrapper; From 12eea4903e277d9be97bd8f4f50c2b5d2dd812d6 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 7 Mar 2020 12:45:09 +0100 Subject: [PATCH 027/187] First version of test for pass_through. --- .../expbuilder/nsd/compose/NsdComposer.java | 45 +++++++++++++--- .../nsd/compose/NsdComposerTest.java | 53 ++++++++----------- 2 files changed, 62 insertions(+), 36 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 5c1ffce..c7993dd 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -10,6 +10,7 @@ import it.cnit.blueprint.expbuilder.nsd.graph.VnfProfileVertex; import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; +import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; @@ -458,7 +459,7 @@ private void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vl @SneakyThrows(JsonProcessingException.class) public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, String ctxMgmtVldId, Nsd ctxNsd) - throws InvalidNsd, InvalidCtxComposeInfo { + throws InvalidNsd { NsVirtualLinkDesc ranVld; try { ranVld = findSapVld(ranSapd, vsbNsd); @@ -475,7 +476,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, NsDf vsbNsDf = vsbNsd.getNsDf().get(0); Graph ctxG = nsdGraphService .buildGraph(ctxNsd.getSapd(), ctxNsDf, ctxNsLvl); - log.debug("ctxG graph composition :\n{}", nsdGraphService.export(ctxG)); + log.debug("ctxG graph:\n{}", nsdGraphService.export(ctxG)); log.info("Composing '{}' with <{}, {}, {}>.", vsbNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), @@ -494,6 +495,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, VnfProfile ctxVnfProfile; try { ctxVnfProfile = getVnfProfileByDescId(ctxVnfdId, ctxNsDf); + log.debug("Found vnfProfile='{}' in context.", ctxVnfProfile.getVnfProfileId()); } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -502,24 +504,28 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, try { ctxVnfWrapper = retrieveVnfInfo(ctxVnfProfile.getVnfProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); + log.debug("Found VnfInfo for vnfProfile='{}' in context.", ctxVnfProfile.getVnfProfileId()); } catch (VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } addVnf(ctxVnfWrapper, vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Added Vnfd='{}' in service (if not present).", ctxVnfdId); // Retrieve non-management VLs from ctx ProfileVertex ctxVnfPVertex; try { ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); + log.debug("ctxVnfPVertex: {}", ctxVnfPVertex.toString()); } catch (ProfileVertexNotFoundException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - List ctxVnfNeighbors = Graphs.neighborListOf(ctxG, ctxVnfPVertex); + List ctxVnfNeigh = Graphs.neighborListOf(ctxG, ctxVnfPVertex); + log.debug("ctxVnfPVertex neighbors: {}", ctxVnfNeigh.toString()); LinkedHashMap ctxNonMgmtVls = new LinkedHashMap<>(); try { - for (ProfileVertex vlpV : ctxVnfNeighbors) { + for (ProfileVertex vlpV : ctxVnfNeigh) { if (!((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() .equals(ctxMgmtVldId)) { VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); @@ -534,15 +540,18 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } + log.debug("ctxNonMgmtVls: {}", ctxNonMgmtVls.toString()); Iterator> ctxNonMgmtVLIter = ctxNonMgmtVls.entrySet().iterator(); Entry ctxPrimaryConn = ctxNonMgmtVLIter.next(); addVirtualLink(ctxPrimaryConn.getValue(), vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Added VirtualLinkDescriptor='{}' in service (if not present).", + ctxPrimaryConn.getValue().getVlDescriptor().getVirtualLinkDescId()); // Retrieve RAN VL information from vsb VlWrapper ranVlWrapper; try { ranVlWrapper = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); - log.debug("Retrieved VL information for RAN vld: '{}'", ranVld.getVirtualLinkDescId()); + log.debug("Found VlInfo for ranVld='{}' in context.", ranVld.getVirtualLinkDescId()); } catch (InvalidNsd | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -554,27 +563,32 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, try { ranVlVertex = nsdGraphService .getVertexById(vsbG, ranVlWrapper.getVlProfile().getVirtualLinkProfileId()); - log.debug("Found ProfileVertex for RAN VL."); + log.debug("ranVlVertex: {}", ranVlVertex.toString()); } catch (ProfileVertexNotFoundException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } List ranVlNeigh = Graphs.neighborListOf(vsbG, ranVlVertex); + log.debug("ranVlVertex neighbors: {}", ranVlNeigh.toString()); VnfProfileVertex ranVnfVertex; Optional optV = ranVlNeigh.stream().filter(v -> v instanceof VnfProfileVertex) .findFirst(); if (optV.isPresent()) { ranVnfVertex = (VnfProfileVertex) optV.get(); + log.debug("ranVnfVertex: {}", ranVnfVertex.toString()); } else { throw new InvalidNsd( "No neighbor of type VnfProfileVertex found for '" + ranVlVertex.getVertexId() + "'."); } String ranVnfCpd = vsbG.getEdge(ranVlVertex, ranVnfVertex); + log.debug("ranVnfCpd: {}", ranVnfCpd); // Connect ranVnf to the new VL coming from ctx try { connectVnfToVL(ranVnfVertex.getVnfProfile(), ranVnfCpd, ctxPrimaryConn.getValue().getVlProfile()); + log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", + ranVnfVertex.getVnfProfile(), ctxPrimaryConn.getValue().getVlProfile()); } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -585,6 +599,8 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, try { connectVnfToVL(ctxVnfWrapper.getVnfProfile(), ctxSecondaryConn.getKey(), ranVlWrapper.getVlProfile()); + log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", + ctxVnfWrapper.getVnfProfile(), ranVlWrapper.getVlProfile()); } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -592,6 +608,23 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, // TODO clear context vnf cpd for mgmt. Handled in another method. + try { + vsbNsd.isValid(); + } catch (MalformattedElementException e) { + String m = "Nsd looks not valid after composition"; + log.error(m, e); + throw new InvalidNsd(m); + } + vsbG = nsdGraphService.buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); + log.debug("Graph AFTER composition with {}:\n{}", + ctxNsd.getNsdIdentifier(), nsdGraphService.export(vsbG)); + log.info("Completed composition for nsDf='{}' and nsLvl='{}'", + vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); + log.debug("Nsd AFTER composition with {}:\n{}", + ctxNsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(vsbNsd)); + log.info("Completed composition of '{}' with <{}, {}, {}>.", + vsbNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), + ctxNsLvl.getNsLevelId()); } } diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java index d5ccd83..c016d4b 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java @@ -8,14 +8,12 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.expbuilder.nsd.graph.GraphVizExporter; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; -import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; -import it.cnit.blueprint.expbuilder.rest.VnfConnection; -import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import java.io.InputStream; import java.net.URL; import java.util.Arrays; -import java.util.List; +import java.util.Optional; import java.util.Properties; import lombok.SneakyThrows; import org.junit.BeforeClass; @@ -24,7 +22,7 @@ public class NsdComposerTest { - static Properties prop; + static Properties urlProp; static ObjectMapper oM; static NsdGraphService nsdGraphService; static NsdComposer nsdComposer; @@ -33,14 +31,14 @@ public class NsdComposerTest { @SneakyThrows public static void setUp() { // Test Setup - prop = new Properties(); + urlProp = new Properties(); InputStream input = ClassLoader.getSystemResourceAsStream("url.properties"); - prop.load(input); + urlProp.load(input); oM = new ObjectMapper(new YAMLFactory()); nsdGraphService = new NsdGraphService(new GraphVizExporter()); nsdComposer = new NsdComposer(nsdGraphService); Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - root.setLevel(Level.ERROR); + root.setLevel(Level.DEBUG); } @Test @@ -48,34 +46,29 @@ public static void setUp() { public void composeTrackerWithDelay() { // Given - Nsd trackerNsd = oM.readValue(new URL(prop.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; - - List delayNsds = Arrays - .asList(oM.readValue(new URL(prop.getProperty("ctx.delay.nsds")), Nsd[].class)); - OnboardCtxBlueprintRequest onbCtxReq = new OnboardCtxBlueprintRequest(null, delayNsds, null); - VnfConnection[] ctxConnections = new VnfConnection[3]; - ctxConnections[0] = new VnfConnection("vnfp_netem", "cp_dg_traffic_in", - "vlp_vl_tracking_mobile"); - ctxConnections[1] = new VnfConnection("vnfp_netem", "cp_dg_traffic_out", - "vlp_vl_dg_out"); - ctxConnections[2] = new VnfConnection("vnfp_netem", "cp_dg_mgt", - "vlp_vl_tracking_mgt"); - VnfConnection[] vsConnections = new VnfConnection[2]; - vsConnections[0] = new VnfConnection("vnfp_big_Ares2T_Tracker", "cp_tracker_ext_in", - "vlp_vl_dg_out"); - vsConnections[1] = new VnfConnection("vnfp_small_Ares2T_Tracker", "cp_tracker_ext_in", - "vlp_vl_dg_out"); - CtxComposeInfo ctxComposeInfo = new CtxComposeInfo(onbCtxReq, ctxConnections, vsConnections); + Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + Sapd ranSapd; + Optional optSapd = vsbNsd.getSapd().stream() + .filter(s -> s.getCpdId().equals("sap_tracking_mobile")).findFirst(); + if (optSapd.isPresent()) { + ranSapd = optSapd.get(); + } else { + throw new Exception(); + } + Nsd ctxNsd = Arrays + .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); + String ctxVnfdId = "396d1b6b-331b-4dd7-b48e-376517d3654a"; + String ctxMgmtVldId = "vl_dg_mgt"; // When - nsdComposer.compose(trackerNsd, new CtxComposeInfo[]{ctxComposeInfo}); + nsdComposer.composePassThrough(ranSapd, vsbNsd, ctxVnfdId, ctxMgmtVldId, ctxNsd); // Setting ID manually for test purpose - trackerNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); - trackerNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); + vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); + vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); // Then InputStream in = getClass().getResourceAsStream("/expb_ares2t_tracker_delay_nsds.yaml"); Nsd expNsd = oM.readValue(in, Nsd[].class)[0]; - assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(trackerNsd)); + assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); } } \ No newline at end of file From f7f5fe407cb147867984ea648b17e67e4fb8bb20 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 7 Mar 2020 13:05:39 +0100 Subject: [PATCH 028/187] Get management cpd from the ctxVnf. --- .../expbuilder/nsd/compose/NsdComposer.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index c7993dd..2ec881f 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -523,14 +523,19 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, } List ctxVnfNeigh = Graphs.neighborListOf(ctxG, ctxVnfPVertex); log.debug("ctxVnfPVertex neighbors: {}", ctxVnfNeigh.toString()); + String ctxMgmtCpdId = null; LinkedHashMap ctxNonMgmtVls = new LinkedHashMap<>(); try { for (ProfileVertex vlpV : ctxVnfNeigh) { - if (!((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() - .equals(ctxMgmtVldId)) { - VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); - ctxNonMgmtVls.put(ctxG.getEdge(ctxVnfPVertex, vlpV), - retrieveVlInfo(vlProfile.getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl)); + if (vlpV instanceof VirtualLinkProfileVertex) { + if (((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() + .equals(ctxMgmtVldId)) { + ctxMgmtCpdId = ctxG.getEdge(ctxVnfPVertex, vlpV); + } else { + VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); + ctxNonMgmtVls.put(ctxG.getEdge(ctxVnfPVertex, vlpV), + retrieveVlInfo(vlProfile.getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl)); + } } } if (ctxNonMgmtVls.isEmpty()) { @@ -606,7 +611,19 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, throw new InvalidNsd(e.getMessage()); } - // TODO clear context vnf cpd for mgmt. Handled in another method. + // Connect ctxVnf to vsbNsd mgmt VL + NsVirtualLinkDesc vsbMgmtVld = null; + if (ctxMgmtCpdId != null) { + try { + connectVnfToVL(ctxVnfWrapper.getVnfProfile(), ctxMgmtCpdId, + retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl)); + } catch (VlNotFoundInLvlMapping | NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + } else { + log.warn("Could not find a management Cp for ctxVnf. Skip."); + } try { vsbNsd.isValid(); From 53262114c8b8ef8d8a1e9349cb30c43d51cc3a7c Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 7 Mar 2020 13:28:18 +0100 Subject: [PATCH 029/187] Change input to work with NsVirtualLinkDesc. --- .../expbuilder/master/MasterComposer.java | 11 +++--- .../expbuilder/nsd/compose/NsdComposer.java | 34 +++++-------------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java index dc923c2..55126ce 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java @@ -8,6 +8,7 @@ import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import lombok.AllArgsConstructor; @@ -44,15 +45,15 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte log.info("pass_through"); // compose Nsd Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); + NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); String ctxVnfdId; if (ctxNsd.getVnfdId().size() == 1) { ctxVnfdId = ctxNsd.getVnfdId().get(0); } else { throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); } - String ctxMgmtVldId = findMgmtVldId(ctxB, ctxNsd); - nsdComposer.composePassThrough(ranSapd, vsbNsd, ctxVnfdId, ctxMgmtVldId, ctxNsd); - // TODO prepare input for mgmt VL and cpdid + NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); + nsdComposer.composePassThrough(ranSapd, vsbMgmtVld, vsbNsd, ctxVnfdId, ctxMgmtVld, ctxNsd); // compose Exp blueprint } else { log.error("not supported"); @@ -62,10 +63,10 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte } } - private String findMgmtVldId(Blueprint b, Nsd nsd) { + private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) { // TODO Visit vlDesc in nsd and check if mgmt in b. // We need model modifications to make this work. - return ""; + return new NsVirtualLinkDesc(); } private Sapd findRanSapd(Blueprint b, Nsd nsd) { diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 2ec881f..55359d4 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -8,7 +8,6 @@ import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; import it.cnit.blueprint.expbuilder.nsd.graph.VirtualLinkProfileVertex; import it.cnit.blueprint.expbuilder.nsd.graph.VnfProfileVertex; -import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; @@ -288,21 +287,6 @@ private VlWrapper retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLev return new VlWrapper(vlMap, vlProfile, vld); } - private NsVirtualLinkDesc findSapVld(Sapd sapd, Nsd nsd) throws InvalidNsd { - NsVirtualLinkDesc vld; - Optional optVld = nsd.getVirtualLinkDesc().stream() - .filter(v -> v.getVirtualLinkDescId().equals(sapd.getNsVirtualLinkDescId())).findFirst(); - if (optVld.isPresent()) { - vld = optVld.get(); - } else { - String m = MessageFormatter - .format("Vld with id='{}' not found.", sapd.getNsVirtualLinkDescId()) - .getMessage(); - throw new InvalidNsd(m); - } - return vld; - } - private void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vlp) throws NotExistingEntityException { Optional optVlConn = vnfp.getNsVirtualLinkConnectivity().stream() @@ -457,15 +441,15 @@ private void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vl // } @SneakyThrows(JsonProcessingException.class) - public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, - String ctxMgmtVldId, Nsd ctxNsd) + public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, + String ctxVnfdId, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) throws InvalidNsd { NsVirtualLinkDesc ranVld; try { - ranVld = findSapVld(ranSapd, vsbNsd); - } catch (InvalidNsd e) { + ranVld = getVlDescriptor(ranSapd.getNsVirtualLinkDescId(), vsbNsd); + } catch (NotExistingEntityException e) { log.error(e.getMessage()); - throw e; + throw new InvalidNsd(e.getMessage()); } // We assume only one NsDf for the context @@ -529,7 +513,7 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, for (ProfileVertex vlpV : ctxVnfNeigh) { if (vlpV instanceof VirtualLinkProfileVertex) { if (((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() - .equals(ctxMgmtVldId)) { + .equals(ctxMgmtVld.getVirtualLinkDescId())) { ctxMgmtCpdId = ctxG.getEdge(ctxVnfPVertex, vlpV); } else { VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); @@ -612,12 +596,12 @@ public void composePassThrough(Sapd ranSapd, Nsd vsbNsd, String ctxVnfdId, } // Connect ctxVnf to vsbNsd mgmt VL - NsVirtualLinkDesc vsbMgmtVld = null; + VlWrapper vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); if (ctxMgmtCpdId != null) { try { connectVnfToVL(ctxVnfWrapper.getVnfProfile(), ctxMgmtCpdId, - retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl)); - } catch (VlNotFoundInLvlMapping | NotExistingEntityException e) { + vsbMgmtVlInfo.getVlProfile()); + } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } From 8d6b45fd3cf0db5380b6d348f1d5f12b633f5ea0 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 7 Mar 2020 13:33:32 +0100 Subject: [PATCH 030/187] Complete code to connect Mgmt stuff. --- .../expbuilder/nsd/compose/NsdComposer.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 55359d4..5ec1122 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -596,19 +596,25 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v } // Connect ctxVnf to vsbNsd mgmt VL - VlWrapper vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); - if (ctxMgmtCpdId != null) { - try { - connectVnfToVL(ctxVnfWrapper.getVnfProfile(), ctxMgmtCpdId, - vsbMgmtVlInfo.getVlProfile()); - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + VlWrapper vsbMgmtVlInfo; + try { + vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); + if (ctxMgmtCpdId != null) { + try { + connectVnfToVL(ctxVnfWrapper.getVnfProfile(), ctxMgmtCpdId, + vsbMgmtVlInfo.getVlProfile()); + } catch (NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + } else { + log.warn("Could not find a management Cp for ctxVnf. Skip."); } - } else { - log.warn("Could not find a management Cp for ctxVnf. Skip."); + } catch (VlNotFoundInLvlMapping e) { + log.warn(e.getMessage() + " Skip."); } + // Nsd validation and logging try { vsbNsd.isValid(); } catch (MalformattedElementException e) { From d9f3bc48e99cedaa95a2f2261c635cb0f115bea3 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 7 Mar 2020 13:40:24 +0100 Subject: [PATCH 031/187] Complete test for Passthrough. Successful. --- .../nsd/compose/NsdComposerTest.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java index c016d4b..2a94bf7 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.expbuilder.nsd.graph.GraphVizExporter; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import java.io.InputStream; @@ -55,13 +56,28 @@ public void composeTrackerWithDelay() { } else { throw new Exception(); } + NsVirtualLinkDesc vsbMgmtVld; + Optional optVsbVld = vsbNsd.getVirtualLinkDesc().stream() + .filter(v->v.getVirtualLinkDescId().equals("vl_tracking_mgt")).findFirst(); + if (optVsbVld.isPresent()){ + vsbMgmtVld=optVsbVld.get(); + } else { + throw new Exception(); + } Nsd ctxNsd = Arrays .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); String ctxVnfdId = "396d1b6b-331b-4dd7-b48e-376517d3654a"; - String ctxMgmtVldId = "vl_dg_mgt"; + NsVirtualLinkDesc ctxMgmtVld; + Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() + .filter(v->v.getVirtualLinkDescId().equals("vl_dg_mgt")).findFirst(); + if (optCtxVld.isPresent()){ + ctxMgmtVld=optCtxVld.get(); + } else { + throw new Exception(); + } // When - nsdComposer.composePassThrough(ranSapd, vsbNsd, ctxVnfdId, ctxMgmtVldId, ctxNsd); + nsdComposer.composePassThrough(ranSapd, vsbMgmtVld, vsbNsd, ctxVnfdId, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); From d0a9a8f89fdddce53938656d90f8b4561002be1e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 7 Mar 2020 17:28:54 +0100 Subject: [PATCH 032/187] Rename wrapper classes with Info. --- .../expbuilder/nsd/compose/NsdComposer.java | 58 +++++++++---------- .../compose/{VlWrapper.java => VlInfo.java} | 2 +- .../compose/{VnfWrapper.java => VnfInfo.java} | 3 +- 3 files changed, 32 insertions(+), 31 deletions(-) rename src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/{VlWrapper.java => VlInfo.java} (95%) rename src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/{VnfWrapper.java => VnfInfo.java} (93%) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 5ec1122..bf94938 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -188,35 +188,35 @@ private VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel ns return vlLvlMap; } - private void addVnf(VnfWrapper vnfWrapper, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { - String vnfdId = vnfWrapper.getVfndId(); + private void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { + String vnfdId = vnfInfo.getVfndId(); if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { nsd.getVnfdId().add(vnfdId); } - VnfProfile vnfProfile = vnfWrapper.getVnfProfile(); + VnfProfile vnfProfile = vnfInfo.getVnfProfile(); if (nsDf.getVnfProfile().stream() .noneMatch(vp -> vp.getVnfProfileId().equals(vnfProfile.getVnfProfileId()))) { nsDf.getVnfProfile().add(vnfProfile); } - VnfToLevelMapping vnfLvlMap = vnfWrapper.getVnfToLevelMapping(); + VnfToLevelMapping vnfLvlMap = vnfInfo.getVnfToLevelMapping(); if (nsLevel.getVnfToLevelMapping().stream() .noneMatch(lm -> lm.getVnfProfileId().equals(vnfProfile.getVnfProfileId()))) { nsLevel.getVnfToLevelMapping().add(vnfLvlMap); } } - private void addVirtualLink(VlWrapper vlWrapper, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { - NsVirtualLinkDesc vlDesc = vlWrapper.getVlDescriptor(); + private void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { + NsVirtualLinkDesc vlDesc = vlInfo.getVlDescriptor(); if (nsd.getVirtualLinkDesc().stream() .noneMatch(nsdVld -> nsdVld.getVirtualLinkDescId().equals(vlDesc.getVirtualLinkDescId()))) { nsd.getVirtualLinkDesc().add(vlDesc); } - VirtualLinkProfile vlProfile = vlWrapper.getVlProfile(); + VirtualLinkProfile vlProfile = vlInfo.getVlProfile(); if (nsDf.getVirtualLinkProfile().stream().noneMatch( nsdfVlP -> nsdfVlP.getVirtualLinkProfileId().equals(vlProfile.getVirtualLinkProfileId()))) { nsDf.getVirtualLinkProfile().add(vlProfile); } - VirtualLinkToLevelMapping vlMap = vlWrapper.getVlToLevelMapping(); + VirtualLinkToLevelMapping vlMap = vlInfo.getVlToLevelMapping(); if (nsLevel.getVirtualLinkToLevelMapping().stream().noneMatch( nslevelMap -> nslevelMap.getVirtualLinkProfileId() .equals(vlMap.getVirtualLinkProfileId()))) { @@ -224,7 +224,7 @@ private void addVirtualLink(VlWrapper vlWrapper, Nsd nsd, NsDf nsDf, NsLevel nsL } } - private VnfWrapper retrieveVnfInfo(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) + private VnfInfo retrieveVnfInfo(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) throws InvalidNsd, VnfNotFoundInLvlMapping { VnfToLevelMapping vnfLvlMap; try { @@ -244,10 +244,10 @@ private VnfWrapper retrieveVnfInfo(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLe } catch (NotExistingEntityException e) { throw new InvalidNsd(e.getMessage()); } - return new VnfWrapper(vnfdId, vnfProfile, vnfLvlMap); + return new VnfInfo(vnfdId, vnfProfile, vnfLvlMap); } - private VlWrapper retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) + private VlInfo retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) throws InvalidNsd, VlNotFoundInLvlMapping { VirtualLinkToLevelMapping vlMap; try { @@ -267,10 +267,10 @@ private VlWrapper retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel } catch (NotExistingEntityException e) { throw new InvalidNsd(e.getMessage()); } - return new VlWrapper(vlMap, vlProfile, vlDesc); + return new VlInfo(vlMap, vlProfile, vlDesc); } - private VlWrapper retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLevel) + private VlInfo retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLevel) throws InvalidNsd, VlNotFoundInLvlMapping { VirtualLinkProfile vlProfile; try { @@ -284,7 +284,7 @@ private VlWrapper retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLev } catch (NotExistingEntityException e) { throw new VlNotFoundInLvlMapping(e.getMessage()); } - return new VlWrapper(vlMap, vlProfile, vld); + return new VlInfo(vlMap, vlProfile, vld); } private void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vlp) @@ -484,16 +484,16 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - VnfWrapper ctxVnfWrapper; + VnfInfo ctxVnfInfo; try { - ctxVnfWrapper = retrieveVnfInfo(ctxVnfProfile.getVnfProfileId(), + ctxVnfInfo = retrieveVnfInfo(ctxVnfProfile.getVnfProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); log.debug("Found VnfInfo for vnfProfile='{}' in context.", ctxVnfProfile.getVnfProfileId()); } catch (VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - addVnf(ctxVnfWrapper, vsbNsd, vsbNsDf, vsbNsLvl); + addVnf(ctxVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); log.debug("Added Vnfd='{}' in service (if not present).", ctxVnfdId); // Retrieve non-management VLs from ctx @@ -508,7 +508,7 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v List ctxVnfNeigh = Graphs.neighborListOf(ctxG, ctxVnfPVertex); log.debug("ctxVnfPVertex neighbors: {}", ctxVnfNeigh.toString()); String ctxMgmtCpdId = null; - LinkedHashMap ctxNonMgmtVls = new LinkedHashMap<>(); + LinkedHashMap ctxNonMgmtVls = new LinkedHashMap<>(); try { for (ProfileVertex vlpV : ctxVnfNeigh) { if (vlpV instanceof VirtualLinkProfileVertex) { @@ -530,16 +530,16 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v throw new InvalidNsd(e.getMessage()); } log.debug("ctxNonMgmtVls: {}", ctxNonMgmtVls.toString()); - Iterator> ctxNonMgmtVLIter = ctxNonMgmtVls.entrySet().iterator(); - Entry ctxPrimaryConn = ctxNonMgmtVLIter.next(); + Iterator> ctxNonMgmtVLIter = ctxNonMgmtVls.entrySet().iterator(); + Entry ctxPrimaryConn = ctxNonMgmtVLIter.next(); addVirtualLink(ctxPrimaryConn.getValue(), vsbNsd, vsbNsDf, vsbNsLvl); log.debug("Added VirtualLinkDescriptor='{}' in service (if not present).", ctxPrimaryConn.getValue().getVlDescriptor().getVirtualLinkDescId()); // Retrieve RAN VL information from vsb - VlWrapper ranVlWrapper; + VlInfo ranVlInfo; try { - ranVlWrapper = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); + ranVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); log.debug("Found VlInfo for ranVld='{}' in context.", ranVld.getVirtualLinkDescId()); } catch (InvalidNsd | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); @@ -551,7 +551,7 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v ProfileVertex ranVlVertex; try { ranVlVertex = nsdGraphService - .getVertexById(vsbG, ranVlWrapper.getVlProfile().getVirtualLinkProfileId()); + .getVertexById(vsbG, ranVlInfo.getVlProfile().getVirtualLinkProfileId()); log.debug("ranVlVertex: {}", ranVlVertex.toString()); } catch (ProfileVertexNotFoundException e) { log.error(e.getMessage()); @@ -584,24 +584,24 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v } // Connect ctxVnf with RAN VL - Entry ctxSecondaryConn = ctxNonMgmtVLIter.next(); + Entry ctxSecondaryConn = ctxNonMgmtVLIter.next(); try { - connectVnfToVL(ctxVnfWrapper.getVnfProfile(), ctxSecondaryConn.getKey(), - ranVlWrapper.getVlProfile()); + connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxSecondaryConn.getKey(), + ranVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", - ctxVnfWrapper.getVnfProfile(), ranVlWrapper.getVlProfile()); + ctxVnfInfo.getVnfProfile(), ranVlInfo.getVlProfile()); } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } // Connect ctxVnf to vsbNsd mgmt VL - VlWrapper vsbMgmtVlInfo; + VlInfo vsbMgmtVlInfo; try { vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); if (ctxMgmtCpdId != null) { try { - connectVnfToVL(ctxVnfWrapper.getVnfProfile(), ctxMgmtCpdId, + connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxMgmtCpdId, vsbMgmtVlInfo.getVlProfile()); } catch (NotExistingEntityException e) { log.error(e.getMessage()); diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlWrapper.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlInfo.java similarity index 95% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlWrapper.java rename to src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlInfo.java index cbfeac2..1a36442 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlWrapper.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlInfo.java @@ -8,7 +8,7 @@ @Data @AllArgsConstructor -public class VlWrapper { +public class VlInfo { private VirtualLinkToLevelMapping vlToLevelMapping; private VirtualLinkProfile vlProfile; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfWrapper.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfInfo.java similarity index 93% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfWrapper.java rename to src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfInfo.java index d461136..1d0c4ec 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfWrapper.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfInfo.java @@ -7,7 +7,8 @@ @Data @AllArgsConstructor -public class VnfWrapper { +public class VnfInfo +{ private String vfndId; private VnfProfile vnfProfile; From 99a0cac38dcbdf0321595f7e8e3f725d6555eb73 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 7 Mar 2020 17:44:06 +0100 Subject: [PATCH 033/187] Remove blank line. --- .../it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index bf94938..bd1f646 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -153,7 +153,6 @@ private String getVnfdId(String vnfdId, Nsd nsd) throws NotExistingEntityExcepti throw new NotExistingEntityException(m); } return vnfdIdFound; - } private NsVirtualLinkDesc getVlDescriptor(String vlDescId, Nsd nsd) From 48da9103c3e12b12139485f5a70a1af2f3a2dc95 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 7 Mar 2020 18:02:43 +0100 Subject: [PATCH 034/187] Remove ctxVnfdId from PassThrough. Unneeded since it's only one vnf. --- .../cnit/blueprint/expbuilder/master/MasterComposer.java | 9 ++++----- .../blueprint/expbuilder/nsd/compose/NsdComposer.java | 3 ++- .../expbuilder/nsd/compose/NsdComposerTest.java | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java index 55126ce..c25ebdc 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java @@ -44,16 +44,15 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)) { log.info("pass_through"); // compose Nsd - Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); - NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); - String ctxVnfdId; if (ctxNsd.getVnfdId().size() == 1) { - ctxVnfdId = ctxNsd.getVnfdId().get(0); + log.debug("ctxNsd has only one vnfdId."); } else { throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); } + Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); + NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); - nsdComposer.composePassThrough(ranSapd, vsbMgmtVld, vsbNsd, ctxVnfdId, ctxMgmtVld, ctxNsd); + nsdComposer.composePassThrough(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // compose Exp blueprint } else { log.error("not supported"); diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index bd1f646..579c3e3 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -441,7 +441,7 @@ private void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vl @SneakyThrows(JsonProcessingException.class) public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, - String ctxVnfdId, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) + NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) throws InvalidNsd { NsVirtualLinkDesc ranVld; try { @@ -450,6 +450,7 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } + String ctxVnfdId = ctxNsd.getVnfdId().get(0); // We assume only one NsDf for the context NsDf ctxNsDf = ctxNsd.getNsDf().get(0); diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java index 2a94bf7..f084dde 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java @@ -66,7 +66,6 @@ public void composeTrackerWithDelay() { } Nsd ctxNsd = Arrays .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); - String ctxVnfdId = "396d1b6b-331b-4dd7-b48e-376517d3654a"; NsVirtualLinkDesc ctxMgmtVld; Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() .filter(v->v.getVirtualLinkDescId().equals("vl_dg_mgt")).findFirst(); @@ -77,7 +76,7 @@ public void composeTrackerWithDelay() { } // When - nsdComposer.composePassThrough(ranSapd, vsbMgmtVld, vsbNsd, ctxVnfdId, ctxMgmtVld, ctxNsd); + nsdComposer.composePassThrough(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); From 9224ebca54c7e2faa0a16833c0bcc6a562348306 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 7 Mar 2020 18:20:28 +0100 Subject: [PATCH 035/187] Fix log lines in passthrough. Add methods for connect. --- .../expbuilder/nsd/compose/NsdComposer.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 579c3e3..9d76969 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -627,12 +627,19 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v ctxNsd.getNsdIdentifier(), nsdGraphService.export(vsbG)); log.info("Completed composition for nsDf='{}' and nsLvl='{}'", vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); - log.debug("Nsd AFTER composition with {}:\n{}", - ctxNsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(vsbNsd)); - log.info("Completed composition of '{}' with <{}, {}, {}>.", - vsbNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), - ctxNsLvl.getNsLevelId()); } + log.debug("Nsd AFTER composition with {}:\n{}", + ctxNsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(vsbNsd)); + log.info("Completed composition of '{}' with <{}, {}, {}>.", + vsbNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), + ctxNsLvl.getNsLevelId()); } + @SneakyThrows(JsonProcessingException.class) + public void composeConnectNoInput(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, + NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd){} + + @SneakyThrows(JsonProcessingException.class) + public void composeConnect(NsVirtualLinkDesc srcVl, NsVirtualLinkDesc dstVl, Nsd vsbNsd, + NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd){} } From 14b360d0bdac2eb35253e80525981e00b64c48e6 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 7 Mar 2020 20:07:53 +0100 Subject: [PATCH 036/187] Implement Template Method pattern to manage strategies. --- .../expbuilder/master/MasterComposer.java | 16 +- .../nsd/compose/ConnectComposer.java | 36 +++ .../expbuilder/nsd/compose/NsdComposer.java | 207 +++--------------- .../nsd/compose/PassThroughComposer.java | 187 ++++++++++++++++ .../nsd/compose/NsdComposerTest.java | 4 +- 5 files changed, 269 insertions(+), 181 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java create mode 100644 src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java index c25ebdc..4ea4d82 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java @@ -13,6 +13,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.stereotype.Service; @@ -24,7 +25,10 @@ @AllArgsConstructor public class MasterComposer { - private NsdComposer nsdComposer; + @Qualifier("PASS_THROUGH") + private NsdComposer passThroughComposer; + @Qualifier("CONNECT") + private NsdComposer connectComposer; // TODO vsbComposer // TODO Composition Strategy comes from CtxB @@ -39,8 +43,13 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte // - The Ctx has only 1 Nsd. Nsd ctxNsd = ctx.getCtxBReq().getNsds().get(0); CtxBlueprint ctxB = ctx.getCtxBReq().getCtxBlueprint(); + + Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); + NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); + NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); if (STRAT.equals(CompositionStrategy.CONNECT)) { log.info("connect"); + connectComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)) { log.info("pass_through"); // compose Nsd @@ -49,10 +58,7 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte } else { throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); } - Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); - NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); - NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); - nsdComposer.composePassThrough(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + passThroughComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // compose Exp blueprint } else { log.error("not supported"); diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java new file mode 100644 index 0000000..334e2ae --- /dev/null +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -0,0 +1,36 @@ +package it.cnit.blueprint.expbuilder.nsd.compose; + +import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; +import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; +import it.cnit.blueprint.expbuilder.rest.InvalidNsd; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import lombok.extern.slf4j.Slf4j; +import org.jgrapht.Graph; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.ScopedProxyMode; +import org.springframework.stereotype.Service; +import org.springframework.web.context.WebApplicationContext; + +@Service +@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS) +@Slf4j +@Qualifier("CONNECT") +public class ConnectComposer extends NsdComposer { + + public ConnectComposer(NsdGraphService nsdGraphService) { + super(nsdGraphService); + } + + @Override + public void composeWithStrategy( + NsVirtualLinkDesc ranVld, NsVirtualLinkDesc vsbMgmtVld, NsVirtualLinkDesc ctxMgmtVld, + Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Graph vsbG, + Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl, Graph ctxG) + throws InvalidNsd { + + } +} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 9d76969..4297249 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -5,9 +5,6 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; -import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; -import it.cnit.blueprint.expbuilder.nsd.graph.VirtualLinkProfileVertex; -import it.cnit.blueprint.expbuilder.nsd.graph.VnfProfileVertex; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; @@ -21,32 +18,22 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map.Entry; import java.util.Optional; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.jgrapht.Graph; -import org.jgrapht.Graphs; import org.slf4j.helpers.MessageFormatter; -import org.springframework.context.annotation.Scope; -import org.springframework.context.annotation.ScopedProxyMode; -import org.springframework.stereotype.Service; -import org.springframework.web.context.WebApplicationContext; -@Service -@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS) @Slf4j @AllArgsConstructor -public class NsdComposer { +public abstract class NsdComposer { - private NsdGraphService nsdGraphService; - static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory()); + protected static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory()); - private VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) + protected NsdGraphService nsdGraphService; + + protected VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) throws NotExistingEntityException { VnfProfile vnfProfile; try { @@ -60,7 +47,7 @@ private VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) return vnfProfile; } - private VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) + protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) throws NotExistingEntityException { VnfProfile vnfProfile; Optional optVnfP = nsDf.getVnfProfile().stream() @@ -76,7 +63,7 @@ private VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) return vnfProfile; } - private VirtualLinkProfile getVlProfile(String vlProfileId, NsDf nsDf) + protected VirtualLinkProfile getVlProfile(String vlProfileId, NsDf nsDf) throws NotExistingEntityException { VirtualLinkProfile vlProfile; try { @@ -90,7 +77,7 @@ private VirtualLinkProfile getVlProfile(String vlProfileId, NsDf nsDf) return vlProfile; } - private VirtualLinkProfile getVlProfile(NsVirtualLinkDesc vld, NsDf nsDf) + protected VirtualLinkProfile getVlProfile(NsVirtualLinkDesc vld, NsDf nsDf) throws NotExistingEntityException { VirtualLinkProfile resultVlp; Optional optVlp = nsDf.getVirtualLinkProfile().stream() @@ -107,7 +94,7 @@ private VirtualLinkProfile getVlProfile(NsVirtualLinkDesc vld, NsDf nsDf) return resultVlp; } - private NsVirtualLinkConnectivity getVlConnectivity(String cpdId, VnfProfile vnfProfile) + protected NsVirtualLinkConnectivity getVlConnectivity(String cpdId, VnfProfile vnfProfile) throws NotExistingEntityException { NsVirtualLinkConnectivity nsVlC; Optional optVlC = vnfProfile.getNsVirtualLinkConnectivity() @@ -124,7 +111,7 @@ private NsVirtualLinkConnectivity getVlConnectivity(String cpdId, VnfProfile vnf return nsVlC; } - private VnfToLevelMapping getVnfLvlMapping(String vnfProfileId, NsLevel nsLvl) + protected VnfToLevelMapping getVnfLvlMapping(String vnfProfileId, NsLevel nsLvl) throws NotExistingEntityException { VnfToLevelMapping vnfLvlMap; Optional optVnfLvlMap = nsLvl.getVnfToLevelMapping().stream() @@ -140,7 +127,7 @@ private VnfToLevelMapping getVnfLvlMapping(String vnfProfileId, NsLevel nsLvl) return vnfLvlMap; } - private String getVnfdId(String vnfdId, Nsd nsd) throws NotExistingEntityException { + protected String getVnfdId(String vnfdId, Nsd nsd) throws NotExistingEntityException { String vnfdIdFound; Optional optVnfdId = nsd.getVnfdId().stream() .filter(id -> id.equals(vnfdId)).findFirst(); @@ -155,7 +142,7 @@ private String getVnfdId(String vnfdId, Nsd nsd) throws NotExistingEntityExcepti return vnfdIdFound; } - private NsVirtualLinkDesc getVlDescriptor(String vlDescId, Nsd nsd) + protected NsVirtualLinkDesc getVlDescriptor(String vlDescId, Nsd nsd) throws NotExistingEntityException { NsVirtualLinkDesc vlDesc; Optional optVlDesc = nsd.getVirtualLinkDesc().stream() @@ -171,7 +158,7 @@ private NsVirtualLinkDesc getVlDescriptor(String vlDescId, Nsd nsd) return vlDesc; } - private VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel nsLvl) + protected VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel nsLvl) throws NotExistingEntityException { VirtualLinkToLevelMapping vlLvlMap; Optional optVlLvlMap = nsLvl.getVirtualLinkToLevelMapping().stream() @@ -187,7 +174,7 @@ private VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel ns return vlLvlMap; } - private void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { + protected void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { String vnfdId = vnfInfo.getVfndId(); if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { nsd.getVnfdId().add(vnfdId); @@ -204,7 +191,7 @@ private void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { } } - private void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { + protected void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { NsVirtualLinkDesc vlDesc = vlInfo.getVlDescriptor(); if (nsd.getVirtualLinkDesc().stream() .noneMatch(nsdVld -> nsdVld.getVirtualLinkDescId().equals(vlDesc.getVirtualLinkDescId()))) { @@ -223,7 +210,7 @@ private void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) } } - private VnfInfo retrieveVnfInfo(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) + protected VnfInfo retrieveVnfInfo(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) throws InvalidNsd, VnfNotFoundInLvlMapping { VnfToLevelMapping vnfLvlMap; try { @@ -246,7 +233,7 @@ private VnfInfo retrieveVnfInfo(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLevel return new VnfInfo(vnfdId, vnfProfile, vnfLvlMap); } - private VlInfo retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) + protected VlInfo retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) throws InvalidNsd, VlNotFoundInLvlMapping { VirtualLinkToLevelMapping vlMap; try { @@ -269,7 +256,7 @@ private VlInfo retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel ns return new VlInfo(vlMap, vlProfile, vlDesc); } - private VlInfo retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLevel) + protected VlInfo retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLevel) throws InvalidNsd, VlNotFoundInLvlMapping { VirtualLinkProfile vlProfile; try { @@ -286,7 +273,7 @@ private VlInfo retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLevel) return new VlInfo(vlMap, vlProfile, vld); } - private void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vlp) + protected void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vlp) throws NotExistingEntityException { Optional optVlConn = vnfp.getNsVirtualLinkConnectivity().stream() .filter(vlConn -> vlConn.getCpdId().get(0).equals(cpdId)).findFirst(); @@ -440,7 +427,7 @@ private void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vl // } @SneakyThrows(JsonProcessingException.class) - public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, + public void compose(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) throws InvalidNsd { NsVirtualLinkDesc ranVld; @@ -450,7 +437,6 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - String ctxVnfdId = ctxNsd.getVnfdId().get(0); // We assume only one NsDf for the context NsDf ctxNsDf = ctxNsd.getNsDf().get(0); @@ -475,144 +461,9 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v .buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); log.debug("vsbG BEFORE composition :\n{}", nsdGraphService.export(vsbG)); - // Retrieve ctx VNF - VnfProfile ctxVnfProfile; - try { - ctxVnfProfile = getVnfProfileByDescId(ctxVnfdId, ctxNsDf); - log.debug("Found vnfProfile='{}' in context.", ctxVnfProfile.getVnfProfileId()); - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - VnfInfo ctxVnfInfo; - try { - ctxVnfInfo = retrieveVnfInfo(ctxVnfProfile.getVnfProfileId(), - ctxNsd, ctxNsDf, ctxNsLvl); - log.debug("Found VnfInfo for vnfProfile='{}' in context.", ctxVnfProfile.getVnfProfileId()); - } catch (VnfNotFoundInLvlMapping e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - addVnf(ctxVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Added Vnfd='{}' in service (if not present).", ctxVnfdId); - - // Retrieve non-management VLs from ctx - ProfileVertex ctxVnfPVertex; - try { - ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); - log.debug("ctxVnfPVertex: {}", ctxVnfPVertex.toString()); - } catch (ProfileVertexNotFoundException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - List ctxVnfNeigh = Graphs.neighborListOf(ctxG, ctxVnfPVertex); - log.debug("ctxVnfPVertex neighbors: {}", ctxVnfNeigh.toString()); - String ctxMgmtCpdId = null; - LinkedHashMap ctxNonMgmtVls = new LinkedHashMap<>(); - try { - for (ProfileVertex vlpV : ctxVnfNeigh) { - if (vlpV instanceof VirtualLinkProfileVertex) { - if (((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() - .equals(ctxMgmtVld.getVirtualLinkDescId())) { - ctxMgmtCpdId = ctxG.getEdge(ctxVnfPVertex, vlpV); - } else { - VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); - ctxNonMgmtVls.put(ctxG.getEdge(ctxVnfPVertex, vlpV), - retrieveVlInfo(vlProfile.getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl)); - } - } - } - if (ctxNonMgmtVls.isEmpty()) { - throw new InvalidNsd("Can't find a non-management VL in Ctx."); - } - } catch (InvalidNsd | VlNotFoundInLvlMapping e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - log.debug("ctxNonMgmtVls: {}", ctxNonMgmtVls.toString()); - Iterator> ctxNonMgmtVLIter = ctxNonMgmtVls.entrySet().iterator(); - Entry ctxPrimaryConn = ctxNonMgmtVLIter.next(); - addVirtualLink(ctxPrimaryConn.getValue(), vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Added VirtualLinkDescriptor='{}' in service (if not present).", - ctxPrimaryConn.getValue().getVlDescriptor().getVirtualLinkDescId()); - - // Retrieve RAN VL information from vsb - VlInfo ranVlInfo; - try { - ranVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); - log.debug("Found VlInfo for ranVld='{}' in context.", ranVld.getVirtualLinkDescId()); - } catch (InvalidNsd | VlNotFoundInLvlMapping e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - - // Retrieve RAN closest VNF information from vsb - // Assumption: select the first VNF attached to the RAN VL - ProfileVertex ranVlVertex; - try { - ranVlVertex = nsdGraphService - .getVertexById(vsbG, ranVlInfo.getVlProfile().getVirtualLinkProfileId()); - log.debug("ranVlVertex: {}", ranVlVertex.toString()); - } catch (ProfileVertexNotFoundException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - List ranVlNeigh = Graphs.neighborListOf(vsbG, ranVlVertex); - log.debug("ranVlVertex neighbors: {}", ranVlNeigh.toString()); - VnfProfileVertex ranVnfVertex; - Optional optV = ranVlNeigh.stream().filter(v -> v instanceof VnfProfileVertex) - .findFirst(); - if (optV.isPresent()) { - ranVnfVertex = (VnfProfileVertex) optV.get(); - log.debug("ranVnfVertex: {}", ranVnfVertex.toString()); - } else { - throw new InvalidNsd( - "No neighbor of type VnfProfileVertex found for '" + ranVlVertex.getVertexId() + "'."); - } - String ranVnfCpd = vsbG.getEdge(ranVlVertex, ranVnfVertex); - log.debug("ranVnfCpd: {}", ranVnfCpd); - - // Connect ranVnf to the new VL coming from ctx - try { - connectVnfToVL(ranVnfVertex.getVnfProfile(), ranVnfCpd, - ctxPrimaryConn.getValue().getVlProfile()); - log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", - ranVnfVertex.getVnfProfile(), ctxPrimaryConn.getValue().getVlProfile()); - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - - // Connect ctxVnf with RAN VL - Entry ctxSecondaryConn = ctxNonMgmtVLIter.next(); - try { - connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxSecondaryConn.getKey(), - ranVlInfo.getVlProfile()); - log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", - ctxVnfInfo.getVnfProfile(), ranVlInfo.getVlProfile()); - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - - // Connect ctxVnf to vsbNsd mgmt VL - VlInfo vsbMgmtVlInfo; - try { - vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); - if (ctxMgmtCpdId != null) { - try { - connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxMgmtCpdId, - vsbMgmtVlInfo.getVlProfile()); - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - } else { - log.warn("Could not find a management Cp for ctxVnf. Skip."); - } - } catch (VlNotFoundInLvlMapping e) { - log.warn(e.getMessage() + " Skip."); - } + composeWithStrategy(ranVld, vsbMgmtVld, ctxMgmtVld, + vsbNsd, vsbNsDf, vsbNsLvl, vsbG, + ctxNsd, ctxNsDf, ctxNsLvl, ctxG); // Nsd validation and logging try { @@ -635,11 +486,19 @@ public void composePassThrough(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd v ctxNsLvl.getNsLevelId()); } + public abstract void composeWithStrategy( + NsVirtualLinkDesc ranVld, NsVirtualLinkDesc vsbMgmtVld, NsVirtualLinkDesc ctxMgmtVld, + Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Graph vsbG, + Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl, Graph ctxG + ) throws InvalidNsd; + @SneakyThrows(JsonProcessingException.class) public void composeConnectNoInput(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, - NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd){} + NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) { + } @SneakyThrows(JsonProcessingException.class) public void composeConnect(NsVirtualLinkDesc srcVl, NsVirtualLinkDesc dstVl, Nsd vsbNsd, - NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd){} + NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) { + } } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java new file mode 100644 index 0000000..aae47e2 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -0,0 +1,187 @@ +package it.cnit.blueprint.expbuilder.nsd.compose; + +import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; +import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; +import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; +import it.cnit.blueprint.expbuilder.nsd.graph.VirtualLinkProfileVertex; +import it.cnit.blueprint.expbuilder.nsd.graph.VnfProfileVertex; +import it.cnit.blueprint.expbuilder.rest.InvalidNsd; +import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; +import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map.Entry; +import java.util.Optional; +import lombok.extern.slf4j.Slf4j; +import org.jgrapht.Graph; +import org.jgrapht.Graphs; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.ScopedProxyMode; +import org.springframework.stereotype.Service; +import org.springframework.web.context.WebApplicationContext; + +@Service +@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS) +@Slf4j +@Qualifier("PASS_THROUGH") +public class PassThroughComposer extends NsdComposer { + + public PassThroughComposer(NsdGraphService nsdGraphService) { + super(nsdGraphService); + } + + @Override + public void composeWithStrategy( + NsVirtualLinkDesc ranVld, NsVirtualLinkDesc vsbMgmtVld, NsVirtualLinkDesc ctxMgmtVld, + Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Graph vsbG, + Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl, Graph ctxG + ) throws InvalidNsd { + // Retrieve ctx VNF + String ctxVnfdId = ctxNsd.getVnfdId().get(0); + VnfProfile ctxVnfProfile; + try { + ctxVnfProfile = getVnfProfileByDescId(ctxVnfdId, ctxNsDf); + log.debug("Found vnfProfile='{}' in context.", ctxVnfProfile.getVnfProfileId()); + } catch (NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + VnfInfo ctxVnfInfo; + try { + ctxVnfInfo = retrieveVnfInfo(ctxVnfProfile.getVnfProfileId(), + ctxNsd, ctxNsDf, ctxNsLvl); + log.debug("Found VnfInfo for vnfProfile='{}' in context.", ctxVnfProfile.getVnfProfileId()); + } catch (VnfNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + addVnf(ctxVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Added Vnfd='{}' in service (if not present).", ctxVnfdId); + + // Retrieve non-management VLs from ctx + ProfileVertex ctxVnfPVertex; + try { + ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); + log.debug("ctxVnfPVertex: {}", ctxVnfPVertex.toString()); + } catch (ProfileVertexNotFoundException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + List ctxVnfNeigh = Graphs.neighborListOf(ctxG, ctxVnfPVertex); + log.debug("ctxVnfPVertex neighbors: {}", ctxVnfNeigh.toString()); + String ctxMgmtCpdId = null; + LinkedHashMap ctxNonMgmtVls = new LinkedHashMap<>(); + try { + for (ProfileVertex vlpV : ctxVnfNeigh) { + if (vlpV instanceof VirtualLinkProfileVertex) { + if (((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() + .equals(ctxMgmtVld.getVirtualLinkDescId())) { + ctxMgmtCpdId = ctxG.getEdge(ctxVnfPVertex, vlpV); + } else { + VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); + ctxNonMgmtVls.put(ctxG.getEdge(ctxVnfPVertex, vlpV), + retrieveVlInfo(vlProfile.getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl)); + } + } + } + if (ctxNonMgmtVls.isEmpty()) { + throw new InvalidNsd("Can't find a non-management VL in Ctx."); + } + } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + log.debug("ctxNonMgmtVls: {}", ctxNonMgmtVls.toString()); + Iterator> ctxNonMgmtVLIter = ctxNonMgmtVls.entrySet().iterator(); + Entry ctxPrimaryConn = ctxNonMgmtVLIter.next(); + addVirtualLink(ctxPrimaryConn.getValue(), vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Added VirtualLinkDescriptor='{}' in service (if not present).", + ctxPrimaryConn.getValue().getVlDescriptor().getVirtualLinkDescId()); + + // Retrieve RAN VL information from vsb + VlInfo ranVlInfo; + try { + ranVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); + log.debug("Found VlInfo for ranVld='{}' in context.", ranVld.getVirtualLinkDescId()); + } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + + // Retrieve RAN closest VNF information from vsb + // Assumption: select the first VNF attached to the RAN VL + ProfileVertex ranVlVertex; + try { + ranVlVertex = nsdGraphService + .getVertexById(vsbG, ranVlInfo.getVlProfile().getVirtualLinkProfileId()); + log.debug("ranVlVertex: {}", ranVlVertex.toString()); + } catch (ProfileVertexNotFoundException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + List ranVlNeigh = Graphs.neighborListOf(vsbG, ranVlVertex); + log.debug("ranVlVertex neighbors: {}", ranVlNeigh.toString()); + VnfProfileVertex ranVnfVertex; + Optional optV = ranVlNeigh.stream().filter(v -> v instanceof VnfProfileVertex) + .findFirst(); + if (optV.isPresent()) { + ranVnfVertex = (VnfProfileVertex) optV.get(); + log.debug("ranVnfVertex: {}", ranVnfVertex.toString()); + } else { + throw new InvalidNsd( + "No neighbor of type VnfProfileVertex found for '" + ranVlVertex.getVertexId() + "'."); + } + String ranVnfCpd = vsbG.getEdge(ranVlVertex, ranVnfVertex); + log.debug("ranVnfCpd: {}", ranVnfCpd); + + // Connect ranVnf to the new VL coming from ctx + try { + connectVnfToVL(ranVnfVertex.getVnfProfile(), ranVnfCpd, + ctxPrimaryConn.getValue().getVlProfile()); + log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", + ranVnfVertex.getVnfProfile(), ctxPrimaryConn.getValue().getVlProfile()); + } catch (NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + + // Connect ctxVnf with RAN VL + Entry ctxSecondaryConn = ctxNonMgmtVLIter.next(); + try { + connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxSecondaryConn.getKey(), + ranVlInfo.getVlProfile()); + log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", + ctxVnfInfo.getVnfProfile(), ranVlInfo.getVlProfile()); + } catch (NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + + // Connect ctxVnf to vsbNsd mgmt VL + VlInfo vsbMgmtVlInfo; + try { + vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); + if (ctxMgmtCpdId != null) { + try { + connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxMgmtCpdId, + vsbMgmtVlInfo.getVlProfile()); + } catch (NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + } else { + log.warn("Could not find a management Cp for ctxVnf. Skip."); + } + } catch (VlNotFoundInLvlMapping e) { + log.warn(e.getMessage() + " Skip."); + } + + } +} diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java index f084dde..6c1d1bb 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java @@ -37,7 +37,7 @@ public static void setUp() { urlProp.load(input); oM = new ObjectMapper(new YAMLFactory()); nsdGraphService = new NsdGraphService(new GraphVizExporter()); - nsdComposer = new NsdComposer(nsdGraphService); + nsdComposer = new PassThroughComposer(nsdGraphService); Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(Level.DEBUG); } @@ -76,7 +76,7 @@ public void composeTrackerWithDelay() { } // When - nsdComposer.composePassThrough(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + nsdComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); From 719f2e7263289d41ae4f231a4f600b955d65f53d Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 17:33:01 +0100 Subject: [PATCH 037/187] Refactor retrieveVnfInfo method. --- .../expbuilder/nsd/compose/NsdComposer.java | 69 ++++--------------- .../nsd/compose/PassThroughComposer.java | 17 ++--- 2 files changed, 17 insertions(+), 69 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 4297249..af29e23 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -33,20 +33,6 @@ public abstract class NsdComposer { protected NsdGraphService nsdGraphService; - protected VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) - throws NotExistingEntityException { - VnfProfile vnfProfile; - try { - vnfProfile = nsDf.getVnfProfile(vnfProfileId); - } catch (NotExistingEntityException e) { - String m = MessageFormatter - .format("VnfProfile='{}' not found in nsDf='{}'", vnfProfileId, nsDf.getNsDfId()) - .getMessage(); - throw new NotExistingEntityException(m); - } - return vnfProfile; - } - protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) throws NotExistingEntityException { VnfProfile vnfProfile; @@ -94,23 +80,6 @@ protected VirtualLinkProfile getVlProfile(NsVirtualLinkDesc vld, NsDf nsDf) return resultVlp; } - protected NsVirtualLinkConnectivity getVlConnectivity(String cpdId, VnfProfile vnfProfile) - throws NotExistingEntityException { - NsVirtualLinkConnectivity nsVlC; - Optional optVlC = vnfProfile.getNsVirtualLinkConnectivity() - .stream().filter(vlc -> vlc.getCpdId().get(0).equals(cpdId)).findFirst(); - if (optVlC.isPresent()) { - nsVlC = optVlC.get(); - } else { - String m = MessageFormatter - .format("NsVirtualLinkConnectivity for cpdId='{}' not found in vnfProfile='{}'", - cpdId, vnfProfile.getVnfProfileId()) - .getMessage(); - throw new NotExistingEntityException(m); - } - return nsVlC; - } - protected VnfToLevelMapping getVnfLvlMapping(String vnfProfileId, NsLevel nsLvl) throws NotExistingEntityException { VnfToLevelMapping vnfLvlMap; @@ -127,21 +96,6 @@ protected VnfToLevelMapping getVnfLvlMapping(String vnfProfileId, NsLevel nsLvl) return vnfLvlMap; } - protected String getVnfdId(String vnfdId, Nsd nsd) throws NotExistingEntityException { - String vnfdIdFound; - Optional optVnfdId = nsd.getVnfdId().stream() - .filter(id -> id.equals(vnfdId)).findFirst(); - if (optVnfdId.isPresent()) { - vnfdIdFound = optVnfdId.get(); - } else { - String m = MessageFormatter - .format("vnfdId='{}' not found in nsd='{}'.", vnfdId, nsd.getNsdIdentifier()) - .getMessage(); - throw new NotExistingEntityException(m); - } - return vnfdIdFound; - } - protected NsVirtualLinkDesc getVlDescriptor(String vlDescId, Nsd nsd) throws NotExistingEntityException { NsVirtualLinkDesc vlDesc; @@ -210,25 +164,28 @@ protected void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel } } - protected VnfInfo retrieveVnfInfo(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) + protected VnfInfo retrieveVnfInfoByDescId(String vnfdId, Nsd nsd, NsDf nsDf, + NsLevel nsLevel) throws InvalidNsd, VnfNotFoundInLvlMapping { - VnfToLevelMapping vnfLvlMap; - try { - vnfLvlMap = getVnfLvlMapping(vnfProfileId, nsLevel); - } catch (NotExistingEntityException e) { - throw new VnfNotFoundInLvlMapping(e.getMessage()); + Optional optVnfdId = nsd.getVnfdId().stream() + .filter(id -> id.equals(vnfdId)).findFirst(); + if (!optVnfdId.isPresent()) { + String m = MessageFormatter + .format("vnfdId='{}' not found in nsd='{}'.", vnfdId, nsd.getNsdIdentifier()) + .getMessage(); + throw new InvalidNsd(m); } VnfProfile vnfProfile; try { - vnfProfile = getVnfProfileById(vnfProfileId, nsDf); + vnfProfile = getVnfProfileByDescId(vnfdId, nsDf); } catch (NotExistingEntityException e) { throw new InvalidNsd(e.getMessage()); } - String vnfdId; + VnfToLevelMapping vnfLvlMap; try { - vnfdId = getVnfdId(vnfProfile.getVnfdId(), nsd); + vnfLvlMap = getVnfLvlMapping(vnfProfile.getVnfProfileId(), nsLevel); } catch (NotExistingEntityException e) { - throw new InvalidNsd(e.getMessage()); + throw new VnfNotFoundInLvlMapping(e.getMessage()); } return new VnfInfo(vnfdId, vnfProfile, vnfLvlMap); } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index aae47e2..326430b 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -12,7 +12,6 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -45,19 +44,10 @@ public void composeWithStrategy( ) throws InvalidNsd { // Retrieve ctx VNF String ctxVnfdId = ctxNsd.getVnfdId().get(0); - VnfProfile ctxVnfProfile; - try { - ctxVnfProfile = getVnfProfileByDescId(ctxVnfdId, ctxNsDf); - log.debug("Found vnfProfile='{}' in context.", ctxVnfProfile.getVnfProfileId()); - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } VnfInfo ctxVnfInfo; try { - ctxVnfInfo = retrieveVnfInfo(ctxVnfProfile.getVnfProfileId(), - ctxNsd, ctxNsDf, ctxNsLvl); - log.debug("Found VnfInfo for vnfProfile='{}' in context.", ctxVnfProfile.getVnfProfileId()); + ctxVnfInfo = retrieveVnfInfoByDescId(ctxVnfdId, ctxNsd, ctxNsDf, ctxNsLvl); + log.debug("Found VnfInfo for vnfdId='{}' in context.", ctxVnfdId); } catch (VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -68,7 +58,8 @@ public void composeWithStrategy( // Retrieve non-management VLs from ctx ProfileVertex ctxVnfPVertex; try { - ctxVnfPVertex = nsdGraphService.getVertexById(ctxG, ctxVnfProfile.getVnfProfileId()); + ctxVnfPVertex = nsdGraphService + .getVertexById(ctxG, ctxVnfInfo.getVnfProfile().getVnfProfileId()); log.debug("ctxVnfPVertex: {}", ctxVnfPVertex.toString()); } catch (ProfileVertexNotFoundException e) { log.error(e.getMessage()); From f68f22e6adca9591e105ea7ff8b68bff1c103b0b Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 17:33:15 +0100 Subject: [PATCH 038/187] Add the vnfs to VSB in connect. --- .../expbuilder/nsd/compose/ConnectComposer.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index 334e2ae..a9634ab 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -31,6 +31,22 @@ public void composeWithStrategy( Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Graph vsbG, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl, Graph ctxG) throws InvalidNsd { + // Retrieve ctx VNFs + VnfInfo srcVnfInfo; + VnfInfo dstVnfInfo; + try { + String srcVnfdId = ctxNsd.getVnfdId().get(0); + srcVnfInfo = retrieveVnfInfoByDescId(srcVnfdId, ctxNsd, ctxNsDf, ctxNsLvl); + String dstVnfdId = ctxNsd.getVnfdId().get(1); + dstVnfInfo = retrieveVnfInfoByDescId(dstVnfdId, ctxNsd, ctxNsDf, ctxNsLvl); + } catch (VnfNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + addVnf(srcVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Added Vnfd='{}' in service (if not present).", srcVnfInfo.getVfndId()); + addVnf(dstVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Added Vnfd='{}' in service (if not present).", dstVnfInfo.getVfndId()); } } From eb75e92e55e164745dc088440c8bc586d315a8c1 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 17:56:40 +0100 Subject: [PATCH 039/187] Fix log message. --- .../blueprint/expbuilder/nsd/compose/PassThroughComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index 326430b..7a8edfe 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -100,7 +100,7 @@ public void composeWithStrategy( VlInfo ranVlInfo; try { ranVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); - log.debug("Found VlInfo for ranVld='{}' in context.", ranVld.getVirtualLinkDescId()); + log.debug("Found VlInfo for ranVld='{}' in vsbNsd.", ranVld.getVirtualLinkDescId()); } catch (InvalidNsd | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); From c70703477ff2eb025767995d74d8df41d26b88fd Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 17:57:13 +0100 Subject: [PATCH 040/187] Retrieve src and dst VLs. --- .../nsd/compose/ConnectComposer.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index a9634ab..f1626c9 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -7,6 +7,8 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import java.util.List; +import java.util.Optional; import lombok.extern.slf4j.Slf4j; import org.jgrapht.Graph; import org.springframework.beans.factory.annotation.Qualifier; @@ -34,6 +36,7 @@ public void composeWithStrategy( // Retrieve ctx VNFs VnfInfo srcVnfInfo; VnfInfo dstVnfInfo; + // Assumption: src is 0 and dst is 1 try { String srcVnfdId = ctxNsd.getVnfdId().get(0); srcVnfInfo = retrieveVnfInfoByDescId(srcVnfdId, ctxNsd, ctxNsDf, ctxNsLvl); @@ -48,5 +51,39 @@ public void composeWithStrategy( addVnf(dstVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); log.debug("Added Vnfd='{}' in service (if not present).", dstVnfInfo.getVfndId()); + // Retrieve src VL + // Retrieve RAN VL information from vsb + VlInfo srcVlInfo; + try { + srcVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); + log.debug("Found VlInfo for ranVld='{}' in vsbNsd.", ranVld.getVirtualLinkDescId()); + } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + // Retrieve dst VL + VlInfo dstVlInfo; + Optional optdstVld = vsbNsd.getVirtualLinkDesc().stream() + .filter(vld -> vld.getVirtualLinkDescId().equals(vsbMgmtVld.getVirtualLinkDescId())) + .findFirst(); + try { + if (optdstVld.isPresent()) { + dstVlInfo = retrieveVlInfo(optdstVld.get(), vsbNsDf, vsbNsLvl); + log.debug("Found non-mgmt VlInfo."); + } else { + throw new InvalidNsd( + "Can't find a non-mgmt VlInfo in vsbNsd: '" + vsbNsd.getNsdIdentifier() + "'"); + } + } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + + // Connect src VNF + connectVnfToVL(srcVnfInfo.getVnfProfile(), "???", srcVlInfo.getVlProfile()); + + // Connect dst VNF + connectVnfToVL(dstVnfInfo.getVnfProfile(), "???", dstVlInfo.getVlProfile()); + } } From d42397236244ab88313e858262b64b9c59dbfa12 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 18:31:43 +0100 Subject: [PATCH 041/187] Retrieve data and mgmt cpd for VNFs. Do appropriate connections. --- .../nsd/compose/ConnectComposer.java | 58 +++++++++++++++++-- .../nsd/compose/PassThroughComposer.java | 1 + 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index f1626c9..f03dfdd 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -5,9 +5,11 @@ import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import lombok.extern.slf4j.Slf4j; import org.jgrapht.Graph; @@ -51,6 +53,27 @@ public void composeWithStrategy( addVnf(dstVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); log.debug("Added Vnfd='{}' in service (if not present).", dstVnfInfo.getVfndId()); + VlInfo ctxMgmtVlInfo = retrieveVlInfo(ctxMgmtVld, ctxNsDf, ctxNsLvl); + // Retrieve CpdId for src VNF + @SuppressWarnings("DuplicatedCode") + Map srcCpds; + try { + srcCpds = getMgmtDataCpds(srcVnfInfo, ctxMgmtVlInfo); + } catch (Exception e) { + throw new InvalidNsd(e.getMessage()); + } + String srcVnfDataCpdId = srcCpds.get("data"); + String srcVnfMgmtCpdId = srcCpds.get("mgmt"); + // Retrieve CpdId for dst VNF + Map dstCpds; + try { + dstCpds = getMgmtDataCpds(srcVnfInfo, ctxMgmtVlInfo); + } catch (Exception e) { + throw new InvalidNsd(e.getMessage()); + } + String dstVnfDataCpdId = dstCpds.get("data"); + String dstVnfMgmtCpdId = dstCpds.get("mgmt"); + // Retrieve src VL // Retrieve RAN VL information from vsb VlInfo srcVlInfo; @@ -79,11 +102,36 @@ public void composeWithStrategy( throw new InvalidNsd(e.getMessage()); } - // Connect src VNF - connectVnfToVL(srcVnfInfo.getVnfProfile(), "???", srcVlInfo.getVlProfile()); + // Connect VNFs to src and dst VLs + connectVnfToVL(srcVnfInfo.getVnfProfile(), srcVnfDataCpdId, srcVlInfo.getVlProfile()); + connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfDataCpdId, dstVlInfo.getVlProfile()); + + // Connect VNFs to mgmt VL (if possible) + if (srcVnfMgmtCpdId != null){ + connectVnfToVL(srcVnfInfo.getVnfProfile(), srcVnfMgmtCpdId, vsbMgmtVld.getVlProfile()); + } + if(dstVnfMgmtCpdId!=null){ + connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfMgmtCpdId, vsbMgmtVld.getVlProfile()); + } - // Connect dst VNF - connectVnfToVL(dstVnfInfo.getVnfProfile(), "???", dstVlInfo.getVlProfile()); + } + private Map getMgmtDataCpds(VnfInfo vnfInfo, VlInfo mgmtVlinfo) throws Exception { + Map cpdIdMap = new HashMap<>(); + for (NsVirtualLinkConnectivity vlc : vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity()) { + if (vlc.getVirtualLinkProfileId() + .equals(mgmtVlinfo.getVlProfile().getVirtualLinkProfileId())) { + cpdIdMap.put("mgmt", vlc.getCpdId().get(0)); + } else { + cpdIdMap.put("data", vlc.getCpdId().get(0)); + } + } + if (!cpdIdMap.containsKey("mgmt")) { + cpdIdMap.put("mgmt", null); + } + if (!cpdIdMap.containsKey("data")) { + throw new Exception(); + } + return cpdIdMap; } } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index 7a8edfe..fac1d00 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -97,6 +97,7 @@ public void composeWithStrategy( ctxPrimaryConn.getValue().getVlDescriptor().getVirtualLinkDescId()); // Retrieve RAN VL information from vsb + // TODO move to abstract class VlInfo ranVlInfo; try { ranVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); From 2ff0eb3c4ff0c30c58f05f026310b1a38715a49a Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 19:04:13 +0100 Subject: [PATCH 042/187] Retrieve all VlInfo in the abstract class. --- .../nsd/compose/ConnectComposer.java | 24 +++++------ .../expbuilder/nsd/compose/NsdComposer.java | 18 ++++++++- .../nsd/compose/PassThroughComposer.java | 40 +++++-------------- 3 files changed, 36 insertions(+), 46 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index f03dfdd..da9e537 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -31,7 +31,7 @@ public ConnectComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( - NsVirtualLinkDesc ranVld, NsVirtualLinkDesc vsbMgmtVld, NsVirtualLinkDesc ctxMgmtVld, + VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Graph vsbG, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl, Graph ctxG) throws InvalidNsd { @@ -53,7 +53,6 @@ public void composeWithStrategy( addVnf(dstVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); log.debug("Added Vnfd='{}' in service (if not present).", dstVnfInfo.getVfndId()); - VlInfo ctxMgmtVlInfo = retrieveVlInfo(ctxMgmtVld, ctxNsDf, ctxNsLvl); // Retrieve CpdId for src VNF @SuppressWarnings("DuplicatedCode") Map srcCpds; @@ -76,18 +75,12 @@ public void composeWithStrategy( // Retrieve src VL // Retrieve RAN VL information from vsb - VlInfo srcVlInfo; - try { - srcVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); - log.debug("Found VlInfo for ranVld='{}' in vsbNsd.", ranVld.getVirtualLinkDescId()); - } catch (InvalidNsd | VlNotFoundInLvlMapping e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } + VlInfo srcVlInfo = ranVlInfo; // Retrieve dst VL VlInfo dstVlInfo; Optional optdstVld = vsbNsd.getVirtualLinkDesc().stream() - .filter(vld -> vld.getVirtualLinkDescId().equals(vsbMgmtVld.getVirtualLinkDescId())) + .filter(vld -> vld.getVirtualLinkDescId() + .equals(vsbMgmtVlInfo.getVlDescriptor().getVirtualLinkDescId())) .findFirst(); try { if (optdstVld.isPresent()) { @@ -107,11 +100,11 @@ public void composeWithStrategy( connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfDataCpdId, dstVlInfo.getVlProfile()); // Connect VNFs to mgmt VL (if possible) - if (srcVnfMgmtCpdId != null){ - connectVnfToVL(srcVnfInfo.getVnfProfile(), srcVnfMgmtCpdId, vsbMgmtVld.getVlProfile()); + if (srcVnfMgmtCpdId != null) { + connectVnfToVL(srcVnfInfo.getVnfProfile(), srcVnfMgmtCpdId, vsbMgmtVlInfo.getVlProfile()); } - if(dstVnfMgmtCpdId!=null){ - connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfMgmtCpdId, vsbMgmtVld.getVlProfile()); + if (dstVnfMgmtCpdId != null) { + connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfMgmtCpdId, vsbMgmtVlInfo.getVlProfile()); } } @@ -130,6 +123,7 @@ private Map getMgmtDataCpds(VnfInfo vnfInfo, VlInfo mgmtVlinfo) cpdIdMap.put("mgmt", null); } if (!cpdIdMap.containsKey("data")) { + // TODO add correct excetpion throw new Exception(); } return cpdIdMap; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index af29e23..effd0fa 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -418,7 +418,21 @@ public void compose(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, .buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); log.debug("vsbG BEFORE composition :\n{}", nsdGraphService.export(vsbG)); - composeWithStrategy(ranVld, vsbMgmtVld, ctxMgmtVld, + VlInfo ranVlInfo; + VlInfo vsbMgmtVlInfo; + VlInfo ctxMgmtVlInfo; + try { + ranVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); + log.debug("Found VlInfo for ranVld='{}' in vsbNsd.", ranVld.getVirtualLinkDescId()); + vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); + log.debug("Found VlInfo for vsbMgmtVld='{}' in vsbNsd.", vsbMgmtVld.getVirtualLinkDescId()); + ctxMgmtVlInfo = retrieveVlInfo(ctxMgmtVld, ctxNsDf, ctxNsLvl); + log.debug("Found VlInfo for vsbMgmtVld='{}' in vsbNsd.", vsbMgmtVld.getVirtualLinkDescId()); + } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + composeWithStrategy(ranVlInfo, vsbMgmtVlInfo, ctxMgmtVlInfo, vsbNsd, vsbNsDf, vsbNsLvl, vsbG, ctxNsd, ctxNsDf, ctxNsLvl, ctxG); @@ -444,7 +458,7 @@ public void compose(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, } public abstract void composeWithStrategy( - NsVirtualLinkDesc ranVld, NsVirtualLinkDesc vsbMgmtVld, NsVirtualLinkDesc ctxMgmtVld, + VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Graph vsbG, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl, Graph ctxG ) throws InvalidNsd; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index fac1d00..611569c 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -10,7 +10,6 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import java.util.Iterator; import java.util.LinkedHashMap; @@ -38,7 +37,7 @@ public PassThroughComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( - NsVirtualLinkDesc ranVld, NsVirtualLinkDesc vsbMgmtVld, NsVirtualLinkDesc ctxMgmtVld, + VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Graph vsbG, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl, Graph ctxG ) throws InvalidNsd { @@ -73,7 +72,7 @@ public void composeWithStrategy( for (ProfileVertex vlpV : ctxVnfNeigh) { if (vlpV instanceof VirtualLinkProfileVertex) { if (((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() - .equals(ctxMgmtVld.getVirtualLinkDescId())) { + .equals(ctxMgmtVlInfo.getVlDescriptor().getVirtualLinkDescId())) { ctxMgmtCpdId = ctxG.getEdge(ctxVnfPVertex, vlpV); } else { VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); @@ -96,17 +95,6 @@ public void composeWithStrategy( log.debug("Added VirtualLinkDescriptor='{}' in service (if not present).", ctxPrimaryConn.getValue().getVlDescriptor().getVirtualLinkDescId()); - // Retrieve RAN VL information from vsb - // TODO move to abstract class - VlInfo ranVlInfo; - try { - ranVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); - log.debug("Found VlInfo for ranVld='{}' in vsbNsd.", ranVld.getVirtualLinkDescId()); - } catch (InvalidNsd | VlNotFoundInLvlMapping e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - // Retrieve RAN closest VNF information from vsb // Assumption: select the first VNF attached to the RAN VL ProfileVertex ranVlVertex; @@ -157,22 +145,16 @@ public void composeWithStrategy( } // Connect ctxVnf to vsbNsd mgmt VL - VlInfo vsbMgmtVlInfo; - try { - vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); - if (ctxMgmtCpdId != null) { - try { - connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxMgmtCpdId, - vsbMgmtVlInfo.getVlProfile()); - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - } else { - log.warn("Could not find a management Cp for ctxVnf. Skip."); + if (ctxMgmtCpdId != null) { + try { + connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxMgmtCpdId, + vsbMgmtVlInfo.getVlProfile()); + } catch (NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); } - } catch (VlNotFoundInLvlMapping e) { - log.warn(e.getMessage() + " Skip."); + } else { + log.warn("Could not find a management Cp for ctxVnf. Skip."); } } From 76b22614dd7bd458b489f66b2e4683f9a43632aa Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 19:15:13 +0100 Subject: [PATCH 043/187] Fix connect algorithm with the new input. --- .../nsd/compose/ConnectComposer.java | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index da9e537..5a36406 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -3,6 +3,7 @@ import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; +import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; @@ -73,18 +74,18 @@ public void composeWithStrategy( String dstVnfDataCpdId = dstCpds.get("data"); String dstVnfMgmtCpdId = dstCpds.get("mgmt"); + // TODO handle custom VL input // Retrieve src VL - // Retrieve RAN VL information from vsb VlInfo srcVlInfo = ranVlInfo; // Retrieve dst VL VlInfo dstVlInfo; - Optional optdstVld = vsbNsd.getVirtualLinkDesc().stream() - .filter(vld -> vld.getVirtualLinkDescId() + Optional optDstVld = vsbNsd.getVirtualLinkDesc().stream() + .filter(vld -> !vld.getVirtualLinkDescId() .equals(vsbMgmtVlInfo.getVlDescriptor().getVirtualLinkDescId())) .findFirst(); try { - if (optdstVld.isPresent()) { - dstVlInfo = retrieveVlInfo(optdstVld.get(), vsbNsDf, vsbNsLvl); + if (optDstVld.isPresent()) { + dstVlInfo = retrieveVlInfo(optDstVld.get(), vsbNsDf, vsbNsLvl); log.debug("Found non-mgmt VlInfo."); } else { throw new InvalidNsd( @@ -95,16 +96,26 @@ public void composeWithStrategy( throw new InvalidNsd(e.getMessage()); } - // Connect VNFs to src and dst VLs - connectVnfToVL(srcVnfInfo.getVnfProfile(), srcVnfDataCpdId, srcVlInfo.getVlProfile()); - connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfDataCpdId, dstVlInfo.getVlProfile()); - - // Connect VNFs to mgmt VL (if possible) - if (srcVnfMgmtCpdId != null) { - connectVnfToVL(srcVnfInfo.getVnfProfile(), srcVnfMgmtCpdId, vsbMgmtVlInfo.getVlProfile()); - } - if (dstVnfMgmtCpdId != null) { - connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfMgmtCpdId, vsbMgmtVlInfo.getVlProfile()); + try { + // Connect VNFs to src and dst VLs + connectVnfToVL(srcVnfInfo.getVnfProfile(), srcVnfDataCpdId, srcVlInfo.getVlProfile()); + log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", + srcVnfInfo.getVnfProfile().getVnfProfileId(), + srcVlInfo.getVlProfile().getVirtualLinkProfileId()); + connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfDataCpdId, dstVlInfo.getVlProfile()); + log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", + dstVnfInfo.getVnfProfile().getVnfProfileId(), + dstVlInfo.getVlProfile().getVirtualLinkProfileId()); + // Connect VNFs to mgmt VL (if possible) + if (srcVnfMgmtCpdId != null) { + connectVnfToVL(srcVnfInfo.getVnfProfile(), srcVnfMgmtCpdId, vsbMgmtVlInfo.getVlProfile()); + } + if (dstVnfMgmtCpdId != null) { + connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfMgmtCpdId, vsbMgmtVlInfo.getVlProfile()); + } + } catch (NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); } } From 9d63ba9af613614e0b6f90b37ade108ce2a0353b Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 19:18:51 +0100 Subject: [PATCH 044/187] Remove unneeded variables. --- .../nsd/compose/ConnectComposer.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index 5a36406..f311ec0 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -55,15 +55,12 @@ public void composeWithStrategy( log.debug("Added Vnfd='{}' in service (if not present).", dstVnfInfo.getVfndId()); // Retrieve CpdId for src VNF - @SuppressWarnings("DuplicatedCode") Map srcCpds; try { srcCpds = getMgmtDataCpds(srcVnfInfo, ctxMgmtVlInfo); } catch (Exception e) { throw new InvalidNsd(e.getMessage()); } - String srcVnfDataCpdId = srcCpds.get("data"); - String srcVnfMgmtCpdId = srcCpds.get("mgmt"); // Retrieve CpdId for dst VNF Map dstCpds; try { @@ -71,8 +68,6 @@ public void composeWithStrategy( } catch (Exception e) { throw new InvalidNsd(e.getMessage()); } - String dstVnfDataCpdId = dstCpds.get("data"); - String dstVnfMgmtCpdId = dstCpds.get("mgmt"); // TODO handle custom VL input // Retrieve src VL @@ -98,20 +93,22 @@ public void composeWithStrategy( try { // Connect VNFs to src and dst VLs - connectVnfToVL(srcVnfInfo.getVnfProfile(), srcVnfDataCpdId, srcVlInfo.getVlProfile()); + connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("data"), srcVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", srcVnfInfo.getVnfProfile().getVnfProfileId(), srcVlInfo.getVlProfile().getVirtualLinkProfileId()); - connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfDataCpdId, dstVlInfo.getVlProfile()); + connectVnfToVL(dstVnfInfo.getVnfProfile(), dstCpds.get("data"), dstVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", dstVnfInfo.getVnfProfile().getVnfProfileId(), dstVlInfo.getVlProfile().getVirtualLinkProfileId()); // Connect VNFs to mgmt VL (if possible) - if (srcVnfMgmtCpdId != null) { - connectVnfToVL(srcVnfInfo.getVnfProfile(), srcVnfMgmtCpdId, vsbMgmtVlInfo.getVlProfile()); + if (srcCpds.get("mgmt") != null) { + connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("mgmt"), + vsbMgmtVlInfo.getVlProfile()); } - if (dstVnfMgmtCpdId != null) { - connectVnfToVL(dstVnfInfo.getVnfProfile(), dstVnfMgmtCpdId, vsbMgmtVlInfo.getVlProfile()); + if (dstCpds.get("mgmt") != null) { + connectVnfToVL(dstVnfInfo.getVnfProfile(), dstCpds.get("mgmt"), + vsbMgmtVlInfo.getVlProfile()); } } catch (NotExistingEntityException e) { log.error(e.getMessage()); From 6cb1c8adc415a11252fd165d5866f0ddf1fe16bf Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 19:19:19 +0100 Subject: [PATCH 045/187] Fix log lines. --- .../expbuilder/nsd/compose/PassThroughComposer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index 611569c..80bc1ea 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -126,7 +126,8 @@ public void composeWithStrategy( connectVnfToVL(ranVnfVertex.getVnfProfile(), ranVnfCpd, ctxPrimaryConn.getValue().getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", - ranVnfVertex.getVnfProfile(), ctxPrimaryConn.getValue().getVlProfile()); + ranVnfVertex.getVnfProfile().getVnfProfileId(), + ctxPrimaryConn.getValue().getVlProfile().getVirtualLinkProfileId()); } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -138,7 +139,8 @@ public void composeWithStrategy( connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxSecondaryConn.getKey(), ranVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", - ctxVnfInfo.getVnfProfile(), ranVlInfo.getVlProfile()); + ctxVnfInfo.getVnfProfile().getVnfProfileId(), + ranVlInfo.getVlProfile().getVirtualLinkProfileId()); } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); From c16cb5645cd30bd31a4bbaddc304789c6bc889e9 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 20:29:35 +0100 Subject: [PATCH 046/187] Using getMgmtDataCpds also in Passthrough to remove graph usage. --- .../nsd/compose/ConnectComposer.java | 43 ++++------ .../expbuilder/nsd/compose/NsdComposer.java | 33 +++++++- .../nsd/compose/PassThroughComposer.java | 82 ++++++------------- 3 files changed, 71 insertions(+), 87 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index f311ec0..e8d4207 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -9,7 +9,6 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; -import java.util.HashMap; import java.util.Map; import java.util.Optional; import lombok.extern.slf4j.Slf4j; @@ -55,16 +54,16 @@ public void composeWithStrategy( log.debug("Added Vnfd='{}' in service (if not present).", dstVnfInfo.getVfndId()); // Retrieve CpdId for src VNF - Map srcCpds; + Map srcCpds; try { - srcCpds = getMgmtDataCpds(srcVnfInfo, ctxMgmtVlInfo); + srcCpds = getMgmtDataCpds(srcVnfInfo, vsbMgmtVlInfo, ctxMgmtVlInfo); } catch (Exception e) { throw new InvalidNsd(e.getMessage()); } // Retrieve CpdId for dst VNF - Map dstCpds; + Map dstCpds; try { - dstCpds = getMgmtDataCpds(srcVnfInfo, ctxMgmtVlInfo); + dstCpds = getMgmtDataCpds(srcVnfInfo, vsbMgmtVlInfo, ctxMgmtVlInfo); } catch (Exception e) { throw new InvalidNsd(e.getMessage()); } @@ -93,47 +92,33 @@ public void composeWithStrategy( try { // Connect VNFs to src and dst VLs - connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("data"), srcVlInfo.getVlProfile()); + connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("data0").getCpdId().get(0), + srcVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", srcVnfInfo.getVnfProfile().getVnfProfileId(), srcVlInfo.getVlProfile().getVirtualLinkProfileId()); - connectVnfToVL(dstVnfInfo.getVnfProfile(), dstCpds.get("data"), dstVlInfo.getVlProfile()); + connectVnfToVL(dstVnfInfo.getVnfProfile(), dstCpds.get("data0").getCpdId().get(0), + dstVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", dstVnfInfo.getVnfProfile().getVnfProfileId(), dstVlInfo.getVlProfile().getVirtualLinkProfileId()); // Connect VNFs to mgmt VL (if possible) if (srcCpds.get("mgmt") != null) { - connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("mgmt"), + connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("mgmt").getCpdId().get(0), vsbMgmtVlInfo.getVlProfile()); + } else { + log.warn("Could not find a management Cp for srcVnf. Skip."); } if (dstCpds.get("mgmt") != null) { - connectVnfToVL(dstVnfInfo.getVnfProfile(), dstCpds.get("mgmt"), + connectVnfToVL(dstVnfInfo.getVnfProfile(), dstCpds.get("mgmt").getCpdId().get(0), vsbMgmtVlInfo.getVlProfile()); + } else { + log.warn("Could not find a management Cp for dstVnf. Skip."); } } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - } - private Map getMgmtDataCpds(VnfInfo vnfInfo, VlInfo mgmtVlinfo) throws Exception { - Map cpdIdMap = new HashMap<>(); - for (NsVirtualLinkConnectivity vlc : vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity()) { - if (vlc.getVirtualLinkProfileId() - .equals(mgmtVlinfo.getVlProfile().getVirtualLinkProfileId())) { - cpdIdMap.put("mgmt", vlc.getCpdId().get(0)); - } else { - cpdIdMap.put("data", vlc.getCpdId().get(0)); - } - } - if (!cpdIdMap.containsKey("mgmt")) { - cpdIdMap.put("mgmt", null); - } - if (!cpdIdMap.containsKey("data")) { - // TODO add correct excetpion - throw new Exception(); - } - return cpdIdMap; - } } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index effd0fa..2793737 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; +import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; @@ -18,6 +19,8 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import lombok.AllArgsConstructor; import lombok.SneakyThrows; @@ -245,6 +248,34 @@ protected void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile } + protected Map getMgmtDataCpds(VnfInfo vnfInfo, + VlInfo vsbMgmtVlinfo, VlInfo ctxMgmtVlInfo) + throws InvalidNsd { + Map cpdIdMap = new HashMap<>(); + int dataCount = 0; + for (NsVirtualLinkConnectivity vlc : vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity()) { + if (vlc.getVirtualLinkProfileId() + .equals(vsbMgmtVlinfo.getVlProfile().getVirtualLinkProfileId()) + || vlc.getVirtualLinkProfileId() + .equals(ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId())) { + cpdIdMap.put("mgmt", vlc); + } else { + cpdIdMap.put("data" + dataCount, vlc); + dataCount++; + } + } + if (!cpdIdMap.containsKey("mgmt")) { + cpdIdMap.put("mgmt", null); + } + Optional dataKey = cpdIdMap.keySet().stream().filter(k -> k.startsWith("data")) + .findFirst(); + if (!dataKey.isPresent()) { + throw new InvalidNsd( + "No data cpd found for vnfProfile: '" + vnfInfo.getVnfProfile().getVnfProfileId() + "'."); + } + return cpdIdMap; + } + // @SuppressWarnings("DuplicatedCode") // @SneakyThrows(JsonProcessingException.class) // public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) @@ -427,7 +458,7 @@ public void compose(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); log.debug("Found VlInfo for vsbMgmtVld='{}' in vsbNsd.", vsbMgmtVld.getVirtualLinkDescId()); ctxMgmtVlInfo = retrieveVlInfo(ctxMgmtVld, ctxNsDf, ctxNsLvl); - log.debug("Found VlInfo for vsbMgmtVld='{}' in vsbNsd.", vsbMgmtVld.getVirtualLinkDescId()); + log.debug("Found VlInfo for ctxMgmtVld='{}' in ctxNsd.", ctxMgmtVld.getVirtualLinkDescId()); } catch (InvalidNsd | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index 80bc1ea..2813b72 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -3,18 +3,15 @@ import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; -import it.cnit.blueprint.expbuilder.nsd.graph.VirtualLinkProfileVertex; import it.cnit.blueprint.expbuilder.nsd.graph.VnfProfileVertex; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; -import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; -import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map.Entry; +import java.util.Map; import java.util.Optional; import lombok.extern.slf4j.Slf4j; import org.jgrapht.Graph; @@ -55,45 +52,19 @@ public void composeWithStrategy( log.debug("Added Vnfd='{}' in service (if not present).", ctxVnfdId); // Retrieve non-management VLs from ctx - ProfileVertex ctxVnfPVertex; + Map ctxVnfCpds; + VlInfo ctxNonMgmtVl; try { - ctxVnfPVertex = nsdGraphService - .getVertexById(ctxG, ctxVnfInfo.getVnfProfile().getVnfProfileId()); - log.debug("ctxVnfPVertex: {}", ctxVnfPVertex.toString()); - } catch (ProfileVertexNotFoundException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - List ctxVnfNeigh = Graphs.neighborListOf(ctxG, ctxVnfPVertex); - log.debug("ctxVnfPVertex neighbors: {}", ctxVnfNeigh.toString()); - String ctxMgmtCpdId = null; - LinkedHashMap ctxNonMgmtVls = new LinkedHashMap<>(); - try { - for (ProfileVertex vlpV : ctxVnfNeigh) { - if (vlpV instanceof VirtualLinkProfileVertex) { - if (((VirtualLinkProfileVertex) vlpV).getVlProfile().getVirtualLinkDescId() - .equals(ctxMgmtVlInfo.getVlDescriptor().getVirtualLinkDescId())) { - ctxMgmtCpdId = ctxG.getEdge(ctxVnfPVertex, vlpV); - } else { - VirtualLinkProfile vlProfile = ((VirtualLinkProfileVertex) vlpV).getVlProfile(); - ctxNonMgmtVls.put(ctxG.getEdge(ctxVnfPVertex, vlpV), - retrieveVlInfo(vlProfile.getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl)); - } - } - } - if (ctxNonMgmtVls.isEmpty()) { - throw new InvalidNsd("Can't find a non-management VL in Ctx."); - } + ctxVnfCpds = getMgmtDataCpds(ctxVnfInfo, vsbMgmtVlInfo, ctxMgmtVlInfo); + ctxNonMgmtVl = retrieveVlInfo(ctxVnfCpds.get("data0").getVirtualLinkProfileId(), + ctxNsd, ctxNsDf, ctxNsLvl); } catch (InvalidNsd | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - log.debug("ctxNonMgmtVls: {}", ctxNonMgmtVls.toString()); - Iterator> ctxNonMgmtVLIter = ctxNonMgmtVls.entrySet().iterator(); - Entry ctxPrimaryConn = ctxNonMgmtVLIter.next(); - addVirtualLink(ctxPrimaryConn.getValue(), vsbNsd, vsbNsDf, vsbNsLvl); + addVirtualLink(ctxNonMgmtVl, vsbNsd, vsbNsDf, vsbNsLvl); log.debug("Added VirtualLinkDescriptor='{}' in service (if not present).", - ctxPrimaryConn.getValue().getVlDescriptor().getVirtualLinkDescId()); + ctxNonMgmtVl.getVlDescriptor().getVirtualLinkDescId()); // Retrieve RAN closest VNF information from vsb // Assumption: select the first VNF attached to the RAN VL @@ -123,41 +94,38 @@ public void composeWithStrategy( // Connect ranVnf to the new VL coming from ctx try { - connectVnfToVL(ranVnfVertex.getVnfProfile(), ranVnfCpd, - ctxPrimaryConn.getValue().getVlProfile()); + connectVnfToVL(ranVnfVertex.getVnfProfile(), ranVnfCpd, ctxNonMgmtVl.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", ranVnfVertex.getVnfProfile().getVnfProfileId(), - ctxPrimaryConn.getValue().getVlProfile().getVirtualLinkProfileId()); + ctxNonMgmtVl.getVlProfile().getVirtualLinkProfileId()); } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - // Connect ctxVnf with RAN VL - Entry ctxSecondaryConn = ctxNonMgmtVLIter.next(); try { - connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxSecondaryConn.getKey(), + // Connect ctxVnf with RAN VL + connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxVnfCpds.get("data1").getCpdId().get(0), ranVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", ctxVnfInfo.getVnfProfile().getVnfProfileId(), ranVlInfo.getVlProfile().getVirtualLinkProfileId()); + // Connect ctxVnf to vsbNsd mgmt VL + if (ctxVnfCpds.get("mgmt") != null) { + connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxVnfCpds.get("mgmt").getCpdId().get(0), + vsbMgmtVlInfo.getVlProfile()); + log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", + ctxVnfInfo.getVnfProfile().getVnfProfileId(), + vsbMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); + log.debug("qui"); + } else { + log.warn("Could not find a management Cp for ctxVnf. Skip."); + } + } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - // Connect ctxVnf to vsbNsd mgmt VL - if (ctxMgmtCpdId != null) { - try { - connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxMgmtCpdId, - vsbMgmtVlInfo.getVlProfile()); - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - } else { - log.warn("Could not find a management Cp for ctxVnf. Skip."); - } - } } From bc603fe1f3bff50ae6e277db6ce053272f7d6d2d Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 8 Mar 2020 22:30:26 +0100 Subject: [PATCH 047/187] Remove all usage of graphs from passthrough. --- .../expbuilder/nsd/compose/NsdComposer.java | 42 ++++++++++++- .../nsd/compose/PassThroughComposer.java | 61 ++++++++++--------- 2 files changed, 72 insertions(+), 31 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 2793737..cab4fb7 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; -import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; @@ -36,6 +35,20 @@ public abstract class NsdComposer { protected NsdGraphService nsdGraphService; + protected VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) + throws NotExistingEntityException { + VnfProfile vnfProfile; + try { + vnfProfile = nsDf.getVnfProfile(vnfProfileId); + } catch (NotExistingEntityException e) { + String m = MessageFormatter + .format("VnfProfile='{}' not found in nsDf='{}'", vnfProfileId, nsDf.getNsDfId()) + .getMessage(); + throw new NotExistingEntityException(m); + } + return vnfProfile; + } + protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) throws NotExistingEntityException { VnfProfile vnfProfile; @@ -167,6 +180,33 @@ protected void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel } } + protected VnfInfo retrieveVnfInfoByProfileId(String vnfProfileId, Nsd nsd, NsDf nsDf, + NsLevel nsLevel) + throws InvalidNsd, VnfNotFoundInLvlMapping { + VnfToLevelMapping vnfLvlMap; + try { + vnfLvlMap = getVnfLvlMapping(vnfProfileId, nsLevel); + } catch (NotExistingEntityException e) { + throw new VnfNotFoundInLvlMapping(e.getMessage()); + } + VnfProfile vnfProfile; + try { + vnfProfile = getVnfProfileById(vnfProfileId, nsDf); + } catch (NotExistingEntityException e) { + throw new InvalidNsd(e.getMessage()); + } + Optional optVnfdId = nsd.getVnfdId().stream() + .filter(id -> id.equals(vnfProfile.getVnfdId())).findFirst(); + if (!optVnfdId.isPresent()) { + String m = MessageFormatter + .format("vnfdId='{}' not found in nsd='{}'.", vnfProfile.getVnfdId(), + nsd.getNsdIdentifier()) + .getMessage(); + throw new InvalidNsd(m); + } + return new VnfInfo(vnfProfile.getVnfdId(), vnfProfile, vnfLvlMap); + } + protected VnfInfo retrieveVnfInfoByDescId(String vnfdId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) throws InvalidNsd, VnfNotFoundInLvlMapping { diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index 2813b72..1b6e7f3 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -2,20 +2,17 @@ import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; -import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertexNotFoundException; -import it.cnit.blueprint.expbuilder.nsd.graph.VnfProfileVertex; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; -import java.util.List; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.util.Map; -import java.util.Optional; import lombok.extern.slf4j.Slf4j; import org.jgrapht.Graph; -import org.jgrapht.Graphs; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; @@ -48,8 +45,6 @@ public void composeWithStrategy( log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - addVnf(ctxVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Added Vnfd='{}' in service (if not present).", ctxVnfdId); // Retrieve non-management VLs from ctx Map ctxVnfCpds; @@ -68,35 +63,41 @@ public void composeWithStrategy( // Retrieve RAN closest VNF information from vsb // Assumption: select the first VNF attached to the RAN VL - ProfileVertex ranVlVertex; - try { - ranVlVertex = nsdGraphService - .getVertexById(vsbG, ranVlInfo.getVlProfile().getVirtualLinkProfileId()); - log.debug("ranVlVertex: {}", ranVlVertex.toString()); - } catch (ProfileVertexNotFoundException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + // TODO Can create composition inconsistencies across multiple NsLvl + String ranVnfCpd = null; + VnfProfile ranVnfProfile = null; + for (VnfToLevelMapping vnfLvl : vsbNsLvl.getVnfToLevelMapping()) { + VnfInfo vnfInfo; + try { + vnfInfo = retrieveVnfInfoByProfileId(vnfLvl.getVnfProfileId(), vsbNsd, vsbNsDf, vsbNsLvl); + } catch (VnfNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + for (NsVirtualLinkConnectivity vlc : vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity()) { + if (vlc.getVirtualLinkProfileId() + .equals(ranVlInfo.getVlProfile().getVirtualLinkProfileId())) { + ranVnfCpd = vlc.getCpdId().get(0); + ranVnfProfile = vnfInfo.getVnfProfile(); + break; + } + } } - List ranVlNeigh = Graphs.neighborListOf(vsbG, ranVlVertex); - log.debug("ranVlVertex neighbors: {}", ranVlNeigh.toString()); - VnfProfileVertex ranVnfVertex; - Optional optV = ranVlNeigh.stream().filter(v -> v instanceof VnfProfileVertex) - .findFirst(); - if (optV.isPresent()) { - ranVnfVertex = (VnfProfileVertex) optV.get(); - log.debug("ranVnfVertex: {}", ranVnfVertex.toString()); - } else { - throw new InvalidNsd( - "No neighbor of type VnfProfileVertex found for '" + ranVlVertex.getVertexId() + "'."); + if (ranVnfCpd == null) { + String m = "Can't find a VNF close to ranVlInfo"; + log.error(m); + throw new InvalidNsd(m); } - String ranVnfCpd = vsbG.getEdge(ranVlVertex, ranVnfVertex); - log.debug("ranVnfCpd: {}", ranVnfCpd); + log.debug("ranVnfProfile: '{}'", ranVnfProfile.getVnfProfileId()); + log.debug("ranVnfCpd: '{}'", ranVnfCpd); + addVnf(ctxVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Added Vnfd='{}' in service (if not present).", ctxVnfdId); // Connect ranVnf to the new VL coming from ctx try { - connectVnfToVL(ranVnfVertex.getVnfProfile(), ranVnfCpd, ctxNonMgmtVl.getVlProfile()); + connectVnfToVL(ranVnfProfile, ranVnfCpd, ctxNonMgmtVl.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", - ranVnfVertex.getVnfProfile().getVnfProfileId(), + ranVnfProfile.getVnfProfileId(), ctxNonMgmtVl.getVlProfile().getVirtualLinkProfileId()); } catch (NotExistingEntityException e) { log.error(e.getMessage()); From ab9e43193231d4579d72e2bc622ab0c35b9faf10 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 11:07:03 +0100 Subject: [PATCH 048/187] Move all vsbNsd modifications at the end. Add some useful comment. --- .../nsd/compose/PassThroughComposer.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index 1b6e7f3..88dacdc 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -47,6 +47,7 @@ public void composeWithStrategy( } // Retrieve non-management VLs from ctx + // Assumption: select the first Vl attached to ctxVnf Map ctxVnfCpds; VlInfo ctxNonMgmtVl; try { @@ -57,9 +58,6 @@ public void composeWithStrategy( log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - addVirtualLink(ctxNonMgmtVl, vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Added VirtualLinkDescriptor='{}' in service (if not present).", - ctxNonMgmtVl.getVlDescriptor().getVirtualLinkDescId()); // Retrieve RAN closest VNF information from vsb // Assumption: select the first VNF attached to the RAN VL @@ -91,20 +89,18 @@ public void composeWithStrategy( log.debug("ranVnfProfile: '{}'", ranVnfProfile.getVnfProfileId()); log.debug("ranVnfCpd: '{}'", ranVnfCpd); + // Modify vsbNsd addVnf(ctxVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); log.debug("Added Vnfd='{}' in service (if not present).", ctxVnfdId); - // Connect ranVnf to the new VL coming from ctx + addVirtualLink(ctxNonMgmtVl, vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Added VirtualLinkDescriptor='{}' in service (if not present).", + ctxNonMgmtVl.getVlDescriptor().getVirtualLinkDescId()); try { + // Connect ranVnf to the new VL coming from ctx connectVnfToVL(ranVnfProfile, ranVnfCpd, ctxNonMgmtVl.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", ranVnfProfile.getVnfProfileId(), ctxNonMgmtVl.getVlProfile().getVirtualLinkProfileId()); - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - - try { // Connect ctxVnf with RAN VL connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxVnfCpds.get("data1").getCpdId().get(0), ranVlInfo.getVlProfile()); @@ -122,11 +118,9 @@ public void composeWithStrategy( } else { log.warn("Could not find a management Cp for ctxVnf. Skip."); } - } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - } } From d7b274450a8ee57629ff648db5d5fdaf98fb98b9 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 11:09:36 +0100 Subject: [PATCH 049/187] Move all vsbNsd modifications at the end. Add some useful comment. Connect. --- .../expbuilder/nsd/compose/ConnectComposer.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index e8d4207..3282cb3 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -48,10 +48,6 @@ public void composeWithStrategy( log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - addVnf(srcVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Added Vnfd='{}' in service (if not present).", srcVnfInfo.getVfndId()); - addVnf(dstVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Added Vnfd='{}' in service (if not present).", dstVnfInfo.getVfndId()); // Retrieve CpdId for src VNF Map srcCpds; @@ -90,13 +86,19 @@ public void composeWithStrategy( throw new InvalidNsd(e.getMessage()); } + // Modify vsbNsd + addVnf(srcVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Added Vnfd='{}' in service (if not present).", srcVnfInfo.getVfndId()); + addVnf(dstVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Added Vnfd='{}' in service (if not present).", dstVnfInfo.getVfndId()); try { - // Connect VNFs to src and dst VLs + // Connect VNFs to src VL connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("data0").getCpdId().get(0), srcVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", srcVnfInfo.getVnfProfile().getVnfProfileId(), srcVlInfo.getVlProfile().getVirtualLinkProfileId()); + // Connect VNFs to dst VL connectVnfToVL(dstVnfInfo.getVnfProfile(), dstCpds.get("data0").getCpdId().get(0), dstVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", From 5fc9a2d5cfe8c8fe18249879f27fa89b40150d69 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 11:13:21 +0100 Subject: [PATCH 050/187] Remove graphs from strategy methods. --- .../expbuilder/nsd/compose/ConnectComposer.java | 6 ++---- .../expbuilder/nsd/compose/NsdComposer.java | 17 ++++------------- .../nsd/compose/PassThroughComposer.java | 8 +++----- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index 3282cb3..cf06ca8 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -1,7 +1,6 @@ package it.cnit.blueprint.expbuilder.nsd.compose; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; -import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; @@ -12,7 +11,6 @@ import java.util.Map; import java.util.Optional; import lombok.extern.slf4j.Slf4j; -import org.jgrapht.Graph; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; @@ -32,8 +30,8 @@ public ConnectComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, - Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Graph vsbG, - Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl, Graph ctxG) + Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, + Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsd { // Retrieve ctx VNFs VnfInfo srcVnfInfo; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index cab4fb7..eabb2b7 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -504,8 +504,8 @@ public void compose(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, throw new InvalidNsd(e.getMessage()); } composeWithStrategy(ranVlInfo, vsbMgmtVlInfo, ctxMgmtVlInfo, - vsbNsd, vsbNsDf, vsbNsLvl, vsbG, - ctxNsd, ctxNsDf, ctxNsLvl, ctxG); + vsbNsd, vsbNsDf, vsbNsLvl, + ctxNsd, ctxNsDf, ctxNsLvl); // Nsd validation and logging try { @@ -530,17 +530,8 @@ public void compose(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, public abstract void composeWithStrategy( VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, - Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Graph vsbG, - Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl, Graph ctxG + Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, + Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl ) throws InvalidNsd; - @SneakyThrows(JsonProcessingException.class) - public void composeConnectNoInput(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, - NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) { - } - - @SneakyThrows(JsonProcessingException.class) - public void composeConnect(NsVirtualLinkDesc srcVl, NsVirtualLinkDesc dstVl, Nsd vsbNsd, - NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) { - } } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index 88dacdc..952b396 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -1,7 +1,6 @@ package it.cnit.blueprint.expbuilder.nsd.compose; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; -import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; @@ -12,7 +11,6 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.util.Map; import lombok.extern.slf4j.Slf4j; -import org.jgrapht.Graph; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; @@ -32,9 +30,9 @@ public PassThroughComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, - Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Graph vsbG, - Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl, Graph ctxG - ) throws InvalidNsd { + Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, + Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) + throws InvalidNsd { // Retrieve ctx VNF String ctxVnfdId = ctxNsd.getVnfdId().get(0); VnfInfo ctxVnfInfo; From f026f379067d58b23a4a08009e73b4bdae5ad8b5 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 11:21:14 +0100 Subject: [PATCH 051/187] Remove debug line. --- .../blueprint/expbuilder/nsd/compose/PassThroughComposer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index 952b396..88e0e04 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -112,7 +112,6 @@ public void composeWithStrategy( log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", ctxVnfInfo.getVnfProfile().getVnfProfileId(), vsbMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); - log.debug("qui"); } else { log.warn("Could not find a management Cp for ctxVnf. Skip."); } From f90a888c34741c5da00b23b77b93641afd167e1e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 12:37:44 +0100 Subject: [PATCH 052/187] Do not use descriptors in strategy. Always reference to NsLvl elements. --- .../nsd/compose/ConnectComposer.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index cf06ca8..8a38b65 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -6,8 +6,8 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import java.util.Map; import java.util.Optional; import lombok.extern.slf4j.Slf4j; @@ -38,10 +38,10 @@ public void composeWithStrategy( VnfInfo dstVnfInfo; // Assumption: src is 0 and dst is 1 try { - String srcVnfdId = ctxNsd.getVnfdId().get(0); - srcVnfInfo = retrieveVnfInfoByDescId(srcVnfdId, ctxNsd, ctxNsDf, ctxNsLvl); - String dstVnfdId = ctxNsd.getVnfdId().get(1); - dstVnfInfo = retrieveVnfInfoByDescId(dstVnfdId, ctxNsd, ctxNsDf, ctxNsLvl); + String srcVnfpId = ctxNsLvl.getVnfToLevelMapping().get(0).getVnfProfileId(); + srcVnfInfo = retrieveVnfInfoByProfileId(srcVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); + String dstVnfpId = ctxNsLvl.getVnfToLevelMapping().get(1).getVnfProfileId(); + dstVnfInfo = retrieveVnfInfoByProfileId(dstVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); } catch (VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -57,7 +57,7 @@ public void composeWithStrategy( // Retrieve CpdId for dst VNF Map dstCpds; try { - dstCpds = getMgmtDataCpds(srcVnfInfo, vsbMgmtVlInfo, ctxMgmtVlInfo); + dstCpds = getMgmtDataCpds(dstVnfInfo, vsbMgmtVlInfo, ctxMgmtVlInfo); } catch (Exception e) { throw new InvalidNsd(e.getMessage()); } @@ -67,14 +67,19 @@ public void composeWithStrategy( VlInfo srcVlInfo = ranVlInfo; // Retrieve dst VL VlInfo dstVlInfo; - Optional optDstVld = vsbNsd.getVirtualLinkDesc().stream() - .filter(vld -> !vld.getVirtualLinkDescId() - .equals(vsbMgmtVlInfo.getVlDescriptor().getVirtualLinkDescId())) + Optional optDstLvlMap = vsbNsLvl.getVirtualLinkToLevelMapping() + .stream() + .filter(m -> !m.getVirtualLinkProfileId() + .equals(vsbMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()) + && !m.getVirtualLinkProfileId() + .equals(ranVlInfo.getVlProfile().getVirtualLinkProfileId())) .findFirst(); try { - if (optDstVld.isPresent()) { - dstVlInfo = retrieveVlInfo(optDstVld.get(), vsbNsDf, vsbNsLvl); - log.debug("Found non-mgmt VlInfo."); + if (optDstLvlMap.isPresent()) { + dstVlInfo = retrieveVlInfo(optDstLvlMap.get().getVirtualLinkProfileId(), + vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Found non-mgmt VlInfo='{}'.", + dstVlInfo.getVlProfile().getVirtualLinkProfileId()); } else { throw new InvalidNsd( "Can't find a non-mgmt VlInfo in vsbNsd: '" + vsbNsd.getNsdIdentifier() + "'"); @@ -86,9 +91,11 @@ public void composeWithStrategy( // Modify vsbNsd addVnf(srcVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Added Vnfd='{}' in service (if not present).", srcVnfInfo.getVfndId()); + log.debug("Added VnfProfile='{}' in service (if not present).", + srcVnfInfo.getVnfProfile().getVnfProfileId()); addVnf(dstVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Added Vnfd='{}' in service (if not present).", dstVnfInfo.getVfndId()); + log.debug("Added VnfProfile='{}' in service (if not present).", + dstVnfInfo.getVnfProfile().getVnfProfileId()); try { // Connect VNFs to src VL connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("data0").getCpdId().get(0), From 454dc5ea93a3f0a24251bf388c49bf043481ec3d Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 12:38:10 +0100 Subject: [PATCH 053/187] Make edge ids unique by appendind vnf profile id. --- .../blueprint/expbuilder/nsd/graph/NsdGraphService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java index 99cbe71..7ed5f82 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java @@ -36,7 +36,7 @@ public Graph buildGraph(List sapdList, NsDf nsDf, N List vlPVertices = new ArrayList<>(); List sapVertices = new ArrayList<>(); - //vertices + // Vertices for (VnfToLevelMapping vnfToLevelMapping : nsLevel.getVnfToLevelMapping()) { VnfProfileVertex v; try { @@ -81,14 +81,14 @@ public Graph buildGraph(List sapdList, NsDf nsDf, N g.addVertex(v); } - // edges + // Edges for (VnfProfileVertex v1 : vnfPVertices) { for (NsVirtualLinkConnectivity vlc : v1.getVnfProfile() .getNsVirtualLinkConnectivity()) { for (VirtualLinkProfileVertex v2 : vlPVertices) { if (vlc.getVirtualLinkProfileId() .equals(v2.getVlProfile().getVirtualLinkProfileId())) { - g.addEdge(v1, v2, vlc.getCpdId().get(0)); + g.addEdge(v1, v2, v1.getVnfProfile().getVnfProfileId() + "_" + vlc.getCpdId().get(0)); } } } @@ -99,7 +99,7 @@ public Graph buildGraph(List sapdList, NsDf nsDf, N for (VirtualLinkProfileVertex v2 : vlPVertices) { if (vlc.getVirtualLinkProfileId() .equals(v2.getVlProfile().getVirtualLinkProfileId())) { - g.addEdge(v1, v2, vlc.getCpdId().get(0)); + g.addEdge(v1, v2, v1.getPnfProfile().getPnfProfileId() + "_" + vlc.getCpdId().get(0)); } } } From 0078e37c69fcdf1365db56cb5acb6b4f78f5df22 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 12:38:33 +0100 Subject: [PATCH 054/187] First version of test for connect. --- .../nsd/compose/NsdComposerTest.java | 88 ++++++++++++++++--- 1 file changed, 78 insertions(+), 10 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java index 6c1d1bb..d51090a 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java @@ -8,11 +8,16 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.expbuilder.nsd.graph.GraphVizExporter; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.io.InputStream; import java.net.URL; +import java.util.ArrayList; import java.util.Arrays; import java.util.Optional; import java.util.Properties; @@ -26,7 +31,8 @@ public class NsdComposerTest { static Properties urlProp; static ObjectMapper oM; static NsdGraphService nsdGraphService; - static NsdComposer nsdComposer; + static NsdComposer passThroughComposer; + static NsdComposer connectComposer; @BeforeClass @SneakyThrows @@ -37,14 +43,15 @@ public static void setUp() { urlProp.load(input); oM = new ObjectMapper(new YAMLFactory()); nsdGraphService = new NsdGraphService(new GraphVizExporter()); - nsdComposer = new PassThroughComposer(nsdGraphService); + passThroughComposer = new PassThroughComposer(nsdGraphService); + connectComposer = new ConnectComposer(nsdGraphService); Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(Level.DEBUG); } @Test @SneakyThrows - public void composeTrackerWithDelay() { + public void composeTrackerWithDelayPassThrough() { // Given Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; @@ -58,9 +65,9 @@ public void composeTrackerWithDelay() { } NsVirtualLinkDesc vsbMgmtVld; Optional optVsbVld = vsbNsd.getVirtualLinkDesc().stream() - .filter(v->v.getVirtualLinkDescId().equals("vl_tracking_mgt")).findFirst(); - if (optVsbVld.isPresent()){ - vsbMgmtVld=optVsbVld.get(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgt")).findFirst(); + if (optVsbVld.isPresent()) { + vsbMgmtVld = optVsbVld.get(); } else { throw new Exception(); } @@ -68,15 +75,76 @@ public void composeTrackerWithDelay() { .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); NsVirtualLinkDesc ctxMgmtVld; Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() - .filter(v->v.getVirtualLinkDescId().equals("vl_dg_mgt")).findFirst(); - if (optCtxVld.isPresent()){ - ctxMgmtVld=optCtxVld.get(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgt")).findFirst(); + if (optCtxVld.isPresent()) { + ctxMgmtVld = optCtxVld.get(); } else { throw new Exception(); } // When - nsdComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + passThroughComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + // Setting ID manually for test purpose + vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); + vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); + + // Then + InputStream in = getClass().getResourceAsStream("/expb_ares2t_tracker_delay_nsds.yaml"); + Nsd expNsd = oM.readValue(in, Nsd[].class)[0]; + assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); + } + + @Test + @SneakyThrows + public void composeTrackerWithDelayConnect() { + + // Given + Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + Sapd ranSapd; + Optional optSapd = vsbNsd.getSapd().stream() + .filter(s -> s.getCpdId().equals("sap_tracking_mobile")).findFirst(); + if (optSapd.isPresent()) { + ranSapd = optSapd.get(); + } else { + throw new Exception(); + } + NsVirtualLinkDesc vsbMgmtVld; + Optional optVsbVld = vsbNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgt")).findFirst(); + if (optVsbVld.isPresent()) { + vsbMgmtVld = optVsbVld.get(); + } else { + throw new Exception(); + } + Nsd ctxNsd = Arrays + .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); + // Add twice the vnfd to fake the connect algorithm TODO use a real CONNECT ctx +// ctxNsd.getVnfdId().add(ctxNsd.getVnfdId().get(0)); + VnfProfile ctxVnfp = ctxNsd.getNsDf().get(0).getVnfProfile().get(0); + VnfProfile ctxVnfpFake = new VnfProfile(ctxNsd.getNsDf().get(0), "vnfp_netem_fake", + "396d1b6b-331b-4dd7-b48e-376517d3654a", "vnf_df_netem", "vnf_il_netem", + 1, 1, null, null, null); + for (NsVirtualLinkConnectivity vlc : ctxVnfp.getNsVirtualLinkConnectivity()) { + NsVirtualLinkConnectivity vlcFake = new NsVirtualLinkConnectivity(ctxVnfpFake, + vlc.getVirtualLinkProfileId(), new ArrayList<>(vlc.getCpdId())); + ctxVnfpFake.getNsVirtualLinkConnectivity().add(vlcFake); + } + VnfToLevelMapping ctxVnfLvlFake = new VnfToLevelMapping(ctxVnfpFake.getVnfProfileId(), 1); + VnfInfo ctxVnfFakeInfo = new VnfInfo(ctxVnfpFake.getVnfdId(), ctxVnfpFake, ctxVnfLvlFake); + connectComposer.addVnf(ctxVnfFakeInfo, ctxNsd, ctxNsd.getNsDf().get(0), + ctxNsd.getNsDf().get(0).getNsInstantiationLevel().get(0)); + + NsVirtualLinkDesc ctxMgmtVld; + Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgt")).findFirst(); + if (optCtxVld.isPresent()) { + ctxMgmtVld = optCtxVld.get(); + } else { + throw new Exception(); + } + + // When + connectComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); From 5a152ae1c4004e42601926450efdbf900c8759dd Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 12:47:42 +0100 Subject: [PATCH 055/187] Remove use of descriptors from Passthrough. Always use profiles here. --- .../expbuilder/nsd/compose/PassThroughComposer.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index 88e0e04..ee3cd1a 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -34,11 +34,11 @@ public void composeWithStrategy( Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsd { // Retrieve ctx VNF - String ctxVnfdId = ctxNsd.getVnfdId().get(0); + String ctxVnfpId = ctxNsLvl.getVnfToLevelMapping().get(0).getVnfProfileId(); VnfInfo ctxVnfInfo; try { - ctxVnfInfo = retrieveVnfInfoByDescId(ctxVnfdId, ctxNsd, ctxNsDf, ctxNsLvl); - log.debug("Found VnfInfo for vnfdId='{}' in context.", ctxVnfdId); + ctxVnfInfo = retrieveVnfInfoByProfileId(ctxVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); + log.debug("Found VnfInfo for vnfpId='{}' in context.", ctxVnfpId); } catch (VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -89,10 +89,11 @@ public void composeWithStrategy( // Modify vsbNsd addVnf(ctxVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Added Vnfd='{}' in service (if not present).", ctxVnfdId); + log.debug("Added VnfProfile='{}' in service (if not present).", + ctxVnfInfo.getVnfProfile().getVnfProfileId()); addVirtualLink(ctxNonMgmtVl, vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Added VirtualLinkDescriptor='{}' in service (if not present).", - ctxNonMgmtVl.getVlDescriptor().getVirtualLinkDescId()); + log.debug("Added VlProfile='{}' in service (if not present).", + ctxNonMgmtVl.getVlProfile().getVirtualLinkProfileId()); try { // Connect ranVnf to the new VL coming from ctx connectVnfToVL(ranVnfProfile, ranVnfCpd, ctxNonMgmtVl.getVlProfile()); From 041be9304bd423b71a0c89cab2a2d918f809e54f Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 12:57:25 +0100 Subject: [PATCH 056/187] Add info log about the strategy used. --- .../cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java | 1 + .../blueprint/expbuilder/nsd/compose/PassThroughComposer.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index 8a38b65..526885f 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -33,6 +33,7 @@ public void composeWithStrategy( Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsd { + log.info("Compose with CONNECT."); // Retrieve ctx VNFs VnfInfo srcVnfInfo; VnfInfo dstVnfInfo; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index ee3cd1a..9d3a5a4 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -33,6 +33,7 @@ public void composeWithStrategy( Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsd { + log.info("Compose with PASS_THROUGH."); // Retrieve ctx VNF String ctxVnfpId = ctxNsLvl.getVnfToLevelMapping().get(0).getVnfProfileId(); VnfInfo ctxVnfInfo; From 715d67aa00b35f15b87ce6bcd358e3ef91c87aa9 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 13:17:16 +0100 Subject: [PATCH 057/187] Cleanup unused cpds in VNFs coming from context. --- .../expbuilder/nsd/compose/ConnectComposer.java | 12 ++++++++++++ .../expbuilder/nsd/compose/PassThroughComposer.java | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index 526885f..10c9dbb 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -9,6 +9,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Qualifier; @@ -123,6 +124,17 @@ public void composeWithStrategy( } else { log.warn("Could not find a management Cp for dstVnf. Skip."); } + // Cleanup unused cpds + for (Entry cpd : srcCpds.entrySet()) { + if (!cpd.getKey().equals("data0") && !cpd.getKey().equals("mgmt")) { + srcVnfInfo.getVnfProfile().getNsVirtualLinkConnectivity().remove(cpd.getValue()); + } + } + for (Entry cpd : dstCpds.entrySet()) { + if (!cpd.getKey().equals("data0") && !cpd.getKey().equals("mgmt")) { + dstVnfInfo.getVnfProfile().getNsVirtualLinkConnectivity().remove(cpd.getValue()); + } + } } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index 9d3a5a4..af3e6c4 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -10,6 +10,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.util.Map; +import java.util.Map.Entry; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; @@ -117,6 +118,13 @@ public void composeWithStrategy( } else { log.warn("Could not find a management Cp for ctxVnf. Skip."); } + // Cleanup unused cpds of ctxVnf (if any) + for (Entry cpd : ctxVnfCpds.entrySet()) { + if (!cpd.getKey().equals("data0") && !cpd.getKey().equals("data1") && !cpd.getKey() + .equals("mgmt")) { + ctxVnfInfo.getVnfProfile().getNsVirtualLinkConnectivity().remove(cpd.getValue()); + } + } } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); From 197a208010b9e084792a2f7e109177a665816ec2 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 14:45:21 +0100 Subject: [PATCH 058/187] Fix tests for NsdComposer. --- .../nsd/compose/NsdComposerTest.java | 9 +- ...xpb_ares2t_tracker_delay_nsds_connect.yaml | 242 ++++++++++++++++++ ...res2t_tracker_delay_nsds_passthrough.yaml} | 0 3 files changed, 247 insertions(+), 4 deletions(-) create mode 100644 src/test/resources/expb_ares2t_tracker_delay_nsds_connect.yaml rename src/test/resources/{expb_ares2t_tracker_delay_nsds.yaml => expb_ares2t_tracker_delay_nsds_passthrough.yaml} (100%) diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java index d51090a..1e3a044 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java @@ -8,7 +8,6 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.expbuilder.nsd.graph.GraphVizExporter; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; @@ -46,7 +45,7 @@ public static void setUp() { passThroughComposer = new PassThroughComposer(nsdGraphService); connectComposer = new ConnectComposer(nsdGraphService); Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - root.setLevel(Level.DEBUG); + root.setLevel(Level.INFO); } @Test @@ -89,7 +88,8 @@ public void composeTrackerWithDelayPassThrough() { vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); // Then - InputStream in = getClass().getResourceAsStream("/expb_ares2t_tracker_delay_nsds.yaml"); + InputStream in = getClass().getResourceAsStream( + "/expb_ares2t_tracker_delay_nsds_passthrough.yaml"); Nsd expNsd = oM.readValue(in, Nsd[].class)[0]; assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); } @@ -150,7 +150,8 @@ public void composeTrackerWithDelayConnect() { vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); // Then - InputStream in = getClass().getResourceAsStream("/expb_ares2t_tracker_delay_nsds.yaml"); + InputStream in = getClass().getResourceAsStream( + "/expb_ares2t_tracker_delay_nsds_connect.yaml"); Nsd expNsd = oM.readValue(in, Nsd[].class)[0]; assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); } diff --git a/src/test/resources/expb_ares2t_tracker_delay_nsds_connect.yaml b/src/test/resources/expb_ares2t_tracker_delay_nsds_connect.yaml new file mode 100644 index 0000000..b0623c1 --- /dev/null +++ b/src/test/resources/expb_ares2t_tracker_delay_nsds_connect.yaml @@ -0,0 +1,242 @@ +# expb_ares2t_tracker_nsds.yaml +--- +- nsdIdentifier: "58886b95-cd29-4b7b-aca0-e884caaa5c68" + designer: "NXW" + version: "1.0" + nsdName: "ARES2T Tracker Service @ 5GEVE + NETEM Traffic Delay Generator Service" + nsdInvariantId: "ae66294b-8dae-406c-af70-f8516e310965" + vnfdId: + - "c84b227e-520e-43c0-a75e-e52781dd54dd" + - "419b1884-aea1-4cad-8647-c2cec55287b9" + - "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" + - "396d1b6b-331b-4dd7-b48e-376517d3654a" + sapd: + - cpdId: "sap_tracking_mobile" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP towards mobile equipment" + addressData: + - addressType: "IP_ADDRESS" + iPAddressAssignment: false + floatingIpActivated: true + management: false + iPAddressType: "IPv4" + numberOfIpAddress: 1 + sapAddressAssignment: false + nsVirtualLinkDescId: "vl_tracking_mobile" + - cpdId: "sap_tracking_mgt" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP for management" + addressData: + - addressType: "IP_ADDRESS" + iPAddressAssignment: false + floatingIpActivated: false + management: false + iPAddressType: "IPv4" + numberOfIpAddress: 1 + sapAddressAssignment: false + nsVirtualLinkDescId: "vl_tracking_mgt" + virtualLinkDesc: + - virtualLinkDescId: "vl_tracking_mobile" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_mobile" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Network to connect to the mobile user equipment" + - virtualLinkDescId: "vl_tracking_mgt" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_mgt" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Management network" + - virtualLinkDescId: "vl_tracking_data" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_data" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Internal network to connect the tracking service components" + nsDf: + - nsDfId: "ns_Ares2T_Tracking_df" + flavourKey: "ns_Ares2T_Tracking_df_fk" + vnfProfile: + - vnfProfileId: "vnfp_small_Ares2T_Tracker" + vnfdId: "419b1884-aea1-4cad-8647-c2cec55287b9" + flavourId: "vnf_df_Ares2T_Tracker" + instantiationLevel: "vnf_il_Ares2T_Tracker" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + cpdId: + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_tracker_mgt" + - vnfProfileId: "vnfp_big_Ares2T_Tracker" + vnfdId: "c84b227e-520e-43c0-a75e-e52781dd54dd" + flavourId: "vnf_df_Ares2T_Tracker" + instantiationLevel: "vnf_il_Ares2T_Tracker" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + cpdId: + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_tracker_mgt" + - vnfProfileId: "vnfp_Ares2T_Vis" + vnfdId: "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" + flavourId: "vnf_df_Ares2T_Vis" + instantiationLevel: "vnf_il_Ares2T_Vis" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_vis_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_vis_mgt" + - vnfProfileId: "vnfp_netem" + vnfdId: "396d1b6b-331b-4dd7-b48e-376517d3654a" + flavourId: "vnf_df_netem" + instantiationLevel: "vnf_il_netem" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + cpdId: + - "cp_dg_traffic_out" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_dg_mgt" + - vnfProfileId: "vnfp_netem_fake" + vnfdId: "396d1b6b-331b-4dd7-b48e-376517d3654a" + flavourId: "vnf_df_netem" + instantiationLevel: "vnf_il_netem" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_dg_traffic_out" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_dg_mgt" + virtualLinkProfile: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + virtualLinkDescId: "vl_tracking_mobile" + flavourId: "df_vl_tracking_mobile" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" + virtualLinkDescId: "vl_tracking_data" + flavourId: "df_vl_tracking_data" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + virtualLinkDescId: "vl_tracking_mgt" + flavourId: "df_vl_tracking_mgt" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + nsInstantiationLevel: + - nsLevelId: "ns_ares2t_tracker_il_big" + description: "Big instantiation level for the ARES2T tracking service" + vnfToLevelMapping: + - vnfProfileId: "vnfp_big_Ares2T_Tracker" + numberOfInstances: 1 + - vnfProfileId: "vnfp_Ares2T_Vis" + numberOfInstances: 1 + - vnfProfileId: "vnfp_netem" + numberOfInstances: 1 + - vnfProfileId: "vnfp_netem_fake" + numberOfInstances: 1 + virtualLinkToLevelMapping: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + bitRateRequirements: + root: "1" + leaf: "1" + - nsLevelId: "ns_ares2t_tracker_il_small" + description: "Small instantiation level for the ARES2T tracking service" + vnfToLevelMapping: + - vnfProfileId: "vnfp_small_Ares2T_Tracker" + numberOfInstances: 1 + - vnfProfileId: "vnfp_Ares2T_Vis" + numberOfInstances: 1 + - vnfProfileId: "vnfp_netem" + numberOfInstances: 1 + - vnfProfileId: "vnfp_netem_fake" + numberOfInstances: 1 + virtualLinkToLevelMapping: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + bitRateRequirements: + root: "1" + leaf: "1" + defaultNsInstantiationLevelId: "ns_ares2t_tracker_il_small" + security: + signature: "FC_NSD_SIGNATURE" + algorithm: "FC_NSD_ALGORITHM" + certificate: "FC_NSD_CERTIFICATE" diff --git a/src/test/resources/expb_ares2t_tracker_delay_nsds.yaml b/src/test/resources/expb_ares2t_tracker_delay_nsds_passthrough.yaml similarity index 100% rename from src/test/resources/expb_ares2t_tracker_delay_nsds.yaml rename to src/test/resources/expb_ares2t_tracker_delay_nsds_passthrough.yaml From 05bad6765fadc839ceee253211f03b9926567fd4 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 14:53:03 +0100 Subject: [PATCH 059/187] Fix tests for NsdGraphService. --- .../resources/ns_ares2t_tracker_exp_il_big.dot | 16 ++++++++-------- .../resources/ns_ares2t_tracker_exp_il_small.dot | 16 ++++++++-------- src/test/resources/ns_ares2t_tracker_il_big.dot | 10 +++++----- .../resources/ns_ares2t_tracker_il_small.dot | 10 +++++----- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/test/resources/ns_ares2t_tracker_exp_il_big.dot b/src/test/resources/ns_ares2t_tracker_exp_il_big.dot index 354a33a..e6697ca 100644 --- a/src/test/resources/ns_ares2t_tracker_exp_il_big.dot +++ b/src/test/resources/ns_ares2t_tracker_exp_il_big.dot @@ -11,14 +11,14 @@ strict graph G { -1971465616 [ label="vlp_vl_tracking_exp_data" shape="oval" style="filled" fillcolor="dodgerblue" ]; 142347183 [ label="sap_tracking_exp_mobile" shape="oval" style="filled" fillcolor="darksalmon" ]; 474467885 [ label="sap_tracking_exp_mgt" shape="oval" style="filled" fillcolor="darksalmon" ]; - 304837012 -- 1008003435 [ label="cp_tracker_ext_in" ]; - 304837012 -- -1971465616 [ label="cp_tracker_data" ]; - 304837012 -- 1183339156 [ label="cp_tracker_mgt" ]; - 1392640733 -- -1971465616 [ label="cp_vis_data" ]; - 1392640733 -- 1183339156 [ label="cp_vis_mgt" ]; - -793362586 -- 1008003435 [ label="cp_dg_traffic_out" ]; - -793362586 -- 1183339156 [ label="cp_dg_mgt" ]; - -793362586 -- -227812888 [ label="cp_dg_traffic_in" ]; + 304837012 -- 1008003435 [ label="vnfp_big_Ares2T_Tracker_exp_cp_tracker_ext_in" ]; + 304837012 -- -1971465616 [ label="vnfp_big_Ares2T_Tracker_exp_cp_tracker_data" ]; + 304837012 -- 1183339156 [ label="vnfp_big_Ares2T_Tracker_exp_cp_tracker_mgt" ]; + 1392640733 -- -1971465616 [ label="vnfp_Ares2T_Vis_exp_cp_vis_data" ]; + 1392640733 -- 1183339156 [ label="vnfp_Ares2T_Vis_exp_cp_vis_mgt" ]; + -793362586 -- 1008003435 [ label="vnfp_netem_exp_cp_dg_traffic_out" ]; + -793362586 -- 1183339156 [ label="vnfp_netem_exp_cp_dg_mgt" ]; + -793362586 -- -227812888 [ label="vnfp_netem_exp_cp_dg_traffic_in" ]; 142347183 -- -227812888 [ label="sap_tracking_exp_mobile" ]; 474467885 -- 1183339156 [ label="sap_tracking_exp_mgt" ]; } diff --git a/src/test/resources/ns_ares2t_tracker_exp_il_small.dot b/src/test/resources/ns_ares2t_tracker_exp_il_small.dot index df12351..dcc72eb 100644 --- a/src/test/resources/ns_ares2t_tracker_exp_il_small.dot +++ b/src/test/resources/ns_ares2t_tracker_exp_il_small.dot @@ -11,14 +11,14 @@ strict graph G { -1971465616 [ label="vlp_vl_tracking_exp_data" shape="oval" style="filled" fillcolor="dodgerblue" ]; 142347183 [ label="sap_tracking_exp_mobile" shape="oval" style="filled" fillcolor="darksalmon" ]; 474467885 [ label="sap_tracking_exp_mgt" shape="oval" style="filled" fillcolor="darksalmon" ]; - -1874275603 -- 1008003435 [ label="cp_tracker_ext_in" ]; - -1874275603 -- -1971465616 [ label="cp_tracker_data" ]; - -1874275603 -- 1183339156 [ label="cp_tracker_mgt" ]; - 1392640733 -- -1971465616 [ label="cp_vis_data" ]; - 1392640733 -- 1183339156 [ label="cp_vis_mgt" ]; - -793362586 -- 1008003435 [ label="cp_dg_traffic_out" ]; - -793362586 -- 1183339156 [ label="cp_dg_mgt" ]; - -793362586 -- -227812888 [ label="cp_dg_traffic_in" ]; + -1874275603 -- 1008003435 [ label="vnfp_small_Ares2T_Tracker_exp_cp_tracker_ext_in" ]; + -1874275603 -- -1971465616 [ label="vnfp_small_Ares2T_Tracker_exp_cp_tracker_data" ]; + -1874275603 -- 1183339156 [ label="vnfp_small_Ares2T_Tracker_exp_cp_tracker_mgt" ]; + 1392640733 -- -1971465616 [ label="vnfp_Ares2T_Vis_exp_cp_vis_data" ]; + 1392640733 -- 1183339156 [ label="vnfp_Ares2T_Vis_exp_cp_vis_mgt" ]; + -793362586 -- 1008003435 [ label="vnfp_netem_exp_cp_dg_traffic_out" ]; + -793362586 -- 1183339156 [ label="vnfp_netem_exp_cp_dg_mgt" ]; + -793362586 -- -227812888 [ label="vnfp_netem_exp_cp_dg_traffic_in" ]; 142347183 -- -227812888 [ label="sap_tracking_exp_mobile" ]; 474467885 -- 1183339156 [ label="sap_tracking_exp_mgt" ]; } diff --git a/src/test/resources/ns_ares2t_tracker_il_big.dot b/src/test/resources/ns_ares2t_tracker_il_big.dot index 5db50fe..75ba9f2 100644 --- a/src/test/resources/ns_ares2t_tracker_il_big.dot +++ b/src/test/resources/ns_ares2t_tracker_il_big.dot @@ -9,11 +9,11 @@ strict graph G { -2137711178 [ label="vlp_vl_tracking_mgt" shape="oval" style="filled" fillcolor="dodgerblue" ]; -734211891 [ label="sap_tracking_mobile" shape="oval" style="filled" fillcolor="darksalmon" ]; 1141657039 [ label="sap_tracking_mgt" shape="oval" style="filled" fillcolor="darksalmon" ]; - -1503706314 -- 1228317574 [ label="cp_tracker_ext_in" ]; - -1503706314 -- -1844810866 [ label="cp_tracker_data" ]; - -1503706314 -- -2137711178 [ label="cp_tracker_mgt" ]; - 1169940735 -- -1844810866 [ label="cp_vis_data" ]; - 1169940735 -- -2137711178 [ label="cp_vis_mgt" ]; + -1503706314 -- 1228317574 [ label="vnfp_big_Ares2T_Tracker_cp_tracker_ext_in" ]; + -1503706314 -- -1844810866 [ label="vnfp_big_Ares2T_Tracker_cp_tracker_data" ]; + -1503706314 -- -2137711178 [ label="vnfp_big_Ares2T_Tracker_cp_tracker_mgt" ]; + 1169940735 -- -1844810866 [ label="vnfp_Ares2T_Vis_cp_vis_data" ]; + 1169940735 -- -2137711178 [ label="vnfp_Ares2T_Vis_cp_vis_mgt" ]; -734211891 -- 1228317574 [ label="sap_tracking_mobile" ]; 1141657039 -- -2137711178 [ label="sap_tracking_mgt" ]; } diff --git a/src/test/resources/ns_ares2t_tracker_il_small.dot b/src/test/resources/ns_ares2t_tracker_il_small.dot index 0118ee0..5cce18d 100644 --- a/src/test/resources/ns_ares2t_tracker_il_small.dot +++ b/src/test/resources/ns_ares2t_tracker_il_small.dot @@ -9,11 +9,11 @@ strict graph G { -2137711178 [ label="vlp_vl_tracking_mgt" shape="oval" style="filled" fillcolor="dodgerblue" ]; -734211891 [ label="sap_tracking_mobile" shape="oval" style="filled" fillcolor="darksalmon" ]; 1141657039 [ label="sap_tracking_mgt" shape="oval" style="filled" fillcolor="darksalmon" ]; - 2056075535 -- 1228317574 [ label="cp_tracker_ext_in" ]; - 2056075535 -- -1844810866 [ label="cp_tracker_data" ]; - 2056075535 -- -2137711178 [ label="cp_tracker_mgt" ]; - 1169940735 -- -1844810866 [ label="cp_vis_data" ]; - 1169940735 -- -2137711178 [ label="cp_vis_mgt" ]; + 2056075535 -- 1228317574 [ label="vnfp_small_Ares2T_Tracker_cp_tracker_ext_in" ]; + 2056075535 -- -1844810866 [ label="vnfp_small_Ares2T_Tracker_cp_tracker_data" ]; + 2056075535 -- -2137711178 [ label="vnfp_small_Ares2T_Tracker_cp_tracker_mgt" ]; + 1169940735 -- -1844810866 [ label="vnfp_Ares2T_Vis_cp_vis_data" ]; + 1169940735 -- -2137711178 [ label="vnfp_Ares2T_Vis_cp_vis_mgt" ]; -734211891 -- 1228317574 [ label="sap_tracking_mobile" ]; 1141657039 -- -2137711178 [ label="sap_tracking_mgt" ]; } From 3ee9cd747c051f5e9b3f1ef30dcb1d861767c152 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 15:09:24 +0100 Subject: [PATCH 060/187] First input review. Including input for connect strategy. --- .../expbuilder/master/MasterComposer.java | 12 ++++++------ .../blueprint/expbuilder/rest/ComposeRequest.java | 4 ++-- .../blueprint/expbuilder/rest/ConnectInput.java | 12 ++++++++++++ .../blueprint/expbuilder/rest/CtxComposeInfo.java | 4 +--- .../blueprint/expbuilder/rest/VnfConnection.java | 14 -------------- 5 files changed, 21 insertions(+), 25 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java delete mode 100644 src/main/java/it/cnit/blueprint/expbuilder/rest/VnfConnection.java diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java index 4ea4d82..ce14bbb 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java @@ -1,13 +1,13 @@ package it.cnit.blueprint.expbuilder.master; import it.cnit.blueprint.expbuilder.nsd.compose.NsdComposer; -import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; +import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; @@ -34,15 +34,15 @@ public class MasterComposer { // TODO Composition Strategy comes from CtxB private static CompositionStrategy STRAT = CompositionStrategy.CONNECT; - public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] contexts) + public void compose(OnBoardVsBlueprintRequest vsbRequest, OnboardCtxBlueprintRequest[] contexts) throws InvalidCtxComposeInfo, InvalidNsd { // Assumptions: // - The Vsb has only 1 Nsd. Nsd vsbNsd = vsbRequest.getNsds().get(0); - for (CtxComposeInfo ctx : contexts) { + for (OnboardCtxBlueprintRequest ctx : contexts) { // - The Ctx has only 1 Nsd. - Nsd ctxNsd = ctx.getCtxBReq().getNsds().get(0); - CtxBlueprint ctxB = ctx.getCtxBReq().getCtxBlueprint(); + Nsd ctxNsd = ctx.getNsds().get(0); + CtxBlueprint ctxB = ctx.getCtxBlueprint(); Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); @@ -59,7 +59,7 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); } passThroughComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); - // compose Exp blueprint + // TODO compose Exp blueprint } else { log.error("not supported"); throw new InvalidCtxComposeInfo("Strategy x not supported."); diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java index 263f3f0..a099779 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java @@ -1,12 +1,12 @@ package it.cnit.blueprint.expbuilder.rest; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; +import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; import lombok.Data; @Data public class ComposeRequest { public OnBoardVsBlueprintRequest vsbRequest; - public CtxComposeInfo[] contexts; - + public OnboardCtxBlueprintRequest[] contexts; } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java new file mode 100644 index 0000000..9cebc36 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java @@ -0,0 +1,12 @@ +package it.cnit.blueprint.expbuilder.rest; + +import lombok.Data; + +@Data +public class ConnectInput { + + String srcVnfdId; + String srcVlId; + String dstVnfdId; + String dstVlId; +} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java index 6563ddf..60bac63 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java @@ -9,7 +9,5 @@ public class CtxComposeInfo { private OnboardCtxBlueprintRequest ctxBReq; - private VnfConnection[] ctxConnections; - private VnfConnection[] vsConnections; - + private ConnectInput connectInput; } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/VnfConnection.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/VnfConnection.java deleted file mode 100644 index 98b3800..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/VnfConnection.java +++ /dev/null @@ -1,14 +0,0 @@ -package it.cnit.blueprint.expbuilder.rest; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class VnfConnection { - - private String vnfProfileId; - private String cpdId; - private String vlProfileId; - -} From f5295c9da5366d2cc50213a5ce51eb13af0143a2 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 17:19:47 +0100 Subject: [PATCH 061/187] Handling and passing ConnectInput. --- .../expbuilder/master/MasterComposer.java | 20 ++++-- .../expbuilder/nsd/compose/NsdComposer.java | 65 ++++++++----------- .../expbuilder/rest/ComposeRequest.java | 3 +- .../expbuilder/rest/ConnectInput.java | 4 ++ 4 files changed, 45 insertions(+), 47 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java index ce14bbb..c21b668 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java @@ -1,13 +1,14 @@ package it.cnit.blueprint.expbuilder.master; import it.cnit.blueprint.expbuilder.nsd.compose.NsdComposer; +import it.cnit.blueprint.expbuilder.rest.ConnectInput; +import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; -import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; @@ -34,22 +35,26 @@ public class MasterComposer { // TODO Composition Strategy comes from CtxB private static CompositionStrategy STRAT = CompositionStrategy.CONNECT; - public void compose(OnBoardVsBlueprintRequest vsbRequest, OnboardCtxBlueprintRequest[] contexts) + public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] contexts) throws InvalidCtxComposeInfo, InvalidNsd { // Assumptions: // - The Vsb has only 1 Nsd. Nsd vsbNsd = vsbRequest.getNsds().get(0); - for (OnboardCtxBlueprintRequest ctx : contexts) { + for (CtxComposeInfo ctx : contexts) { // - The Ctx has only 1 Nsd. - Nsd ctxNsd = ctx.getNsds().get(0); - CtxBlueprint ctxB = ctx.getCtxBlueprint(); + Nsd ctxNsd = ctx.getCtxBReq().getNsds().get(0); + CtxBlueprint ctxB = ctx.getCtxBReq().getCtxBlueprint(); + if (ctx.getConnectInput() == null) { + ctx.setConnectInput(new ConnectInput()); + } Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); if (STRAT.equals(CompositionStrategy.CONNECT)) { log.info("connect"); - connectComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + connectComposer + .compose(ctx.getConnectInput(), ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)) { log.info("pass_through"); // compose Nsd @@ -58,7 +63,8 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, OnboardCtxBlueprintReq } else { throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); } - passThroughComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + passThroughComposer + .compose(ctx.getConnectInput(), ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // TODO compose Exp blueprint } else { log.error("not supported"); diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index eabb2b7..553f334 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; +import it.cnit.blueprint.expbuilder.rest.ConnectInput; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; @@ -19,8 +20,10 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -49,19 +52,31 @@ protected VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) return vnfProfile; } - protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) - throws NotExistingEntityException { - VnfProfile vnfProfile; - Optional optVnfP = nsDf.getVnfProfile().stream() - .filter(p -> p.getVnfdId().equals(vnfdId)).findFirst(); - if (optVnfP.isPresent()) { - vnfProfile = optVnfP.get(); - } else { + protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf, NsLevel nsLvl) + throws NotExistingEntityException, VnfNotFoundInLvlMapping { + VnfProfile vnfProfile = null; + List filterVnfp = nsDf.getVnfProfile().stream() + .filter(p -> p.getVnfdId().equals(vnfdId)).collect(Collectors.toList()); + if (filterVnfp.isEmpty()) { String m = MessageFormatter .format("No VnfProfile with vnfdId='{}' found in nsDf='{}'", vnfdId, nsDf.getNsDfId()) .getMessage(); throw new NotExistingEntityException(m); } + for (VnfProfile vnfp : filterVnfp) { + if (nsLvl.getVnfToLevelMapping().stream() + .anyMatch(m -> m.getVnfProfileId().equals(vnfp.getVnfProfileId()))) { + vnfProfile = vnfp; + break; + } + } + if (vnfProfile == null) { + String m = MessageFormatter + .format("No VnfProfile with vnfdId='{}' found in nsLvl='{}'", vnfdId, + nsLvl.getNsLevelId()) + .getMessage(); + throw new VnfNotFoundInLvlMapping(m); + } return vnfProfile; } @@ -207,32 +222,6 @@ protected VnfInfo retrieveVnfInfoByProfileId(String vnfProfileId, Nsd nsd, NsDf return new VnfInfo(vnfProfile.getVnfdId(), vnfProfile, vnfLvlMap); } - protected VnfInfo retrieveVnfInfoByDescId(String vnfdId, Nsd nsd, NsDf nsDf, - NsLevel nsLevel) - throws InvalidNsd, VnfNotFoundInLvlMapping { - Optional optVnfdId = nsd.getVnfdId().stream() - .filter(id -> id.equals(vnfdId)).findFirst(); - if (!optVnfdId.isPresent()) { - String m = MessageFormatter - .format("vnfdId='{}' not found in nsd='{}'.", vnfdId, nsd.getNsdIdentifier()) - .getMessage(); - throw new InvalidNsd(m); - } - VnfProfile vnfProfile; - try { - vnfProfile = getVnfProfileByDescId(vnfdId, nsDf); - } catch (NotExistingEntityException e) { - throw new InvalidNsd(e.getMessage()); - } - VnfToLevelMapping vnfLvlMap; - try { - vnfLvlMap = getVnfLvlMapping(vnfProfile.getVnfProfileId(), nsLevel); - } catch (NotExistingEntityException e) { - throw new VnfNotFoundInLvlMapping(e.getMessage()); - } - return new VnfInfo(vnfdId, vnfProfile, vnfLvlMap); - } - protected VlInfo retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) throws InvalidNsd, VlNotFoundInLvlMapping { VirtualLinkToLevelMapping vlMap; @@ -455,8 +444,8 @@ protected Map getMgmtDataCpds(VnfInfo vnfInfo // } @SneakyThrows(JsonProcessingException.class) - public void compose(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, - NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) + public void compose(ConnectInput connectInput, Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, + Nsd vsbNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) throws InvalidNsd { NsVirtualLinkDesc ranVld; try { @@ -503,7 +492,7 @@ public void compose(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - composeWithStrategy(ranVlInfo, vsbMgmtVlInfo, ctxMgmtVlInfo, + composeWithStrategy(connectInput, ranVlInfo, vsbMgmtVlInfo, ctxMgmtVlInfo, vsbNsd, vsbNsDf, vsbNsLvl, ctxNsd, ctxNsDf, ctxNsLvl); @@ -529,7 +518,7 @@ public void compose(Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, } public abstract void composeWithStrategy( - VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, + ConnectInput connectInput, VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl ) throws InvalidNsd; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java index a099779..53ee920 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java @@ -1,12 +1,11 @@ package it.cnit.blueprint.expbuilder.rest; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; -import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; import lombok.Data; @Data public class ComposeRequest { public OnBoardVsBlueprintRequest vsbRequest; - public OnboardCtxBlueprintRequest[] contexts; + public CtxComposeInfo[] contexts; } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java index 9cebc36..31a3ed0 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java @@ -1,8 +1,12 @@ package it.cnit.blueprint.expbuilder.rest; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data +@AllArgsConstructor +@NoArgsConstructor public class ConnectInput { String srcVnfdId; From 2e64abffd5d5987dff4c9e57883980b93891daa1 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 17:20:42 +0100 Subject: [PATCH 062/187] Remove old, commented method. --- .../expbuilder/nsd/compose/NsdComposer.java | 138 ------------------ 1 file changed, 138 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java index 553f334..0fd6bd7 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java @@ -305,144 +305,6 @@ protected Map getMgmtDataCpds(VnfInfo vnfInfo return cpdIdMap; } -// @SuppressWarnings("DuplicatedCode") -// @SneakyThrows(JsonProcessingException.class) -// public void compose(Nsd vsNsd, CtxComposeInfo[] ctxComposeInfos) -// throws InvalidCtxComposeInfo, InvalidNsd { -// ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); -// for (CtxComposeInfo ctxComposeInfo : ctxComposeInfos) { -// Nsd ctxNsd = ctxComposeInfo.getCtxBReq().getNsds().get(0); -// // We assume only one NsDf for the context -// NsDf ctxNsDf = ctxNsd.getNsDf().get(0); -// // We assume only one NsLevel for the context -// NsLevel ctxNsLvl = ctxNsDf.getNsInstantiationLevel().get(0); -// log.info("Composing '{}' with <{}, {}, {}>.", -// vsNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), -// ctxNsLvl.getNsLevelId()); -// log.debug("Nsd BEFORE composition:\n{}", objectMapper.writeValueAsString(vsNsd)); -// vsNsd.setNsdName(vsNsd.getNsdName() + " + " + ctxNsd.getNsdName()); -// for (NsDf vsNsDf : vsNsd.getNsDf()) { -// for (NsLevel vsNsLvl : vsNsDf.getNsInstantiationLevel()) { -// log.info("Start composition for nsDf='{}' and nsLvl='{}'", -// vsNsDf.getNsDfId(), vsNsLvl.getNsLevelId()); -// Graph g = nsdGraphService -// .buildGraph(vsNsd.getSapd(), vsNsDf, vsNsLvl); -// log.debug("Graph BEFORE composition :\n{}", nsdGraphService.export(g)); -// for (VnfConnection ctxC : ctxComposeInfo.getCtxConnections()) { -// log.info("ctxConnection: {}", ctxC); -// VnfWrapper vnfWrapper; -// VlWrapper vlWrapper; -// -// // Retrieve the VNF from context Nsd -// try { -// vnfWrapper = retrieveVnfInfo(ctxC.getVnfProfileId(), ctxC.getCpdId(), -// ctxNsd, ctxNsDf, ctxNsLvl); -// log.debug("Found vnfProfile='{}' in context.", ctxC.getVnfProfileId()); -// } catch (VnfNotFoundInLvlMapping e) { -// log.warn(e.getMessage() + " Skip."); -// continue; -// } catch (InvalidNsd e) { -// log.error(e.getMessage()); -// throw e; -// } -// -// // Retrieve the VirtualLink from context Nsd (and add it) -// try { -// vlWrapper = retrieveVlInfo(ctxC.getVlProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); -// log.debug("Found vlProfile='{}' in context.", ctxC.getVlProfileId()); -// addVirtualLink(vsNsd, vsNsDf, vsNsLvl, vlWrapper); -// log.debug("Added vlProfile='{}' in service (if not present).", ctxC.getVlProfileId()); -// } catch (VlNotFoundInLvlMapping e) { -// log.debug(e.getMessage() + " Trying in service."); -// // Retrieve the VirtualLink from vertical Nsd -// try { -// vlWrapper = retrieveVlInfo(ctxC.getVlProfileId(), vsNsd, vsNsDf, vsNsLvl); -// log.debug("Found vlProfile='{}' in vertical service.", ctxC.getVlProfileId()); -// } catch (VlNotFoundInLvlMapping vlNotFoundInLvlMapping) { -// String m = MessageFormatter -// .format("vlProfile='{}' not found neither in context or vertical service.", -// ctxC.getVlProfileId()).getMessage(); -// log.error(m, e); -// throw new InvalidCtxComposeInfo(m); -// } -// } catch (InvalidNsd e) { -// log.error(e.getMessage()); -// throw e; -// } -// -// // Create connection between Vnf and VL -// vnfWrapper.getVlConnectivity() -// .setVirtualLinkProfileId(vlWrapper.getVlProfile().getVirtualLinkProfileId()); -// log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", -// ctxC.getVnfProfileId(), ctxC.getVlProfileId()); -// addVnf(vsNsd, vsNsDf, vsNsLvl, vnfWrapper); -// log.debug("Added vnfProfile='{}' in service (if not present).", ctxC.getVnfProfileId()); -// } -// for (VnfConnection vsC : ctxComposeInfo.getVsConnections()) { -// log.info("vsConnection: {}", vsC); -// VnfWrapper vnfWrapper; -// VlWrapper vlWrapper; -// -// // Retrieve the VNF from vertical Nsd -// try { -// vnfWrapper = retrieveVnfInfo(vsC.getVnfProfileId(), vsC.getCpdId(), -// vsNsd, vsNsDf, vsNsLvl); -// log.debug("Found vnfProfile='{}' in vertical service.", vsC.getVnfProfileId()); -// } catch (VnfNotFoundInLvlMapping e) { -// log.warn(e.getMessage() + " Skip."); -// continue; -// } catch (InvalidNsd e) { -// log.error(e.getMessage()); -// throw e; -// } -// -// // Retrieve the VirtualLink from context Nsd (and add it) -// try { -// vlWrapper = retrieveVlInfo(vsC.getVlProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); -// log.debug("Found vlProfile='{}' in context.", vsC.getVlProfileId()); -// addVirtualLink(vsNsd, vsNsDf, vsNsLvl, vlWrapper); -// log.info("Added vlProfile='{}' in service. (if not present).", vsC.getVlProfileId()); -// } catch (VlNotFoundInLvlMapping e) { -// String m = MessageFormatter -// .format("vlProfile='{}' not found in context.", vsC.getVlProfileId()) -// .getMessage(); -// log.error(m, e); -// throw new InvalidCtxComposeInfo(m); -// } catch (InvalidNsd e) { -// log.error(e.getMessage()); -// throw e; -// } -// -// // Create connection between Vnf and VL -// vnfWrapper.getVlConnectivity() -// .setVirtualLinkProfileId(vlWrapper.getVlProfile().getVirtualLinkProfileId()); -// log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", -// vsC.getVnfProfileId(), vsC.getVlProfileId()); -// } -// try { -// vsNsd.isValid(); -// } catch (MalformattedElementException e) { -// String m = "Nsd looks not valid after composition"; -// log.error(m, e); -// throw new InvalidNsd(m); -// } -// g = nsdGraphService.buildGraph(vsNsd.getSapd(), vsNsDf, vsNsLvl); -// log.debug("Graph AFTER composition with {}:\n{}", -// ctxNsd.getNsdIdentifier(), nsdGraphService.export(g)); -// log.info("Completed composition for nsDf='{}' and nsLvl='{}'", -// vsNsDf.getNsDfId(), vsNsLvl.getNsLevelId()); -// } -// } -// vsNsd.setNsdIdentifier(UUID.randomUUID().toString()); -// vsNsd.setNsdInvariantId(UUID.randomUUID().toString()); -// log.debug("Nsd AFTER composition with {}:\n{}", -// ctxNsd.getNsdIdentifier(), objectMapper.writeValueAsString(vsNsd)); -// log.info("Completed composition of '{}' with <{}, {}, {}>.", -// vsNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), -// ctxNsLvl.getNsLevelId()); -// } -// } - @SneakyThrows(JsonProcessingException.class) public void compose(ConnectInput connectInput, Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) From b61cc480823ecdfd97fb860cd133aa8133322cd9 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 17:21:28 +0100 Subject: [PATCH 063/187] Add connectInput to Passthrough. Unused. --- .../blueprint/expbuilder/nsd/compose/PassThroughComposer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java index af3e6c4..17b7c2b 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java @@ -1,6 +1,7 @@ package it.cnit.blueprint.expbuilder.nsd.compose; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; +import it.cnit.blueprint.expbuilder.rest.ConnectInput; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; @@ -30,7 +31,7 @@ public PassThroughComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( - VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, + ConnectInput connectInput, VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsd { From ea78542e8f469224c4d66da67d32f3115c5e1943 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 17:47:31 +0100 Subject: [PATCH 064/187] Handling input in ConnectComposer. --- .../nsd/compose/ConnectComposer.java | 102 +++++++++++++----- .../expbuilder/rest/ConnectInput.java | 4 +- 2 files changed, 75 insertions(+), 31 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java index 10c9dbb..ee0627d 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java @@ -1,6 +1,7 @@ package it.cnit.blueprint.expbuilder.nsd.compose; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; +import it.cnit.blueprint.expbuilder.rest.ConnectInput; import it.cnit.blueprint.expbuilder.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; @@ -30,65 +31,108 @@ public ConnectComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( - VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, + ConnectInput connectInput, VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsd { log.info("Compose with CONNECT."); // Retrieve ctx VNFs VnfInfo srcVnfInfo; - VnfInfo dstVnfInfo; - // Assumption: src is 0 and dst is 1 try { - String srcVnfpId = ctxNsLvl.getVnfToLevelMapping().get(0).getVnfProfileId(); + String srcVnfpId; + if (connectInput.getSrcVnfdId() != null && !connectInput.getSrcVnfdId().isEmpty()) { + srcVnfpId = getVnfProfileByDescId(connectInput.getSrcVnfdId(), ctxNsDf, ctxNsLvl) + .getVnfProfileId(); + } else { + // Assumption: src is 0 + srcVnfpId = ctxNsLvl.getVnfToLevelMapping().get(0).getVnfProfileId(); + } srcVnfInfo = retrieveVnfInfoByProfileId(srcVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); - String dstVnfpId = ctxNsLvl.getVnfToLevelMapping().get(1).getVnfProfileId(); + } catch (NotExistingEntityException | VnfNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + + VnfInfo dstVnfInfo; + try { + String dstVnfpId; + if (connectInput.getDstVnfdId() != null && !connectInput.getDstVnfdId().isEmpty()) { + dstVnfpId = getVnfProfileByDescId(connectInput.getDstVnfdId(), ctxNsDf, ctxNsLvl) + .getVnfProfileId(); + } else { + // Assumption: dst is 1 + dstVnfpId = ctxNsLvl.getVnfToLevelMapping().get(1).getVnfProfileId(); + } dstVnfInfo = retrieveVnfInfoByProfileId(dstVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); - } catch (VnfNotFoundInLvlMapping e) { + } catch (NotExistingEntityException | VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - // Retrieve CpdId for src VNF + // Retrieve Cpds for src VNF Map srcCpds; try { srcCpds = getMgmtDataCpds(srcVnfInfo, vsbMgmtVlInfo, ctxMgmtVlInfo); } catch (Exception e) { + log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - // Retrieve CpdId for dst VNF + // Retrieve Cpds for dst VNF Map dstCpds; try { dstCpds = getMgmtDataCpds(dstVnfInfo, vsbMgmtVlInfo, ctxMgmtVlInfo); } catch (Exception e) { + log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - // TODO handle custom VL input // Retrieve src VL - VlInfo srcVlInfo = ranVlInfo; + VlInfo srcVlInfo; + if (connectInput.getSrcVldId() != null && !connectInput.getSrcVldId().isEmpty()) { + try { + srcVlInfo = retrieveVlInfo(getVlDescriptor(connectInput.getSrcVldId(), vsbNsd), vsbNsDf, + vsbNsLvl); + } catch (VlNotFoundInLvlMapping | NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + } else { + // Default: select a RAN VL + srcVlInfo = ranVlInfo; + } // Retrieve dst VL VlInfo dstVlInfo; - Optional optDstLvlMap = vsbNsLvl.getVirtualLinkToLevelMapping() - .stream() - .filter(m -> !m.getVirtualLinkProfileId() - .equals(vsbMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()) - && !m.getVirtualLinkProfileId() - .equals(ranVlInfo.getVlProfile().getVirtualLinkProfileId())) - .findFirst(); - try { - if (optDstLvlMap.isPresent()) { - dstVlInfo = retrieveVlInfo(optDstLvlMap.get().getVirtualLinkProfileId(), - vsbNsd, vsbNsDf, vsbNsLvl); - log.debug("Found non-mgmt VlInfo='{}'.", - dstVlInfo.getVlProfile().getVirtualLinkProfileId()); - } else { - throw new InvalidNsd( - "Can't find a non-mgmt VlInfo in vsbNsd: '" + vsbNsd.getNsdIdentifier() + "'"); + if (connectInput.getDstVldId() != null && !connectInput.getDstVldId().isEmpty()) { + try { + dstVlInfo = retrieveVlInfo(getVlDescriptor(connectInput.getDstVldId(), vsbNsd), vsbNsDf, + vsbNsLvl); + } catch (VlNotFoundInLvlMapping | NotExistingEntityException e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + } else { + // Default: select a non-management VL, different from RAN VL + Optional optDstLvlMap = vsbNsLvl.getVirtualLinkToLevelMapping() + .stream() + .filter(m -> !m.getVirtualLinkProfileId() + .equals(vsbMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()) + && !m.getVirtualLinkProfileId() + .equals(ranVlInfo.getVlProfile().getVirtualLinkProfileId())) + .findFirst(); + try { + if (optDstLvlMap.isPresent()) { + dstVlInfo = retrieveVlInfo(optDstLvlMap.get().getVirtualLinkProfileId(), + vsbNsd, vsbNsDf, vsbNsLvl); + log.debug("Found non-mgmt VlInfo='{}'.", + dstVlInfo.getVlProfile().getVirtualLinkProfileId()); + } else { + throw new InvalidNsd( + "Can't find a non-mgmt VlInfo in vsbNsd: '" + vsbNsd.getNsdIdentifier() + "'"); + } + } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); } - } catch (InvalidNsd | VlNotFoundInLvlMapping e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); } // Modify vsbNsd diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java index 31a3ed0..273fb6f 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java @@ -10,7 +10,7 @@ public class ConnectInput { String srcVnfdId; - String srcVlId; + String srcVldId; String dstVnfdId; - String dstVlId; + String dstVldId; } From 109b62d0a45f250d415869114c3ed511e2422c4c Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 17:47:42 +0100 Subject: [PATCH 065/187] Fixing tests. --- .../blueprint/expbuilder/nsd/compose/NsdComposerTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java index 1e3a044..8c45f62 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.expbuilder.nsd.graph.GraphVizExporter; import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; +import it.cnit.blueprint.expbuilder.rest.ConnectInput; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; @@ -82,7 +83,8 @@ public void composeTrackerWithDelayPassThrough() { } // When - passThroughComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + passThroughComposer + .compose(new ConnectInput(), ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); @@ -144,7 +146,7 @@ public void composeTrackerWithDelayConnect() { } // When - connectComposer.compose(ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + connectComposer.compose(new ConnectInput(), ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); From 01613d7594cc9336858a10045f469b9678a31a6c Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 9 Mar 2020 18:24:46 +0100 Subject: [PATCH 066/187] Rename variable for better readability. --- .../it/cnit/blueprint/expbuilder/master/MasterComposer.java | 4 ++-- .../it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java index c21b668..0a449e6 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java @@ -42,8 +42,8 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte Nsd vsbNsd = vsbRequest.getNsds().get(0); for (CtxComposeInfo ctx : contexts) { // - The Ctx has only 1 Nsd. - Nsd ctxNsd = ctx.getCtxBReq().getNsds().get(0); - CtxBlueprint ctxB = ctx.getCtxBReq().getCtxBlueprint(); + Nsd ctxNsd = ctx.getCtxbRequest().getNsds().get(0); + CtxBlueprint ctxB = ctx.getCtxbRequest().getCtxBlueprint(); if (ctx.getConnectInput() == null) { ctx.setConnectInput(new ConnectInput()); } diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java index 60bac63..a618a66 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java +++ b/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java @@ -8,6 +8,6 @@ @AllArgsConstructor public class CtxComposeInfo { - private OnboardCtxBlueprintRequest ctxBReq; + private OnboardCtxBlueprintRequest ctxbRequest; private ConnectInput connectInput; } From a5e35233f05912db36d46fec35f959b3830f3564 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 11 Mar 2020 17:13:05 +0100 Subject: [PATCH 067/187] Renaming project and main package. --- .../blueprint/{expbuilder => composer}/App.java | 2 +- .../master/CompositionStrategy.java | 2 +- .../master/MasterComposer.java | 12 ++++++------ .../nsd/compose/ConnectComposer.java | 14 +++++++------- .../nsd/compose/NsdComposer.java | 12 ++++++------ .../nsd/compose/PassThroughComposer.java | 14 +++++++------- .../nsd/compose/VlInfo.java | 2 +- .../nsd/compose/VlNotFoundInLvlMapping.java | 2 +- .../nsd/compose/VnfInfo.java | 2 +- .../nsd/compose/VnfNotFoundInLvlMapping.java | 2 +- .../nsd/graph/GraphExporter.java | 2 +- .../nsd/graph/GraphVizExporter.java | 2 +- .../nsd/graph/NsdGraphService.java | 4 ++-- .../nsd/graph/PnfProfileVertex.java | 2 +- .../nsd/graph/ProfileVertex.java | 2 +- .../nsd/graph/ProfileVertexNotFoundException.java | 2 +- .../nsd/graph/SapVertex.java | 2 +- .../nsd/graph/VirtualLinkProfileVertex.java | 2 +- .../nsd/graph/VnfProfileVertex.java | 2 +- .../rest/ComposeRequest.java | 2 +- .../rest/ConnectInput.java | 2 +- .../rest/CtxComposeInfo.java | 2 +- .../rest/ExperimentsController.java | 4 ++-- .../rest/InvalidCtxComposeInfo.java | 2 +- .../{expbuilder => composer}/rest/InvalidNsd.java | 2 +- .../vsbgraph/AtomicComponentVertex.java | 2 +- .../vsbgraph/VsbGraph.java | 2 +- .../vsbgraph/VsbLinkVertex.java | 2 +- .../vsbgraph/VsbSapVertex.java | 2 +- .../vsbgraph/VsbVertex.java | 2 +- .../it/cnit/blueprint/expbuilder/VsbGraphTest.java | 2 +- .../expbuilder/nsd/compose/NsdComposerTest.java | 10 +++++++--- .../expbuilder/nsd/graph/NsdGraphServiceTest.java | 2 ++ 33 files changed, 64 insertions(+), 58 deletions(-) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/App.java (96%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/master/CompositionStrategy.java (58%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/master/MasterComposer.java (91%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/compose/ConnectComposer.java (94%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/compose/NsdComposer.java (97%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/compose/PassThroughComposer.java (92%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/compose/VlInfo.java (90%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/compose/VlNotFoundInLvlMapping.java (72%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/compose/VnfInfo.java (87%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/compose/VnfNotFoundInLvlMapping.java (73%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/graph/GraphExporter.java (78%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/graph/GraphVizExporter.java (97%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/graph/NsdGraphService.java (98%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/graph/PnfProfileVertex.java (87%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/graph/ProfileVertex.java (89%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/graph/ProfileVertexNotFoundException.java (75%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/graph/SapVertex.java (86%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/graph/VirtualLinkProfileVertex.java (88%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/nsd/graph/VnfProfileVertex.java (87%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/rest/ComposeRequest.java (84%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/rest/ConnectInput.java (84%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/rest/CtxComposeInfo.java (86%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/rest/ExperimentsController.java (91%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/rest/InvalidCtxComposeInfo.java (75%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/rest/InvalidNsd.java (71%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/vsbgraph/AtomicComponentVertex.java (92%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/vsbgraph/VsbGraph.java (99%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/vsbgraph/VsbLinkVertex.java (94%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/vsbgraph/VsbSapVertex.java (94%) rename src/main/java/it/cnit/blueprint/{expbuilder => composer}/vsbgraph/VsbVertex.java (69%) diff --git a/src/main/java/it/cnit/blueprint/expbuilder/App.java b/src/main/java/it/cnit/blueprint/composer/App.java similarity index 96% rename from src/main/java/it/cnit/blueprint/expbuilder/App.java rename to src/main/java/it/cnit/blueprint/composer/App.java index 9484402..21e9fed 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/App.java +++ b/src/main/java/it/cnit/blueprint/composer/App.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder; +package it.cnit.blueprint.composer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/CompositionStrategy.java b/src/main/java/it/cnit/blueprint/composer/master/CompositionStrategy.java similarity index 58% rename from src/main/java/it/cnit/blueprint/expbuilder/master/CompositionStrategy.java rename to src/main/java/it/cnit/blueprint/composer/master/CompositionStrategy.java index 2998c79..068ebc7 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/CompositionStrategy.java +++ b/src/main/java/it/cnit/blueprint/composer/master/CompositionStrategy.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.master; +package it.cnit.blueprint.composer.master; public enum CompositionStrategy { PASS_THROUGH, diff --git a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java similarity index 91% rename from src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java rename to src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java index 0a449e6..629d89f 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java @@ -1,10 +1,10 @@ -package it.cnit.blueprint.expbuilder.master; +package it.cnit.blueprint.composer.master; -import it.cnit.blueprint.expbuilder.nsd.compose.NsdComposer; -import it.cnit.blueprint.expbuilder.rest.ConnectInput; -import it.cnit.blueprint.expbuilder.rest.CtxComposeInfo; -import it.cnit.blueprint.expbuilder.rest.InvalidCtxComposeInfo; -import it.cnit.blueprint.expbuilder.rest.InvalidNsd; +import it.cnit.blueprint.composer.rest.ConnectInput; +import it.cnit.blueprint.composer.rest.CtxComposeInfo; +import it.cnit.blueprint.composer.nsd.compose.NsdComposer; +import it.cnit.blueprint.composer.rest.InvalidCtxComposeInfo; +import it.cnit.blueprint.composer.rest.InvalidNsd; import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java similarity index 94% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java rename to src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index ee0627d..136eb5d 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -1,8 +1,8 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; +package it.cnit.blueprint.composer.nsd.compose; -import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; -import it.cnit.blueprint.expbuilder.rest.ConnectInput; -import it.cnit.blueprint.expbuilder.rest.InvalidNsd; +import it.cnit.blueprint.composer.rest.ConnectInput; +import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; +import it.cnit.blueprint.composer.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; @@ -31,9 +31,9 @@ public ConnectComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( - ConnectInput connectInput, VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, - Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, - Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) + ConnectInput connectInput, VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, + Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, + Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsd { log.info("Compose with CONNECT."); // Retrieve ctx VNFs diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java similarity index 97% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java rename to src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 0fd6bd7..3d83ad3 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -1,12 +1,12 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; +package it.cnit.blueprint.composer.nsd.compose; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; -import it.cnit.blueprint.expbuilder.nsd.graph.ProfileVertex; -import it.cnit.blueprint.expbuilder.rest.ConnectInput; -import it.cnit.blueprint.expbuilder.rest.InvalidNsd; +import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; +import it.cnit.blueprint.composer.rest.ConnectInput; +import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; +import it.cnit.blueprint.composer.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; @@ -307,7 +307,7 @@ protected Map getMgmtDataCpds(VnfInfo vnfInfo @SneakyThrows(JsonProcessingException.class) public void compose(ConnectInput connectInput, Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, - Nsd vsbNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) + Nsd vsbNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) throws InvalidNsd { NsVirtualLinkDesc ranVld; try { diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java similarity index 92% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java rename to src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index 17b7c2b..d39821b 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -1,8 +1,8 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; +package it.cnit.blueprint.composer.nsd.compose; -import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; -import it.cnit.blueprint.expbuilder.rest.ConnectInput; -import it.cnit.blueprint.expbuilder.rest.InvalidNsd; +import it.cnit.blueprint.composer.rest.ConnectInput; +import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; +import it.cnit.blueprint.composer.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; @@ -31,9 +31,9 @@ public PassThroughComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( - ConnectInput connectInput, VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, - Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, - Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) + ConnectInput connectInput, VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, + Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, + Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsd { log.info("Compose with PASS_THROUGH."); // Retrieve ctx VNF diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlInfo.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlInfo.java similarity index 90% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlInfo.java rename to src/main/java/it/cnit/blueprint/composer/nsd/compose/VlInfo.java index 1a36442..a958ce6 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlInfo.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; +package it.cnit.blueprint.composer.nsd.compose; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlNotFoundInLvlMapping.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlNotFoundInLvlMapping.java similarity index 72% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlNotFoundInLvlMapping.java rename to src/main/java/it/cnit/blueprint/composer/nsd/compose/VlNotFoundInLvlMapping.java index b82d590..b4616a0 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlNotFoundInLvlMapping.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlNotFoundInLvlMapping.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; +package it.cnit.blueprint.composer.nsd.compose; public class VlNotFoundInLvlMapping extends Exception { diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfInfo.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java similarity index 87% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfInfo.java rename to src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java index 1d0c4ec..ce5c60c 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; +package it.cnit.blueprint.composer.nsd.compose; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfNotFoundInLvlMapping.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfNotFoundInLvlMapping.java similarity index 73% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfNotFoundInLvlMapping.java rename to src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfNotFoundInLvlMapping.java index cde36f0..6c5bbb9 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfNotFoundInLvlMapping.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfNotFoundInLvlMapping.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; +package it.cnit.blueprint.composer.nsd.compose; public class VnfNotFoundInLvlMapping extends Exception { diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/GraphExporter.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphExporter.java similarity index 78% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/GraphExporter.java rename to src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphExporter.java index f5a9fdb..be7d89f 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/GraphExporter.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphExporter.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +package it.cnit.blueprint.composer.nsd.graph; import org.jgrapht.Graph; import org.springframework.stereotype.Component; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/GraphVizExporter.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphVizExporter.java similarity index 97% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/GraphVizExporter.java rename to src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphVizExporter.java index 81d290e..3ea49a3 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/GraphVizExporter.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphVizExporter.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +package it.cnit.blueprint.composer.nsd.graph; import java.io.StringWriter; import java.io.Writer; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java similarity index 98% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java rename to src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java index 7ed5f82..94a01e3 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java @@ -1,6 +1,6 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +package it.cnit.blueprint.composer.nsd.graph; -import it.cnit.blueprint.expbuilder.rest.InvalidNsd; +import it.cnit.blueprint.composer.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/PnfProfileVertex.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/PnfProfileVertex.java similarity index 87% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/PnfProfileVertex.java rename to src/main/java/it/cnit/blueprint/composer/nsd/graph/PnfProfileVertex.java index b7172b7..ce3742c 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/PnfProfileVertex.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/PnfProfileVertex.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +package it.cnit.blueprint.composer.nsd.graph; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.PnfProfile; import lombok.AllArgsConstructor; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/ProfileVertex.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/ProfileVertex.java similarity index 89% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/ProfileVertex.java rename to src/main/java/it/cnit/blueprint/composer/nsd/graph/ProfileVertex.java index 61c53fd..cc270bb 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/ProfileVertex.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/ProfileVertex.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +package it.cnit.blueprint.composer.nsd.graph; public abstract class ProfileVertex { diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/ProfileVertexNotFoundException.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/ProfileVertexNotFoundException.java similarity index 75% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/ProfileVertexNotFoundException.java rename to src/main/java/it/cnit/blueprint/composer/nsd/graph/ProfileVertexNotFoundException.java index ca77b6a..b65856f 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/ProfileVertexNotFoundException.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/ProfileVertexNotFoundException.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +package it.cnit.blueprint.composer.nsd.graph; public class ProfileVertexNotFoundException extends Exception { diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/SapVertex.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/SapVertex.java similarity index 86% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/SapVertex.java rename to src/main/java/it/cnit/blueprint/composer/nsd/graph/SapVertex.java index a119972..770c7cc 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/SapVertex.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/SapVertex.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +package it.cnit.blueprint.composer.nsd.graph; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import lombok.AllArgsConstructor; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/VirtualLinkProfileVertex.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/VirtualLinkProfileVertex.java similarity index 88% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/VirtualLinkProfileVertex.java rename to src/main/java/it/cnit/blueprint/composer/nsd/graph/VirtualLinkProfileVertex.java index a223e5e..b496fed 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/VirtualLinkProfileVertex.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/VirtualLinkProfileVertex.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +package it.cnit.blueprint.composer.nsd.graph; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; import lombok.AllArgsConstructor; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/VnfProfileVertex.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/VnfProfileVertex.java similarity index 87% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/VnfProfileVertex.java rename to src/main/java/it/cnit/blueprint/composer/nsd/graph/VnfProfileVertex.java index 9d07d80..15d8157 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/graph/VnfProfileVertex.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/VnfProfileVertex.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +package it.cnit.blueprint.composer.nsd.graph; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import lombok.AllArgsConstructor; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java similarity index 84% rename from src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java rename to src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java index 53ee920..973d5fb 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.rest; +package it.cnit.blueprint.composer.rest; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; import lombok.Data; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java b/src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java similarity index 84% rename from src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java rename to src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java index 273fb6f..3216ad5 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/ConnectInput.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.rest; +package it.cnit.blueprint.composer.rest; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java b/src/main/java/it/cnit/blueprint/composer/rest/CtxComposeInfo.java similarity index 86% rename from src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java rename to src/main/java/it/cnit/blueprint/composer/rest/CtxComposeInfo.java index a618a66..e18716c 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/CtxComposeInfo.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.rest; +package it.cnit.blueprint.composer.rest; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; import lombok.AllArgsConstructor; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java similarity index 91% rename from src/main/java/it/cnit/blueprint/expbuilder/rest/ExperimentsController.java rename to src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 9e4c645..daae61a 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -1,6 +1,6 @@ -package it.cnit.blueprint.expbuilder.rest; +package it.cnit.blueprint.composer.rest; -import it.cnit.blueprint.expbuilder.master.MasterComposer; +import it.cnit.blueprint.composer.master.MasterComposer; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardExpBlueprintRequest; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidCtxComposeInfo.java b/src/main/java/it/cnit/blueprint/composer/rest/InvalidCtxComposeInfo.java similarity index 75% rename from src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidCtxComposeInfo.java rename to src/main/java/it/cnit/blueprint/composer/rest/InvalidCtxComposeInfo.java index cb670d9..0006187 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidCtxComposeInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/InvalidCtxComposeInfo.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.rest; +package it.cnit.blueprint.composer.rest; public class InvalidCtxComposeInfo extends Exception { diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidNsd.java b/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsd.java similarity index 71% rename from src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidNsd.java rename to src/main/java/it/cnit/blueprint/composer/rest/InvalidNsd.java index 6042caf..09f06ae 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidNsd.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsd.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.rest; +package it.cnit.blueprint.composer.rest; public class InvalidNsd extends Exception { diff --git a/src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/AtomicComponentVertex.java b/src/main/java/it/cnit/blueprint/composer/vsbgraph/AtomicComponentVertex.java similarity index 92% rename from src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/AtomicComponentVertex.java rename to src/main/java/it/cnit/blueprint/composer/vsbgraph/AtomicComponentVertex.java index 03f0928..512b11d 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/AtomicComponentVertex.java +++ b/src/main/java/it/cnit/blueprint/composer/vsbgraph/AtomicComponentVertex.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.vsbgraph; +package it.cnit.blueprint.composer.vsbgraph; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsComponent; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbGraph.java b/src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbGraph.java similarity index 99% rename from src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbGraph.java rename to src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbGraph.java index 8dd0502..ec44772 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbGraph.java +++ b/src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbGraph.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.vsbgraph; +package it.cnit.blueprint.composer.vsbgraph; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsComponent; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbLinkVertex.java b/src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbLinkVertex.java similarity index 94% rename from src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbLinkVertex.java rename to src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbLinkVertex.java index 55c3d36..19ca1eb 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbLinkVertex.java +++ b/src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbLinkVertex.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.vsbgraph; +package it.cnit.blueprint.composer.vsbgraph; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbLink; import java.util.concurrent.atomic.AtomicLong; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbSapVertex.java b/src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbSapVertex.java similarity index 94% rename from src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbSapVertex.java rename to src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbSapVertex.java index c6dcf2f..e551e0f 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbSapVertex.java +++ b/src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbSapVertex.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.vsbgraph; +package it.cnit.blueprint.composer.vsbgraph; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import java.util.concurrent.atomic.AtomicLong; diff --git a/src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbVertex.java b/src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbVertex.java similarity index 69% rename from src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbVertex.java rename to src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbVertex.java index 864b80e..d66a822 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/vsbgraph/VsbVertex.java +++ b/src/main/java/it/cnit/blueprint/composer/vsbgraph/VsbVertex.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.vsbgraph; +package it.cnit.blueprint.composer.vsbgraph; public abstract class VsbVertex { diff --git a/src/test/java/it/cnit/blueprint/expbuilder/VsbGraphTest.java b/src/test/java/it/cnit/blueprint/expbuilder/VsbGraphTest.java index f9b783d..6cd75ac 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/VsbGraphTest.java +++ b/src/test/java/it/cnit/blueprint/expbuilder/VsbGraphTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import it.cnit.blueprint.expbuilder.vsbgraph.VsbGraph; +import it.cnit.blueprint.composer.vsbgraph.VsbGraph; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import java.io.IOException; diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java index 8c45f62..cd6f43a 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java @@ -6,9 +6,13 @@ import ch.qos.logback.classic.Logger; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import it.cnit.blueprint.expbuilder.nsd.graph.GraphVizExporter; -import it.cnit.blueprint.expbuilder.nsd.graph.NsdGraphService; -import it.cnit.blueprint.expbuilder.rest.ConnectInput; +import it.cnit.blueprint.composer.nsd.compose.ConnectComposer; +import it.cnit.blueprint.composer.nsd.compose.NsdComposer; +import it.cnit.blueprint.composer.nsd.compose.PassThroughComposer; +import it.cnit.blueprint.composer.nsd.compose.VnfInfo; +import it.cnit.blueprint.composer.nsd.graph.GraphVizExporter; +import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; +import it.cnit.blueprint.composer.rest.ConnectInput; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphServiceTest.java b/src/test/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphServiceTest.java index 39e4394..760cf87 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphServiceTest.java +++ b/src/test/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphServiceTest.java @@ -6,6 +6,8 @@ import ch.qos.logback.classic.Logger; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.cnit.blueprint.composer.nsd.graph.GraphVizExporter; +import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import java.io.InputStream; import java.net.URL; From bc36a45eeca438605b8aef6bc6469b5fd7636a02 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 11 Mar 2020 17:35:47 +0100 Subject: [PATCH 068/187] Complete rename for the whole project. --- README.md | 4 ++-- pom.xml | 5 ++--- src/main/java/it/cnit/blueprint/composer/App.java | 2 +- .../blueprint/{expbuilder => composer}/VsbGraphTest.java | 2 +- .../nsd/compose/NsdComposerTest.java | 6 +----- .../nsd/graph/NsdGraphServiceTest.java | 4 +--- src/test/resources/application-logging-test.properties | 2 +- 7 files changed, 9 insertions(+), 16 deletions(-) rename src/test/java/it/cnit/blueprint/{expbuilder => composer}/VsbGraphTest.java (97%) rename src/test/java/it/cnit/blueprint/{expbuilder => composer}/nsd/compose/NsdComposerTest.java (95%) rename src/test/java/it/cnit/blueprint/{expbuilder => composer}/nsd/graph/NsdGraphServiceTest.java (96%) diff --git a/README.md b/README.md index 75dd634..9e186f9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# 5geve-experiment-builder -A REST API module to compose VSB and CBs. +# 5G EVE Experment NSD composer +A REST API module to compose the NSD of a VSB and multiple CBs. The project is designed to be deployed with Docker. Check the pom.xml for details about plugins to ease docker image build. diff --git a/pom.xml b/pom.xml index 76a8676..45d9730 100644 --- a/pom.xml +++ b/pom.xml @@ -11,10 +11,9 @@ it.cnit.blueprint - expbuilder + composer 0.0.2-SNAPSHOT - A REST API module to compose VSD and CDs. - https://github.com/TheWall89/5geve-experiment-builder + A REST API module to compose NSDs. docker-build diff --git a/src/main/java/it/cnit/blueprint/composer/App.java b/src/main/java/it/cnit/blueprint/composer/App.java index 21e9fed..15ad333 100644 --- a/src/main/java/it/cnit/blueprint/composer/App.java +++ b/src/main/java/it/cnit/blueprint/composer/App.java @@ -9,7 +9,7 @@ import org.springframework.context.ConfigurableApplicationContext; @SpringBootApplication -@EntityScan(basePackages = {"it.nextworks.nfvmano.libs.ifa", "it.cnit.blueprint.expbuilder"}) +@EntityScan(basePackages = {"it.nextworks.nfvmano.libs.ifa", "it.cnit.blueprint.composer"}) @Slf4j public class App { diff --git a/src/test/java/it/cnit/blueprint/expbuilder/VsbGraphTest.java b/src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java similarity index 97% rename from src/test/java/it/cnit/blueprint/expbuilder/VsbGraphTest.java rename to src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java index 6cd75ac..9572c6a 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/VsbGraphTest.java +++ b/src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder; +package it.cnit.blueprint.composer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java similarity index 95% rename from src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java rename to src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java index cd6f43a..3137372 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; +package it.cnit.blueprint.composer.nsd.compose; import static org.junit.Assert.assertEquals; @@ -6,10 +6,6 @@ import ch.qos.logback.classic.Logger; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import it.cnit.blueprint.composer.nsd.compose.ConnectComposer; -import it.cnit.blueprint.composer.nsd.compose.NsdComposer; -import it.cnit.blueprint.composer.nsd.compose.PassThroughComposer; -import it.cnit.blueprint.composer.nsd.compose.VnfInfo; import it.cnit.blueprint.composer.nsd.graph.GraphVizExporter; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.rest.ConnectInput; diff --git a/src/test/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphServiceTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java similarity index 96% rename from src/test/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphServiceTest.java rename to src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java index 760cf87..c6c8b64 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/graph/NsdGraphServiceTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +package it.cnit.blueprint.composer.nsd.graph; import static org.junit.Assert.assertEquals; @@ -6,8 +6,6 @@ import ch.qos.logback.classic.Logger; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import it.cnit.blueprint.composer.nsd.graph.GraphVizExporter; -import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import java.io.InputStream; import java.net.URL; diff --git a/src/test/resources/application-logging-test.properties b/src/test/resources/application-logging-test.properties index 8b7f4c2..2929eec 100644 --- a/src/test/resources/application-logging-test.properties +++ b/src/test/resources/application-logging-test.properties @@ -1,2 +1,2 @@ -logging.level.it.cnit.blueprint.expbuilder.=DEBUG +logging.level.it.cnit.blueprint.composer.=DEBUG logging.level.root=ERROR From 4e4521155e279736f775885feb45c9f07075fa37 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 12 Mar 2020 18:17:51 +0100 Subject: [PATCH 069/187] Move common method outside of compose. --- .../composer/master/MasterComposer.java | 19 ++++++++++++------- .../composer/nsd/compose/NsdComposer.java | 11 +++++++---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java index 629d89f..95af41b 100644 --- a/src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java @@ -40,6 +40,7 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte // Assumptions: // - The Vsb has only 1 Nsd. Nsd vsbNsd = vsbRequest.getNsds().get(0); + NsVirtualLinkDesc ranVld = findRanVld(vsbRequest.getVsBlueprint(), vsbNsd); for (CtxComposeInfo ctx : contexts) { // - The Ctx has only 1 Nsd. Nsd ctxNsd = ctx.getCtxbRequest().getNsds().get(0); @@ -48,13 +49,12 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte ctx.setConnectInput(new ConnectInput()); } - Sapd ranSapd = findRanSapd(vsbRequest.getVsBlueprint(), vsbNsd); NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); if (STRAT.equals(CompositionStrategy.CONNECT)) { log.info("connect"); connectComposer - .compose(ctx.getConnectInput(), ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + .compose(ctx.getConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)) { log.info("pass_through"); // compose Nsd @@ -64,7 +64,7 @@ public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] conte throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); } passThroughComposer - .compose(ctx.getConnectInput(), ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + .compose(ctx.getConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // TODO compose Exp blueprint } else { log.error("not supported"); @@ -80,18 +80,23 @@ private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) { return new NsVirtualLinkDesc(); } - private Sapd findRanSapd(Blueprint b, Nsd nsd) { + private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsd { + Sapd ranSapd = null; for (VsbEndpoint e : b.getEndPoints()) { if (e.isRanConnection()) { for (Sapd sapd : nsd.getSapd()) { if (e.getEndPointId().equals(sapd.getCpdId())) { - return sapd; + ranSapd = sapd; + break; } } } } - // TODO exception invalid blueprint or nsd - return null; + if (ranSapd == null) { + // TODO think of a better message + throw new InvalidNsd("Cannot find a Sap descriptor for RAN."); + } + return connectComposer.getRanVlDesc(ranSapd, nsd); } } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 3d83ad3..145db44 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -305,10 +305,7 @@ protected Map getMgmtDataCpds(VnfInfo vnfInfo return cpdIdMap; } - @SneakyThrows(JsonProcessingException.class) - public void compose(ConnectInput connectInput, Sapd ranSapd, NsVirtualLinkDesc vsbMgmtVld, - Nsd vsbNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) - throws InvalidNsd { + public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd vsbNsd) throws InvalidNsd { NsVirtualLinkDesc ranVld; try { ranVld = getVlDescriptor(ranSapd.getNsVirtualLinkDescId(), vsbNsd); @@ -316,7 +313,13 @@ public void compose(ConnectInput connectInput, Sapd ranSapd, NsVirtualLinkDesc v log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } + return ranVld; + } + @SneakyThrows(JsonProcessingException.class) + public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, + NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) + throws InvalidNsd { // We assume only one NsDf for the context NsDf ctxNsDf = ctxNsd.getNsDf().get(0); // We assume only one NsLevel for the context From 0d0d764c28e352c68f1ea4e05d79c84fcaa404d1 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 14 Mar 2020 19:59:18 +0100 Subject: [PATCH 070/187] First version of NSD generator and tests. --- .../composer/nsd/generate/NsdGenerator.java | 106 ++++++++++++++++++ .../nsd/generate/NsdGeneratorTest.java | 52 +++++++++ src/test/resources/url.properties | 3 +- 3 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java create mode 100644 src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java new file mode 100644 index 0000000..58d374d --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -0,0 +1,106 @@ +package it.cnit.blueprint.composer.nsd.generate; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.cnit.blueprint.composer.rest.InvalidNsd; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsComponent; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbLink; +import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.SecurityParameters; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.ScopedProxyMode; +import org.springframework.stereotype.Service; +import org.springframework.web.context.WebApplicationContext; + +@Service +@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS) +@Slf4j +public class NsdGenerator { + + protected static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory()); + + @SneakyThrows(JsonProcessingException.class) + public Nsd generate(VsBlueprint vsb) throws InvalidNsd { + + log.debug(OBJECT_MAPPER.writeValueAsString(vsb)); + + Nsd nsd = new Nsd(); + nsd.setNsdIdentifier(vsb.getBlueprintId() + "_nsd"); + nsd.setDesigner("NSD generator"); + nsd.setNsdInvariantId(vsb.getBlueprintId() + "_nsd"); + nsd.setVersion(vsb.getVersion()); + nsd.setNsdName(vsb.getName() + "_nsd"); + nsd.setSecurity(new SecurityParameters( + "FC_NSD_SIGNATURE", + "FC_NSD_ALGORITHM", + "FC_NSD_CERTIFICATE" + )); + + NsDf nsDf = new NsDf(); + nsDf.setNsDfId(vsb.getBlueprintId() + "_df"); + nsDf.setFlavourKey(vsb.getBlueprintId() + "_df_fk"); + + NsLevel nsLevel = new NsLevel(); + nsLevel.setNsLevelId(vsb.getBlueprintId() + "_il_default"); + nsLevel.setDescription("Default Instantiation Level"); + for (VsComponent vsc : vsb.getAtomicComponents()) { + nsd.getVnfdId().add(vsc.getComponentId()); + VnfProfile vnfp = new VnfProfile(); + vnfp.setVnfProfileId(vsc.getComponentId() + "_vnfp"); + vnfp.setVnfdId(vsc.getComponentId()); + vnfp.setFlavourId(vsc.getComponentId() + "_vnf_df"); + vnfp.setInstantiationLevel(vsc.getComponentId() + "_vnf_il"); + vnfp.setMinNumberOfInstances(1); + vnfp.setMaxNumberOfInstances(1); + List nsVirtualLinkConnectivities = new ArrayList<>(); + for (String ep : vsc.getEndPointsIds()) { + for (VsbLink cs : vsb.getConnectivityServices()) { + for (String csEp : cs.getEndPointIds()) { + if (csEp.equals(ep)) { + NsVirtualLinkConnectivity nsVLC = new NsVirtualLinkConnectivity(); + // TODO change this when connectivity service has a name + nsVLC.setVirtualLinkProfileId("new Vl profile"); + nsVLC.setCpdId(Collections.singletonList("ep")); + nsVirtualLinkConnectivities.add(nsVLC); + } + } + } + } + vnfp.setNsVirtualLinkConnectivity(nsVirtualLinkConnectivities); + nsDf.getVnfProfile().add(vnfp); + nsLevel.getVnfToLevelMapping().add(new VnfToLevelMapping(vnfp.getVnfProfileId(), 1)); + } +// for (VsbLink connService: vsb.getConnectivityServices()){ +// +// } + + nsDf.setNsInstantiationLevel(Collections.singletonList(nsLevel)); + nsDf.setDefaultNsInstantiationLevelId(nsLevel.getNsLevelId()); + nsd.setNsDf(Collections.singletonList(nsDf)); + + // Nsd validation and logging + try { + nsd.isValid(); + } catch (MalformattedElementException e) { + String m = "Nsd looks not valid after composition"; + log.error(m, e); + throw new InvalidNsd(m); + } + log.debug(OBJECT_MAPPER.writeValueAsString(nsd)); + return nsd; + } + +} diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java new file mode 100644 index 0000000..63cbd51 --- /dev/null +++ b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java @@ -0,0 +1,52 @@ +package it.cnit.blueprint.composer.nsd.generate; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.cnit.blueprint.composer.nsd.graph.GraphVizExporter; +import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import java.io.InputStream; +import java.net.URL; +import java.util.Properties; +import lombok.SneakyThrows; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +public class NsdGeneratorTest { + + static Properties urlProp; + static ObjectMapper oM; + static NsdGraphService nsdGraphService; + static NsdGenerator nsdGenerator; + + @BeforeClass + @SneakyThrows + public static void setUp() { + // Test Setup + urlProp = new Properties(); + InputStream input = ClassLoader.getSystemResourceAsStream("url.properties"); + urlProp.load(input); + oM = new ObjectMapper(new YAMLFactory()); + nsdGraphService = new NsdGraphService(new GraphVizExporter()); + nsdGenerator = new NsdGenerator(); + Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + root.setLevel(Level.DEBUG); + } + + + @Test + @SneakyThrows + public void generate() { + + // Given + VsBlueprint vsb = oM.readValue(new URL(urlProp.getProperty("vsb.tracker")), VsBlueprint.class); + + //When + Nsd vsbNsd = nsdGenerator.generate(vsb); + + } +} \ No newline at end of file diff --git a/src/test/resources/url.properties b/src/test/resources/url.properties index c5f94b9..8486e96 100644 --- a/src/test/resources/url.properties +++ b/src/test/resources/url.properties @@ -1,3 +1,4 @@ +vsb.tracker=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker.yaml vsb.tracker.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker_nsds.yaml ctx.delay.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay_nsds.yaml -expb.tracker.delay.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/expb/expb_ares2t_tracker_delay/expb_ares2t_tracker_delay_nsds.yaml \ No newline at end of file +expb.tracker.delay.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/expb/expb_ares2t_tracker_delay/expb_ares2t_tracker_delay_nsds.yaml From 0b10bb1c3255466b14704ac683df9980a33db57b Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 14 Mar 2020 20:00:16 +0100 Subject: [PATCH 071/187] Fix errors in NsdComposerTest. --- .../composer/nsd/compose/NsdComposerTest.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java index 3137372..e5d71f7 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -12,7 +12,6 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.io.InputStream; @@ -55,11 +54,12 @@ public void composeTrackerWithDelayPassThrough() { // Given Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; - Sapd ranSapd; - Optional optSapd = vsbNsd.getSapd().stream() - .filter(s -> s.getCpdId().equals("sap_tracking_mobile")).findFirst(); - if (optSapd.isPresent()) { - ranSapd = optSapd.get(); + NsVirtualLinkDesc ranVld; + Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) + .findFirst(); + if (optRanVl.isPresent()) { + ranVld = optRanVl.get(); } else { throw new Exception(); } @@ -84,7 +84,7 @@ public void composeTrackerWithDelayPassThrough() { // When passThroughComposer - .compose(new ConnectInput(), ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + .compose(new ConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); @@ -102,11 +102,12 @@ public void composeTrackerWithDelayConnect() { // Given Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; - Sapd ranSapd; - Optional optSapd = vsbNsd.getSapd().stream() - .filter(s -> s.getCpdId().equals("sap_tracking_mobile")).findFirst(); - if (optSapd.isPresent()) { - ranSapd = optSapd.get(); + NsVirtualLinkDesc ranVld; + Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) + .findFirst(); + if (optRanVl.isPresent()) { + ranVld = optRanVl.get(); } else { throw new Exception(); } @@ -146,7 +147,7 @@ public void composeTrackerWithDelayConnect() { } // When - connectComposer.compose(new ConnectInput(), ranSapd, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + connectComposer.compose(new ConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); From d08318c1ac7ead99914d388f2a98e91e5d20fc9d Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sat, 14 Mar 2020 21:26:47 +0100 Subject: [PATCH 072/187] Generate endpoints. Create graph to check if correct. --- .../composer/nsd/generate/NsdGenerator.java | 74 +++++++++++++++++-- .../nsd/generate/NsdGeneratorTest.java | 2 +- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index 58d374d..edecb75 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -3,23 +3,36 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; +import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; import it.cnit.blueprint.composer.rest.InvalidNsd; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsComponent; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbLink; +import it.nextworks.nfvmano.libs.ifa.common.enums.LayerProtocol; +import it.nextworks.nfvmano.libs.ifa.common.enums.ServiceAvailabilityLevel; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; +import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.ConnectivityType; +import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.LinkBitrateRequirements; +import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkDf; +import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.SecurityParameters; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Optional; +import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import org.jgrapht.Graph; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.stereotype.Service; @@ -28,10 +41,13 @@ @Service @Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS) @Slf4j +@AllArgsConstructor public class NsdGenerator { protected static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory()); + private NsdGraphService nsdGraphService; + @SneakyThrows(JsonProcessingException.class) public Nsd generate(VsBlueprint vsb) throws InvalidNsd { @@ -56,6 +72,40 @@ public Nsd generate(VsBlueprint vsb) throws InvalidNsd { NsLevel nsLevel = new NsLevel(); nsLevel.setNsLevelId(vsb.getBlueprintId() + "_il_default"); nsLevel.setDescription("Default Instantiation Level"); + + int vldCount = 0; + for (VsbLink connService : vsb.getConnectivityServices()) { + NsVirtualLinkDesc vld = new NsVirtualLinkDesc(); +// TODO vld.setVirtualLinkDescId(connService.getName()); + vld.setVirtualLinkDescId("vld_" + vldCount); + vld.setVirtualLinkDescProvider(nsd.getDesigner()); + vld.setVirtuaLinkDescVersion(nsd.getVersion()); + vld.setDescription(vld.getVirtualLinkDescId()); + vld.setConnectivityType(new ConnectivityType(LayerProtocol.IPV4, "")); + VirtualLinkDf vldf = new VirtualLinkDf(); + vldf.setFlavourId(vld.getVirtualLinkDescId() + "_df"); + vldf.setServiceAvaibilityLevel(ServiceAvailabilityLevel.LEVEL_1); + vld.setVirtualLinkDf(Collections.singletonList(vldf)); + nsd.getVirtualLinkDesc().add(vld); + + VirtualLinkProfile vlp = new VirtualLinkProfile(); + vlp.setVirtualLinkProfileId(vld.getVirtualLinkDescId() + "_vlp"); + vlp.setVirtualLinkDescId(vld.getVirtualLinkDescId()); + vlp.setFlavourId(vldf.getFlavourId()); + vlp.setMaxBitrateRequirements(new LinkBitrateRequirements("1", "1")); + vlp.setMinBitrateRequirements(new LinkBitrateRequirements("1", "1")); + nsDf.getVirtualLinkProfile().add(vlp); + + VirtualLinkToLevelMapping vlMap = new VirtualLinkToLevelMapping(); + vlMap.setVirtualLinkProfileId(vlp.getVirtualLinkProfileId()); + vlMap.setBitRateRequirements(new LinkBitrateRequirements("1", "1")); + nsLevel.getVirtualLinkToLevelMapping().add(vlMap); + + vldCount++; + } + + // TODO generate Sapd + for (VsComponent vsc : vsb.getAtomicComponents()) { nsd.getVnfdId().add(vsc.getComponentId()); VnfProfile vnfp = new VnfProfile(); @@ -67,25 +117,29 @@ public Nsd generate(VsBlueprint vsb) throws InvalidNsd { vnfp.setMaxNumberOfInstances(1); List nsVirtualLinkConnectivities = new ArrayList<>(); for (String ep : vsc.getEndPointsIds()) { + int count = 0; for (VsbLink cs : vsb.getConnectivityServices()) { for (String csEp : cs.getEndPointIds()) { if (csEp.equals(ep)) { NsVirtualLinkConnectivity nsVLC = new NsVirtualLinkConnectivity(); // TODO change this when connectivity service has a name - nsVLC.setVirtualLinkProfileId("new Vl profile"); - nsVLC.setCpdId(Collections.singletonList("ep")); - nsVirtualLinkConnectivities.add(nsVLC); + String vldId = "vld_" + count; + Optional optVlp = nsDf.getVirtualLinkProfile().stream() + .filter(vlp -> vlp.getVirtualLinkDescId().equals(vldId)).findFirst(); + if (optVlp.isPresent()) { + nsVLC.setVirtualLinkProfileId(optVlp.get().getVirtualLinkProfileId()); + nsVLC.setCpdId(Collections.singletonList(ep)); + nsVirtualLinkConnectivities.add(nsVLC); + } } } + count++; } } vnfp.setNsVirtualLinkConnectivity(nsVirtualLinkConnectivities); nsDf.getVnfProfile().add(vnfp); nsLevel.getVnfToLevelMapping().add(new VnfToLevelMapping(vnfp.getVnfProfileId(), 1)); } -// for (VsbLink connService: vsb.getConnectivityServices()){ -// -// } nsDf.setNsInstantiationLevel(Collections.singletonList(nsLevel)); nsDf.setDefaultNsInstantiationLevelId(nsLevel.getNsLevelId()); @@ -99,7 +153,13 @@ public Nsd generate(VsBlueprint vsb) throws InvalidNsd { log.error(m, e); throw new InvalidNsd(m); } - log.debug(OBJECT_MAPPER.writeValueAsString(nsd)); + log.debug("Nsd AFTER generation with {}:\n{}", + nsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(nsd)); + + Graph g = nsdGraphService.buildGraph(nsd.getSapd(), nsDf, nsLevel); + log.debug("Graph AFTER generation with {}:\n{}", + nsd.getNsdIdentifier(), nsdGraphService.export(g)); + return nsd; } diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java index 63cbd51..16a0a73 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java @@ -32,7 +32,7 @@ public static void setUp() { urlProp.load(input); oM = new ObjectMapper(new YAMLFactory()); nsdGraphService = new NsdGraphService(new GraphVizExporter()); - nsdGenerator = new NsdGenerator(); + nsdGenerator = new NsdGenerator(nsdGraphService); Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(Level.DEBUG); } From 961bdb3e2e12034fdcf3380b42b4cc49c2a2d19e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 15 Mar 2020 12:18:41 +0100 Subject: [PATCH 073/187] Add code to generate sapd. --- .../composer/nsd/generate/NsdGenerator.java | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index edecb75..6095fda 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -8,10 +8,15 @@ import it.cnit.blueprint.composer.rest.InvalidNsd; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsComponent; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbLink; +import it.nextworks.nfvmano.libs.ifa.common.enums.AddressType; +import it.nextworks.nfvmano.libs.ifa.common.enums.CpRole; +import it.nextworks.nfvmano.libs.ifa.common.enums.IpVersion; import it.nextworks.nfvmano.libs.ifa.common.enums.LayerProtocol; import it.nextworks.nfvmano.libs.ifa.common.enums.ServiceAvailabilityLevel; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; +import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.AddressData; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.ConnectivityType; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.LinkBitrateRequirements; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkDf; @@ -21,6 +26,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.SecurityParameters; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; @@ -104,7 +110,38 @@ public Nsd generate(VsBlueprint vsb) throws InvalidNsd { vldCount++; } - // TODO generate Sapd + List sapdList = new ArrayList<>(); + for (VsbEndpoint e : vsb.getEndPoints()) { + if (e.isExternal() && e.getEndPointId().contains("sap")) { + Sapd sapd = new Sapd(); + sapd.setCpdId(e.getEndPointId()); + sapd.setDescription("A generated Sapd"); + sapd.setLayerProtocol(LayerProtocol.IPV4); + sapd.setCpRole(CpRole.ROOT); // TODO meaning of this? + sapd.setSapAddressAssignment(false); + int count = 0; + for (VsbLink cs : vsb.getConnectivityServices()) { + for (String ep : cs.getEndPointIds()) { + if (ep.equals(sapd.getCpdId())) { + // TODO change this when connectivity service has a name + sapd.setNsVirtualLinkDescId("vld_" + count); + break; + } + } + count++; + } + AddressData addressData = new AddressData(); + addressData.setAddressType(AddressType.IP_ADDRESS); + addressData.setiPAddressType(IpVersion.IPv4); + addressData.setiPAddressAssignment(false); + addressData.setFloatingIpActivated(true); + addressData.setNumberOfIpAddress(1); + sapd.setAddressData(Collections.singletonList(addressData)); + + sapdList.add(sapd); + } + } + nsd.setSapd(sapdList); for (VsComponent vsc : vsb.getAtomicComponents()) { nsd.getVnfdId().add(vsc.getComponentId()); From 86ce014ad58d31e00d9a8bf87fdf5b3a0e28eae2 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 15 Mar 2020 12:22:12 +0100 Subject: [PATCH 074/187] Add test for Orange V360 generation. --- .../composer/nsd/generate/NsdGeneratorTest.java | 14 +++++++++++++- src/test/resources/url.properties | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java index 16a0a73..1139c3e 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java @@ -40,7 +40,7 @@ public static void setUp() { @Test @SneakyThrows - public void generate() { + public void generateTracker() { // Given VsBlueprint vsb = oM.readValue(new URL(urlProp.getProperty("vsb.tracker")), VsBlueprint.class); @@ -49,4 +49,16 @@ public void generate() { Nsd vsbNsd = nsdGenerator.generate(vsb); } + + @Test + @SneakyThrows + public void generateV360() { + + // Given + VsBlueprint vsb = oM.readValue(new URL(urlProp.getProperty("vsb.v360")), VsBlueprint.class); + + //When + Nsd vsbNsd = nsdGenerator.generate(vsb); + + } } \ No newline at end of file diff --git a/src/test/resources/url.properties b/src/test/resources/url.properties index 8486e96..c69bad6 100644 --- a/src/test/resources/url.properties +++ b/src/test/resources/url.properties @@ -2,3 +2,5 @@ vsb.tracker=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vs vsb.tracker.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker_nsds.yaml ctx.delay.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay_nsds.yaml expb.tracker.delay.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/expb/expb_ares2t_tracker_delay/expb_ares2t_tracker_delay_nsds.yaml + +vsb.v360=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_orange_v360/vsb_V360.yml From 8e8ac7c05d128419db73056f3cd575b3847ef365 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 15 Mar 2020 12:22:58 +0100 Subject: [PATCH 075/187] Add TODOs in test. --- .../blueprint/composer/nsd/generate/NsdGeneratorTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java index 1139c3e..aad6677 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java @@ -48,6 +48,9 @@ public void generateTracker() { //When Nsd vsbNsd = nsdGenerator.generate(vsb); + //Then + //TODO + } @Test @@ -60,5 +63,8 @@ public void generateV360() { //When Nsd vsbNsd = nsdGenerator.generate(vsb); + //Then + //TODO + } } \ No newline at end of file From 3bf5846732659eeb1055da265f1c06b53f78f3b9 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 15 Mar 2020 12:32:44 +0100 Subject: [PATCH 076/187] Add REST paths for services. --- .../composer/rest/ServicesController.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java new file mode 100644 index 0000000..e7cf404 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java @@ -0,0 +1,36 @@ +package it.cnit.blueprint.composer.rest; + +import it.cnit.blueprint.composer.nsd.generate.NsdGenerator; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +public class ServicesController { + + private NsdGenerator nsdGenerator; + + @GetMapping("/services") + public Nsd retrieveService() { + return null; + } + + @PostMapping("/services") + public Nsd generateService(@RequestBody VsBlueprint vsb) { + Nsd nsd; + try { + nsd = nsdGenerator.generate(vsb); + } catch (InvalidNsd e) { + //TODO handle exception + nsd = null; + e.printStackTrace(); + } + return nsd; + } + +} From df2157dad706f4281e4c0bb34dd110ea79778e6b Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 15 Mar 2020 12:51:39 +0100 Subject: [PATCH 077/187] Remove MasterComposer. Fix some input class problems. --- .../composer/master/MasterComposer.java | 102 ------------------ .../composer/rest/ComposeRequest.java | 4 +- .../{master => rest}/CompositionStrategy.java | 2 +- .../blueprint/composer/rest/ConnectInput.java | 8 +- .../composer/rest/ExperimentsController.java | 89 +++++++++++++-- 5 files changed, 87 insertions(+), 118 deletions(-) delete mode 100644 src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java rename src/main/java/it/cnit/blueprint/composer/{master => rest}/CompositionStrategy.java (59%) diff --git a/src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java b/src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java deleted file mode 100644 index 95af41b..0000000 --- a/src/main/java/it/cnit/blueprint/composer/master/MasterComposer.java +++ /dev/null @@ -1,102 +0,0 @@ -package it.cnit.blueprint.composer.master; - -import it.cnit.blueprint.composer.rest.ConnectInput; -import it.cnit.blueprint.composer.rest.CtxComposeInfo; -import it.cnit.blueprint.composer.nsd.compose.NsdComposer; -import it.cnit.blueprint.composer.rest.InvalidCtxComposeInfo; -import it.cnit.blueprint.composer.rest.InvalidNsd; -import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; -import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; -import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; -import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Scope; -import org.springframework.context.annotation.ScopedProxyMode; -import org.springframework.stereotype.Service; -import org.springframework.web.context.WebApplicationContext; - -@Service -@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS) -@Slf4j -@AllArgsConstructor -public class MasterComposer { - - @Qualifier("PASS_THROUGH") - private NsdComposer passThroughComposer; - @Qualifier("CONNECT") - private NsdComposer connectComposer; - // TODO vsbComposer - - // TODO Composition Strategy comes from CtxB - private static CompositionStrategy STRAT = CompositionStrategy.CONNECT; - - public void compose(OnBoardVsBlueprintRequest vsbRequest, CtxComposeInfo[] contexts) - throws InvalidCtxComposeInfo, InvalidNsd { - // Assumptions: - // - The Vsb has only 1 Nsd. - Nsd vsbNsd = vsbRequest.getNsds().get(0); - NsVirtualLinkDesc ranVld = findRanVld(vsbRequest.getVsBlueprint(), vsbNsd); - for (CtxComposeInfo ctx : contexts) { - // - The Ctx has only 1 Nsd. - Nsd ctxNsd = ctx.getCtxbRequest().getNsds().get(0); - CtxBlueprint ctxB = ctx.getCtxbRequest().getCtxBlueprint(); - if (ctx.getConnectInput() == null) { - ctx.setConnectInput(new ConnectInput()); - } - - NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); - NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); - if (STRAT.equals(CompositionStrategy.CONNECT)) { - log.info("connect"); - connectComposer - .compose(ctx.getConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); - } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)) { - log.info("pass_through"); - // compose Nsd - if (ctxNsd.getVnfdId().size() == 1) { - log.debug("ctxNsd has only one vnfdId."); - } else { - throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); - } - passThroughComposer - .compose(ctx.getConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); - // TODO compose Exp blueprint - } else { - log.error("not supported"); - throw new InvalidCtxComposeInfo("Strategy x not supported."); - } - - } - } - - private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) { - // TODO Visit vlDesc in nsd and check if mgmt in b. - // We need model modifications to make this work. - return new NsVirtualLinkDesc(); - } - - private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsd { - Sapd ranSapd = null; - for (VsbEndpoint e : b.getEndPoints()) { - if (e.isRanConnection()) { - for (Sapd sapd : nsd.getSapd()) { - if (e.getEndPointId().equals(sapd.getCpdId())) { - ranSapd = sapd; - break; - } - } - } - } - if (ranSapd == null) { - // TODO think of a better message - throw new InvalidNsd("Cannot find a Sap descriptor for RAN."); - } - return connectComposer.getRanVlDesc(ranSapd, nsd); - } - -} diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java index 973d5fb..e80f459 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java @@ -6,6 +6,6 @@ @Data public class ComposeRequest { - public OnBoardVsBlueprintRequest vsbRequest; - public CtxComposeInfo[] contexts; + private OnBoardVsBlueprintRequest vsbRequest; + private CtxComposeInfo[] contexts; } diff --git a/src/main/java/it/cnit/blueprint/composer/master/CompositionStrategy.java b/src/main/java/it/cnit/blueprint/composer/rest/CompositionStrategy.java similarity index 59% rename from src/main/java/it/cnit/blueprint/composer/master/CompositionStrategy.java rename to src/main/java/it/cnit/blueprint/composer/rest/CompositionStrategy.java index 068ebc7..f2f21c4 100644 --- a/src/main/java/it/cnit/blueprint/composer/master/CompositionStrategy.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/CompositionStrategy.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.composer.master; +package it.cnit.blueprint.composer.rest; public enum CompositionStrategy { PASS_THROUGH, diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java b/src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java index 3216ad5..da9eb86 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java @@ -9,8 +9,8 @@ @NoArgsConstructor public class ConnectInput { - String srcVnfdId; - String srcVldId; - String dstVnfdId; - String dstVldId; + private String srcVnfdId; + private String srcVldId; + private String dstVnfdId; + private String dstVldId; } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index daae61a..90745ac 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -1,18 +1,34 @@ package it.cnit.blueprint.composer.rest; -import it.cnit.blueprint.composer.master.MasterComposer; +import it.cnit.blueprint.composer.nsd.compose.NsdComposer; +import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardExpBlueprintRequest; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.helpers.MessageFormatter; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @RestController +@Slf4j @AllArgsConstructor public class ExperimentsController { - private final MasterComposer masterComposer; + // TODO Composition Strategy comes from CtxB + private static CompositionStrategy STRAT = CompositionStrategy.CONNECT; + + @Qualifier("PASS_THROUGH") + private NsdComposer passThroughComposer; + @Qualifier("CONNECT") + private NsdComposer connectComposer; @GetMapping("/experiments") public OnboardExpBlueprintRequest retrieveExperiment() { @@ -22,16 +38,71 @@ public OnboardExpBlueprintRequest retrieveExperiment() { @PostMapping("/experiments") public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest composeRequest) { try { - masterComposer.compose(composeRequest.getVsbRequest(), composeRequest.getContexts()); - } catch (InvalidCtxComposeInfo e) { - //TODO create and return a 422 response. - e.printStackTrace(); - } catch (InvalidNsd e) { - e.printStackTrace(); + // Assumptions: + // - The Vsb has only 1 Nsd. + Nsd vsbNsd = composeRequest.getVsbRequest().getNsds().get(0); + NsVirtualLinkDesc ranVld = findRanVld(composeRequest.getVsbRequest().getVsBlueprint(), + vsbNsd); + for (CtxComposeInfo ctx : composeRequest.getContexts()) { + // - The Ctx has only 1 Nsd. + Nsd ctxNsd = ctx.getCtxbRequest().getNsds().get(0); + CtxBlueprint ctxB = ctx.getCtxbRequest().getCtxBlueprint(); + if (ctx.getConnectInput() == null) { + ctx.setConnectInput(new ConnectInput()); + } + + NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); + NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); + if (STRAT.equals(CompositionStrategy.CONNECT)) { + log.info("connect"); + connectComposer + .compose(ctx.getConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)) { + log.info("pass_through"); + if (ctxNsd.getVnfdId().size() == 1) { + log.debug("ctxNsd has only one vnfdId."); + } else { + throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); + } + passThroughComposer + .compose(ctx.getConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + } else { + String m = MessageFormatter.format("Composition strategy {} not supported.", STRAT) + .getMessage(); + log.error(m); + throw new InvalidCtxComposeInfo(m); + } + + } + } catch (InvalidNsd | InvalidCtxComposeInfo e) { + log.error(e.getMessage()); //TODO create and return a 422 response. } - //TODO return new OnboardExpBlueprintRequest(); } + private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsd { + Sapd ranSapd = null; + for (VsbEndpoint e : b.getEndPoints()) { + if (e.isRanConnection()) { + for (Sapd sapd : nsd.getSapd()) { + if (e.getEndPointId().equals(sapd.getCpdId())) { + ranSapd = sapd; + break; + } + } + } + } + if (ranSapd == null) { + // TODO think of a better message + throw new InvalidNsd("Cannot find a Sap descriptor for RAN."); + } + return connectComposer.getRanVlDesc(ranSapd, nsd); + } + + private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) { + // TODO Visit vlDesc in nsd and check if mgmt in b. + // We need model modifications to make this work. + return new NsVirtualLinkDesc(); + } } From c12bf385af662dcb355a65431fe4b5bb23502d86 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 16 Mar 2020 22:37:42 +0100 Subject: [PATCH 078/187] Supporting multiple NsDf. --- .../composer/nsd/compose/NsdComposer.java | 78 ++++++++++--------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 145db44..bba7feb 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; import it.cnit.blueprint.composer.rest.ConnectInput; -import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.rest.InvalidNsd; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; @@ -324,8 +324,6 @@ public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, NsDf ctxNsDf = ctxNsd.getNsDf().get(0); // We assume only one NsLevel for the context NsLevel ctxNsLvl = ctxNsDf.getNsInstantiationLevel().get(0); - // We assume only one NsDf for the vertical service - NsDf vsbNsDf = vsbNsd.getNsDf().get(0); Graph ctxG = nsdGraphService .buildGraph(ctxNsd.getSapd(), ctxNsDf, ctxNsLvl); log.debug("ctxG graph:\n{}", nsdGraphService.export(ctxG)); @@ -336,44 +334,48 @@ public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, log.debug("Nsd BEFORE composition:\n{}", OBJECT_MAPPER.writeValueAsString(vsbNsd)); vsbNsd.setNsdName(vsbNsd.getNsdName() + " + " + ctxNsd.getNsdName()); - for (NsLevel vsbNsLvl : vsbNsDf.getNsInstantiationLevel()) { - log.info("Start composition for nsDf='{}' and nsLvl='{}'", - vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); - Graph vsbG = nsdGraphService - .buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); - log.debug("vsbG BEFORE composition :\n{}", nsdGraphService.export(vsbG)); + for (NsDf vsbNsDf : vsbNsd.getNsDf()) { + for (NsLevel vsbNsLvl : vsbNsDf.getNsInstantiationLevel()) { + log.info("Start composition for nsDf='{}' and nsLvl='{}'", + vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); + Graph vsbG = nsdGraphService + .buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); + log.debug("vsbG BEFORE composition :\n{}", nsdGraphService.export(vsbG)); - VlInfo ranVlInfo; - VlInfo vsbMgmtVlInfo; - VlInfo ctxMgmtVlInfo; - try { - ranVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); - log.debug("Found VlInfo for ranVld='{}' in vsbNsd.", ranVld.getVirtualLinkDescId()); - vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); - log.debug("Found VlInfo for vsbMgmtVld='{}' in vsbNsd.", vsbMgmtVld.getVirtualLinkDescId()); - ctxMgmtVlInfo = retrieveVlInfo(ctxMgmtVld, ctxNsDf, ctxNsLvl); - log.debug("Found VlInfo for ctxMgmtVld='{}' in ctxNsd.", ctxMgmtVld.getVirtualLinkDescId()); - } catch (InvalidNsd | VlNotFoundInLvlMapping e) { - log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); - } - composeWithStrategy(connectInput, ranVlInfo, vsbMgmtVlInfo, ctxMgmtVlInfo, - vsbNsd, vsbNsDf, vsbNsLvl, - ctxNsd, ctxNsDf, ctxNsLvl); + VlInfo ranVlInfo; + VlInfo vsbMgmtVlInfo; + VlInfo ctxMgmtVlInfo; + try { + ranVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); + log.debug("Found VlInfo for ranVld='{}' in vsbNsd.", ranVld.getVirtualLinkDescId()); + vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); + log.debug("Found VlInfo for vsbMgmtVld='{}' in vsbNsd.", + vsbMgmtVld.getVirtualLinkDescId()); + ctxMgmtVlInfo = retrieveVlInfo(ctxMgmtVld, ctxNsDf, ctxNsLvl); + log.debug("Found VlInfo for ctxMgmtVld='{}' in ctxNsd.", + ctxMgmtVld.getVirtualLinkDescId()); + } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + log.error(e.getMessage()); + throw new InvalidNsd(e.getMessage()); + } + composeWithStrategy(connectInput, ranVlInfo, vsbMgmtVlInfo, ctxMgmtVlInfo, + vsbNsd, vsbNsDf, vsbNsLvl, + ctxNsd, ctxNsDf, ctxNsLvl); - // Nsd validation and logging - try { - vsbNsd.isValid(); - } catch (MalformattedElementException e) { - String m = "Nsd looks not valid after composition"; - log.error(m, e); - throw new InvalidNsd(m); + // Nsd validation and logging + try { + vsbNsd.isValid(); + } catch (MalformattedElementException e) { + String m = "Nsd looks not valid after composition"; + log.error(m, e); + throw new InvalidNsd(m); + } + vsbG = nsdGraphService.buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); + log.debug("Graph AFTER composition with {}:\n{}", + ctxNsd.getNsdIdentifier(), nsdGraphService.export(vsbG)); + log.info("Completed composition for nsDf='{}' and nsLvl='{}'", + vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); } - vsbG = nsdGraphService.buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); - log.debug("Graph AFTER composition with {}:\n{}", - ctxNsd.getNsdIdentifier(), nsdGraphService.export(vsbG)); - log.info("Completed composition for nsDf='{}' and nsLvl='{}'", - vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); } log.debug("Nsd AFTER composition with {}:\n{}", ctxNsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(vsbNsd)); From 2dc17b55f79b9843b4719d1fcbc73eb49b6a85d3 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 16 Mar 2020 22:48:23 +0100 Subject: [PATCH 079/187] Rename all vsb references to exp. --- .../composer/nsd/compose/ConnectComposer.java | 34 +++++------ .../composer/nsd/compose/NsdComposer.java | 60 +++++++++---------- .../nsd/compose/PassThroughComposer.java | 24 ++++---- .../composer/rest/ExperimentsController.java | 10 ++-- 4 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index 136eb5d..e48cb2b 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -31,8 +31,8 @@ public ConnectComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( - ConnectInput connectInput, VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, - Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, + ConnectInput connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, VlInfo ctxMgmtVlInfo, + Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsd { log.info("Compose with CONNECT."); @@ -72,7 +72,7 @@ public void composeWithStrategy( // Retrieve Cpds for src VNF Map srcCpds; try { - srcCpds = getMgmtDataCpds(srcVnfInfo, vsbMgmtVlInfo, ctxMgmtVlInfo); + srcCpds = getMgmtDataCpds(srcVnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); } catch (Exception e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -80,7 +80,7 @@ public void composeWithStrategy( // Retrieve Cpds for dst VNF Map dstCpds; try { - dstCpds = getMgmtDataCpds(dstVnfInfo, vsbMgmtVlInfo, ctxMgmtVlInfo); + dstCpds = getMgmtDataCpds(dstVnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); } catch (Exception e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -90,8 +90,8 @@ public void composeWithStrategy( VlInfo srcVlInfo; if (connectInput.getSrcVldId() != null && !connectInput.getSrcVldId().isEmpty()) { try { - srcVlInfo = retrieveVlInfo(getVlDescriptor(connectInput.getSrcVldId(), vsbNsd), vsbNsDf, - vsbNsLvl); + srcVlInfo = retrieveVlInfo(getVlDescriptor(connectInput.getSrcVldId(), expNsd), expNsDf, + expNsLvl); } catch (VlNotFoundInLvlMapping | NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -104,30 +104,30 @@ public void composeWithStrategy( VlInfo dstVlInfo; if (connectInput.getDstVldId() != null && !connectInput.getDstVldId().isEmpty()) { try { - dstVlInfo = retrieveVlInfo(getVlDescriptor(connectInput.getDstVldId(), vsbNsd), vsbNsDf, - vsbNsLvl); + dstVlInfo = retrieveVlInfo(getVlDescriptor(connectInput.getDstVldId(), expNsd), expNsDf, + expNsLvl); } catch (VlNotFoundInLvlMapping | NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } } else { // Default: select a non-management VL, different from RAN VL - Optional optDstLvlMap = vsbNsLvl.getVirtualLinkToLevelMapping() + Optional optDstLvlMap = expNsLvl.getVirtualLinkToLevelMapping() .stream() .filter(m -> !m.getVirtualLinkProfileId() - .equals(vsbMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()) + .equals(expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()) && !m.getVirtualLinkProfileId() .equals(ranVlInfo.getVlProfile().getVirtualLinkProfileId())) .findFirst(); try { if (optDstLvlMap.isPresent()) { dstVlInfo = retrieveVlInfo(optDstLvlMap.get().getVirtualLinkProfileId(), - vsbNsd, vsbNsDf, vsbNsLvl); + expNsd, expNsDf, expNsLvl); log.debug("Found non-mgmt VlInfo='{}'.", dstVlInfo.getVlProfile().getVirtualLinkProfileId()); } else { throw new InvalidNsd( - "Can't find a non-mgmt VlInfo in vsbNsd: '" + vsbNsd.getNsdIdentifier() + "'"); + "Can't find a non-mgmt VlInfo in expNsd: '" + expNsd.getNsdIdentifier() + "'"); } } catch (InvalidNsd | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); @@ -135,11 +135,11 @@ public void composeWithStrategy( } } - // Modify vsbNsd - addVnf(srcVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); + // Modify expNsd + addVnf(srcVnfInfo, expNsd, expNsDf, expNsLvl); log.debug("Added VnfProfile='{}' in service (if not present).", srcVnfInfo.getVnfProfile().getVnfProfileId()); - addVnf(dstVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); + addVnf(dstVnfInfo, expNsd, expNsDf, expNsLvl); log.debug("Added VnfProfile='{}' in service (if not present).", dstVnfInfo.getVnfProfile().getVnfProfileId()); try { @@ -158,13 +158,13 @@ public void composeWithStrategy( // Connect VNFs to mgmt VL (if possible) if (srcCpds.get("mgmt") != null) { connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("mgmt").getCpdId().get(0), - vsbMgmtVlInfo.getVlProfile()); + expMgmtVlInfo.getVlProfile()); } else { log.warn("Could not find a management Cp for srcVnf. Skip."); } if (dstCpds.get("mgmt") != null) { connectVnfToVL(dstVnfInfo.getVnfProfile(), dstCpds.get("mgmt").getCpdId().get(0), - vsbMgmtVlInfo.getVlProfile()); + expMgmtVlInfo.getVlProfile()); } else { log.warn("Could not find a management Cp for dstVnf. Skip."); } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index bba7feb..3efc7cf 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -278,13 +278,13 @@ protected void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile } protected Map getMgmtDataCpds(VnfInfo vnfInfo, - VlInfo vsbMgmtVlinfo, VlInfo ctxMgmtVlInfo) + VlInfo expMgmtVlinfo, VlInfo ctxMgmtVlInfo) throws InvalidNsd { Map cpdIdMap = new HashMap<>(); int dataCount = 0; for (NsVirtualLinkConnectivity vlc : vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity()) { if (vlc.getVirtualLinkProfileId() - .equals(vsbMgmtVlinfo.getVlProfile().getVirtualLinkProfileId()) + .equals(expMgmtVlinfo.getVlProfile().getVirtualLinkProfileId()) || vlc.getVirtualLinkProfileId() .equals(ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId())) { cpdIdMap.put("mgmt", vlc); @@ -305,10 +305,10 @@ protected Map getMgmtDataCpds(VnfInfo vnfInfo return cpdIdMap; } - public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd vsbNsd) throws InvalidNsd { + public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws InvalidNsd { NsVirtualLinkDesc ranVld; try { - ranVld = getVlDescriptor(ranSapd.getNsVirtualLinkDescId(), vsbNsd); + ranVld = getVlDescriptor(ranSapd.getNsVirtualLinkDescId(), expNsd); } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -318,7 +318,7 @@ public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd vsbNsd) throws InvalidNs @SneakyThrows(JsonProcessingException.class) public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, - NsVirtualLinkDesc vsbMgmtVld, Nsd vsbNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) + NsVirtualLinkDesc expMgmtVld, Nsd expNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) throws InvalidNsd { // We assume only one NsDf for the context NsDf ctxNsDf = ctxNsd.getNsDf().get(0); @@ -329,28 +329,28 @@ public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, log.debug("ctxG graph:\n{}", nsdGraphService.export(ctxG)); log.info("Composing '{}' with <{}, {}, {}>.", - vsbNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), + expNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), ctxNsLvl.getNsLevelId()); - log.debug("Nsd BEFORE composition:\n{}", OBJECT_MAPPER.writeValueAsString(vsbNsd)); + log.debug("Nsd BEFORE composition:\n{}", OBJECT_MAPPER.writeValueAsString(expNsd)); - vsbNsd.setNsdName(vsbNsd.getNsdName() + " + " + ctxNsd.getNsdName()); - for (NsDf vsbNsDf : vsbNsd.getNsDf()) { - for (NsLevel vsbNsLvl : vsbNsDf.getNsInstantiationLevel()) { + expNsd.setNsdName(expNsd.getNsdName() + " + " + ctxNsd.getNsdName()); + for (NsDf expNsDf: expNsd.getNsDf()) { + for (NsLevel expNsLvl : expNsDf.getNsInstantiationLevel()) { log.info("Start composition for nsDf='{}' and nsLvl='{}'", - vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); - Graph vsbG = nsdGraphService - .buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); - log.debug("vsbG BEFORE composition :\n{}", nsdGraphService.export(vsbG)); + expNsDf.getNsDfId(), expNsLvl.getNsLevelId()); + Graph expG = nsdGraphService + .buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); + log.debug("expG BEFORE composition :\n{}", nsdGraphService.export(expG)); VlInfo ranVlInfo; - VlInfo vsbMgmtVlInfo; + VlInfo expMgmtVlInfo; VlInfo ctxMgmtVlInfo; try { - ranVlInfo = retrieveVlInfo(ranVld, vsbNsDf, vsbNsLvl); - log.debug("Found VlInfo for ranVld='{}' in vsbNsd.", ranVld.getVirtualLinkDescId()); - vsbMgmtVlInfo = retrieveVlInfo(vsbMgmtVld, vsbNsDf, vsbNsLvl); - log.debug("Found VlInfo for vsbMgmtVld='{}' in vsbNsd.", - vsbMgmtVld.getVirtualLinkDescId()); + ranVlInfo = retrieveVlInfo(ranVld, expNsDf, expNsLvl); + log.debug("Found VlInfo for ranVld='{}' in expNsd.", ranVld.getVirtualLinkDescId()); + expMgmtVlInfo = retrieveVlInfo(expMgmtVld, expNsDf, expNsLvl); + log.debug("Found VlInfo for expMgmtVld='{}' in expNsd.", + expMgmtVld.getVirtualLinkDescId()); ctxMgmtVlInfo = retrieveVlInfo(ctxMgmtVld, ctxNsDf, ctxNsLvl); log.debug("Found VlInfo for ctxMgmtVld='{}' in ctxNsd.", ctxMgmtVld.getVirtualLinkDescId()); @@ -358,35 +358,35 @@ public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); } - composeWithStrategy(connectInput, ranVlInfo, vsbMgmtVlInfo, ctxMgmtVlInfo, - vsbNsd, vsbNsDf, vsbNsLvl, + composeWithStrategy(connectInput, ranVlInfo, expMgmtVlInfo, ctxMgmtVlInfo, + expNsd, expNsDf, expNsLvl, ctxNsd, ctxNsDf, ctxNsLvl); // Nsd validation and logging try { - vsbNsd.isValid(); + expNsd.isValid(); } catch (MalformattedElementException e) { String m = "Nsd looks not valid after composition"; log.error(m, e); throw new InvalidNsd(m); } - vsbG = nsdGraphService.buildGraph(vsbNsd.getSapd(), vsbNsDf, vsbNsLvl); + expG = nsdGraphService.buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("Graph AFTER composition with {}:\n{}", - ctxNsd.getNsdIdentifier(), nsdGraphService.export(vsbG)); + ctxNsd.getNsdIdentifier(), nsdGraphService.export(expG)); log.info("Completed composition for nsDf='{}' and nsLvl='{}'", - vsbNsDf.getNsDfId(), vsbNsLvl.getNsLevelId()); + expNsDf.getNsDfId(), expNsLvl.getNsLevelId()); } } log.debug("Nsd AFTER composition with {}:\n{}", - ctxNsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(vsbNsd)); + ctxNsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(expNsd)); log.info("Completed composition of '{}' with <{}, {}, {}>.", - vsbNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), + expNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), ctxNsLvl.getNsLevelId()); } public abstract void composeWithStrategy( - ConnectInput connectInput, VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, - Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, + ConnectInput connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, VlInfo ctxMgmtVlInfo, + Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl ) throws InvalidNsd; diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index d39821b..4db6537 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -31,8 +31,8 @@ public PassThroughComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( - ConnectInput connectInput, VlInfo ranVlInfo, VlInfo vsbMgmtVlInfo, VlInfo ctxMgmtVlInfo, - Nsd vsbNsd, NsDf vsbNsDf, NsLevel vsbNsLvl, + ConnectInput connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, VlInfo ctxMgmtVlInfo, + Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsd { log.info("Compose with PASS_THROUGH."); @@ -52,7 +52,7 @@ public void composeWithStrategy( Map ctxVnfCpds; VlInfo ctxNonMgmtVl; try { - ctxVnfCpds = getMgmtDataCpds(ctxVnfInfo, vsbMgmtVlInfo, ctxMgmtVlInfo); + ctxVnfCpds = getMgmtDataCpds(ctxVnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); ctxNonMgmtVl = retrieveVlInfo(ctxVnfCpds.get("data0").getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); } catch (InvalidNsd | VlNotFoundInLvlMapping e) { @@ -60,15 +60,15 @@ public void composeWithStrategy( throw new InvalidNsd(e.getMessage()); } - // Retrieve RAN closest VNF information from vsb + // Retrieve RAN closest VNF information from exp // Assumption: select the first VNF attached to the RAN VL // TODO Can create composition inconsistencies across multiple NsLvl String ranVnfCpd = null; VnfProfile ranVnfProfile = null; - for (VnfToLevelMapping vnfLvl : vsbNsLvl.getVnfToLevelMapping()) { + for (VnfToLevelMapping vnfLvl : expNsLvl.getVnfToLevelMapping()) { VnfInfo vnfInfo; try { - vnfInfo = retrieveVnfInfoByProfileId(vnfLvl.getVnfProfileId(), vsbNsd, vsbNsDf, vsbNsLvl); + vnfInfo = retrieveVnfInfoByProfileId(vnfLvl.getVnfProfileId(), expNsd, expNsDf, expNsLvl); } catch (VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsd(e.getMessage()); @@ -90,11 +90,11 @@ public void composeWithStrategy( log.debug("ranVnfProfile: '{}'", ranVnfProfile.getVnfProfileId()); log.debug("ranVnfCpd: '{}'", ranVnfCpd); - // Modify vsbNsd - addVnf(ctxVnfInfo, vsbNsd, vsbNsDf, vsbNsLvl); + // Modify expNsd + addVnf(ctxVnfInfo, expNsd, expNsDf, expNsLvl); log.debug("Added VnfProfile='{}' in service (if not present).", ctxVnfInfo.getVnfProfile().getVnfProfileId()); - addVirtualLink(ctxNonMgmtVl, vsbNsd, vsbNsDf, vsbNsLvl); + addVirtualLink(ctxNonMgmtVl, expNsd, expNsDf, expNsLvl); log.debug("Added VlProfile='{}' in service (if not present).", ctxNonMgmtVl.getVlProfile().getVirtualLinkProfileId()); try { @@ -109,13 +109,13 @@ public void composeWithStrategy( log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", ctxVnfInfo.getVnfProfile().getVnfProfileId(), ranVlInfo.getVlProfile().getVirtualLinkProfileId()); - // Connect ctxVnf to vsbNsd mgmt VL + // Connect ctxVnf to expNsd mgmt VL if (ctxVnfCpds.get("mgmt") != null) { connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxVnfCpds.get("mgmt").getCpdId().get(0), - vsbMgmtVlInfo.getVlProfile()); + expMgmtVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", ctxVnfInfo.getVnfProfile().getVnfProfileId(), - vsbMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); + expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); } else { log.warn("Could not find a management Cp for ctxVnf. Skip."); } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 90745ac..2e4ef1d 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -40,9 +40,9 @@ public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest try { // Assumptions: // - The Vsb has only 1 Nsd. - Nsd vsbNsd = composeRequest.getVsbRequest().getNsds().get(0); + Nsd expNsd = composeRequest.getVsbRequest().getNsds().get(0); NsVirtualLinkDesc ranVld = findRanVld(composeRequest.getVsbRequest().getVsBlueprint(), - vsbNsd); + expNsd); for (CtxComposeInfo ctx : composeRequest.getContexts()) { // - The Ctx has only 1 Nsd. Nsd ctxNsd = ctx.getCtxbRequest().getNsds().get(0); @@ -51,12 +51,12 @@ public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest ctx.setConnectInput(new ConnectInput()); } - NsVirtualLinkDesc vsbMgmtVld = findMgmtVld(ctxB, ctxNsd); + NsVirtualLinkDesc expMgmtVld = findMgmtVld(ctxB, ctxNsd); NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); if (STRAT.equals(CompositionStrategy.CONNECT)) { log.info("connect"); connectComposer - .compose(ctx.getConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + .compose(ctx.getConnectInput(), ranVld, expMgmtVld, expNsd, ctxMgmtVld, ctxNsd); } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)) { log.info("pass_through"); if (ctxNsd.getVnfdId().size() == 1) { @@ -65,7 +65,7 @@ public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); } passThroughComposer - .compose(ctx.getConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + .compose(ctx.getConnectInput(), ranVld, expMgmtVld, expNsd, ctxMgmtVld, ctxNsd); } else { String m = MessageFormatter.format("Composition strategy {} not supported.", STRAT) .getMessage(); From 8774906fe50f4e43141f38d6c65f9e0cb56c5000 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 17 Mar 2020 18:09:58 +0100 Subject: [PATCH 080/187] Rename ContextComposeInfo to simply Context. --- .../it/cnit/blueprint/composer/rest/ComposeRequest.java | 2 +- .../composer/rest/{CtxComposeInfo.java => Context.java} | 2 +- .../blueprint/composer/rest/ExperimentsController.java | 9 +++++---- .../blueprint/composer/rest/InvalidContextException.java | 8 ++++++++ .../blueprint/composer/rest/InvalidCtxComposeInfo.java | 8 -------- 5 files changed, 15 insertions(+), 14 deletions(-) rename src/main/java/it/cnit/blueprint/composer/rest/{CtxComposeInfo.java => Context.java} (90%) create mode 100644 src/main/java/it/cnit/blueprint/composer/rest/InvalidContextException.java delete mode 100644 src/main/java/it/cnit/blueprint/composer/rest/InvalidCtxComposeInfo.java diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java index e80f459..ee44b9c 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java @@ -7,5 +7,5 @@ public class ComposeRequest { private OnBoardVsBlueprintRequest vsbRequest; - private CtxComposeInfo[] contexts; + private Context[] contexts; } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/CtxComposeInfo.java b/src/main/java/it/cnit/blueprint/composer/rest/Context.java similarity index 90% rename from src/main/java/it/cnit/blueprint/composer/rest/CtxComposeInfo.java rename to src/main/java/it/cnit/blueprint/composer/rest/Context.java index e18716c..614671a 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/CtxComposeInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/Context.java @@ -6,7 +6,7 @@ @Data @AllArgsConstructor -public class CtxComposeInfo { +public class Context { private OnboardCtxBlueprintRequest ctxbRequest; private ConnectInput connectInput; diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 2e4ef1d..9c01100 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -35,6 +35,7 @@ public OnboardExpBlueprintRequest retrieveExperiment() { return null; } + // TODO change return object @PostMapping("/experiments") public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest composeRequest) { try { @@ -43,7 +44,7 @@ public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest Nsd expNsd = composeRequest.getVsbRequest().getNsds().get(0); NsVirtualLinkDesc ranVld = findRanVld(composeRequest.getVsbRequest().getVsBlueprint(), expNsd); - for (CtxComposeInfo ctx : composeRequest.getContexts()) { + for (Context ctx : composeRequest.getContexts()) { // - The Ctx has only 1 Nsd. Nsd ctxNsd = ctx.getCtxbRequest().getNsds().get(0); CtxBlueprint ctxB = ctx.getCtxbRequest().getCtxBlueprint(); @@ -62,7 +63,7 @@ public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest if (ctxNsd.getVnfdId().size() == 1) { log.debug("ctxNsd has only one vnfdId."); } else { - throw new InvalidCtxComposeInfo("More than one VNF found in Ctx for PASS_THROUGH"); + throw new InvalidContextException("More than one VNF found in Ctx for PASS_THROUGH"); } passThroughComposer .compose(ctx.getConnectInput(), ranVld, expMgmtVld, expNsd, ctxMgmtVld, ctxNsd); @@ -70,11 +71,11 @@ public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest String m = MessageFormatter.format("Composition strategy {} not supported.", STRAT) .getMessage(); log.error(m); - throw new InvalidCtxComposeInfo(m); + throw new InvalidContextException(m); } } - } catch (InvalidNsd | InvalidCtxComposeInfo e) { + } catch (InvalidNsd | InvalidContextException e) { log.error(e.getMessage()); //TODO create and return a 422 response. } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/InvalidContextException.java b/src/main/java/it/cnit/blueprint/composer/rest/InvalidContextException.java new file mode 100644 index 0000000..2b3d081 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/InvalidContextException.java @@ -0,0 +1,8 @@ +package it.cnit.blueprint.composer.rest; + +public class InvalidContextException extends Exception { + + public InvalidContextException(String message) { + super(message); + } +} diff --git a/src/main/java/it/cnit/blueprint/composer/rest/InvalidCtxComposeInfo.java b/src/main/java/it/cnit/blueprint/composer/rest/InvalidCtxComposeInfo.java deleted file mode 100644 index 0006187..0000000 --- a/src/main/java/it/cnit/blueprint/composer/rest/InvalidCtxComposeInfo.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.composer.rest; - -public class InvalidCtxComposeInfo extends Exception { - - public InvalidCtxComposeInfo(String message) { - super(message); - } -} From c7739e986973b791aefab0d28b62209f977e5126 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 17 Mar 2020 18:11:02 +0100 Subject: [PATCH 081/187] Rename exception to InvalidNsdException. --- .../composer/nsd/compose/ConnectComposer.java | 24 ++++++------- .../composer/nsd/compose/NsdComposer.java | 36 +++++++++---------- .../nsd/compose/PassThroughComposer.java | 16 ++++----- .../composer/nsd/generate/NsdGenerator.java | 6 ++-- .../composer/nsd/graph/NsdGraphService.java | 8 ++--- .../composer/rest/ExperimentsController.java | 6 ++-- .../blueprint/composer/rest/InvalidNsd.java | 8 ----- .../composer/rest/InvalidNsdException.java | 8 +++++ .../composer/rest/ServicesController.java | 2 +- 9 files changed, 57 insertions(+), 57 deletions(-) delete mode 100644 src/main/java/it/cnit/blueprint/composer/rest/InvalidNsd.java create mode 100644 src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index e48cb2b..7143527 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -2,7 +2,7 @@ import it.cnit.blueprint.composer.rest.ConnectInput; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; -import it.cnit.blueprint.composer.rest.InvalidNsd; +import it.cnit.blueprint.composer.rest.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; @@ -34,7 +34,7 @@ public void composeWithStrategy( ConnectInput connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, VlInfo ctxMgmtVlInfo, Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) - throws InvalidNsd { + throws InvalidNsdException { log.info("Compose with CONNECT."); // Retrieve ctx VNFs VnfInfo srcVnfInfo; @@ -50,7 +50,7 @@ public void composeWithStrategy( srcVnfInfo = retrieveVnfInfoByProfileId(srcVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); } catch (NotExistingEntityException | VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } VnfInfo dstVnfInfo; @@ -66,7 +66,7 @@ public void composeWithStrategy( dstVnfInfo = retrieveVnfInfoByProfileId(dstVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); } catch (NotExistingEntityException | VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } // Retrieve Cpds for src VNF @@ -75,7 +75,7 @@ public void composeWithStrategy( srcCpds = getMgmtDataCpds(srcVnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); } catch (Exception e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } // Retrieve Cpds for dst VNF Map dstCpds; @@ -83,7 +83,7 @@ public void composeWithStrategy( dstCpds = getMgmtDataCpds(dstVnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); } catch (Exception e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } // Retrieve src VL @@ -94,7 +94,7 @@ public void composeWithStrategy( expNsLvl); } catch (VlNotFoundInLvlMapping | NotExistingEntityException e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } } else { // Default: select a RAN VL @@ -108,7 +108,7 @@ public void composeWithStrategy( expNsLvl); } catch (VlNotFoundInLvlMapping | NotExistingEntityException e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } } else { // Default: select a non-management VL, different from RAN VL @@ -126,12 +126,12 @@ public void composeWithStrategy( log.debug("Found non-mgmt VlInfo='{}'.", dstVlInfo.getVlProfile().getVirtualLinkProfileId()); } else { - throw new InvalidNsd( + throw new InvalidNsdException( "Can't find a non-mgmt VlInfo in expNsd: '" + expNsd.getNsdIdentifier() + "'"); } - } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + } catch (InvalidNsdException | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } } @@ -181,7 +181,7 @@ public void composeWithStrategy( } } catch (NotExistingEntityException e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 3efc7cf..9ba37b3 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -6,7 +6,7 @@ import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; import it.cnit.blueprint.composer.rest.ConnectInput; -import it.cnit.blueprint.composer.rest.InvalidNsd; +import it.cnit.blueprint.composer.rest.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; @@ -197,7 +197,7 @@ protected void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel protected VnfInfo retrieveVnfInfoByProfileId(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) - throws InvalidNsd, VnfNotFoundInLvlMapping { + throws InvalidNsdException, VnfNotFoundInLvlMapping { VnfToLevelMapping vnfLvlMap; try { vnfLvlMap = getVnfLvlMapping(vnfProfileId, nsLevel); @@ -208,7 +208,7 @@ protected VnfInfo retrieveVnfInfoByProfileId(String vnfProfileId, Nsd nsd, NsDf try { vnfProfile = getVnfProfileById(vnfProfileId, nsDf); } catch (NotExistingEntityException e) { - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } Optional optVnfdId = nsd.getVnfdId().stream() .filter(id -> id.equals(vnfProfile.getVnfdId())).findFirst(); @@ -217,13 +217,13 @@ protected VnfInfo retrieveVnfInfoByProfileId(String vnfProfileId, Nsd nsd, NsDf .format("vnfdId='{}' not found in nsd='{}'.", vnfProfile.getVnfdId(), nsd.getNsdIdentifier()) .getMessage(); - throw new InvalidNsd(m); + throw new InvalidNsdException(m); } return new VnfInfo(vnfProfile.getVnfdId(), vnfProfile, vnfLvlMap); } protected VlInfo retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) - throws InvalidNsd, VlNotFoundInLvlMapping { + throws InvalidNsdException, VlNotFoundInLvlMapping { VirtualLinkToLevelMapping vlMap; try { vlMap = getVlLvlMapping(vlProfileId, nsLevel); @@ -234,24 +234,24 @@ protected VlInfo retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel try { vlProfile = getVlProfile(vlProfileId, nsDf); } catch (NotExistingEntityException e) { - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } NsVirtualLinkDesc vlDesc; try { vlDesc = getVlDescriptor(vlProfile.getVirtualLinkDescId(), nsd); } catch (NotExistingEntityException e) { - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } return new VlInfo(vlMap, vlProfile, vlDesc); } protected VlInfo retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLevel) - throws InvalidNsd, VlNotFoundInLvlMapping { + throws InvalidNsdException, VlNotFoundInLvlMapping { VirtualLinkProfile vlProfile; try { vlProfile = getVlProfile(vld, nsDf); } catch (NotExistingEntityException e) { - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } VirtualLinkToLevelMapping vlMap; try { @@ -279,7 +279,7 @@ protected void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile protected Map getMgmtDataCpds(VnfInfo vnfInfo, VlInfo expMgmtVlinfo, VlInfo ctxMgmtVlInfo) - throws InvalidNsd { + throws InvalidNsdException { Map cpdIdMap = new HashMap<>(); int dataCount = 0; for (NsVirtualLinkConnectivity vlc : vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity()) { @@ -299,19 +299,19 @@ protected Map getMgmtDataCpds(VnfInfo vnfInfo Optional dataKey = cpdIdMap.keySet().stream().filter(k -> k.startsWith("data")) .findFirst(); if (!dataKey.isPresent()) { - throw new InvalidNsd( + throw new InvalidNsdException( "No data cpd found for vnfProfile: '" + vnfInfo.getVnfProfile().getVnfProfileId() + "'."); } return cpdIdMap; } - public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws InvalidNsd { + public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws InvalidNsdException { NsVirtualLinkDesc ranVld; try { ranVld = getVlDescriptor(ranSapd.getNsVirtualLinkDescId(), expNsd); } catch (NotExistingEntityException e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } return ranVld; } @@ -319,7 +319,7 @@ public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws InvalidNs @SneakyThrows(JsonProcessingException.class) public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, NsVirtualLinkDesc expMgmtVld, Nsd expNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) - throws InvalidNsd { + throws InvalidNsdException { // We assume only one NsDf for the context NsDf ctxNsDf = ctxNsd.getNsDf().get(0); // We assume only one NsLevel for the context @@ -354,9 +354,9 @@ public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, ctxMgmtVlInfo = retrieveVlInfo(ctxMgmtVld, ctxNsDf, ctxNsLvl); log.debug("Found VlInfo for ctxMgmtVld='{}' in ctxNsd.", ctxMgmtVld.getVirtualLinkDescId()); - } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + } catch (InvalidNsdException | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } composeWithStrategy(connectInput, ranVlInfo, expMgmtVlInfo, ctxMgmtVlInfo, expNsd, expNsDf, expNsLvl, @@ -368,7 +368,7 @@ public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, } catch (MalformattedElementException e) { String m = "Nsd looks not valid after composition"; log.error(m, e); - throw new InvalidNsd(m); + throw new InvalidNsdException(m); } expG = nsdGraphService.buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("Graph AFTER composition with {}:\n{}", @@ -388,6 +388,6 @@ public abstract void composeWithStrategy( ConnectInput connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, VlInfo ctxMgmtVlInfo, Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl - ) throws InvalidNsd; + ) throws InvalidNsdException; } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index 4db6537..f51c779 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -2,7 +2,7 @@ import it.cnit.blueprint.composer.rest.ConnectInput; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; -import it.cnit.blueprint.composer.rest.InvalidNsd; +import it.cnit.blueprint.composer.rest.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; @@ -34,7 +34,7 @@ public void composeWithStrategy( ConnectInput connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, VlInfo ctxMgmtVlInfo, Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) - throws InvalidNsd { + throws InvalidNsdException { log.info("Compose with PASS_THROUGH."); // Retrieve ctx VNF String ctxVnfpId = ctxNsLvl.getVnfToLevelMapping().get(0).getVnfProfileId(); @@ -44,7 +44,7 @@ public void composeWithStrategy( log.debug("Found VnfInfo for vnfpId='{}' in context.", ctxVnfpId); } catch (VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } // Retrieve non-management VLs from ctx @@ -55,9 +55,9 @@ public void composeWithStrategy( ctxVnfCpds = getMgmtDataCpds(ctxVnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); ctxNonMgmtVl = retrieveVlInfo(ctxVnfCpds.get("data0").getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); - } catch (InvalidNsd | VlNotFoundInLvlMapping e) { + } catch (InvalidNsdException | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } // Retrieve RAN closest VNF information from exp @@ -71,7 +71,7 @@ public void composeWithStrategy( vnfInfo = retrieveVnfInfoByProfileId(vnfLvl.getVnfProfileId(), expNsd, expNsDf, expNsLvl); } catch (VnfNotFoundInLvlMapping e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } for (NsVirtualLinkConnectivity vlc : vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity()) { if (vlc.getVirtualLinkProfileId() @@ -85,7 +85,7 @@ public void composeWithStrategy( if (ranVnfCpd == null) { String m = "Can't find a VNF close to ranVlInfo"; log.error(m); - throw new InvalidNsd(m); + throw new InvalidNsdException(m); } log.debug("ranVnfProfile: '{}'", ranVnfProfile.getVnfProfileId()); log.debug("ranVnfCpd: '{}'", ranVnfCpd); @@ -128,7 +128,7 @@ public void composeWithStrategy( } } catch (NotExistingEntityException e) { log.error(e.getMessage()); - throw new InvalidNsd(e.getMessage()); + throw new InvalidNsdException(e.getMessage()); } } } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index 6095fda..6e101f0 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; -import it.cnit.blueprint.composer.rest.InvalidNsd; +import it.cnit.blueprint.composer.rest.InvalidNsdException; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsComponent; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; @@ -55,7 +55,7 @@ public class NsdGenerator { private NsdGraphService nsdGraphService; @SneakyThrows(JsonProcessingException.class) - public Nsd generate(VsBlueprint vsb) throws InvalidNsd { + public Nsd generate(VsBlueprint vsb) throws InvalidNsdException { log.debug(OBJECT_MAPPER.writeValueAsString(vsb)); @@ -188,7 +188,7 @@ public Nsd generate(VsBlueprint vsb) throws InvalidNsd { } catch (MalformattedElementException e) { String m = "Nsd looks not valid after composition"; log.error(m, e); - throw new InvalidNsd(m); + throw new InvalidNsdException(m); } log.debug("Nsd AFTER generation with {}:\n{}", nsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(nsd)); diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java index 94a01e3..ef21b1f 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java @@ -1,6 +1,6 @@ package it.cnit.blueprint.composer.nsd.graph; -import it.cnit.blueprint.composer.rest.InvalidNsd; +import it.cnit.blueprint.composer.rest.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; @@ -29,7 +29,7 @@ public class NsdGraphService { private GraphExporter graphExporter; public Graph buildGraph(List sapdList, NsDf nsDf, NsLevel nsLevel) - throws InvalidNsd { + throws InvalidNsdException { Graph g = new SimpleGraph<>(String.class); List vnfPVertices = new ArrayList<>(); List pnfPVertices = new ArrayList<>(); @@ -48,7 +48,7 @@ public Graph buildGraph(List sapdList, NsDf nsDf, N new String[]{vnfToLevelMapping.getVnfProfileId(), nsDf.getNsDfId(), nsLevel.getNsLevelId()}).getMessage(); log.error(message); - throw new InvalidNsd(message); + throw new InvalidNsdException(message); } // TODO handle the number of instances to build the graph vnfPVertices.add(v); @@ -70,7 +70,7 @@ public Graph buildGraph(List sapdList, NsDf nsDf, N new String[]{vlToLevelMapping.getVirtualLinkProfileId(), nsDf.getNsDfId(), nsLevel.getNsLevelId()}).getMessage(); log.error(message); - throw new InvalidNsd(message); + throw new InvalidNsdException(message); } vlPVertices.add(v); g.addVertex(v); diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 9c01100..118845b 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -75,14 +75,14 @@ public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest } } - } catch (InvalidNsd | InvalidContextException e) { + } catch (InvalidNsdException | InvalidContextException e) { log.error(e.getMessage()); //TODO create and return a 422 response. } return new OnboardExpBlueprintRequest(); } - private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsd { + private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsdException { Sapd ranSapd = null; for (VsbEndpoint e : b.getEndPoints()) { if (e.isRanConnection()) { @@ -96,7 +96,7 @@ private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsd { } if (ranSapd == null) { // TODO think of a better message - throw new InvalidNsd("Cannot find a Sap descriptor for RAN."); + throw new InvalidNsdException("Cannot find a Sap descriptor for RAN."); } return connectComposer.getRanVlDesc(ranSapd, nsd); } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsd.java b/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsd.java deleted file mode 100644 index 09f06ae..0000000 --- a/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsd.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.composer.rest; - -public class InvalidNsd extends Exception { - - public InvalidNsd(String message) { - super(message); - } -} diff --git a/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java b/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java new file mode 100644 index 0000000..6815ef8 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java @@ -0,0 +1,8 @@ +package it.cnit.blueprint.composer.rest; + +public class InvalidNsdException extends Exception { + + public InvalidNsdException(String message) { + super(message); + } +} diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java index e7cf404..79f3338 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java @@ -25,7 +25,7 @@ public Nsd generateService(@RequestBody VsBlueprint vsb) { Nsd nsd; try { nsd = nsdGenerator.generate(vsb); - } catch (InvalidNsd e) { + } catch (InvalidNsdException e) { //TODO handle exception nsd = null; e.printStackTrace(); From 623219d4ee2fad1488f97ddbce915adc195bd894 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 17 Mar 2020 18:24:44 +0100 Subject: [PATCH 082/187] Change response to REST method. First draft for translation rules. --- .../blueprint/composer/rest/ComposeResponse.java | 15 +++++++++++++++ .../composer/rest/ExperimentsController.java | 15 +++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java new file mode 100644 index 0000000..eb0a21d --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java @@ -0,0 +1,15 @@ +package it.cnit.blueprint.composer.rest; + +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class ComposeResponse { + + private Nsd expNsd; + private List translationRules; +} diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 118845b..e7db470 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -4,10 +4,12 @@ import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardExpBlueprintRequest; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; +import java.util.List; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.slf4j.helpers.MessageFormatter; @@ -35,13 +37,12 @@ public OnboardExpBlueprintRequest retrieveExperiment() { return null; } - // TODO change return object @PostMapping("/experiments") - public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest composeRequest) { + public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequest) { + Nsd expNsd = composeRequest.getVsbRequest().getNsds().get(0); try { // Assumptions: // - The Vsb has only 1 Nsd. - Nsd expNsd = composeRequest.getVsbRequest().getNsds().get(0); NsVirtualLinkDesc ranVld = findRanVld(composeRequest.getVsbRequest().getVsBlueprint(), expNsd); for (Context ctx : composeRequest.getContexts()) { @@ -79,7 +80,13 @@ public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest log.error(e.getMessage()); //TODO create and return a 422 response. } - return new OnboardExpBlueprintRequest(); + + List translationRules = composeRequest.getVsbRequest() + .getTranslationRules(); + for (VsdNsdTranslationRule tr : translationRules) { + tr.setNsdInfoId(expNsd.getNsdIdentifier()); + } + return new ComposeResponse(expNsd, translationRules); } private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsdException { From e8e0e3738f4b8ef18157819a1f02664b365df0f2 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 17 Mar 2020 18:55:29 +0100 Subject: [PATCH 083/187] Refactor, add exception. --- .../composer/rest/ExperimentsController.java | 15 +++++-- .../InvalidTranslationRuleException.java | 8 ++++ .../rules/TranslationRulesComposer.java | 45 +++++++++++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/composer/rules/InvalidTranslationRuleException.java create mode 100644 src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index e7db470..942115f 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -1,6 +1,8 @@ package it.cnit.blueprint.composer.rest; import it.cnit.blueprint.composer.nsd.compose.NsdComposer; +import it.cnit.blueprint.composer.rules.InvalidTranslationRuleException; +import it.cnit.blueprint.composer.rules.TranslationRulesComposer; import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; @@ -32,6 +34,8 @@ public class ExperimentsController { @Qualifier("CONNECT") private NsdComposer connectComposer; + private TranslationRulesComposer translationRulesComposer; + @GetMapping("/experiments") public OnboardExpBlueprintRequest retrieveExperiment() { return null; @@ -81,10 +85,13 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ //TODO create and return a 422 response. } - List translationRules = composeRequest.getVsbRequest() - .getTranslationRules(); - for (VsdNsdTranslationRule tr : translationRules) { - tr.setNsdInfoId(expNsd.getNsdIdentifier()); + List translationRules = null; + try { + translationRules = translationRulesComposer + .compose(expNsd, composeRequest.getVsbRequest().getTranslationRules()); + } catch (InvalidTranslationRuleException e) { + // TODO create proper error response. + e.printStackTrace(); } return new ComposeResponse(expNsd, translationRules); } diff --git a/src/main/java/it/cnit/blueprint/composer/rules/InvalidTranslationRuleException.java b/src/main/java/it/cnit/blueprint/composer/rules/InvalidTranslationRuleException.java new file mode 100644 index 0000000..38ee5a3 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rules/InvalidTranslationRuleException.java @@ -0,0 +1,8 @@ +package it.cnit.blueprint.composer.rules; + +public class InvalidTranslationRuleException extends Exception { + + public InvalidTranslationRuleException(String message) { + super(message); + } +} diff --git a/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java new file mode 100644 index 0000000..9cf5b73 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java @@ -0,0 +1,45 @@ +package it.cnit.blueprint.composer.rules; + +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.helpers.MessageFormatter; + +@Slf4j +@AllArgsConstructor +public class TranslationRulesComposer { + + public List compose(Nsd expNsd, + List translationRules) throws InvalidTranslationRuleException { + log.info("Compose and check translation rules for expNsd: '{}'", expNsd.getNsdIdentifier()); + List newTranslationRules = new ArrayList<>(); + for (VsdNsdTranslationRule tr : translationRules) { + Optional optNsDf = expNsd.getNsDf().stream() + .filter(nsDf -> nsDf.getNsDfId().equals(tr.getNsFlavourId())).findFirst(); + if (optNsDf.isPresent()) { + boolean isNsLevelFound = optNsDf.get().getNsInstantiationLevel().stream() + .anyMatch(nsLevel -> nsLevel.getNsLevelId().equals(tr.getNsInstantiationLevelId())); + if (!isNsLevelFound) { + String m = MessageFormatter.format("Invalid translation rule. NsLevel='{}' not found", + tr.getNsInstantiationLevelId()).getMessage(); + log.error(m); + throw new InvalidTranslationRuleException(m); + } + } else { + String m = MessageFormatter.format("Invalid translation rule. NsDf='{}' not found", + tr.getNsFlavourId()).getMessage(); + log.error(m); + throw new InvalidTranslationRuleException(m); + } + newTranslationRules.add(new VsdNsdTranslationRule(tr.getInput(), expNsd.getNsdIdentifier(), + expNsd.getVersion(), tr.getNsFlavourId(), tr.getNsInstantiationLevelId())); + } + return newTranslationRules; + } + +} From 260e3082df942037a20a573032bedbe97afa6751 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 18 Mar 2020 11:46:19 +0100 Subject: [PATCH 084/187] Add check on graph connectivity. --- .../composer/nsd/compose/NsdComposer.java | 16 +++++++++++++++- .../composer/nsd/graph/NsdGraphService.java | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 9ba37b3..e0fded4 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -334,13 +334,20 @@ public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, log.debug("Nsd BEFORE composition:\n{}", OBJECT_MAPPER.writeValueAsString(expNsd)); expNsd.setNsdName(expNsd.getNsdName() + " + " + ctxNsd.getNsdName()); - for (NsDf expNsDf: expNsd.getNsDf()) { + for (NsDf expNsDf : expNsd.getNsDf()) { for (NsLevel expNsLvl : expNsDf.getNsInstantiationLevel()) { log.info("Start composition for nsDf='{}' and nsLvl='{}'", expNsDf.getNsDfId(), expNsLvl.getNsLevelId()); Graph expG = nsdGraphService .buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("expG BEFORE composition :\n{}", nsdGraphService.export(expG)); + if (!nsdGraphService.isConnected(expG)) { + String m = MessageFormatter.format( + "Network topology for NsLevel='{}' is not connected", expNsLvl.getNsLevelId()) + .getMessage(); + log.error(m); + throw new InvalidNsdException(m); + } VlInfo ranVlInfo; VlInfo expMgmtVlInfo; @@ -373,6 +380,13 @@ public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, expG = nsdGraphService.buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("Graph AFTER composition with {}:\n{}", ctxNsd.getNsdIdentifier(), nsdGraphService.export(expG)); + if (!nsdGraphService.isConnected(expG)) { + String m = MessageFormatter.format("Network topology not connected after composition", + expNsDf.getNsDfId(), expNsLvl.getNsLevelId()) + .getMessage(); + log.error(m); + throw new InvalidNsdException(m); + } log.info("Completed composition for nsDf='{}' and nsLvl='{}'", expNsDf.getNsDfId(), expNsLvl.getNsLevelId()); } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java index ef21b1f..da37b72 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java @@ -16,6 +16,7 @@ import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.jgrapht.Graph; +import org.jgrapht.alg.connectivity.ConnectivityInspector; import org.jgrapht.graph.SimpleGraph; import org.slf4j.helpers.MessageFormatter; import org.springframework.stereotype.Service; @@ -132,6 +133,10 @@ public ProfileVertex getVertexById(Graph g, String vertex } } - // TODO implement constraint on coloring: no VL and Vnf directly connected. + @SuppressWarnings("BooleanMethodIsAlwaysInverted") + public boolean isConnected(Graph g){ + ConnectivityInspector inspector = new ConnectivityInspector<>(g); + return inspector.isConnected(); + } } From 8b78b138ba36343eb59288e0d04ab04533c5c87f Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 23 Mar 2020 16:44:32 +0100 Subject: [PATCH 085/187] Make the generate method take a generic blueprint as input. --- .../composer/nsd/generate/NsdGenerator.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index 6e101f0..504c1c7 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -6,7 +6,7 @@ import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; import it.cnit.blueprint.composer.rest.InvalidNsdException; -import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsComponent; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbLink; @@ -55,16 +55,16 @@ public class NsdGenerator { private NsdGraphService nsdGraphService; @SneakyThrows(JsonProcessingException.class) - public Nsd generate(VsBlueprint vsb) throws InvalidNsdException { + public Nsd generate(Blueprint blueprint) throws InvalidNsdException { - log.debug(OBJECT_MAPPER.writeValueAsString(vsb)); + log.debug(OBJECT_MAPPER.writeValueAsString(blueprint)); Nsd nsd = new Nsd(); - nsd.setNsdIdentifier(vsb.getBlueprintId() + "_nsd"); + nsd.setNsdIdentifier(blueprint.getBlueprintId() + "_nsd"); nsd.setDesigner("NSD generator"); - nsd.setNsdInvariantId(vsb.getBlueprintId() + "_nsd"); - nsd.setVersion(vsb.getVersion()); - nsd.setNsdName(vsb.getName() + "_nsd"); + nsd.setNsdInvariantId(blueprint.getBlueprintId() + "_nsd"); + nsd.setVersion(blueprint.getVersion()); + nsd.setNsdName(blueprint.getName() + "_nsd"); nsd.setSecurity(new SecurityParameters( "FC_NSD_SIGNATURE", "FC_NSD_ALGORITHM", @@ -72,15 +72,15 @@ public Nsd generate(VsBlueprint vsb) throws InvalidNsdException { )); NsDf nsDf = new NsDf(); - nsDf.setNsDfId(vsb.getBlueprintId() + "_df"); - nsDf.setFlavourKey(vsb.getBlueprintId() + "_df_fk"); + nsDf.setNsDfId(blueprint.getBlueprintId() + "_df"); + nsDf.setFlavourKey(blueprint.getBlueprintId() + "_df_fk"); NsLevel nsLevel = new NsLevel(); - nsLevel.setNsLevelId(vsb.getBlueprintId() + "_il_default"); + nsLevel.setNsLevelId(blueprint.getBlueprintId() + "_il_default"); nsLevel.setDescription("Default Instantiation Level"); int vldCount = 0; - for (VsbLink connService : vsb.getConnectivityServices()) { + for (VsbLink connService : blueprint.getConnectivityServices()) { NsVirtualLinkDesc vld = new NsVirtualLinkDesc(); // TODO vld.setVirtualLinkDescId(connService.getName()); vld.setVirtualLinkDescId("vld_" + vldCount); @@ -111,7 +111,7 @@ public Nsd generate(VsBlueprint vsb) throws InvalidNsdException { } List sapdList = new ArrayList<>(); - for (VsbEndpoint e : vsb.getEndPoints()) { + for (VsbEndpoint e : blueprint.getEndPoints()) { if (e.isExternal() && e.getEndPointId().contains("sap")) { Sapd sapd = new Sapd(); sapd.setCpdId(e.getEndPointId()); @@ -120,7 +120,7 @@ public Nsd generate(VsBlueprint vsb) throws InvalidNsdException { sapd.setCpRole(CpRole.ROOT); // TODO meaning of this? sapd.setSapAddressAssignment(false); int count = 0; - for (VsbLink cs : vsb.getConnectivityServices()) { + for (VsbLink cs : blueprint.getConnectivityServices()) { for (String ep : cs.getEndPointIds()) { if (ep.equals(sapd.getCpdId())) { // TODO change this when connectivity service has a name @@ -143,7 +143,7 @@ public Nsd generate(VsBlueprint vsb) throws InvalidNsdException { } nsd.setSapd(sapdList); - for (VsComponent vsc : vsb.getAtomicComponents()) { + for (VsComponent vsc : blueprint.getAtomicComponents()) { nsd.getVnfdId().add(vsc.getComponentId()); VnfProfile vnfp = new VnfProfile(); vnfp.setVnfProfileId(vsc.getComponentId() + "_vnfp"); @@ -155,7 +155,7 @@ public Nsd generate(VsBlueprint vsb) throws InvalidNsdException { List nsVirtualLinkConnectivities = new ArrayList<>(); for (String ep : vsc.getEndPointsIds()) { int count = 0; - for (VsbLink cs : vsb.getConnectivityServices()) { + for (VsbLink cs : blueprint.getConnectivityServices()) { for (String csEp : cs.getEndPointIds()) { if (csEp.equals(ep)) { NsVirtualLinkConnectivity nsVLC = new NsVirtualLinkConnectivity(); From 2411f503154a76faefcab2b063d704ad25ec5722 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 23 Mar 2020 16:59:51 +0100 Subject: [PATCH 086/187] Add Test for generating Nsd from CtxB. --- .../nsd/generate/NsdGeneratorTest.java | 24 ++++++++++++++++++- src/test/resources/url.properties | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java index aad6677..177d410 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java @@ -1,11 +1,14 @@ package it.cnit.blueprint.composer.nsd.generate; +import static org.junit.Assert.assertEquals; + import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.composer.nsd.graph.GraphVizExporter; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; +import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import java.io.InputStream; @@ -16,6 +19,7 @@ import org.junit.Test; import org.slf4j.LoggerFactory; + public class NsdGeneratorTest { static Properties urlProp; @@ -65,6 +69,24 @@ public void generateV360() { //Then //TODO - + + } + + @Test + @SneakyThrows + public void generateBgTrafficCtxB() { + + // Given + CtxBlueprint ctxB = oM + .readValue(new URL(urlProp.getProperty("ctx.bg_traffic")), CtxBlueprint.class); + + //When + Nsd actual = nsdGenerator.generate(ctxB); + + //Then + Nsd expected = oM + .readValue(new URL(urlProp.getProperty("ctx.bg_traffic.nsds")), Nsd[].class)[0]; + assertEquals(oM.writeValueAsString(expected), oM.writeValueAsString(actual)); + } } \ No newline at end of file diff --git a/src/test/resources/url.properties b/src/test/resources/url.properties index c69bad6..b3754d3 100644 --- a/src/test/resources/url.properties +++ b/src/test/resources/url.properties @@ -1,6 +1,8 @@ vsb.tracker=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker.yaml vsb.tracker.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker_nsds.yaml ctx.delay.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay_nsds.yaml +ctx.bg_traffic=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic.yaml +ctx.bg_traffic.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic_nsds.yaml expb.tracker.delay.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/expb/expb_ares2t_tracker_delay/expb_ares2t_tracker_delay_nsds.yaml vsb.v360=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_orange_v360/vsb_V360.yml From 768d84894cc7c037d871baa0f339379222b1abdd Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 23 Mar 2020 17:16:49 +0100 Subject: [PATCH 087/187] Add test for composition with bg_traffic. --- .../composer/nsd/compose/NsdComposerTest.java | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java index e5d71f7..e17579a 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -45,7 +45,7 @@ public static void setUp() { passThroughComposer = new PassThroughComposer(nsdGraphService); connectComposer = new ConnectComposer(nsdGraphService); Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - root.setLevel(Level.INFO); + root.setLevel(Level.DEBUG); } @Test @@ -158,4 +158,52 @@ public void composeTrackerWithDelayConnect() { Nsd expNsd = oM.readValue(in, Nsd[].class)[0]; assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); } + + @Test + @SneakyThrows + public void composeTrackerWithBackgroundConnect() { + // Given + Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + NsVirtualLinkDesc ranVld; + Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) + .findFirst(); + if (optRanVl.isPresent()) { + ranVld = optRanVl.get(); + } else { + throw new Exception(); + } + NsVirtualLinkDesc vsbMgmtVld; + Optional optVsbVld = vsbNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgt")).findFirst(); + if (optVsbVld.isPresent()) { + vsbMgmtVld = optVsbVld.get(); + } else { + throw new Exception(); + } + Nsd ctxNsd = Arrays + .asList(oM.readValue(new URL(urlProp.getProperty("ctx.bg_traffic.nsds")), Nsd[].class)) + .get(0); + NsVirtualLinkDesc ctxMgmtVld; + Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vld_1")).findFirst(); + if (optCtxVld.isPresent()) { + ctxMgmtVld = optCtxVld.get(); + } else { + throw new Exception(); + } + + // When + connectComposer.compose(new ConnectInput(), ranVld,vsbMgmtVld,vsbNsd,ctxMgmtVld,ctxNsd); + // Setting ID manually for test purpose + vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); + vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); + + // Then +// InputStream in = getClass().getResourceAsStream( +// "/expb_ares2t_tracker_bg_nsds_connect.yaml"); +// Nsd expNsd = oM.readValue(in, Nsd[].class)[0]; +// assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); + + } } \ No newline at end of file From c47907d581994862223a2c4cf309329325624e89 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 23 Mar 2020 17:28:33 +0100 Subject: [PATCH 088/187] Complete test for composition with bg_traffic. --- .../composer/nsd/compose/NsdComposerTest.java | 12 +- ...res2t_tracker_bg_traffic_nsds_connect.yaml | 243 ++++++++++++++++++ 2 files changed, 249 insertions(+), 6 deletions(-) create mode 100644 src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java index e17579a..d56079e 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -196,14 +196,14 @@ public void composeTrackerWithBackgroundConnect() { // When connectComposer.compose(new ConnectInput(), ranVld,vsbMgmtVld,vsbNsd,ctxMgmtVld,ctxNsd); // Setting ID manually for test purpose - vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); - vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); + vsbNsd.setNsdIdentifier("2dd7b5b1-9f39-4978-a035-6654d7bc9068"); + vsbNsd.setNsdInvariantId("d5959420-1ef7-4441-9eb9-9113172c988b"); // Then -// InputStream in = getClass().getResourceAsStream( -// "/expb_ares2t_tracker_bg_nsds_connect.yaml"); -// Nsd expNsd = oM.readValue(in, Nsd[].class)[0]; -// assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); + InputStream in = getClass().getResourceAsStream( + "/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml"); + Nsd expNsd = oM.readValue(in, Nsd[].class)[0]; + assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); } } \ No newline at end of file diff --git a/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml b/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml new file mode 100644 index 0000000..66f5111 --- /dev/null +++ b/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml @@ -0,0 +1,243 @@ +# expb_ares2t_tracker_nsds.yaml +--- +- nsdIdentifier: "2dd7b5b1-9f39-4978-a035-6654d7bc9068" + designer: "NXW" + version: "1.0" + nsdName: "ARES2T Tracker Service @ 5GEVE + Context Blueprint Background Traffic_nsd" + nsdInvariantId: "d5959420-1ef7-4441-9eb9-9113172c988b" + vnfdId: + - "c84b227e-520e-43c0-a75e-e52781dd54dd" + - "419b1884-aea1-4cad-8647-c2cec55287b9" + - "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" + - "bg_traffic_src" + - "bg_traffic_dst" + sapd: + - cpdId: "sap_tracking_mobile" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP towards mobile equipment" + addressData: + - addressType: "IP_ADDRESS" + iPAddressAssignment: false + floatingIpActivated: true + management: false + iPAddressType: "IPv4" + numberOfIpAddress: 1 + sapAddressAssignment: false + nsVirtualLinkDescId: "vl_tracking_mobile" + - cpdId: "sap_tracking_mgt" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP for management" + addressData: + - addressType: "IP_ADDRESS" + iPAddressAssignment: false + floatingIpActivated: false + management: false + iPAddressType: "IPv4" + numberOfIpAddress: 1 + sapAddressAssignment: false + nsVirtualLinkDescId: "vl_tracking_mgt" + virtualLinkDesc: + - virtualLinkDescId: "vl_tracking_mobile" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_mobile" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Network to connect to the mobile user equipment" + - virtualLinkDescId: "vl_tracking_mgt" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_mgt" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Management network" + - virtualLinkDescId: "vl_tracking_data" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_data" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Internal network to connect the tracking service components" + nsDf: + - nsDfId: "ns_Ares2T_Tracking_df" + flavourKey: "ns_Ares2T_Tracking_df_fk" + vnfProfile: + - vnfProfileId: "vnfp_small_Ares2T_Tracker" + vnfdId: "419b1884-aea1-4cad-8647-c2cec55287b9" + flavourId: "vnf_df_Ares2T_Tracker" + instantiationLevel: "vnf_il_Ares2T_Tracker" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + cpdId: + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_tracker_mgt" + - vnfProfileId: "vnfp_big_Ares2T_Tracker" + vnfdId: "c84b227e-520e-43c0-a75e-e52781dd54dd" + flavourId: "vnf_df_Ares2T_Tracker" + instantiationLevel: "vnf_il_Ares2T_Tracker" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + cpdId: + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_tracker_mgt" + - vnfProfileId: "vnfp_Ares2T_Vis" + vnfdId: "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" + flavourId: "vnf_df_Ares2T_Vis" + instantiationLevel: "vnf_il_Ares2T_Vis" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_vis_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_vis_mgt" + - vnfProfileId: "bg_traffic_src_vnfp" + vnfdId: "bg_traffic_src" + flavourId: "bg_traffic_src_vnf_df" + instantiationLevel: "bg_traffic_src_vnf_il" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + cpdId: + - "cp_bg_src_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_bg_src_mgmt" + - vnfProfileId: "bg_traffic_dst_vnfp" + vnfdId: "bg_traffic_dst" + flavourId: "bg_traffic_dst_vnf_df" + instantiationLevel: "bg_traffic_dst_vnf_il" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_bg_dst_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_bg_dst_mgmt" + virtualLinkProfile: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + virtualLinkDescId: "vl_tracking_mobile" + flavourId: "df_vl_tracking_mobile" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" + virtualLinkDescId: "vl_tracking_data" + flavourId: "df_vl_tracking_data" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + virtualLinkDescId: "vl_tracking_mgt" + flavourId: "df_vl_tracking_mgt" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + nsInstantiationLevel: + - nsLevelId: "ns_ares2t_tracker_il_big" + description: "Big instantiation level for the ARES2T tracking service" + vnfToLevelMapping: + - vnfProfileId: "vnfp_big_Ares2T_Tracker" + numberOfInstances: 1 + - vnfProfileId: "vnfp_Ares2T_Vis" + numberOfInstances: 1 + - vnfProfileId: "bg_traffic_src_vnfp" + numberOfInstances: 1 + - vnfProfileId: "bg_traffic_dst_vnfp" + numberOfInstances: 1 + virtualLinkToLevelMapping: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + bitRateRequirements: + root: "1" + leaf: "1" + - nsLevelId: "ns_ares2t_tracker_il_small" + description: "Small instantiation level for the ARES2T tracking service" + vnfToLevelMapping: + - vnfProfileId: "vnfp_small_Ares2T_Tracker" + numberOfInstances: 1 + - vnfProfileId: "vnfp_Ares2T_Vis" + numberOfInstances: 1 + - vnfProfileId: "bg_traffic_src_vnfp" + numberOfInstances: 1 + - vnfProfileId: "bg_traffic_dst_vnfp" + numberOfInstances: 1 + virtualLinkToLevelMapping: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + bitRateRequirements: + root: "1" + leaf: "1" + defaultNsInstantiationLevelId: "ns_ares2t_tracker_il_small" + security: + signature: "FC_NSD_SIGNATURE" + algorithm: "FC_NSD_ALGORITHM" + certificate: "FC_NSD_CERTIFICATE" From ab52d85719e81f3a190f03b797861d0caf438721 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 23 Mar 2020 17:29:43 +0100 Subject: [PATCH 089/187] Remove Logger configuration from tests. DEBUG level as default. --- .../blueprint/composer/nsd/compose/NsdComposerTest.java | 7 +------ .../blueprint/composer/nsd/generate/NsdGeneratorTest.java | 5 ----- .../blueprint/composer/nsd/graph/NsdGraphServiceTest.java | 5 ----- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java index d56079e..638095c 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -2,8 +2,6 @@ import static org.junit.Assert.assertEquals; -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.composer.nsd.graph.GraphVizExporter; @@ -23,7 +21,6 @@ import lombok.SneakyThrows; import org.junit.BeforeClass; import org.junit.Test; -import org.slf4j.LoggerFactory; public class NsdComposerTest { @@ -44,8 +41,6 @@ public static void setUp() { nsdGraphService = new NsdGraphService(new GraphVizExporter()); passThroughComposer = new PassThroughComposer(nsdGraphService); connectComposer = new ConnectComposer(nsdGraphService); - Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - root.setLevel(Level.DEBUG); } @Test @@ -194,7 +189,7 @@ public void composeTrackerWithBackgroundConnect() { } // When - connectComposer.compose(new ConnectInput(), ranVld,vsbMgmtVld,vsbNsd,ctxMgmtVld,ctxNsd); + connectComposer.compose(new ConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("2dd7b5b1-9f39-4978-a035-6654d7bc9068"); vsbNsd.setNsdInvariantId("d5959420-1ef7-4441-9eb9-9113172c988b"); diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java index 177d410..d2ca829 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java @@ -2,8 +2,6 @@ import static org.junit.Assert.assertEquals; -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.composer.nsd.graph.GraphVizExporter; @@ -17,7 +15,6 @@ import lombok.SneakyThrows; import org.junit.BeforeClass; import org.junit.Test; -import org.slf4j.LoggerFactory; public class NsdGeneratorTest { @@ -37,8 +34,6 @@ public static void setUp() { oM = new ObjectMapper(new YAMLFactory()); nsdGraphService = new NsdGraphService(new GraphVizExporter()); nsdGenerator = new NsdGenerator(nsdGraphService); - Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - root.setLevel(Level.DEBUG); } diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java index c6c8b64..df4fda4 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java @@ -2,8 +2,6 @@ import static org.junit.Assert.assertEquals; -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; @@ -15,7 +13,6 @@ import lombok.SneakyThrows; import org.junit.BeforeClass; import org.junit.Test; -import org.slf4j.LoggerFactory; public class NsdGraphServiceTest { @@ -32,8 +29,6 @@ public static void setUp() { prop.load(input); oM = new ObjectMapper(new YAMLFactory()); nsdGraphService = new NsdGraphService(new GraphVizExporter()); - Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - root.setLevel(Level.ERROR); } @Test From 8e404be0331b4c553278d47bd2c3322590938c25 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 23 Mar 2020 18:07:37 +0100 Subject: [PATCH 090/187] Add test to compose tracker Nsd with delay AND bg traffic. --- .../composer/nsd/compose/NsdComposerTest.java | 62 ++++ ..._ares2t_tracker_delay_bg_traffic_nsds.yaml | 297 ++++++++++++++++++ 2 files changed, 359 insertions(+) create mode 100644 src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java index 638095c..823f9ea 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -18,6 +18,7 @@ import java.util.Arrays; import java.util.Optional; import java.util.Properties; +import java.util.UUID; import lombok.SneakyThrows; import org.junit.BeforeClass; import org.junit.Test; @@ -201,4 +202,65 @@ public void composeTrackerWithBackgroundConnect() { assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); } + @Test + @SneakyThrows + public void composeTrackerWithBackgroundAndDelay() { + + // Given + Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + NsVirtualLinkDesc ranVld; + Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) + .findFirst(); + if (optRanVl.isPresent()) { + ranVld = optRanVl.get(); + } else { + throw new Exception(); + } + NsVirtualLinkDesc vsbMgmtVld; + Optional optVsbVld = vsbNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgt")).findFirst(); + if (optVsbVld.isPresent()) { + vsbMgmtVld = optVsbVld.get(); + } else { + throw new Exception(); + } + Nsd delayNsd = Arrays + .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); + NsVirtualLinkDesc delayMgmtVld; + Optional optCtxVld = delayNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgt")).findFirst(); + if (optCtxVld.isPresent()) { + delayMgmtVld = optCtxVld.get(); + } else { + throw new Exception(); + } + Nsd bgNsd = Arrays + .asList(oM.readValue(new URL(urlProp.getProperty("ctx.bg_traffic.nsds")), Nsd[].class)) + .get(0); + NsVirtualLinkDesc bgMgmtVld; + optCtxVld = bgNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vld_1")).findFirst(); + if (optCtxVld.isPresent()) { + bgMgmtVld = optCtxVld.get(); + } else { + throw new Exception(); + } + + // When + passThroughComposer + .compose(new ConnectInput(), ranVld, vsbMgmtVld, vsbNsd, delayMgmtVld, delayNsd); + connectComposer.compose(new ConnectInput(), ranVld, vsbMgmtVld, vsbNsd, bgMgmtVld, bgNsd); + // Setting ID manually for test purpose + vsbNsd.setNsdIdentifier("bfb761be-ab0f-499c-88d7-ac6ce7263651"); + vsbNsd.setNsdInvariantId("d650cb24-28c5-41ba-8541-12a9cb93238c"); + vsbNsd.setDesigner(vsbNsd.getDesigner() + " + NSD Generator"); + + // Then + InputStream in = getClass().getResourceAsStream( + "/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml"); + Nsd expNsd = oM.readValue(in, Nsd[].class)[0]; + assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); + + } } \ No newline at end of file diff --git a/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml b/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml new file mode 100644 index 0000000..ed096c1 --- /dev/null +++ b/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml @@ -0,0 +1,297 @@ +# expb_ares2t_tracker_nsds.yaml +--- +- nsdIdentifier: bfb761be-ab0f-499c-88d7-ac6ce7263651 + designer: "NXW + NSD Generator" + version: "1.0" + nsdName: "ARES2T Tracker Service @ 5GEVE + NETEM Traffic Delay Generator Service +\ + \ Context Blueprint Background Traffic_nsd" + nsdInvariantId: "d650cb24-28c5-41ba-8541-12a9cb93238c" + vnfdId: + - "c84b227e-520e-43c0-a75e-e52781dd54dd" + - "419b1884-aea1-4cad-8647-c2cec55287b9" + - "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" + - "396d1b6b-331b-4dd7-b48e-376517d3654a" + - "bg_traffic_src" + - "bg_traffic_dst" + sapd: + - cpdId: "sap_tracking_mobile" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP towards mobile equipment" + addressData: + - addressType: "IP_ADDRESS" + iPAddressAssignment: false + floatingIpActivated: true + management: false + iPAddressType: "IPv4" + numberOfIpAddress: 1 + sapAddressAssignment: false + nsVirtualLinkDescId: "vl_tracking_mobile" + - cpdId: "sap_tracking_mgt" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP for management" + addressData: + - addressType: "IP_ADDRESS" + iPAddressAssignment: false + floatingIpActivated: false + management: false + iPAddressType: "IPv4" + numberOfIpAddress: 1 + sapAddressAssignment: false + nsVirtualLinkDescId: "vl_tracking_mgt" + virtualLinkDesc: + - virtualLinkDescId: "vl_tracking_mobile" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_mobile" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Network to connect to the mobile user equipment" + - virtualLinkDescId: "vl_tracking_mgt" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_mgt" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Management network" + - virtualLinkDescId: "vl_tracking_data" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_data" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Internal network to connect the tracking service components" + - virtualLinkDescId: "vl_dg_out" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_dg_out" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Network to send outgoing delayed traffic." + nsDf: + - nsDfId: "ns_Ares2T_Tracking_df" + flavourKey: "ns_Ares2T_Tracking_df_fk" + vnfProfile: + - vnfProfileId: "vnfp_small_Ares2T_Tracker" + vnfdId: "419b1884-aea1-4cad-8647-c2cec55287b9" + flavourId: "vnf_df_Ares2T_Tracker" + instantiationLevel: "vnf_il_Ares2T_Tracker" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_dg_out" + cpdId: + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_tracker_mgt" + - vnfProfileId: "vnfp_big_Ares2T_Tracker" + vnfdId: "c84b227e-520e-43c0-a75e-e52781dd54dd" + flavourId: "vnf_df_Ares2T_Tracker" + instantiationLevel: "vnf_il_Ares2T_Tracker" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_dg_out" + cpdId: + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_tracker_mgt" + - vnfProfileId: "vnfp_Ares2T_Vis" + vnfdId: "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" + flavourId: "vnf_df_Ares2T_Vis" + instantiationLevel: "vnf_il_Ares2T_Vis" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_vis_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_vis_mgt" + - vnfProfileId: "vnfp_netem" + vnfdId: "396d1b6b-331b-4dd7-b48e-376517d3654a" + flavourId: "vnf_df_netem" + instantiationLevel: "vnf_il_netem" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_dg_out" + cpdId: + - "cp_dg_traffic_out" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_dg_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + cpdId: + - "cp_dg_traffic_in" + - vnfProfileId: "bg_traffic_src_vnfp" + vnfdId: "bg_traffic_src" + flavourId: "bg_traffic_src_vnf_df" + instantiationLevel: "bg_traffic_src_vnf_il" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + cpdId: + - "cp_bg_src_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_bg_src_mgmt" + - vnfProfileId: "bg_traffic_dst_vnfp" + vnfdId: "bg_traffic_dst" + flavourId: "bg_traffic_dst_vnf_df" + instantiationLevel: "bg_traffic_dst_vnf_il" + minNumberOfInstances: 1 + maxNumberOfInstances: 1 + nsVirtualLinkConnectivity: + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_bg_dst_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + cpdId: + - "cp_bg_dst_mgmt" + virtualLinkProfile: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + virtualLinkDescId: "vl_tracking_mobile" + flavourId: "df_vl_tracking_mobile" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" + virtualLinkDescId: "vl_tracking_data" + flavourId: "df_vl_tracking_data" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + virtualLinkDescId: "vl_tracking_mgt" + flavourId: "df_vl_tracking_mgt" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_dg_out" + virtualLinkDescId: "vl_dg_out" + flavourId: "df_vl_dg_out" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + nsInstantiationLevel: + - nsLevelId: "ns_ares2t_tracker_il_big" + description: "Big instantiation level for the ARES2T tracking service" + vnfToLevelMapping: + - vnfProfileId: "vnfp_big_Ares2T_Tracker" + numberOfInstances: 1 + - vnfProfileId: "vnfp_Ares2T_Vis" + numberOfInstances: 1 + - vnfProfileId: "vnfp_netem" + numberOfInstances: 1 + - vnfProfileId: "bg_traffic_src_vnfp" + numberOfInstances: 1 + - vnfProfileId: "bg_traffic_dst_vnfp" + numberOfInstances: 1 + virtualLinkToLevelMapping: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_dg_out" + bitRateRequirements: + root: "1" + leaf: "1" + - nsLevelId: "ns_ares2t_tracker_il_small" + description: "Small instantiation level for the ARES2T tracking service" + vnfToLevelMapping: + - vnfProfileId: "vnfp_small_Ares2T_Tracker" + numberOfInstances: 1 + - vnfProfileId: "vnfp_Ares2T_Vis" + numberOfInstances: 1 + - vnfProfileId: "vnfp_netem" + numberOfInstances: 1 + - vnfProfileId: "bg_traffic_src_vnfp" + numberOfInstances: 1 + - vnfProfileId: "bg_traffic_dst_vnfp" + numberOfInstances: 1 + virtualLinkToLevelMapping: + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_dg_out" + bitRateRequirements: + root: "1" + leaf: "1" + defaultNsInstantiationLevelId: "ns_ares2t_tracker_il_small" + security: + signature: "FC_NSD_SIGNATURE" + algorithm: "FC_NSD_ALGORITHM" + certificate: "FC_NSD_CERTIFICATE" From 3b2bab52f70c9b51877c15a24be819faac93cce6 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 23 Mar 2020 18:08:17 +0100 Subject: [PATCH 091/187] Add generation of new IDs for the expNSD. --- .../cnit/blueprint/composer/rest/ExperimentsController.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 942115f..061c963 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -12,6 +12,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import java.util.List; +import java.util.UUID; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.slf4j.helpers.MessageFormatter; @@ -43,7 +44,12 @@ public OnboardExpBlueprintRequest retrieveExperiment() { @PostMapping("/experiments") public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequest) { + Nsd expNsd = composeRequest.getVsbRequest().getNsds().get(0); + expNsd.setNsdIdentifier(UUID.randomUUID().toString()); + expNsd.setNsdInvariantId(UUID.randomUUID().toString()); + expNsd.setDesigner(expNsd.getDesigner() + " + NSD Generator"); + try { // Assumptions: // - The Vsb has only 1 Nsd. From ab196a8d882232b827475a3ab7a5e04eb5f1fd02 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 23 Mar 2020 18:08:35 +0100 Subject: [PATCH 092/187] Fix name generation for NSD. --- .../it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index 504c1c7..e95a644 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -64,7 +64,7 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { nsd.setDesigner("NSD generator"); nsd.setNsdInvariantId(blueprint.getBlueprintId() + "_nsd"); nsd.setVersion(blueprint.getVersion()); - nsd.setNsdName(blueprint.getName() + "_nsd"); + nsd.setNsdName(blueprint.getName() + " NSD"); nsd.setSecurity(new SecurityParameters( "FC_NSD_SIGNATURE", "FC_NSD_ALGORITHM", From 91ed8da532dca8fc651fa1f721a62b58aad733d4 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 30 Mar 2020 12:50:20 +0200 Subject: [PATCH 093/187] Add service annotation to TranslationRulesComposer.java --- .../cnit/blueprint/composer/rules/TranslationRulesComposer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java index 9cf5b73..3944a84 100644 --- a/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java @@ -9,7 +9,9 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.slf4j.helpers.MessageFormatter; +import org.springframework.stereotype.Service; +@Service @Slf4j @AllArgsConstructor public class TranslationRulesComposer { From 7c0185a438950342a3af0b88733b4a669fd64c71 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 30 Mar 2020 12:50:43 +0200 Subject: [PATCH 094/187] Improve TODO comment. --- .../it/cnit/blueprint/composer/rest/ExperimentsController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 061c963..407ef2f 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -122,7 +122,7 @@ private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsdExce } private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) { - // TODO Visit vlDesc in nsd and check if mgmt in b. + // TODO Visit vlDesc in nsd and check if mgmt in connectivityServices of b. // We need model modifications to make this work. return new NsVirtualLinkDesc(); } From 646a671847c12fc55e22848c400363991c496f54 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 30 Mar 2020 14:22:27 +0200 Subject: [PATCH 095/187] Add test for isConnected. --- .../composer/nsd/graph/NsdGraphService.java | 3 +- .../nsd/graph/NsdGraphServiceTest.java | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java index da37b72..9b123cf 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java @@ -133,8 +133,7 @@ public ProfileVertex getVertexById(Graph g, String vertex } } - @SuppressWarnings("BooleanMethodIsAlwaysInverted") - public boolean isConnected(Graph g){ + public boolean isConnected(Graph g) { ConnectivityInspector inspector = new ConnectivityInspector<>(g); return inspector.isConnected(); } diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java index df4fda4..ce98b32 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java @@ -1,6 +1,8 @@ package it.cnit.blueprint.composer.nsd.graph; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; @@ -8,9 +10,12 @@ import java.io.InputStream; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.util.HashSet; import java.util.Properties; import java.util.Scanner; +import java.util.Set; import lombok.SneakyThrows; +import org.jgrapht.Graph; import org.junit.BeforeClass; import org.junit.Test; @@ -119,4 +124,41 @@ public void buildGraphAres2TDelayExperimentSmall() { assertEquals(expected, actual); } + @Test + @SneakyThrows + public void isConnectedAres2TTrackerSmallTest() { + + // Given + Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + String nsLevel = "ns_ares2t_tracker_il_small"; + + // When + Graph g = nsdGraphService + .buildGraph(nsd.getSapd(), nsd.getNsDf().get(0), nsd.getNsDf().get(0).getNsLevel(nsLevel)); + + // Then + assertTrue(nsdGraphService.isConnected(g)); + } + + @Test + @SneakyThrows + public void isNotConnectedAres2TTrackerSmallTest() { + + // Given + Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + String nsLevel = "ns_ares2t_tracker_il_small"; + + // When + Graph g = nsdGraphService + .buildGraph(nsd.getSapd(), nsd.getNsDf().get(0), nsd.getNsDf().get(0).getNsLevel(nsLevel)); + // Get the first vertex and remove its edges + ProfileVertex v = g.vertexSet().iterator().next(); + Set edges = new HashSet<>(g.edgesOf(v)); + for (String e: edges){ + g.removeEdge(e); + } + + // Then + assertFalse(nsdGraphService.isConnected(g)); + } } From a612903ecd08c2b921210f1384a2c113cf4ef44e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 6 Apr 2020 13:12:34 +0200 Subject: [PATCH 096/187] Add logging to NsdGraphServiceTest.java --- .../blueprint/composer/nsd/graph/NsdGraphServiceTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java index ce98b32..1e591a6 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java @@ -15,10 +15,12 @@ import java.util.Scanner; import java.util.Set; import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; import org.jgrapht.Graph; import org.junit.BeforeClass; import org.junit.Test; +@Slf4j public class NsdGraphServiceTest { static Properties prop; @@ -46,6 +48,7 @@ public void buildGraphAres2TTrackerBig() { // When String actual = nsdGraphService.export(nsdGraphService .buildGraph(nsd.getSapd(), nsd.getNsDf().get(0), nsd.getNsDf().get(0).getNsLevel(nsLevel))); + log.debug("actual graph:\n{}", actual); // Then InputStream in = ClassLoader.getSystemResourceAsStream(nsLevel + ".dot"); @@ -68,6 +71,7 @@ public void buildGraphAres2TTrackerSmall() { // When String actual = nsdGraphService.export(nsdGraphService .buildGraph(nsd.getSapd(), nsd.getNsDf().get(0), nsd.getNsDf().get(0).getNsLevel(nsLevel))); + log.debug("actual graph:\n{}", actual); // Then InputStream in = ClassLoader.getSystemResourceAsStream(nsLevel + ".dot"); @@ -90,6 +94,7 @@ public void buildGraphAres2TDelayExperimentBig() { // When String actual = nsdGraphService.export(nsdGraphService .buildGraph(nsd.getSapd(), nsd.getNsDf().get(0), nsd.getNsDf().get(0).getNsLevel(nsLevel))); + log.debug("actual graph:\n{}", actual); // Then InputStream in = ClassLoader.getSystemResourceAsStream(nsLevel + ".dot"); @@ -112,6 +117,7 @@ public void buildGraphAres2TDelayExperimentSmall() { // When String actual = nsdGraphService.export(nsdGraphService .buildGraph(nsd.getSapd(), nsd.getNsDf().get(0), nsd.getNsDf().get(0).getNsLevel(nsLevel))); + log.debug("actual graph:\n{}", actual); // Then InputStream in = ClassLoader.getSystemResourceAsStream(nsLevel + ".dot"); From ee6ea1b11d8e78513706cd7b0b24dbddadc09bc8 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 6 Apr 2020 13:12:55 +0200 Subject: [PATCH 097/187] Update graphviz export for test after Elian modifications. --- src/test/resources/ns_ares2t_tracker_il_big.dot | 14 +++++++++----- src/test/resources/ns_ares2t_tracker_il_small.dot | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/test/resources/ns_ares2t_tracker_il_big.dot b/src/test/resources/ns_ares2t_tracker_il_big.dot index 75ba9f2..923da01 100644 --- a/src/test/resources/ns_ares2t_tracker_il_big.dot +++ b/src/test/resources/ns_ares2t_tracker_il_big.dot @@ -6,14 +6,18 @@ strict graph G { 1169940735 [ label="vnfp_Ares2T_Vis" shape="box" style="filled" fillcolor="yellowgreen" ]; 1228317574 [ label="vlp_vl_tracking_mobile" shape="oval" style="filled" fillcolor="dodgerblue" ]; -1844810866 [ label="vlp_vl_tracking_data" shape="oval" style="filled" fillcolor="dodgerblue" ]; - -2137711178 [ label="vlp_vl_tracking_mgt" shape="oval" style="filled" fillcolor="dodgerblue" ]; + -1844537179 [ label="vlp_vl_tracking_mgmt" shape="oval" style="filled" fillcolor="dodgerblue" ]; + -1844287569 [ label="vlp_vl_tracking_user" shape="oval" style="filled" fillcolor="dodgerblue" ]; -734211891 [ label="sap_tracking_mobile" shape="oval" style="filled" fillcolor="darksalmon" ]; - 1141657039 [ label="sap_tracking_mgt" shape="oval" style="filled" fillcolor="darksalmon" ]; + 1031629740 [ label="sap_tracking_mgmt" shape="oval" style="filled" fillcolor="darksalmon" ]; + 585344071 [ label="sap_vis_user" shape="oval" style="filled" fillcolor="darksalmon" ]; -1503706314 -- 1228317574 [ label="vnfp_big_Ares2T_Tracker_cp_tracker_ext_in" ]; -1503706314 -- -1844810866 [ label="vnfp_big_Ares2T_Tracker_cp_tracker_data" ]; - -1503706314 -- -2137711178 [ label="vnfp_big_Ares2T_Tracker_cp_tracker_mgt" ]; + -1503706314 -- -1844537179 [ label="vnfp_big_Ares2T_Tracker_cp_tracker_mgmt" ]; 1169940735 -- -1844810866 [ label="vnfp_Ares2T_Vis_cp_vis_data" ]; - 1169940735 -- -2137711178 [ label="vnfp_Ares2T_Vis_cp_vis_mgt" ]; + 1169940735 -- -1844537179 [ label="vnfp_Ares2T_Vis_cp_vis_mgmt" ]; + 1169940735 -- -1844287569 [ label="vnfp_Ares2T_Vis_cp_vis_user" ]; -734211891 -- 1228317574 [ label="sap_tracking_mobile" ]; - 1141657039 -- -2137711178 [ label="sap_tracking_mgt" ]; + 1031629740 -- -1844537179 [ label="sap_tracking_mgmt" ]; + 585344071 -- -1844287569 [ label="sap_vis_user" ]; } diff --git a/src/test/resources/ns_ares2t_tracker_il_small.dot b/src/test/resources/ns_ares2t_tracker_il_small.dot index 5cce18d..6dee665 100644 --- a/src/test/resources/ns_ares2t_tracker_il_small.dot +++ b/src/test/resources/ns_ares2t_tracker_il_small.dot @@ -6,14 +6,18 @@ strict graph G { 1169940735 [ label="vnfp_Ares2T_Vis" shape="box" style="filled" fillcolor="yellowgreen" ]; 1228317574 [ label="vlp_vl_tracking_mobile" shape="oval" style="filled" fillcolor="dodgerblue" ]; -1844810866 [ label="vlp_vl_tracking_data" shape="oval" style="filled" fillcolor="dodgerblue" ]; - -2137711178 [ label="vlp_vl_tracking_mgt" shape="oval" style="filled" fillcolor="dodgerblue" ]; + -1844537179 [ label="vlp_vl_tracking_mgmt" shape="oval" style="filled" fillcolor="dodgerblue" ]; + -1844287569 [ label="vlp_vl_tracking_user" shape="oval" style="filled" fillcolor="dodgerblue" ]; -734211891 [ label="sap_tracking_mobile" shape="oval" style="filled" fillcolor="darksalmon" ]; - 1141657039 [ label="sap_tracking_mgt" shape="oval" style="filled" fillcolor="darksalmon" ]; + 1031629740 [ label="sap_tracking_mgmt" shape="oval" style="filled" fillcolor="darksalmon" ]; + 585344071 [ label="sap_vis_user" shape="oval" style="filled" fillcolor="darksalmon" ]; 2056075535 -- 1228317574 [ label="vnfp_small_Ares2T_Tracker_cp_tracker_ext_in" ]; 2056075535 -- -1844810866 [ label="vnfp_small_Ares2T_Tracker_cp_tracker_data" ]; - 2056075535 -- -2137711178 [ label="vnfp_small_Ares2T_Tracker_cp_tracker_mgt" ]; + 2056075535 -- -1844537179 [ label="vnfp_small_Ares2T_Tracker_cp_tracker_mgmt" ]; 1169940735 -- -1844810866 [ label="vnfp_Ares2T_Vis_cp_vis_data" ]; - 1169940735 -- -2137711178 [ label="vnfp_Ares2T_Vis_cp_vis_mgt" ]; + 1169940735 -- -1844537179 [ label="vnfp_Ares2T_Vis_cp_vis_mgmt" ]; + 1169940735 -- -1844287569 [ label="vnfp_Ares2T_Vis_cp_vis_user" ]; -734211891 -- 1228317574 [ label="sap_tracking_mobile" ]; - 1141657039 -- -2137711178 [ label="sap_tracking_mgt" ]; + 1031629740 -- -1844537179 [ label="sap_tracking_mgmt" ]; + 585344071 -- -1844287569 [ label="sap_vis_user" ]; } From 2ac6ddc6a6f5a875f55de683b7ee6875cd92db1a Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 6 Apr 2020 15:59:25 +0200 Subject: [PATCH 098/187] Update graphviz export also for experiment NSD. --- .../resources/ns_ares2t_tracker_exp_il_big.dot | 16 ++++++++++------ .../resources/ns_ares2t_tracker_exp_il_small.dot | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/test/resources/ns_ares2t_tracker_exp_il_big.dot b/src/test/resources/ns_ares2t_tracker_exp_il_big.dot index e6697ca..7e551f5 100644 --- a/src/test/resources/ns_ares2t_tracker_exp_il_big.dot +++ b/src/test/resources/ns_ares2t_tracker_exp_il_big.dot @@ -6,19 +6,23 @@ strict graph G { 1392640733 [ label="vnfp_Ares2T_Vis_exp" shape="box" style="filled" fillcolor="yellowgreen" ]; -793362586 [ label="vnfp_netem_exp" shape="box" style="filled" fillcolor="yellowgreen" ]; -227812888 [ label="vlp_vl_tracking_exp_mobile" shape="oval" style="filled" fillcolor="dodgerblue" ]; - 1183339156 [ label="vlp_vl_tracking_exp_mgt" shape="oval" style="filled" fillcolor="dodgerblue" ]; + -1971191929 [ label="vlp_vl_tracking_exp_mgmt" shape="oval" style="filled" fillcolor="dodgerblue" ]; 1008003435 [ label="vlp_vl_tracking_exp_in" shape="oval" style="filled" fillcolor="dodgerblue" ]; -1971465616 [ label="vlp_vl_tracking_exp_data" shape="oval" style="filled" fillcolor="dodgerblue" ]; + 1542916426 [ label="vlp_vl_visualizer_exp_user" shape="oval" style="filled" fillcolor="dodgerblue" ]; 142347183 [ label="sap_tracking_exp_mobile" shape="oval" style="filled" fillcolor="darksalmon" ]; - 474467885 [ label="sap_tracking_exp_mgt" shape="oval" style="filled" fillcolor="darksalmon" ]; + 1823602446 [ label="sap_tracking_exp_mgmt" shape="oval" style="filled" fillcolor="darksalmon" ]; + 1913076497 [ label="sap_visualizer_exp_user" shape="oval" style="filled" fillcolor="darksalmon" ]; 304837012 -- 1008003435 [ label="vnfp_big_Ares2T_Tracker_exp_cp_tracker_ext_in" ]; 304837012 -- -1971465616 [ label="vnfp_big_Ares2T_Tracker_exp_cp_tracker_data" ]; - 304837012 -- 1183339156 [ label="vnfp_big_Ares2T_Tracker_exp_cp_tracker_mgt" ]; + 304837012 -- -1971191929 [ label="vnfp_big_Ares2T_Tracker_exp_cp_tracker_mgmt" ]; 1392640733 -- -1971465616 [ label="vnfp_Ares2T_Vis_exp_cp_vis_data" ]; - 1392640733 -- 1183339156 [ label="vnfp_Ares2T_Vis_exp_cp_vis_mgt" ]; + 1392640733 -- -1971191929 [ label="vnfp_Ares2T_Vis_exp_cp_vis_mgmt" ]; + 1392640733 -- 1542916426 [ label="vnfp_Ares2T_Vis_exp_cp_vis_user" ]; -793362586 -- 1008003435 [ label="vnfp_netem_exp_cp_dg_traffic_out" ]; - -793362586 -- 1183339156 [ label="vnfp_netem_exp_cp_dg_mgt" ]; + -793362586 -- -1971191929 [ label="vnfp_netem_exp_cp_dg_mgmt" ]; -793362586 -- -227812888 [ label="vnfp_netem_exp_cp_dg_traffic_in" ]; 142347183 -- -227812888 [ label="sap_tracking_exp_mobile" ]; - 474467885 -- 1183339156 [ label="sap_tracking_exp_mgt" ]; + 1823602446 -- -1971191929 [ label="sap_tracking_exp_mgmt" ]; + 1913076497 -- 1542916426 [ label="sap_visualizer_exp_user" ]; } diff --git a/src/test/resources/ns_ares2t_tracker_exp_il_small.dot b/src/test/resources/ns_ares2t_tracker_exp_il_small.dot index dcc72eb..d5af086 100644 --- a/src/test/resources/ns_ares2t_tracker_exp_il_small.dot +++ b/src/test/resources/ns_ares2t_tracker_exp_il_small.dot @@ -6,19 +6,23 @@ strict graph G { 1392640733 [ label="vnfp_Ares2T_Vis_exp" shape="box" style="filled" fillcolor="yellowgreen" ]; -793362586 [ label="vnfp_netem_exp" shape="box" style="filled" fillcolor="yellowgreen" ]; -227812888 [ label="vlp_vl_tracking_exp_mobile" shape="oval" style="filled" fillcolor="dodgerblue" ]; - 1183339156 [ label="vlp_vl_tracking_exp_mgt" shape="oval" style="filled" fillcolor="dodgerblue" ]; + -1971191929 [ label="vlp_vl_tracking_exp_mgmt" shape="oval" style="filled" fillcolor="dodgerblue" ]; 1008003435 [ label="vlp_vl_tracking_exp_in" shape="oval" style="filled" fillcolor="dodgerblue" ]; -1971465616 [ label="vlp_vl_tracking_exp_data" shape="oval" style="filled" fillcolor="dodgerblue" ]; + 1542916426 [ label="vlp_vl_visualizer_exp_user" shape="oval" style="filled" fillcolor="dodgerblue" ]; 142347183 [ label="sap_tracking_exp_mobile" shape="oval" style="filled" fillcolor="darksalmon" ]; - 474467885 [ label="sap_tracking_exp_mgt" shape="oval" style="filled" fillcolor="darksalmon" ]; + 1823602446 [ label="sap_tracking_exp_mgmt" shape="oval" style="filled" fillcolor="darksalmon" ]; + 1913076497 [ label="sap_visualizer_exp_user" shape="oval" style="filled" fillcolor="darksalmon" ]; -1874275603 -- 1008003435 [ label="vnfp_small_Ares2T_Tracker_exp_cp_tracker_ext_in" ]; -1874275603 -- -1971465616 [ label="vnfp_small_Ares2T_Tracker_exp_cp_tracker_data" ]; - -1874275603 -- 1183339156 [ label="vnfp_small_Ares2T_Tracker_exp_cp_tracker_mgt" ]; + -1874275603 -- -1971191929 [ label="vnfp_small_Ares2T_Tracker_exp_cp_tracker_mgmt" ]; 1392640733 -- -1971465616 [ label="vnfp_Ares2T_Vis_exp_cp_vis_data" ]; - 1392640733 -- 1183339156 [ label="vnfp_Ares2T_Vis_exp_cp_vis_mgt" ]; + 1392640733 -- -1971191929 [ label="vnfp_Ares2T_Vis_exp_cp_vis_mgmt" ]; + 1392640733 -- 1542916426 [ label="vnfp_Ares2T_Vis_exp_cp_vis_user" ]; -793362586 -- 1008003435 [ label="vnfp_netem_exp_cp_dg_traffic_out" ]; - -793362586 -- 1183339156 [ label="vnfp_netem_exp_cp_dg_mgt" ]; + -793362586 -- -1971191929 [ label="vnfp_netem_exp_cp_dg_mgmt" ]; -793362586 -- -227812888 [ label="vnfp_netem_exp_cp_dg_traffic_in" ]; 142347183 -- -227812888 [ label="sap_tracking_exp_mobile" ]; - 474467885 -- 1183339156 [ label="sap_tracking_exp_mgt" ]; + 1823602446 -- -1971191929 [ label="sap_tracking_exp_mgmt" ]; + 1913076497 -- 1542916426 [ label="sap_visualizer_exp_user" ]; } From 9ef0e5866e793d4767eacddccb03524b38d73076 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 6 Apr 2020 16:28:14 +0200 Subject: [PATCH 099/187] Fix NsdComposerTest after Elian changes. --- .../composer/nsd/compose/NsdComposerTest.java | 19 +- ...res2t_tracker_bg_traffic_nsds_connect.yaml | 84 +++- ..._ares2t_tracker_delay_bg_traffic_nsds.yaml | 90 ++++- ...xpb_ares2t_tracker_delay_nsds_connect.yaml | 88 ++++- ...ares2t_tracker_delay_nsds_passthrough.yaml | 369 ++++++++++-------- 5 files changed, 425 insertions(+), 225 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java index 823f9ea..fa6f1d9 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -61,7 +61,7 @@ public void composeTrackerWithDelayPassThrough() { } NsVirtualLinkDesc vsbMgmtVld; Optional optVsbVld = vsbNsd.getVirtualLinkDesc().stream() - .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgt")).findFirst(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgmt")).findFirst(); if (optVsbVld.isPresent()) { vsbMgmtVld = optVsbVld.get(); } else { @@ -71,7 +71,7 @@ public void composeTrackerWithDelayPassThrough() { .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); NsVirtualLinkDesc ctxMgmtVld; Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() - .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgt")).findFirst(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgmt")).findFirst(); if (optCtxVld.isPresent()) { ctxMgmtVld = optCtxVld.get(); } else { @@ -84,6 +84,7 @@ public void composeTrackerWithDelayPassThrough() { // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); + vsbNsd.setDesigner(vsbNsd.getDesigner() + " + NSD Composer"); // Then InputStream in = getClass().getResourceAsStream( @@ -109,7 +110,7 @@ public void composeTrackerWithDelayConnect() { } NsVirtualLinkDesc vsbMgmtVld; Optional optVsbVld = vsbNsd.getVirtualLinkDesc().stream() - .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgt")).findFirst(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgmt")).findFirst(); if (optVsbVld.isPresent()) { vsbMgmtVld = optVsbVld.get(); } else { @@ -135,7 +136,7 @@ public void composeTrackerWithDelayConnect() { NsVirtualLinkDesc ctxMgmtVld; Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() - .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgt")).findFirst(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgmt")).findFirst(); if (optCtxVld.isPresent()) { ctxMgmtVld = optCtxVld.get(); } else { @@ -147,6 +148,7 @@ public void composeTrackerWithDelayConnect() { // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); + vsbNsd.setDesigner(vsbNsd.getDesigner() + " + NSD Composer"); // Then InputStream in = getClass().getResourceAsStream( @@ -171,7 +173,7 @@ public void composeTrackerWithBackgroundConnect() { } NsVirtualLinkDesc vsbMgmtVld; Optional optVsbVld = vsbNsd.getVirtualLinkDesc().stream() - .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgt")).findFirst(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgmt")).findFirst(); if (optVsbVld.isPresent()) { vsbMgmtVld = optVsbVld.get(); } else { @@ -194,6 +196,7 @@ public void composeTrackerWithBackgroundConnect() { // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("2dd7b5b1-9f39-4978-a035-6654d7bc9068"); vsbNsd.setNsdInvariantId("d5959420-1ef7-4441-9eb9-9113172c988b"); + vsbNsd.setDesigner(vsbNsd.getDesigner() + " + NSD Composer"); // Then InputStream in = getClass().getResourceAsStream( @@ -219,7 +222,7 @@ public void composeTrackerWithBackgroundAndDelay() { } NsVirtualLinkDesc vsbMgmtVld; Optional optVsbVld = vsbNsd.getVirtualLinkDesc().stream() - .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgt")).findFirst(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mgmt")).findFirst(); if (optVsbVld.isPresent()) { vsbMgmtVld = optVsbVld.get(); } else { @@ -229,7 +232,7 @@ public void composeTrackerWithBackgroundAndDelay() { .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); NsVirtualLinkDesc delayMgmtVld; Optional optCtxVld = delayNsd.getVirtualLinkDesc().stream() - .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgt")).findFirst(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgmt")).findFirst(); if (optCtxVld.isPresent()) { delayMgmtVld = optCtxVld.get(); } else { @@ -254,7 +257,7 @@ public void composeTrackerWithBackgroundAndDelay() { // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("bfb761be-ab0f-499c-88d7-ac6ce7263651"); vsbNsd.setNsdInvariantId("d650cb24-28c5-41ba-8541-12a9cb93238c"); - vsbNsd.setDesigner(vsbNsd.getDesigner() + " + NSD Generator"); + vsbNsd.setDesigner(vsbNsd.getDesigner() + " + NSD Composer"); // Then InputStream in = getClass().getResourceAsStream( diff --git a/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml b/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml index 66f5111..6d31663 100644 --- a/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml +++ b/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml @@ -1,7 +1,7 @@ # expb_ares2t_tracker_nsds.yaml --- - nsdIdentifier: "2dd7b5b1-9f39-4978-a035-6654d7bc9068" - designer: "NXW" + designer: "NXW + NSD Composer" version: "1.0" nsdName: "ARES2T Tracker Service @ 5GEVE + Context Blueprint Background Traffic_nsd" nsdInvariantId: "d5959420-1ef7-4441-9eb9-9113172c988b" @@ -25,7 +25,7 @@ numberOfIpAddress: 1 sapAddressAssignment: false nsVirtualLinkDescId: "vl_tracking_mobile" - - cpdId: "sap_tracking_mgt" + - cpdId: "sap_tracking_mgmt" layerProtocol: "IPV4" cpRole: "ROOT" description: "SAP for management" @@ -37,7 +37,20 @@ iPAddressType: "IPv4" numberOfIpAddress: 1 sapAddressAssignment: false - nsVirtualLinkDescId: "vl_tracking_mgt" + nsVirtualLinkDescId: "vl_tracking_mgmt" + - cpdId: "sap_vis_user" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP for user access to visualizer" + addressData: + - addressType: "IP_ADDRESS" + iPAddressAssignment: false + floatingIpActivated: false + management: false + iPAddressType: "IPv4" + numberOfIpAddress: 1 + sapAddressAssignment: false + nsVirtualLinkDescId: "vl_tracking_user" virtualLinkDesc: - virtualLinkDescId: "vl_tracking_mobile" virtualLinkDescProvider: "NXW" @@ -54,14 +67,14 @@ priority: 0 serviceAvaibilityLevel: "LEVEL_1" description: "Network to connect to the mobile user equipment" - - virtualLinkDescId: "vl_tracking_mgt" + - virtualLinkDescId: "vl_tracking_mgmt" virtualLinkDescProvider: "NXW" virtuaLinkDescVersion: "1.0" connectivityType: layerProtocol: "IPV4" flowPattern: null virtualLinkDf: - - flavourId: "df_vl_tracking_mgt" + - flavourId: "df_vl_tracking_mgmt" qos: latency: 0 packetDelayVariation: 0 @@ -84,6 +97,21 @@ priority: 0 serviceAvaibilityLevel: "LEVEL_1" description: "Internal network to connect the tracking service components" + - virtualLinkDescId: "vl_tracking_user" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_user" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Network to connect to the Visualizer dashboard" nsDf: - nsDfId: "ns_Ares2T_Tracking_df" flavourKey: "ns_Ares2T_Tracking_df_fk" @@ -101,9 +129,9 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_tracker_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - "cp_tracker_mgt" + - "cp_tracker_mgmt" - vnfProfileId: "vnfp_big_Ares2T_Tracker" vnfdId: "c84b227e-520e-43c0-a75e-e52781dd54dd" flavourId: "vnf_df_Ares2T_Tracker" @@ -117,9 +145,9 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_tracker_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - "cp_tracker_mgt" + - "cp_tracker_mgmt" - vnfProfileId: "vnfp_Ares2T_Vis" vnfdId: "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" flavourId: "vnf_df_Ares2T_Vis" @@ -130,9 +158,12 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_vis_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "cp_vis_mgmt" + - virtualLinkProfileId: "vlp_vl_tracking_user" cpdId: - - "cp_vis_mgt" + - "cp_vis_user" - vnfProfileId: "bg_traffic_src_vnfp" vnfdId: "bg_traffic_src" flavourId: "bg_traffic_src_vnf_df" @@ -143,7 +174,7 @@ - virtualLinkProfileId: "vlp_vl_tracking_mobile" cpdId: - "cp_bg_src_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - "cp_bg_src_mgmt" - vnfProfileId: "bg_traffic_dst_vnfp" @@ -156,7 +187,7 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_bg_dst_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - "cp_bg_dst_mgmt" virtualLinkProfile: @@ -178,9 +209,18 @@ minBitrateRequirements: root: "1" leaf: "1" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" - virtualLinkDescId: "vl_tracking_mgt" - flavourId: "df_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + virtualLinkDescId: "vl_tracking_mgmt" + flavourId: "df_vl_tracking_mgmt" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" + virtualLinkDescId: "vl_tracking_user" + flavourId: "df_vl_tracking_user" maxBitrateRequirements: root: "1" leaf: "1" @@ -208,7 +248,11 @@ bitRateRequirements: root: "1" leaf: "1" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" bitRateRequirements: root: "1" leaf: "1" @@ -232,7 +276,11 @@ bitRateRequirements: root: "1" leaf: "1" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" bitRateRequirements: root: "1" leaf: "1" diff --git a/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml b/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml index ed096c1..f921531 100644 --- a/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml +++ b/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml @@ -1,7 +1,7 @@ # expb_ares2t_tracker_nsds.yaml --- -- nsdIdentifier: bfb761be-ab0f-499c-88d7-ac6ce7263651 - designer: "NXW + NSD Generator" +- nsdIdentifier: "bfb761be-ab0f-499c-88d7-ac6ce7263651" + designer: "NXW + NSD Composer" version: "1.0" nsdName: "ARES2T Tracker Service @ 5GEVE + NETEM Traffic Delay Generator Service +\ \ Context Blueprint Background Traffic_nsd" @@ -27,7 +27,7 @@ numberOfIpAddress: 1 sapAddressAssignment: false nsVirtualLinkDescId: "vl_tracking_mobile" - - cpdId: "sap_tracking_mgt" + - cpdId: "sap_tracking_mgmt" layerProtocol: "IPV4" cpRole: "ROOT" description: "SAP for management" @@ -39,7 +39,20 @@ iPAddressType: "IPv4" numberOfIpAddress: 1 sapAddressAssignment: false - nsVirtualLinkDescId: "vl_tracking_mgt" + nsVirtualLinkDescId: "vl_tracking_mgmt" + - cpdId: "sap_vis_user" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP for user access to visualizer" + addressData: + - addressType: "IP_ADDRESS" + iPAddressAssignment: false + floatingIpActivated: false + management: false + iPAddressType: "IPv4" + numberOfIpAddress: 1 + sapAddressAssignment: false + nsVirtualLinkDescId: "vl_tracking_user" virtualLinkDesc: - virtualLinkDescId: "vl_tracking_mobile" virtualLinkDescProvider: "NXW" @@ -56,14 +69,14 @@ priority: 0 serviceAvaibilityLevel: "LEVEL_1" description: "Network to connect to the mobile user equipment" - - virtualLinkDescId: "vl_tracking_mgt" + - virtualLinkDescId: "vl_tracking_mgmt" virtualLinkDescProvider: "NXW" virtuaLinkDescVersion: "1.0" connectivityType: layerProtocol: "IPV4" flowPattern: null virtualLinkDf: - - flavourId: "df_vl_tracking_mgt" + - flavourId: "df_vl_tracking_mgmt" qos: latency: 0 packetDelayVariation: 0 @@ -86,6 +99,21 @@ priority: 0 serviceAvaibilityLevel: "LEVEL_1" description: "Internal network to connect the tracking service components" + - virtualLinkDescId: "vl_tracking_user" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_user" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Network to connect to the Visualizer dashboard" - virtualLinkDescId: "vl_dg_out" virtualLinkDescProvider: "NXW" virtuaLinkDescVersion: "1.0" @@ -118,9 +146,9 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_tracker_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - "cp_tracker_mgt" + - "cp_tracker_mgmt" - vnfProfileId: "vnfp_big_Ares2T_Tracker" vnfdId: "c84b227e-520e-43c0-a75e-e52781dd54dd" flavourId: "vnf_df_Ares2T_Tracker" @@ -134,9 +162,9 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_tracker_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - "cp_tracker_mgt" + - "cp_tracker_mgmt" - vnfProfileId: "vnfp_Ares2T_Vis" vnfdId: "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" flavourId: "vnf_df_Ares2T_Vis" @@ -147,9 +175,12 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_vis_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "cp_vis_mgmt" + - virtualLinkProfileId: "vlp_vl_tracking_user" cpdId: - - "cp_vis_mgt" + - "cp_vis_user" - vnfProfileId: "vnfp_netem" vnfdId: "396d1b6b-331b-4dd7-b48e-376517d3654a" flavourId: "vnf_df_netem" @@ -160,9 +191,9 @@ - virtualLinkProfileId: "vlp_vl_dg_out" cpdId: - "cp_dg_traffic_out" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - "cp_dg_mgt" + - "cp_dg_mgmt" - virtualLinkProfileId: "vlp_vl_tracking_mobile" cpdId: - "cp_dg_traffic_in" @@ -176,7 +207,7 @@ - virtualLinkProfileId: "vlp_vl_tracking_mobile" cpdId: - "cp_bg_src_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - "cp_bg_src_mgmt" - vnfProfileId: "bg_traffic_dst_vnfp" @@ -189,7 +220,7 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_bg_dst_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - "cp_bg_dst_mgmt" virtualLinkProfile: @@ -211,9 +242,18 @@ minBitrateRequirements: root: "1" leaf: "1" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" - virtualLinkDescId: "vl_tracking_mgt" - flavourId: "df_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + virtualLinkDescId: "vl_tracking_mgmt" + flavourId: "df_vl_tracking_mgmt" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" + virtualLinkDescId: "vl_tracking_user" + flavourId: "df_vl_tracking_user" maxBitrateRequirements: root: "1" leaf: "1" @@ -252,7 +292,11 @@ bitRateRequirements: root: "1" leaf: "1" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" bitRateRequirements: root: "1" leaf: "1" @@ -282,7 +326,11 @@ bitRateRequirements: root: "1" leaf: "1" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" bitRateRequirements: root: "1" leaf: "1" diff --git a/src/test/resources/expb_ares2t_tracker_delay_nsds_connect.yaml b/src/test/resources/expb_ares2t_tracker_delay_nsds_connect.yaml index b0623c1..f255af8 100644 --- a/src/test/resources/expb_ares2t_tracker_delay_nsds_connect.yaml +++ b/src/test/resources/expb_ares2t_tracker_delay_nsds_connect.yaml @@ -1,7 +1,7 @@ # expb_ares2t_tracker_nsds.yaml --- - nsdIdentifier: "58886b95-cd29-4b7b-aca0-e884caaa5c68" - designer: "NXW" + designer: "NXW + NSD Composer" version: "1.0" nsdName: "ARES2T Tracker Service @ 5GEVE + NETEM Traffic Delay Generator Service" nsdInvariantId: "ae66294b-8dae-406c-af70-f8516e310965" @@ -24,7 +24,7 @@ numberOfIpAddress: 1 sapAddressAssignment: false nsVirtualLinkDescId: "vl_tracking_mobile" - - cpdId: "sap_tracking_mgt" + - cpdId: "sap_tracking_mgmt" layerProtocol: "IPV4" cpRole: "ROOT" description: "SAP for management" @@ -36,7 +36,20 @@ iPAddressType: "IPv4" numberOfIpAddress: 1 sapAddressAssignment: false - nsVirtualLinkDescId: "vl_tracking_mgt" + nsVirtualLinkDescId: "vl_tracking_mgmt" + - cpdId: "sap_vis_user" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP for user access to visualizer" + addressData: + - addressType: "IP_ADDRESS" + iPAddressAssignment: false + floatingIpActivated: false + management: false + iPAddressType: "IPv4" + numberOfIpAddress: 1 + sapAddressAssignment: false + nsVirtualLinkDescId: "vl_tracking_user" virtualLinkDesc: - virtualLinkDescId: "vl_tracking_mobile" virtualLinkDescProvider: "NXW" @@ -53,14 +66,14 @@ priority: 0 serviceAvaibilityLevel: "LEVEL_1" description: "Network to connect to the mobile user equipment" - - virtualLinkDescId: "vl_tracking_mgt" + - virtualLinkDescId: "vl_tracking_mgmt" virtualLinkDescProvider: "NXW" virtuaLinkDescVersion: "1.0" connectivityType: layerProtocol: "IPV4" flowPattern: null virtualLinkDf: - - flavourId: "df_vl_tracking_mgt" + - flavourId: "df_vl_tracking_mgmt" qos: latency: 0 packetDelayVariation: 0 @@ -83,6 +96,21 @@ priority: 0 serviceAvaibilityLevel: "LEVEL_1" description: "Internal network to connect the tracking service components" + - virtualLinkDescId: "vl_tracking_user" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_tracking_user" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Network to connect to the Visualizer dashboard" nsDf: - nsDfId: "ns_Ares2T_Tracking_df" flavourKey: "ns_Ares2T_Tracking_df_fk" @@ -100,9 +128,9 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_tracker_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - "cp_tracker_mgt" + - "cp_tracker_mgmt" - vnfProfileId: "vnfp_big_Ares2T_Tracker" vnfdId: "c84b227e-520e-43c0-a75e-e52781dd54dd" flavourId: "vnf_df_Ares2T_Tracker" @@ -116,9 +144,9 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_tracker_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - "cp_tracker_mgt" + - "cp_tracker_mgmt" - vnfProfileId: "vnfp_Ares2T_Vis" vnfdId: "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" flavourId: "vnf_df_Ares2T_Vis" @@ -129,9 +157,12 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_vis_data" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "cp_vis_mgmt" + - virtualLinkProfileId: "vlp_vl_tracking_user" cpdId: - - "cp_vis_mgt" + - "cp_vis_user" - vnfProfileId: "vnfp_netem" vnfdId: "396d1b6b-331b-4dd7-b48e-376517d3654a" flavourId: "vnf_df_netem" @@ -142,9 +173,9 @@ - virtualLinkProfileId: "vlp_vl_tracking_mobile" cpdId: - "cp_dg_traffic_out" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - "cp_dg_mgt" + - "cp_dg_mgmt" - vnfProfileId: "vnfp_netem_fake" vnfdId: "396d1b6b-331b-4dd7-b48e-376517d3654a" flavourId: "vnf_df_netem" @@ -155,9 +186,9 @@ - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - "cp_dg_traffic_out" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - "cp_dg_mgt" + - "cp_dg_mgmt" virtualLinkProfile: - virtualLinkProfileId: "vlp_vl_tracking_mobile" virtualLinkDescId: "vl_tracking_mobile" @@ -177,9 +208,18 @@ minBitrateRequirements: root: "1" leaf: "1" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" - virtualLinkDescId: "vl_tracking_mgt" - flavourId: "df_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + virtualLinkDescId: "vl_tracking_mgmt" + flavourId: "df_vl_tracking_mgmt" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" + virtualLinkDescId: "vl_tracking_user" + flavourId: "df_vl_tracking_user" maxBitrateRequirements: root: "1" leaf: "1" @@ -207,7 +247,11 @@ bitRateRequirements: root: "1" leaf: "1" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" bitRateRequirements: root: "1" leaf: "1" @@ -231,7 +275,11 @@ bitRateRequirements: root: "1" leaf: "1" - - virtualLinkProfileId: "vlp_vl_tracking_mgt" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" bitRateRequirements: root: "1" leaf: "1" diff --git a/src/test/resources/expb_ares2t_tracker_delay_nsds_passthrough.yaml b/src/test/resources/expb_ares2t_tracker_delay_nsds_passthrough.yaml index b4b4630..6b3b297 100644 --- a/src/test/resources/expb_ares2t_tracker_delay_nsds_passthrough.yaml +++ b/src/test/resources/expb_ares2t_tracker_delay_nsds_passthrough.yaml @@ -1,255 +1,308 @@ # expb_ares2t_tracker_nsds.yaml --- -- nsdIdentifier: 58886b95-cd29-4b7b-aca0-e884caaa5c68 - designer: NXW - version: '1.0' - nsdName: ARES2T Tracker Service @ 5GEVE + NETEM Traffic Delay Generator Service - nsdInvariantId: ae66294b-8dae-406c-af70-f8516e310965 +- nsdIdentifier: "58886b95-cd29-4b7b-aca0-e884caaa5c68" + designer: "NXW + NSD Composer" + version: "1.0" + nsdName: "ARES2T Tracker Service @ 5GEVE + NETEM Traffic Delay Generator Service" + nsdInvariantId: "ae66294b-8dae-406c-af70-f8516e310965" vnfdId: - - c84b227e-520e-43c0-a75e-e52781dd54dd - - 419b1884-aea1-4cad-8647-c2cec55287b9 - - 51c420e3-c83d-4ce9-a5bf-0dbe339b351d - - 396d1b6b-331b-4dd7-b48e-376517d3654a + - "c84b227e-520e-43c0-a75e-e52781dd54dd" + - "419b1884-aea1-4cad-8647-c2cec55287b9" + - "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" + - "396d1b6b-331b-4dd7-b48e-376517d3654a" sapd: - - cpdId: sap_tracking_mobile - description: SAP towards mobile equipment - layerProtocol: IPV4 - cpRole: ROOT + - cpdId: "sap_tracking_mobile" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP towards mobile equipment" addressData: - - addressType: IP_ADDRESS + - addressType: "IP_ADDRESS" iPAddressAssignment: false floatingIpActivated: true - iPAddressType: IPv4 + management: false + iPAddressType: "IPv4" numberOfIpAddress: 1 sapAddressAssignment: false - nsVirtualLinkDescId: vl_tracking_mobile - - cpdId: sap_tracking_mgt - description: SAP for management - layerProtocol: IPV4 - cpRole: ROOT + nsVirtualLinkDescId: "vl_tracking_mobile" + - cpdId: "sap_tracking_mgmt" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP for management" addressData: - - addressType: IP_ADDRESS + - addressType: "IP_ADDRESS" iPAddressAssignment: false floatingIpActivated: false - iPAddressType: IPv4 + management: false + iPAddressType: "IPv4" numberOfIpAddress: 1 sapAddressAssignment: false - nsVirtualLinkDescId: vl_tracking_mgt + nsVirtualLinkDescId: "vl_tracking_mgmt" + - cpdId: "sap_vis_user" + layerProtocol: "IPV4" + cpRole: "ROOT" + description: "SAP for user access to visualizer" + addressData: + - addressType: "IP_ADDRESS" + iPAddressAssignment: false + floatingIpActivated: false + management: false + iPAddressType: "IPv4" + numberOfIpAddress: 1 + sapAddressAssignment: false + nsVirtualLinkDescId: "vl_tracking_user" virtualLinkDesc: - - virtualLinkDescId: vl_tracking_mobile - virtualLinkDescProvider: NXW - virtuaLinkDescVersion: '1.0' + - virtualLinkDescId: "vl_tracking_mobile" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" connectivityType: - layerProtocol: IPV4 + layerProtocol: "IPV4" + flowPattern: null virtualLinkDf: - - flavourId: df_vl_tracking_mobile + - flavourId: "df_vl_tracking_mobile" qos: latency: 0 packetDelayVariation: 0 packetLossRatio: 0 priority: 0 - serviceAvaibilityLevel: LEVEL_1 - description: Network to connect to the mobile user equipment - - virtualLinkDescId: vl_tracking_mgt - virtualLinkDescProvider: NXW - virtuaLinkDescVersion: '1.0' + serviceAvaibilityLevel: "LEVEL_1" + description: "Network to connect to the mobile user equipment" + - virtualLinkDescId: "vl_tracking_mgmt" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" connectivityType: - layerProtocol: IPV4 + layerProtocol: "IPV4" + flowPattern: null virtualLinkDf: - - flavourId: df_vl_tracking_mgt + - flavourId: "df_vl_tracking_mgmt" qos: latency: 0 packetDelayVariation: 0 packetLossRatio: 0 priority: 0 - serviceAvaibilityLevel: LEVEL_1 - description: Management network - - virtualLinkDescId: vl_tracking_data - virtualLinkDescProvider: NXW - virtuaLinkDescVersion: '1.0' + serviceAvaibilityLevel: "LEVEL_1" + description: "Management network" + - virtualLinkDescId: "vl_tracking_data" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" connectivityType: - layerProtocol: IPV4 + layerProtocol: "IPV4" + flowPattern: null virtualLinkDf: - - flavourId: df_vl_tracking_data + - flavourId: "df_vl_tracking_data" qos: latency: 0 packetDelayVariation: 0 packetLossRatio: 0 priority: 0 - serviceAvaibilityLevel: LEVEL_1 - description: Internal network to connect the tracking service components - - virtualLinkDescId: vl_dg_out - virtualLinkDescProvider: NXW - virtuaLinkDescVersion: '1.0' + serviceAvaibilityLevel: "LEVEL_1" + description: "Internal network to connect the tracking service components" + - virtualLinkDescId: "vl_tracking_user" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" connectivityType: - layerProtocol: IPV4 + layerProtocol: "IPV4" + flowPattern: null virtualLinkDf: - - flavourId: df_vl_dg_out + - flavourId: "df_vl_tracking_user" qos: latency: 0 packetDelayVariation: 0 packetLossRatio: 0 priority: 0 - serviceAvaibilityLevel: LEVEL_1 - description: Network to send outgoing delayed traffic. + serviceAvaibilityLevel: "LEVEL_1" + description: "Network to connect to the Visualizer dashboard" + - virtualLinkDescId: "vl_dg_out" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - flavourId: "df_vl_dg_out" + qos: + latency: 0 + packetDelayVariation: 0 + packetLossRatio: 0 + priority: 0 + serviceAvaibilityLevel: "LEVEL_1" + description: "Network to send outgoing delayed traffic." nsDf: - - nsDfId: ns_Ares2T_Tracking_df - flavourKey: ns_Ares2T_Tracking_df_fk + - nsDfId: "ns_Ares2T_Tracking_df" + flavourKey: "ns_Ares2T_Tracking_df_fk" vnfProfile: - - vnfProfileId: vnfp_small_Ares2T_Tracker - vnfdId: 419b1884-aea1-4cad-8647-c2cec55287b9 - flavourId: vnf_df_Ares2T_Tracker - instantiationLevel: vnf_il_Ares2T_Tracker + - vnfProfileId: "vnfp_small_Ares2T_Tracker" + vnfdId: "419b1884-aea1-4cad-8647-c2cec55287b9" + flavourId: "vnf_df_Ares2T_Tracker" + instantiationLevel: "vnf_il_Ares2T_Tracker" minNumberOfInstances: 1 maxNumberOfInstances: 1 nsVirtualLinkConnectivity: - - virtualLinkProfileId: vlp_vl_dg_out + - virtualLinkProfileId: "vlp_vl_dg_out" cpdId: - - cp_tracker_ext_in - - virtualLinkProfileId: vlp_vl_tracking_data + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - - cp_tracker_data - - virtualLinkProfileId: vlp_vl_tracking_mgt + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - cp_tracker_mgt - - vnfProfileId: vnfp_big_Ares2T_Tracker - vnfdId: c84b227e-520e-43c0-a75e-e52781dd54dd - flavourId: vnf_df_Ares2T_Tracker - instantiationLevel: vnf_il_Ares2T_Tracker + - "cp_tracker_mgmt" + - vnfProfileId: "vnfp_big_Ares2T_Tracker" + vnfdId: "c84b227e-520e-43c0-a75e-e52781dd54dd" + flavourId: "vnf_df_Ares2T_Tracker" + instantiationLevel: "vnf_il_Ares2T_Tracker" minNumberOfInstances: 1 maxNumberOfInstances: 1 nsVirtualLinkConnectivity: - - virtualLinkProfileId: vlp_vl_dg_out + - virtualLinkProfileId: "vlp_vl_dg_out" cpdId: - - cp_tracker_ext_in - - virtualLinkProfileId: vlp_vl_tracking_data + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" cpdId: - - cp_tracker_data - - virtualLinkProfileId: vlp_vl_tracking_mgt + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - cp_tracker_mgt - - vnfProfileId: vnfp_Ares2T_Vis - vnfdId: 51c420e3-c83d-4ce9-a5bf-0dbe339b351d - flavourId: vnf_df_Ares2T_Vis - instantiationLevel: vnf_il_Ares2T_Vis + - "cp_tracker_mgmt" + - vnfProfileId: "vnfp_Ares2T_Vis" + vnfdId: "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" + flavourId: "vnf_df_Ares2T_Vis" + instantiationLevel: "vnf_il_Ares2T_Vis" minNumberOfInstances: 1 maxNumberOfInstances: 1 nsVirtualLinkConnectivity: - - virtualLinkProfileId: vlp_vl_tracking_data + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_vis_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - cp_vis_data - - virtualLinkProfileId: vlp_vl_tracking_mgt + - "cp_vis_mgmt" + - virtualLinkProfileId: "vlp_vl_tracking_user" cpdId: - - cp_vis_mgt - - vnfProfileId: vnfp_netem - vnfdId: 396d1b6b-331b-4dd7-b48e-376517d3654a - flavourId: vnf_df_netem - instantiationLevel: vnf_il_netem + - "cp_vis_user" + - vnfProfileId: "vnfp_netem" + vnfdId: "396d1b6b-331b-4dd7-b48e-376517d3654a" + flavourId: "vnf_df_netem" + instantiationLevel: "vnf_il_netem" minNumberOfInstances: 1 maxNumberOfInstances: 1 nsVirtualLinkConnectivity: - - virtualLinkProfileId: vlp_vl_dg_out + - virtualLinkProfileId: "vlp_vl_dg_out" cpdId: - - cp_dg_traffic_out - - virtualLinkProfileId: vlp_vl_tracking_mgt + - "cp_dg_traffic_out" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" cpdId: - - cp_dg_mgt - - virtualLinkProfileId: vlp_vl_tracking_mobile + - "cp_dg_mgmt" + - virtualLinkProfileId: "vlp_vl_tracking_mobile" cpdId: - - cp_dg_traffic_in + - "cp_dg_traffic_in" virtualLinkProfile: - - virtualLinkProfileId: vlp_vl_tracking_mobile - virtualLinkDescId: vl_tracking_mobile - flavourId: df_vl_tracking_mobile + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + virtualLinkDescId: "vl_tracking_mobile" + flavourId: "df_vl_tracking_mobile" maxBitrateRequirements: - root: '1' - leaf: '1' + root: "1" + leaf: "1" minBitrateRequirements: - root: '1' - leaf: '1' - - virtualLinkProfileId: vlp_vl_tracking_data - virtualLinkDescId: vl_tracking_data - flavourId: df_vl_tracking_data + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" + virtualLinkDescId: "vl_tracking_data" + flavourId: "df_vl_tracking_data" maxBitrateRequirements: - root: '1' - leaf: '1' + root: "1" + leaf: "1" minBitrateRequirements: - root: '1' - leaf: '1' - - virtualLinkProfileId: vlp_vl_tracking_mgt - virtualLinkDescId: vl_tracking_mgt - flavourId: df_vl_tracking_mgt + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + virtualLinkDescId: "vl_tracking_mgmt" + flavourId: "df_vl_tracking_mgmt" maxBitrateRequirements: - root: '1' - leaf: '1' + root: "1" + leaf: "1" minBitrateRequirements: - root: '1' - leaf: '1' - - virtualLinkProfileId: vlp_vl_dg_out - virtualLinkDescId: vl_dg_out - flavourId: df_vl_dg_out + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" + virtualLinkDescId: "vl_tracking_user" + flavourId: "df_vl_tracking_user" maxBitrateRequirements: - root: '1' - leaf: '1' + root: "1" + leaf: "1" minBitrateRequirements: - root: '1' - leaf: '1' + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_dg_out" + virtualLinkDescId: "vl_dg_out" + flavourId: "df_vl_dg_out" + maxBitrateRequirements: + root: "1" + leaf: "1" + minBitrateRequirements: + root: "1" + leaf: "1" nsInstantiationLevel: - - nsLevelId: ns_ares2t_tracker_il_big - description: Big instantiation level for the ARES2T tracking service + - nsLevelId: "ns_ares2t_tracker_il_big" + description: "Big instantiation level for the ARES2T tracking service" vnfToLevelMapping: - - vnfProfileId: vnfp_big_Ares2T_Tracker + - vnfProfileId: "vnfp_big_Ares2T_Tracker" numberOfInstances: 1 - - vnfProfileId: vnfp_Ares2T_Vis + - vnfProfileId: "vnfp_Ares2T_Vis" numberOfInstances: 1 - - vnfProfileId: vnfp_netem + - vnfProfileId: "vnfp_netem" numberOfInstances: 1 virtualLinkToLevelMapping: - - virtualLinkProfileId: vlp_vl_tracking_mobile + - virtualLinkProfileId: "vlp_vl_tracking_mobile" bitRateRequirements: - root: '1' - leaf: '1' - - virtualLinkProfileId: vlp_vl_tracking_data + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" bitRateRequirements: - root: '1' - leaf: '1' - - virtualLinkProfileId: vlp_vl_tracking_mgt + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" bitRateRequirements: - root: '1' - leaf: '1' - - virtualLinkProfileId: vlp_vl_dg_out + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" bitRateRequirements: - root: '1' - leaf: '1' - - nsLevelId: ns_ares2t_tracker_il_small - description: Small instantiation level for the ARES2T tracking service + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_dg_out" + bitRateRequirements: + root: "1" + leaf: "1" + - nsLevelId: "ns_ares2t_tracker_il_small" + description: "Small instantiation level for the ARES2T tracking service" vnfToLevelMapping: - - vnfProfileId: vnfp_small_Ares2T_Tracker + - vnfProfileId: "vnfp_small_Ares2T_Tracker" numberOfInstances: 1 - - vnfProfileId: vnfp_Ares2T_Vis + - vnfProfileId: "vnfp_Ares2T_Vis" numberOfInstances: 1 - - vnfProfileId: vnfp_netem + - vnfProfileId: "vnfp_netem" numberOfInstances: 1 virtualLinkToLevelMapping: - - virtualLinkProfileId: vlp_vl_tracking_mobile + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_data" bitRateRequirements: - root: '1' - leaf: '1' - - virtualLinkProfileId: vlp_vl_tracking_data + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" bitRateRequirements: - root: '1' - leaf: '1' - - virtualLinkProfileId: vlp_vl_tracking_mgt + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" bitRateRequirements: - root: '1' - leaf: '1' - - virtualLinkProfileId: vlp_vl_dg_out + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_dg_out" bitRateRequirements: - root: '1' - leaf: '1' - defaultNsInstantiationLevelId: ns_ares2t_tracker_il_small - dependencies: [] + root: "1" + leaf: "1" + defaultNsInstantiationLevelId: "ns_ares2t_tracker_il_small" security: - signature: FC_NSD_SIGNATURE - algorithm: FC_NSD_ALGORITHM - certificate: FC_NSD_CERTIFICATE + signature: "FC_NSD_SIGNATURE" + algorithm: "FC_NSD_ALGORITHM" + certificate: "FC_NSD_CERTIFICATE" From 46aa185aae3b8909040e6a9091ecb76ded8a120e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 6 Apr 2020 16:53:59 +0200 Subject: [PATCH 100/187] Fix name of test Nsd --- .../resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml | 2 +- .../resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml b/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml index 6d31663..cd31cfc 100644 --- a/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml +++ b/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml @@ -3,7 +3,7 @@ - nsdIdentifier: "2dd7b5b1-9f39-4978-a035-6654d7bc9068" designer: "NXW + NSD Composer" version: "1.0" - nsdName: "ARES2T Tracker Service @ 5GEVE + Context Blueprint Background Traffic_nsd" + nsdName: "ARES2T Tracker Service @ 5GEVE + Context Blueprint Background Traffic NSD" nsdInvariantId: "d5959420-1ef7-4441-9eb9-9113172c988b" vnfdId: - "c84b227e-520e-43c0-a75e-e52781dd54dd" diff --git a/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml b/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml index f921531..ae3f83c 100644 --- a/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml +++ b/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml @@ -4,7 +4,7 @@ designer: "NXW + NSD Composer" version: "1.0" nsdName: "ARES2T Tracker Service @ 5GEVE + NETEM Traffic Delay Generator Service +\ - \ Context Blueprint Background Traffic_nsd" + \ Context Blueprint Background Traffic NSD" nsdInvariantId: "d650cb24-28c5-41ba-8541-12a9cb93238c" vnfdId: - "c84b227e-520e-43c0-a75e-e52781dd54dd" From 6d40a7582cbe3276ea034bb495ac6f96078041b5 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 20 Apr 2020 11:36:08 +0200 Subject: [PATCH 101/187] Fix log of the blueprint for NSD generator. --- .../it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index e95a644..c9f5a3d 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -57,7 +57,8 @@ public class NsdGenerator { @SneakyThrows(JsonProcessingException.class) public Nsd generate(Blueprint blueprint) throws InvalidNsdException { - log.debug(OBJECT_MAPPER.writeValueAsString(blueprint)); + log.debug("blueprint {}:\n{}", blueprint.getBlueprintId(), + OBJECT_MAPPER.writeValueAsString(blueprint)); Nsd nsd = new Nsd(); nsd.setNsdIdentifier(blueprint.getBlueprintId() + "_nsd"); From 6ef47858af5083b13fbeaaaea3d224d3163a3f65 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 20 Apr 2020 11:37:36 +0200 Subject: [PATCH 102/187] optimize import for NsdComposerTest --- .../it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java index fa6f1d9..89c15cc 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -18,7 +18,6 @@ import java.util.Arrays; import java.util.Optional; import java.util.Properties; -import java.util.UUID; import lombok.SneakyThrows; import org.junit.BeforeClass; import org.junit.Test; @@ -205,6 +204,7 @@ public void composeTrackerWithBackgroundConnect() { assertEquals(oM.writeValueAsString(expNsd), oM.writeValueAsString(vsbNsd)); } + @Test @SneakyThrows public void composeTrackerWithBackgroundAndDelay() { From e016de6cd71c93c28884a7213df2486e77f53a0a Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 15:58:42 +0200 Subject: [PATCH 103/187] Change default port to 8086 --- src/main/resources/application.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c2eac03..8eb6524 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,4 @@ +server.port=8086 spring.profiles.active=prod spring.output.ansi.enabled=always springdoc.api-docs.path=/api-docs From e01cdef10227340faacfc985bd45853c2f21925f Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 16:24:41 +0200 Subject: [PATCH 104/187] Use CompositionStrategy from NXW library. Update controller. --- .../composer/rest/CompositionStrategy.java | 6 ------ .../composer/rest/ExperimentsController.java | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 15 deletions(-) delete mode 100644 src/main/java/it/cnit/blueprint/composer/rest/CompositionStrategy.java diff --git a/src/main/java/it/cnit/blueprint/composer/rest/CompositionStrategy.java b/src/main/java/it/cnit/blueprint/composer/rest/CompositionStrategy.java deleted file mode 100644 index f2f21c4..0000000 --- a/src/main/java/it/cnit/blueprint/composer/rest/CompositionStrategy.java +++ /dev/null @@ -1,6 +0,0 @@ -package it.cnit.blueprint.composer.rest; - -public enum CompositionStrategy { - PASS_THROUGH, - CONNECT -} diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 407ef2f..82fb10b 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -4,6 +4,7 @@ import it.cnit.blueprint.composer.rules.InvalidTranslationRuleException; import it.cnit.blueprint.composer.rules.TranslationRulesComposer; import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.CompositionStrategy; import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; @@ -27,9 +28,6 @@ @AllArgsConstructor public class ExperimentsController { - // TODO Composition Strategy comes from CtxB - private static CompositionStrategy STRAT = CompositionStrategy.CONNECT; - @Qualifier("PASS_THROUGH") private NsdComposer passThroughComposer; @Qualifier("CONNECT") @@ -59,18 +57,20 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ // - The Ctx has only 1 Nsd. Nsd ctxNsd = ctx.getCtxbRequest().getNsds().get(0); CtxBlueprint ctxB = ctx.getCtxbRequest().getCtxBlueprint(); + + log.info("Current CtxB: {}", ctxB.getBlueprintId()); + if (ctx.getConnectInput() == null) { ctx.setConnectInput(new ConnectInput()); } - NsVirtualLinkDesc expMgmtVld = findMgmtVld(ctxB, ctxNsd); NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); - if (STRAT.equals(CompositionStrategy.CONNECT)) { - log.info("connect"); + if (ctxB.getCompositionStrategy().equals(CompositionStrategy.CONNECT)) { + log.info("Strategy is CONNECT"); connectComposer .compose(ctx.getConnectInput(), ranVld, expMgmtVld, expNsd, ctxMgmtVld, ctxNsd); - } else if (STRAT.equals(CompositionStrategy.PASS_THROUGH)) { - log.info("pass_through"); + } else if (ctxB.getCompositionStrategy().equals(CompositionStrategy.PASS_THROUGH)) { + log.info("Strategy is PASS_THROUGH"); if (ctxNsd.getVnfdId().size() == 1) { log.debug("ctxNsd has only one vnfdId."); } else { @@ -79,7 +79,8 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ passThroughComposer .compose(ctx.getConnectInput(), ranVld, expMgmtVld, expNsd, ctxMgmtVld, ctxNsd); } else { - String m = MessageFormatter.format("Composition strategy {} not supported.", STRAT) + String m = MessageFormatter.format("Composition strategy {} not supported.", + ctxB.getCompositionStrategy().name()) .getMessage(); log.error(m); throw new InvalidContextException(m); From 8f5212318b0979d310f60eb48b3a79e026382e2b Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 16:51:01 +0200 Subject: [PATCH 105/187] Use isManagement() in connectivity service t ofind mgmt Vld. --- .../composer/rest/ExperimentsController.java | 26 +++++++++++++++---- .../composer/rest/InvalidVsbException.java | 8 ++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/composer/rest/InvalidVsbException.java diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 82fb10b..646517b 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -7,12 +7,14 @@ import it.nextworks.nfvmano.catalogue.blueprint.elements.CompositionStrategy; import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbLink; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardExpBlueprintRequest; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; import java.util.List; +import java.util.Optional; import java.util.UUID; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -87,7 +89,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ } } - } catch (InvalidNsdException | InvalidContextException e) { + } catch (InvalidVsbException | InvalidNsdException | InvalidContextException e) { log.error(e.getMessage()); //TODO create and return a 422 response. } @@ -122,9 +124,23 @@ private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsdExce return connectComposer.getRanVlDesc(ranSapd, nsd); } - private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) { - // TODO Visit vlDesc in nsd and check if mgmt in connectivityServices of b. - // We need model modifications to make this work. - return new NsVirtualLinkDesc(); + private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) + throws InvalidVsbException, InvalidNsdException { + Optional optConnServ = b.getConnectivityServices().stream() + .filter(VsbLink::isManagement) + .findFirst(); + if (optConnServ.isPresent()) { + String name = optConnServ.get().getName(); + Optional optVld = nsd.getVirtualLinkDesc().stream() + .filter(vld -> vld.getVirtualLinkDescId().equals(name)) + .findFirst(); + if (optVld.isPresent()) { + return optVld.get(); + } else { + throw new InvalidNsdException("Management Vld with id=" + name + "not found in NSD."); + } + } else { + throw new InvalidVsbException("No management connectivity service found in VSB."); + } } } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/InvalidVsbException.java b/src/main/java/it/cnit/blueprint/composer/rest/InvalidVsbException.java new file mode 100644 index 0000000..6d41ad7 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/InvalidVsbException.java @@ -0,0 +1,8 @@ +package it.cnit.blueprint.composer.rest; + +public class InvalidVsbException extends Exception { + + public InvalidVsbException(String message) { + super(message); + } +} From 881eb150101b16a1399fe993301f1a2128bddf80 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 17:03:29 +0200 Subject: [PATCH 106/187] Fix findRanVld method. Improve error messages. --- .../composer/rest/ExperimentsController.java | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 646517b..901cd00 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -105,23 +105,25 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ return new ComposeResponse(expNsd, translationRules); } - private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsdException { - Sapd ranSapd = null; - for (VsbEndpoint e : b.getEndPoints()) { - if (e.isRanConnection()) { - for (Sapd sapd : nsd.getSapd()) { - if (e.getEndPointId().equals(sapd.getCpdId())) { - ranSapd = sapd; - break; - } - } + private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) + throws InvalidNsdException, InvalidVsbException { + Optional ranEp = b.getEndPoints().stream() + .filter(VsbEndpoint::isRanConnection) + .findFirst(); + if (ranEp.isPresent()) { + String epId = ranEp.get().getEndPointId(); + Optional ranSapd = nsd.getSapd().stream() + .filter(sapd -> sapd.getCpdId().equals(epId)) + .findFirst(); + if (ranSapd.isPresent()) { + return connectComposer.getRanVlDesc(ranSapd.get(), nsd); + } else { + throw new InvalidNsdException( + "RAN Sap with id=" + epId + "not found in NSD " + nsd.getNsdIdentifier() + "."); } + } else { + throw new InvalidVsbException("No RAN endpoint found in VSB " + b.getBlueprintId() + "."); } - if (ranSapd == null) { - // TODO think of a better message - throw new InvalidNsdException("Cannot find a Sap descriptor for RAN."); - } - return connectComposer.getRanVlDesc(ranSapd, nsd); } private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) @@ -137,10 +139,12 @@ private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) if (optVld.isPresent()) { return optVld.get(); } else { - throw new InvalidNsdException("Management Vld with id=" + name + "not found in NSD."); + throw new InvalidNsdException( + "Management Vld with id=" + name + "not found in NSD " + nsd.getNsdIdentifier() + "."); } } else { - throw new InvalidVsbException("No management connectivity service found in VSB."); + throw new InvalidVsbException( + "No management connectivity service found in VSB " + b.getBlueprintId() + "."); } } } From 2dbef0e70715775c206d8352e293a49fd2b1c4ad Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 17:05:35 +0200 Subject: [PATCH 107/187] Make beans final in ExperimentsController. --- .../cnit/blueprint/composer/rest/ExperimentsController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 901cd00..ecac440 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -31,11 +31,11 @@ public class ExperimentsController { @Qualifier("PASS_THROUGH") - private NsdComposer passThroughComposer; + private final NsdComposer passThroughComposer; @Qualifier("CONNECT") - private NsdComposer connectComposer; + private final NsdComposer connectComposer; - private TranslationRulesComposer translationRulesComposer; + private final TranslationRulesComposer translationRulesComposer; @GetMapping("/experiments") public OnboardExpBlueprintRequest retrieveExperiment() { From e01827ff05fee29673f8b9129d09fb53c17d89a7 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 17:15:42 +0200 Subject: [PATCH 108/187] Using connectivty service name in NsdGenerator. --- .../cnit/blueprint/composer/nsd/generate/NsdGenerator.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index c9f5a3d..a368910 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -80,14 +80,11 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { nsLevel.setNsLevelId(blueprint.getBlueprintId() + "_il_default"); nsLevel.setDescription("Default Instantiation Level"); - int vldCount = 0; for (VsbLink connService : blueprint.getConnectivityServices()) { NsVirtualLinkDesc vld = new NsVirtualLinkDesc(); -// TODO vld.setVirtualLinkDescId(connService.getName()); - vld.setVirtualLinkDescId("vld_" + vldCount); + vld.setVirtualLinkDescId(connService.getName()); vld.setVirtualLinkDescProvider(nsd.getDesigner()); vld.setVirtuaLinkDescVersion(nsd.getVersion()); - vld.setDescription(vld.getVirtualLinkDescId()); vld.setConnectivityType(new ConnectivityType(LayerProtocol.IPV4, "")); VirtualLinkDf vldf = new VirtualLinkDf(); vldf.setFlavourId(vld.getVirtualLinkDescId() + "_df"); @@ -107,8 +104,6 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { vlMap.setVirtualLinkProfileId(vlp.getVirtualLinkProfileId()); vlMap.setBitRateRequirements(new LinkBitrateRequirements("1", "1")); nsLevel.getVirtualLinkToLevelMapping().add(vlMap); - - vldCount++; } List sapdList = new ArrayList<>(); From fb29353893794c133573341794421784b5a0649f Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 17:16:20 +0200 Subject: [PATCH 109/187] Make bean final in NsdGenerator. --- .../it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index a368910..c53d702 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -52,7 +52,7 @@ public class NsdGenerator { protected static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory()); - private NsdGraphService nsdGraphService; + private final NsdGraphService nsdGraphService; @SneakyThrows(JsonProcessingException.class) public Nsd generate(Blueprint blueprint) throws InvalidNsdException { From 4e8ba5a74899efe79883651bdc3a4139eb32620e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 17:29:34 +0200 Subject: [PATCH 110/187] Use connectivity service name in NsdGenerator. --- .../composer/nsd/generate/NsdGenerator.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index c53d702..b6e76fa 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -111,20 +111,16 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { if (e.isExternal() && e.getEndPointId().contains("sap")) { Sapd sapd = new Sapd(); sapd.setCpdId(e.getEndPointId()); - sapd.setDescription("A generated Sapd"); sapd.setLayerProtocol(LayerProtocol.IPV4); - sapd.setCpRole(CpRole.ROOT); // TODO meaning of this? + sapd.setCpRole(CpRole.ROOT); sapd.setSapAddressAssignment(false); - int count = 0; for (VsbLink cs : blueprint.getConnectivityServices()) { for (String ep : cs.getEndPointIds()) { if (ep.equals(sapd.getCpdId())) { - // TODO change this when connectivity service has a name - sapd.setNsVirtualLinkDescId("vld_" + count); + cs.getName(); break; } } - count++; } AddressData addressData = new AddressData(); addressData.setAddressType(AddressType.IP_ADDRESS); @@ -150,13 +146,11 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { vnfp.setMaxNumberOfInstances(1); List nsVirtualLinkConnectivities = new ArrayList<>(); for (String ep : vsc.getEndPointsIds()) { - int count = 0; for (VsbLink cs : blueprint.getConnectivityServices()) { for (String csEp : cs.getEndPointIds()) { if (csEp.equals(ep)) { NsVirtualLinkConnectivity nsVLC = new NsVirtualLinkConnectivity(); - // TODO change this when connectivity service has a name - String vldId = "vld_" + count; + String vldId = cs.getName(); Optional optVlp = nsDf.getVirtualLinkProfile().stream() .filter(vlp -> vlp.getVirtualLinkDescId().equals(vldId)).findFirst(); if (optVlp.isPresent()) { @@ -166,7 +160,6 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { } } } - count++; } } vnfp.setNsVirtualLinkConnectivity(nsVirtualLinkConnectivities); From f508d00867842745e640b602bfcd4223f883b633 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 17:39:13 +0200 Subject: [PATCH 111/187] Use a simpler Dockerfile. --- Dockerfile | 56 ++++++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/Dockerfile b/Dockerfile index a4412d7..3a78074 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,42 +1,14 @@ -FROM azul/zulu-openjdk-alpine:8 as copy - -# Copy files -#COPY target/lib /usr/share/myservice/lib -RUN mkdir /5geve-experiment-builder -ARG JAR_FILE -ENV JAR_FILE=${JAR_FILE} -COPY target/${JAR_FILE} /5geve-experiment-builder -WORKDIR /5geve-experiment-builder - - -FROM copy as dev - -LABEL target=DEV - -# Enable remote debugger -EXPOSE 5005 -ENV JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" - -CMD java -jar ${JAR_FILE} - - -FROM copy as prod - -LABEL maintainer="Matteo Pergolesi" -LABEL org.label-schema.schema-version="1.0" -ARG BUILD_DATE -LABEL org.label-schema.build-date=$BUILD_DATE -ARG REPOSITORY -LABEL org.label-schema.name=$REPOSITORY -ARG DESCRIPTION -LABEL org.label-schema.description=$DESCRIPTION -ARG VERSION -LABEL org.label-schema.version=$VERSION -ARG VCS_URL -LABEL org.label-schema.vcs-url=$VCS_URL -ARG VCS_REF -LABEL org.label-schema.vcs-ref=$VCS_REF -ARG COMMAND -LABEL org.label-schema.docker.cmd=$COMMAND - -CMD java -jar ${JAR_FILE} +FROM maven:3.6.3-jdk-8 as mvn-build +# speed up Maven JVM a bit +ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xmx4G" +WORKDIR /usr/src/mymaven +# Copy pom.xml and download all dependencies for offline use +COPY pom.xml pom.xml +RUN mvn -T 1C verify clean --fail-never +# Copy code +COPY ./src ./src +RUN mvn -T 1C verify + +FROM azul/zulu-openjdk-alpine:8-jre +COPY --from=mvn-build /usr/src/mymaven/target/*.jar /app.jar +CMD java -jar app.jar From 36924fe6064f5d258a32ae76fa5709941474cbd0 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 17:39:31 +0200 Subject: [PATCH 112/187] Remove docker plugin and others. --- pom.xml | 104 -------------------------------------------------------- 1 file changed, 104 deletions(-) diff --git a/pom.xml b/pom.xml index 45d9730..1d61b91 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,6 @@ composer 0.0.2-SNAPSHOT A REST API module to compose NSDs. - docker-build UTF-8 @@ -128,88 +127,8 @@ - - - - dev - - true - - - - - io.fabric8 - docker-maven-plugin - - - - expbuilder-dev - ${docker.repository}/${project.name}:${project.version} - - ${project.basedir} - - ${project.build.finalName}.jar - - - dev - - - - - - - - - - - prod - - - - io.fabric8 - docker-maven-plugin - - - - expbuilder-prod - ${docker.repository}/${project.name}:${project.version} - - ${project.basedir} - - ${project.build.finalName}.jar - - ${maven.build.timestamp} - ${project.name} - ${project.description} - ${project.version} - - ${git.remote.origin.url} - - ${git.commit.id} - java -jar ${project.build.finalName}.jar - - - prod - - - - - - - - pl.project13.maven - git-commit-id-plugin - - true - - - - - - - @@ -272,29 +191,6 @@ maven-project-info-reports-plugin 3.0.0 - - - io.fabric8 - docker-maven-plugin - 0.28.0 - true - - - pl.project13.maven - git-commit-id-plugin - 2.2.5 - - - get-the-git-infos - - revision - - - initialize - - - From e4caaf951c49bc9530e2b2706544fcda413c80c1 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 17:44:20 +0200 Subject: [PATCH 113/187] Remove maven compile from Dockerfile since we have local deps. --- Dockerfile | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3a78074..610075d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,4 @@ -FROM maven:3.6.3-jdk-8 as mvn-build -# speed up Maven JVM a bit -ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xmx4G" -WORKDIR /usr/src/mymaven -# Copy pom.xml and download all dependencies for offline use -COPY pom.xml pom.xml -RUN mvn -T 1C verify clean --fail-never -# Copy code -COPY ./src ./src -RUN mvn -T 1C verify - FROM azul/zulu-openjdk-alpine:8-jre -COPY --from=mvn-build /usr/src/mymaven/target/*.jar /app.jar +# TODO check +COPY ./target/*.jar /app.jar CMD java -jar app.jar From 5e635f8c84590832370c4e23efeab343f1ecb46e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 17:48:58 +0200 Subject: [PATCH 114/187] Complete docker cleanup. --- .maven-dockerignore | 0 .maven-dockerinclude | 2 -- pom.xml | 1 - 3 files changed, 3 deletions(-) delete mode 100644 .maven-dockerignore delete mode 100644 .maven-dockerinclude diff --git a/.maven-dockerignore b/.maven-dockerignore deleted file mode 100644 index e69de29..0000000 diff --git a/.maven-dockerinclude b/.maven-dockerinclude deleted file mode 100644 index d1391ce..0000000 --- a/.maven-dockerinclude +++ /dev/null @@ -1,2 +0,0 @@ -Dockerfile -target/** diff --git a/pom.xml b/pom.xml index 1d61b91..fa0a886 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,6 @@ UTF-8 8 8 - mpergolesi 1.3.0 From 813840a0af40f30fe19bf04946efa3373cd0c1d9 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 18:01:49 +0200 Subject: [PATCH 115/187] Add docker-compose --- docker-compose.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..54440fb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: '3.7' +services: + exp-nsd-composer: + build: + context: . + container_name: exp-nsd-composer + ports: + - 8086:8086 From 20bd7c315454d6a1050803d090c76a6d2421b2a2 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 21 Apr 2020 18:02:00 +0200 Subject: [PATCH 116/187] simplify README. Install instructions. --- README.md | 66 ++++++++++--------------------------------------------- 1 file changed, 11 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 9e186f9..5f5f1ce 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,27 @@ -# 5G EVE Experment NSD composer +# 5G EVE Experiment NSD composer A REST API module to compose the NSD of a VSB and multiple CBs. -The project is designed to be deployed with Docker. -Check the pom.xml for details about plugins to ease docker image build. -## Developer guide +## Install -After cloning the repository you can create Docker images to debug the software. +Some dependencies are not available in Maven repository. Check [pom.xml]. -To build a developer image with Maven, use the following (provides Java remote debugger). +Compile the project with: ``` -mvn clean package docker:build -P dev +mvn clean package ``` -To build a developer image with Dockerfile, use the following (provides Java remote debugger). -JAR file must be compiled manually and passed as an argument. +We use Docker Compose for deployment. Run: ``` -docker build \ - --tag mpergolesi/5geve-experiment-builder: \ - --target dev \ - --build-arg JAR_FILE=5geve-experiment-builder-.jar +docker pull azul/zulu-openjdk-alpine:8-jre +docker-compose build +docker-compose up ``` -To debug the app, create a running configuration in IDEA or Eclipse to connect your Java debugger -to `localhost:5005` . +## Graph export for visualization -To run the Docker container with Maven, use the following (this will automatically run the debugger -in IDEA): - -``` -mvn docker:run -P dev -``` - -To run the Docker container with plain Docker, use the following (substitute the image tag with your version): - -``` -docker run -it --rm -p 5005:5005 mpergolesi/5geve-experiment-builder:0.0.1-SNAPSHOT -``` - -### Graph export for visualization - -`VsbGraph` and `NsdGraph` provide methods to export graphs to graphviz format. +Debug log often provides network topology export into graphviz format. Running tests will produce output examples. Copy the output to a text file called 'example.txt' and create a PNG with @@ -51,27 +31,3 @@ circo -Tpng example.txt -o example.png Or copy the output to an online Graphviz editor like [Edotor](https://edotor.net/). -## User guide (release) - -To build a production image with Maven, use the following (provides labels for the Docker image). - -``` -mvn clean package docker:build -P prod -``` - -To build a production image with Dockerfile, use the following (you can optionally setup labels as build-args). -JAR file must be compiled manually and passed as an argument. - -``` -docker build \ - --tag mpergolesi/5geve-experiment-builder: \ - --target prod \ - --build-arg JAR_FILE=5geve-experiment-builder-.jar \ - --build-arg BUILD_DATE= \ - --build-arg REPOSITORY=mpergolesi \ - --build-arg DESCRIPTION="A REST API module to compose VSD and CDs." \ - --build-arg VERSION= \ - --build-arg VCS_URL= \ - --build-arg VCS_REF= \ - --build-arg COMMAND= -``` From 6df36df13ee4936ba85af71764b4def85cfe1bf2 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 22 Apr 2020 18:10:51 +0200 Subject: [PATCH 117/187] Add URL for ctx.delay blueprint. --- src/test/resources/url.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/resources/url.properties b/src/test/resources/url.properties index b3754d3..7dbd33f 100644 --- a/src/test/resources/url.properties +++ b/src/test/resources/url.properties @@ -1,5 +1,6 @@ vsb.tracker=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker.yaml vsb.tracker.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker_nsds.yaml +ctx.delay=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay.yaml ctx.delay.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay_nsds.yaml ctx.bg_traffic=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic.yaml ctx.bg_traffic.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic_nsds.yaml From 40e67272db1e9ffb076ef142268b7eeb0cbfaccc Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 22 Apr 2020 18:29:51 +0200 Subject: [PATCH 118/187] Fix bug in sapd generation. Move debug log before validation. --- .../cnit/blueprint/composer/nsd/generate/NsdGenerator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index b6e76fa..a64dbeb 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -117,7 +117,7 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { for (VsbLink cs : blueprint.getConnectivityServices()) { for (String ep : cs.getEndPointIds()) { if (ep.equals(sapd.getCpdId())) { - cs.getName(); + sapd.setNsVirtualLinkDescId(cs.getName()); break; } } @@ -171,6 +171,9 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { nsDf.setDefaultNsInstantiationLevelId(nsLevel.getNsLevelId()); nsd.setNsDf(Collections.singletonList(nsDf)); + log.debug("Nsd AFTER generation with {}:\n{}", + nsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(nsd)); + // Nsd validation and logging try { nsd.isValid(); @@ -179,8 +182,6 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { log.error(m, e); throw new InvalidNsdException(m); } - log.debug("Nsd AFTER generation with {}:\n{}", - nsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(nsd)); Graph g = nsdGraphService.buildGraph(nsd.getSapd(), nsDf, nsLevel); log.debug("Graph AFTER generation with {}:\n{}", From 5c5013a2db63a467a99ea28d07a7a845cbd27c0c Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Thu, 23 Apr 2020 12:07:58 +0200 Subject: [PATCH 119/187] Use mindist=0.5 for more compact graphs. --- .../it/cnit/blueprint/composer/nsd/graph/GraphVizExporter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphVizExporter.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphVizExporter.java index 3ea49a3..680882b 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphVizExporter.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphVizExporter.java @@ -47,7 +47,7 @@ public String export(Graph g) { vertexLabelProvider, new StringComponentNameProvider<>(), vertexAttributeProvider, null); exporter.putGraphAttribute("splines", "false"); exporter.putGraphAttribute("overlap", "false"); - exporter.putGraphAttribute("mindist", "2.0"); + exporter.putGraphAttribute("mindist", "0.5"); Writer writer = new StringWriter(); exporter.exportGraph(g, writer); return writer.toString(); From 90b658adfb83ec6a58f88bf5d54605df6589b728 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 27 Apr 2020 11:46:54 +0200 Subject: [PATCH 120/187] Change mindist value in dot files for tests. --- src/test/resources/ns_ares2t_tracker_exp_il_big.dot | 2 +- src/test/resources/ns_ares2t_tracker_exp_il_small.dot | 2 +- src/test/resources/ns_ares2t_tracker_il_big.dot | 2 +- src/test/resources/ns_ares2t_tracker_il_small.dot | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/resources/ns_ares2t_tracker_exp_il_big.dot b/src/test/resources/ns_ares2t_tracker_exp_il_big.dot index 7e551f5..bb39a8d 100644 --- a/src/test/resources/ns_ares2t_tracker_exp_il_big.dot +++ b/src/test/resources/ns_ares2t_tracker_exp_il_big.dot @@ -1,7 +1,7 @@ strict graph G { splines=false; overlap=false; - mindist=2.0; + mindist=0.5; 304837012 [ label="vnfp_big_Ares2T_Tracker_exp" shape="box" style="filled" fillcolor="yellowgreen" ]; 1392640733 [ label="vnfp_Ares2T_Vis_exp" shape="box" style="filled" fillcolor="yellowgreen" ]; -793362586 [ label="vnfp_netem_exp" shape="box" style="filled" fillcolor="yellowgreen" ]; diff --git a/src/test/resources/ns_ares2t_tracker_exp_il_small.dot b/src/test/resources/ns_ares2t_tracker_exp_il_small.dot index d5af086..0edb4f1 100644 --- a/src/test/resources/ns_ares2t_tracker_exp_il_small.dot +++ b/src/test/resources/ns_ares2t_tracker_exp_il_small.dot @@ -1,7 +1,7 @@ strict graph G { splines=false; overlap=false; - mindist=2.0; + mindist=0.5; -1874275603 [ label="vnfp_small_Ares2T_Tracker_exp" shape="box" style="filled" fillcolor="yellowgreen" ]; 1392640733 [ label="vnfp_Ares2T_Vis_exp" shape="box" style="filled" fillcolor="yellowgreen" ]; -793362586 [ label="vnfp_netem_exp" shape="box" style="filled" fillcolor="yellowgreen" ]; diff --git a/src/test/resources/ns_ares2t_tracker_il_big.dot b/src/test/resources/ns_ares2t_tracker_il_big.dot index 923da01..214330e 100644 --- a/src/test/resources/ns_ares2t_tracker_il_big.dot +++ b/src/test/resources/ns_ares2t_tracker_il_big.dot @@ -1,7 +1,7 @@ strict graph G { splines=false; overlap=false; - mindist=2.0; + mindist=0.5; -1503706314 [ label="vnfp_big_Ares2T_Tracker" shape="box" style="filled" fillcolor="yellowgreen" ]; 1169940735 [ label="vnfp_Ares2T_Vis" shape="box" style="filled" fillcolor="yellowgreen" ]; 1228317574 [ label="vlp_vl_tracking_mobile" shape="oval" style="filled" fillcolor="dodgerblue" ]; diff --git a/src/test/resources/ns_ares2t_tracker_il_small.dot b/src/test/resources/ns_ares2t_tracker_il_small.dot index 6dee665..4272c09 100644 --- a/src/test/resources/ns_ares2t_tracker_il_small.dot +++ b/src/test/resources/ns_ares2t_tracker_il_small.dot @@ -1,7 +1,7 @@ strict graph G { splines=false; overlap=false; - mindist=2.0; + mindist=0.5; 2056075535 [ label="vnfp_small_Ares2T_Tracker" shape="box" style="filled" fillcolor="yellowgreen" ]; 1169940735 [ label="vnfp_Ares2T_Vis" shape="box" style="filled" fillcolor="yellowgreen" ]; 1228317574 [ label="vlp_vl_tracking_mobile" shape="oval" style="filled" fillcolor="dodgerblue" ]; From 9b7d0f8094f4a40dffbd798ee8d331edeed1e349 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 27 Apr 2020 11:53:07 +0200 Subject: [PATCH 121/187] Use same names as blueprint-yaml repo in url.properties. Fix tests. --- .../composer/nsd/compose/NsdComposerTest.java | 18 +++++++++--------- .../nsd/generate/NsdGeneratorTest.java | 8 ++++---- .../nsd/graph/NsdGraphServiceTest.java | 12 ++++++------ src/test/resources/url.properties | 18 ++++++++++-------- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java index 89c15cc..a930a0b 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -48,7 +48,7 @@ public static void setUp() { public void composeTrackerWithDelayPassThrough() { // Given - Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; NsVirtualLinkDesc ranVld; Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) @@ -67,7 +67,7 @@ public void composeTrackerWithDelayPassThrough() { throw new Exception(); } Nsd ctxNsd = Arrays - .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); + .asList(oM.readValue(new URL(urlProp.getProperty("ctx_delay_nsds")), Nsd[].class)).get(0); NsVirtualLinkDesc ctxMgmtVld; Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgmt")).findFirst(); @@ -97,7 +97,7 @@ public void composeTrackerWithDelayPassThrough() { public void composeTrackerWithDelayConnect() { // Given - Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; NsVirtualLinkDesc ranVld; Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) @@ -116,7 +116,7 @@ public void composeTrackerWithDelayConnect() { throw new Exception(); } Nsd ctxNsd = Arrays - .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); + .asList(oM.readValue(new URL(urlProp.getProperty("ctx_delay_nsds")), Nsd[].class)).get(0); // Add twice the vnfd to fake the connect algorithm TODO use a real CONNECT ctx // ctxNsd.getVnfdId().add(ctxNsd.getVnfdId().get(0)); VnfProfile ctxVnfp = ctxNsd.getNsDf().get(0).getVnfProfile().get(0); @@ -160,7 +160,7 @@ public void composeTrackerWithDelayConnect() { @SneakyThrows public void composeTrackerWithBackgroundConnect() { // Given - Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; NsVirtualLinkDesc ranVld; Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) @@ -179,7 +179,7 @@ public void composeTrackerWithBackgroundConnect() { throw new Exception(); } Nsd ctxNsd = Arrays - .asList(oM.readValue(new URL(urlProp.getProperty("ctx.bg_traffic.nsds")), Nsd[].class)) + .asList(oM.readValue(new URL(urlProp.getProperty("ctx_bg_traffic_nsds")), Nsd[].class)) .get(0); NsVirtualLinkDesc ctxMgmtVld; Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() @@ -210,7 +210,7 @@ public void composeTrackerWithBackgroundConnect() { public void composeTrackerWithBackgroundAndDelay() { // Given - Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; NsVirtualLinkDesc ranVld; Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) @@ -229,7 +229,7 @@ public void composeTrackerWithBackgroundAndDelay() { throw new Exception(); } Nsd delayNsd = Arrays - .asList(oM.readValue(new URL(urlProp.getProperty("ctx.delay.nsds")), Nsd[].class)).get(0); + .asList(oM.readValue(new URL(urlProp.getProperty("ctx_delay_nsds")), Nsd[].class)).get(0); NsVirtualLinkDesc delayMgmtVld; Optional optCtxVld = delayNsd.getVirtualLinkDesc().stream() .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgmt")).findFirst(); @@ -239,7 +239,7 @@ public void composeTrackerWithBackgroundAndDelay() { throw new Exception(); } Nsd bgNsd = Arrays - .asList(oM.readValue(new URL(urlProp.getProperty("ctx.bg_traffic.nsds")), Nsd[].class)) + .asList(oM.readValue(new URL(urlProp.getProperty("ctx_bg_traffic_nsds")), Nsd[].class)) .get(0); NsVirtualLinkDesc bgMgmtVld; optCtxVld = bgNsd.getVirtualLinkDesc().stream() diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java index d2ca829..7d69685 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java @@ -42,7 +42,7 @@ public static void setUp() { public void generateTracker() { // Given - VsBlueprint vsb = oM.readValue(new URL(urlProp.getProperty("vsb.tracker")), VsBlueprint.class); + VsBlueprint vsb = oM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker")), VsBlueprint.class); //When Nsd vsbNsd = nsdGenerator.generate(vsb); @@ -57,7 +57,7 @@ public void generateTracker() { public void generateV360() { // Given - VsBlueprint vsb = oM.readValue(new URL(urlProp.getProperty("vsb.v360")), VsBlueprint.class); + VsBlueprint vsb = oM.readValue(new URL(urlProp.getProperty("vsb_orange_v360")), VsBlueprint.class); //When Nsd vsbNsd = nsdGenerator.generate(vsb); @@ -73,14 +73,14 @@ public void generateBgTrafficCtxB() { // Given CtxBlueprint ctxB = oM - .readValue(new URL(urlProp.getProperty("ctx.bg_traffic")), CtxBlueprint.class); + .readValue(new URL(urlProp.getProperty("ctx_bg_traffic")), CtxBlueprint.class); //When Nsd actual = nsdGenerator.generate(ctxB); //Then Nsd expected = oM - .readValue(new URL(urlProp.getProperty("ctx.bg_traffic.nsds")), Nsd[].class)[0]; + .readValue(new URL(urlProp.getProperty("ctx_bg_traffic_nsds")), Nsd[].class)[0]; assertEquals(oM.writeValueAsString(expected), oM.writeValueAsString(actual)); } diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java index 1e591a6..0e9b1fc 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphServiceTest.java @@ -42,7 +42,7 @@ public static void setUp() { @SneakyThrows public void buildGraphAres2TTrackerBig() { // Given - Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; String nsLevel = "ns_ares2t_tracker_il_big"; // When @@ -65,7 +65,7 @@ public void buildGraphAres2TTrackerBig() { @SneakyThrows public void buildGraphAres2TTrackerSmall() { // Given - Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; String nsLevel = "ns_ares2t_tracker_il_small"; // When @@ -88,7 +88,7 @@ public void buildGraphAres2TTrackerSmall() { @SneakyThrows public void buildGraphAres2TDelayExperimentBig() { // Given - Nsd nsd = oM.readValue(new URL(prop.getProperty("expb.tracker.delay.nsds")), Nsd[].class)[0]; + Nsd nsd = oM.readValue(new URL(prop.getProperty("expb_ares2t_tracker_delay_nsds")), Nsd[].class)[0]; String nsLevel = "ns_ares2t_tracker_exp_il_big"; // When @@ -111,7 +111,7 @@ public void buildGraphAres2TDelayExperimentBig() { @SneakyThrows public void buildGraphAres2TDelayExperimentSmall() { // Given - Nsd nsd = oM.readValue(new URL(prop.getProperty("expb.tracker.delay.nsds")), Nsd[].class)[0]; + Nsd nsd = oM.readValue(new URL(prop.getProperty("expb_ares2t_tracker_delay_nsds")), Nsd[].class)[0]; String nsLevel = "ns_ares2t_tracker_exp_il_small"; // When @@ -135,7 +135,7 @@ public void buildGraphAres2TDelayExperimentSmall() { public void isConnectedAres2TTrackerSmallTest() { // Given - Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; String nsLevel = "ns_ares2t_tracker_il_small"; // When @@ -151,7 +151,7 @@ public void isConnectedAres2TTrackerSmallTest() { public void isNotConnectedAres2TTrackerSmallTest() { // Given - Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb.tracker.nsds")), Nsd[].class)[0]; + Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; String nsLevel = "ns_ares2t_tracker_il_small"; // When diff --git a/src/test/resources/url.properties b/src/test/resources/url.properties index 7dbd33f..d1b0ca8 100644 --- a/src/test/resources/url.properties +++ b/src/test/resources/url.properties @@ -1,9 +1,11 @@ -vsb.tracker=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker.yaml -vsb.tracker.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker_nsds.yaml -ctx.delay=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay.yaml -ctx.delay.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay_nsds.yaml -ctx.bg_traffic=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic.yaml -ctx.bg_traffic.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic_nsds.yaml -expb.tracker.delay.nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/expb/expb_ares2t_tracker_delay/expb_ares2t_tracker_delay_nsds.yaml +vsb_ares2t_tracker=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker.yaml +vsb_ares2t_tracker_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker_nsds.yaml +expb_ares2t_tracker_delay_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/expb/expb_ares2t_tracker_delay/expb_ares2t_tracker_delay_nsds.yaml -vsb.v360=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_orange_v360/vsb_V360.yml +ctx_delay=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay.yaml +ctx_delay_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay_nsds.yaml + +ctx_bg_traffic=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic.yaml +ctx_bg_traffic_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic_nsds.yaml + +vsb_orange_v360=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_orange_v360/vsb_V360.yml From 59f92fa951eaba1848e3d87bc8a301a38d583777 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 28 Apr 2020 18:15:26 +0200 Subject: [PATCH 122/187] Add test to generate vsb polito smartcity. Remove V360 test. --- .../nsd/generate/NsdGeneratorTest.java | 27 +++++-------------- src/test/resources/url.properties | 5 ++-- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java index 7d69685..305eb38 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java @@ -39,32 +39,19 @@ public static void setUp() { @Test @SneakyThrows - public void generateTracker() { + public void generateVsbPolitoSmartCity() { // Given - VsBlueprint vsb = oM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker")), VsBlueprint.class); + VsBlueprint vsb = oM + .readValue(new URL(urlProp.getProperty("vsb_polito_smartcity")), VsBlueprint.class); //When - Nsd vsbNsd = nsdGenerator.generate(vsb); + Nsd actualNsd = nsdGenerator.generate(vsb); //Then - //TODO - - } - - @Test - @SneakyThrows - public void generateV360() { - - // Given - VsBlueprint vsb = oM.readValue(new URL(urlProp.getProperty("vsb_orange_v360")), VsBlueprint.class); - - //When - Nsd vsbNsd = nsdGenerator.generate(vsb); - - //Then - //TODO - + Nsd expectedNsd = oM + .readValue(new URL(urlProp.getProperty("vsb_polito_smartcity_nsds")), Nsd[].class)[0]; + assertEquals(oM.writeValueAsString(expectedNsd), oM.writeValueAsString(actualNsd)); } @Test diff --git a/src/test/resources/url.properties b/src/test/resources/url.properties index d1b0ca8..f929e77 100644 --- a/src/test/resources/url.properties +++ b/src/test/resources/url.properties @@ -2,10 +2,11 @@ vsb_ares2t_tracker=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master vsb_ares2t_tracker_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker_nsds.yaml expb_ares2t_tracker_delay_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/expb/expb_ares2t_tracker_delay/expb_ares2t_tracker_delay_nsds.yaml +vsb_polito_smartcity=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_polito_smartcity/vsb_polito_smartcity.yaml +vsb_polito_smartcity_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_polito_smartcity/vsb_polito_smartcity_nsds.yaml + ctx_delay=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay.yaml ctx_delay_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay_nsds.yaml ctx_bg_traffic=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic.yaml ctx_bg_traffic_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic_nsds.yaml - -vsb_orange_v360=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_orange_v360/vsb_V360.yml From 952d3a3ba1c815fffa364ecb2659e85a1252974e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 28 Apr 2020 18:16:26 +0200 Subject: [PATCH 123/187] rename variable, reformat. --- .../blueprint/composer/nsd/generate/NsdGeneratorTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java index 305eb38..9dd5a38 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java @@ -63,12 +63,11 @@ public void generateBgTrafficCtxB() { .readValue(new URL(urlProp.getProperty("ctx_bg_traffic")), CtxBlueprint.class); //When - Nsd actual = nsdGenerator.generate(ctxB); + Nsd actualNsd = nsdGenerator.generate(ctxB); //Then - Nsd expected = oM + Nsd expectedNsd = oM .readValue(new URL(urlProp.getProperty("ctx_bg_traffic_nsds")), Nsd[].class)[0]; - assertEquals(oM.writeValueAsString(expected), oM.writeValueAsString(actual)); - + assertEquals(oM.writeValueAsString(expectedNsd), oM.writeValueAsString(actualNsd)); } } \ No newline at end of file From 41e5b66d3b356f02dd8edbb4798ae018b437a958 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 28 Apr 2020 18:46:57 +0200 Subject: [PATCH 124/187] Add constructor with cause to InvalidNsdException. --- .../it/cnit/blueprint/composer/rest/InvalidNsdException.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java b/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java index 6815ef8..74cbead 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java @@ -5,4 +5,8 @@ public class InvalidNsdException extends Exception { public InvalidNsdException(String message) { super(message); } + + public InvalidNsdException(String message, Throwable cause) { + super(message, cause); + } } From 5035a0a47d640340d681988100fe00eff6987553 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 12:19:16 +0200 Subject: [PATCH 125/187] Make connect input a Map of strings. --- src/main/java/it/cnit/blueprint/composer/rest/Context.java | 3 ++- .../it/cnit/blueprint/composer/rest/ExperimentsController.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/Context.java b/src/main/java/it/cnit/blueprint/composer/rest/Context.java index 614671a..b2ab8b2 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/Context.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/Context.java @@ -1,6 +1,7 @@ package it.cnit.blueprint.composer.rest; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; +import java.util.Map; import lombok.AllArgsConstructor; import lombok.Data; @@ -9,5 +10,5 @@ public class Context { private OnboardCtxBlueprintRequest ctxbRequest; - private ConnectInput connectInput; + private Map connectInput; } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index ecac440..776d4f5 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -13,6 +13,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; +import java.util.HashMap; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -63,7 +64,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ log.info("Current CtxB: {}", ctxB.getBlueprintId()); if (ctx.getConnectInput() == null) { - ctx.setConnectInput(new ConnectInput()); + ctx.setConnectInput(new HashMap<>()); } NsVirtualLinkDesc expMgmtVld = findMgmtVld(ctxB, ctxNsd); NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); From 7a42878033026543a79af56614ff65f30a498d1f Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 12:19:48 +0200 Subject: [PATCH 126/187] Fix connectInput parameter. Add and refactor methods. --- .../composer/nsd/compose/NsdComposer.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index e0fded4..b76bbf9 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; -import it.cnit.blueprint.composer.rest.ConnectInput; import it.cnit.blueprint.composer.rest.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; @@ -38,6 +37,7 @@ public abstract class NsdComposer { protected NsdGraphService nsdGraphService; + // TODO refactor protected VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) throws NotExistingEntityException { VnfProfile vnfProfile; @@ -52,7 +52,15 @@ protected VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) return vnfProfile; } - protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf, NsLevel nsLvl) + protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) + throws NotExistingEntityException { + for (VnfProfile vp : nsDf.getVnfProfile()) { + if (vp.getVnfdId().equals(vnfdId)) return vp; + } + throw new NotExistingEntityException("VNF profile for VNFD ID " + vnfdId + " not found"); + } + + protected VnfProfile getVnfProfileByDescIdOLd(String vnfdId, NsDf nsDf, NsLevel nsLvl) throws NotExistingEntityException, VnfNotFoundInLvlMapping { VnfProfile vnfProfile = null; List filterVnfp = nsDf.getVnfProfile().stream() @@ -94,6 +102,14 @@ protected VirtualLinkProfile getVlProfile(String vlProfileId, NsDf nsDf) return vlProfile; } + protected VirtualLinkProfile getVlProfileByDescId(String vldId, NsDf nsDf) + throws NotExistingEntityException { + for (VirtualLinkProfile vl : nsDf.getVirtualLinkProfile()) { + if (vl.getVirtualLinkDescId().equals(vldId)) return vl; + } + throw new NotExistingEntityException("VL profile for VLD ID " + vldId + " not found"); + } + protected VirtualLinkProfile getVlProfile(NsVirtualLinkDesc vld, NsDf nsDf) throws NotExistingEntityException { VirtualLinkProfile resultVlp; @@ -317,7 +333,7 @@ public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws InvalidNs } @SneakyThrows(JsonProcessingException.class) - public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, + public void compose(Map connectInput, NsVirtualLinkDesc ranVld, NsVirtualLinkDesc expMgmtVld, Nsd expNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) throws InvalidNsdException { // We assume only one NsDf for the context @@ -399,7 +415,8 @@ public void compose(ConnectInput connectInput, NsVirtualLinkDesc ranVld, } public abstract void composeWithStrategy( - ConnectInput connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, VlInfo ctxMgmtVlInfo, + Map connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, + VlInfo ctxMgmtVlInfo, Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl ) throws InvalidNsdException; From 6ea9bb1531e62a4c7c3e2e233fa231d8f3990e09 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 12:20:21 +0200 Subject: [PATCH 127/187] Fix connectInpu parameter (not used here). --- .../composer/nsd/compose/PassThroughComposer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index f51c779..7e8dedd 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -1,6 +1,5 @@ package it.cnit.blueprint.composer.nsd.compose; -import it.cnit.blueprint.composer.rest.ConnectInput; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.rest.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; @@ -31,9 +30,10 @@ public PassThroughComposer(NsdGraphService nsdGraphService) { @Override public void composeWithStrategy( - ConnectInput connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, VlInfo ctxMgmtVlInfo, - Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, - Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) + Map connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, + VlInfo ctxMgmtVlInfo, + Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, + Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsdException { log.info("Compose with PASS_THROUGH."); // Retrieve ctx VNF From 84f7f57266ab69cc36df5999075f4fe715f5a4c5 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 12:20:49 +0200 Subject: [PATCH 128/187] Refactor ConnectComposer to support any number of components in ctx. --- .../composer/nsd/compose/ConnectComposer.java | 234 +++++++----------- 1 file changed, 92 insertions(+), 142 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index 7143527..f3a18fa 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -9,6 +9,10 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; +import it.nextworks.nfvmano.libs.ifa.descriptors.vnfd.Vnfd; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; @@ -29,160 +33,106 @@ public ConnectComposer(NsdGraphService nsdGraphService) { super(nsdGraphService); } - @Override - public void composeWithStrategy( - ConnectInput connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, VlInfo ctxMgmtVlInfo, - Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, - Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) - throws InvalidNsdException { - log.info("Compose with CONNECT."); - // Retrieve ctx VNFs - VnfInfo srcVnfInfo; - try { - String srcVnfpId; - if (connectInput.getSrcVnfdId() != null && !connectInput.getSrcVnfdId().isEmpty()) { - srcVnfpId = getVnfProfileByDescId(connectInput.getSrcVnfdId(), ctxNsDf, ctxNsLvl) - .getVnfProfileId(); - } else { - // Assumption: src is 0 - srcVnfpId = ctxNsLvl.getVnfToLevelMapping().get(0).getVnfProfileId(); - } - srcVnfInfo = retrieveVnfInfoByProfileId(srcVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); - } catch (NotExistingEntityException | VnfNotFoundInLvlMapping e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); - } - - VnfInfo dstVnfInfo; - try { - String dstVnfpId; - if (connectInput.getDstVnfdId() != null && !connectInput.getDstVnfdId().isEmpty()) { - dstVnfpId = getVnfProfileByDescId(connectInput.getDstVnfdId(), ctxNsDf, ctxNsLvl) - .getVnfProfileId(); - } else { - // Assumption: dst is 1 - dstVnfpId = ctxNsLvl.getVnfToLevelMapping().get(1).getVnfProfileId(); - } - dstVnfInfo = retrieveVnfInfoByProfileId(dstVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); - } catch (NotExistingEntityException | VnfNotFoundInLvlMapping e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); - } - - // Retrieve Cpds for src VNF - Map srcCpds; - try { - srcCpds = getMgmtDataCpds(srcVnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); - } catch (Exception e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); - } - // Retrieve Cpds for dst VNF - Map dstCpds; - try { - dstCpds = getMgmtDataCpds(dstVnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); - } catch (Exception e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); + private VirtualLinkToLevelMapping getNonMgmtVlMap(NsLevel expNsLvl, VlInfo expMgmtVlInfo, + VlInfo ranVlInfo) throws NotExistingEntityException { + Optional optLvlMap = + expNsLvl.getVirtualLinkToLevelMapping().stream() + .filter( + m -> + !m.getVirtualLinkProfileId() + .equals(expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()) + && !m.getVirtualLinkProfileId() + .equals(ranVlInfo.getVlProfile().getVirtualLinkProfileId())) + .findFirst(); + if (optLvlMap.isPresent()) { + return optLvlMap.get(); + } else { + throw new NotExistingEntityException( + "Can't find a non-mgmt VL in NsLevel " + expNsLvl.getNsLevelId()); } + } - // Retrieve src VL - VlInfo srcVlInfo; - if (connectInput.getSrcVldId() != null && !connectInput.getSrcVldId().isEmpty()) { - try { - srcVlInfo = retrieveVlInfo(getVlDescriptor(connectInput.getSrcVldId(), expNsd), expNsDf, - expNsLvl); - } catch (VlNotFoundInLvlMapping | NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); - } + private void addConnectVnfToVl(VnfInfo vnfInfo, Map cpds, + VlInfo dataVlInfo, VlInfo mgmtVlInfo, Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl) + throws NotExistingEntityException { + // Modify expNsd + addVnf(vnfInfo, expNsd, expNsDf, expNsLvl); + log.debug( + "Added VnfProfile='{}' in service (if not present).", + vnfInfo.getVnfProfile().getVnfProfileId()); + connectVnfToVL( + vnfInfo.getVnfProfile(), cpds.get("data0").getCpdId().get(0), dataVlInfo.getVlProfile()); + log.debug( + "Created connection between vnfProfile='{}' and vlProfile='{}'", + vnfInfo.getVnfProfile().getVnfProfileId(), + dataVlInfo.getVlProfile().getVirtualLinkProfileId()); + if (cpds.get("mgmt") != null) { + connectVnfToVL( + vnfInfo.getVnfProfile(), cpds.get("mgmt").getCpdId().get(0), mgmtVlInfo.getVlProfile()); } else { - // Default: select a RAN VL - srcVlInfo = ranVlInfo; + log.warn("Could not find a management Cp for srcVnf. Skip."); } - // Retrieve dst VL - VlInfo dstVlInfo; - if (connectInput.getDstVldId() != null && !connectInput.getDstVldId().isEmpty()) { - try { - dstVlInfo = retrieveVlInfo(getVlDescriptor(connectInput.getDstVldId(), expNsd), expNsDf, - expNsLvl); - } catch (VlNotFoundInLvlMapping | NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); - } - } else { - // Default: select a non-management VL, different from RAN VL - Optional optDstLvlMap = expNsLvl.getVirtualLinkToLevelMapping() - .stream() - .filter(m -> !m.getVirtualLinkProfileId() - .equals(expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()) - && !m.getVirtualLinkProfileId() - .equals(ranVlInfo.getVlProfile().getVirtualLinkProfileId())) - .findFirst(); - try { - if (optDstLvlMap.isPresent()) { - dstVlInfo = retrieveVlInfo(optDstLvlMap.get().getVirtualLinkProfileId(), - expNsd, expNsDf, expNsLvl); - log.debug("Found non-mgmt VlInfo='{}'.", - dstVlInfo.getVlProfile().getVirtualLinkProfileId()); - } else { - throw new InvalidNsdException( - "Can't find a non-mgmt VlInfo in expNsd: '" + expNsd.getNsdIdentifier() + "'"); - } - } catch (InvalidNsdException | VlNotFoundInLvlMapping e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); + for (Entry cpd : cpds.entrySet()) { + if (!cpd.getKey().equals("data0") && !cpd.getKey().equals("mgmt")) { + vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity().remove(cpd.getValue()); } } + } - // Modify expNsd - addVnf(srcVnfInfo, expNsd, expNsDf, expNsLvl); - log.debug("Added VnfProfile='{}' in service (if not present).", - srcVnfInfo.getVnfProfile().getVnfProfileId()); - addVnf(dstVnfInfo, expNsd, expNsDf, expNsLvl); - log.debug("Added VnfProfile='{}' in service (if not present).", - dstVnfInfo.getVnfProfile().getVnfProfileId()); + @Override + public void composeWithStrategy( + Map connectInput, + VlInfo ranVlInfo, + VlInfo expMgmtVlInfo, + VlInfo ctxMgmtVlInfo, + Nsd expNsd, + NsDf expNsDf, + NsLevel expNsLvl, + Nsd ctxNsd, + NsDf ctxNsDf, + NsLevel ctxNsLvl) + throws InvalidNsdException { + log.info("Compose with CONNECT."); + // Retrieve ctx VNFs + List vnfToConnect = new ArrayList<>(); try { - // Connect VNFs to src VL - connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("data0").getCpdId().get(0), - srcVlInfo.getVlProfile()); - log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", - srcVnfInfo.getVnfProfile().getVnfProfileId(), - srcVlInfo.getVlProfile().getVirtualLinkProfileId()); - // Connect VNFs to dst VL - connectVnfToVL(dstVnfInfo.getVnfProfile(), dstCpds.get("data0").getCpdId().get(0), - dstVlInfo.getVlProfile()); - log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", - dstVnfInfo.getVnfProfile().getVnfProfileId(), - dstVlInfo.getVlProfile().getVirtualLinkProfileId()); - // Connect VNFs to mgmt VL (if possible) - if (srcCpds.get("mgmt") != null) { - connectVnfToVL(srcVnfInfo.getVnfProfile(), srcCpds.get("mgmt").getCpdId().get(0), - expMgmtVlInfo.getVlProfile()); - } else { - log.warn("Could not find a management Cp for srcVnf. Skip."); - } - if (dstCpds.get("mgmt") != null) { - connectVnfToVL(dstVnfInfo.getVnfProfile(), dstCpds.get("mgmt").getCpdId().get(0), - expMgmtVlInfo.getVlProfile()); - } else { - log.warn("Could not find a management Cp for dstVnf. Skip."); - } - // Cleanup unused cpds - for (Entry cpd : srcCpds.entrySet()) { - if (!cpd.getKey().equals("data0") && !cpd.getKey().equals("mgmt")) { - srcVnfInfo.getVnfProfile().getNsVirtualLinkConnectivity().remove(cpd.getValue()); + if (connectInput.isEmpty()) { + // select all VNFs + boolean first = true; + for (VnfToLevelMapping vnfMap : ctxNsLvl.getVnfToLevelMapping()) { + String vnfpId = vnfMap.getVnfProfileId(); + VnfInfo vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); + Map cpds = + getMgmtDataCpds(vnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); + VlInfo vlInfo; + if (first) { + vlInfo = ranVlInfo; + first = false; + } else { + vlInfo = + retrieveVlInfo( + getNonMgmtVlMap(expNsLvl, expMgmtVlInfo, ranVlInfo).getVirtualLinkProfileId(), + expNsd, + expNsDf, + expNsLvl); + } + addConnectVnfToVl(vnfInfo, cpds, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } - } - for (Entry cpd : dstCpds.entrySet()) { - if (!cpd.getKey().equals("data0") && !cpd.getKey().equals("mgmt")) { - dstVnfInfo.getVnfProfile().getNsVirtualLinkConnectivity().remove(cpd.getValue()); + } else { + // only VNFs in connectInput + for (Entry entry : connectInput.entrySet()) { + String vnfpId = getVnfProfileByDescId(entry.getKey(), ctxNsDf).getVnfProfileId(); + VnfInfo vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); + Map cpds = + getMgmtDataCpds(vnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); + String vlpId = getVlProfileByDescId(entry.getValue(), ctxNsDf).getVirtualLinkProfileId(); + VlInfo vlInfo = retrieveVlInfo(vlpId, ctxNsd, ctxNsDf, ctxNsLvl); + addConnectVnfToVl(vnfInfo, cpds, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } } - } catch (NotExistingEntityException e) { + } catch (NotExistingEntityException | VnfNotFoundInLvlMapping | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); + throw new InvalidNsdException("Nsd " + ctxNsd.getNsdIdentifier(), e); } } - } From bd0c20244faaeaa2e096226547c23728d22a770c Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 12:21:13 +0200 Subject: [PATCH 129/187] Fix tests for NsdComposer. --- .../composer/nsd/compose/NsdComposerTest.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java index a930a0b..844bf80 100644 --- a/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.composer.nsd.graph.GraphVizExporter; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; -import it.cnit.blueprint.composer.rest.ConnectInput; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; @@ -16,6 +15,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.Optional; import java.util.Properties; import lombok.SneakyThrows; @@ -48,7 +48,8 @@ public static void setUp() { public void composeTrackerWithDelayPassThrough() { // Given - Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; + Nsd vsbNsd = oM + .readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; NsVirtualLinkDesc ranVld; Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) @@ -79,7 +80,7 @@ public void composeTrackerWithDelayPassThrough() { // When passThroughComposer - .compose(new ConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + .compose(new HashMap<>(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); @@ -97,7 +98,8 @@ public void composeTrackerWithDelayPassThrough() { public void composeTrackerWithDelayConnect() { // Given - Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; + Nsd vsbNsd = oM + .readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; NsVirtualLinkDesc ranVld; Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) @@ -143,7 +145,7 @@ public void composeTrackerWithDelayConnect() { } // When - connectComposer.compose(new ConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + connectComposer.compose(new HashMap<>(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); vsbNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); @@ -160,7 +162,8 @@ public void composeTrackerWithDelayConnect() { @SneakyThrows public void composeTrackerWithBackgroundConnect() { // Given - Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; + Nsd vsbNsd = oM + .readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; NsVirtualLinkDesc ranVld; Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) @@ -183,7 +186,7 @@ public void composeTrackerWithBackgroundConnect() { .get(0); NsVirtualLinkDesc ctxMgmtVld; Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() - .filter(v -> v.getVirtualLinkDescId().equals("vld_1")).findFirst(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_bg_traffic_mgmt")).findFirst(); if (optCtxVld.isPresent()) { ctxMgmtVld = optCtxVld.get(); } else { @@ -191,7 +194,7 @@ public void composeTrackerWithBackgroundConnect() { } // When - connectComposer.compose(new ConnectInput(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); + connectComposer.compose(new HashMap<>(), ranVld, vsbMgmtVld, vsbNsd, ctxMgmtVld, ctxNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("2dd7b5b1-9f39-4978-a035-6654d7bc9068"); vsbNsd.setNsdInvariantId("d5959420-1ef7-4441-9eb9-9113172c988b"); @@ -210,7 +213,8 @@ public void composeTrackerWithBackgroundConnect() { public void composeTrackerWithBackgroundAndDelay() { // Given - Nsd vsbNsd = oM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; + Nsd vsbNsd = oM + .readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), Nsd[].class)[0]; NsVirtualLinkDesc ranVld; Optional optRanVl = vsbNsd.getVirtualLinkDesc().stream() .filter(v -> v.getVirtualLinkDescId().equals("vl_tracking_mobile")) @@ -243,7 +247,7 @@ public void composeTrackerWithBackgroundAndDelay() { .get(0); NsVirtualLinkDesc bgMgmtVld; optCtxVld = bgNsd.getVirtualLinkDesc().stream() - .filter(v -> v.getVirtualLinkDescId().equals("vld_1")).findFirst(); + .filter(v -> v.getVirtualLinkDescId().equals("vl_bg_traffic_mgmt")).findFirst(); if (optCtxVld.isPresent()) { bgMgmtVld = optCtxVld.get(); } else { @@ -252,8 +256,8 @@ public void composeTrackerWithBackgroundAndDelay() { // When passThroughComposer - .compose(new ConnectInput(), ranVld, vsbMgmtVld, vsbNsd, delayMgmtVld, delayNsd); - connectComposer.compose(new ConnectInput(), ranVld, vsbMgmtVld, vsbNsd, bgMgmtVld, bgNsd); + .compose(new HashMap<>(), ranVld, vsbMgmtVld, vsbNsd, delayMgmtVld, delayNsd); + connectComposer.compose(new HashMap<>(), ranVld, vsbMgmtVld, vsbNsd, bgMgmtVld, bgNsd); // Setting ID manually for test purpose vsbNsd.setNsdIdentifier("bfb761be-ab0f-499c-88d7-ac6ce7263651"); vsbNsd.setNsdInvariantId("d650cb24-28c5-41ba-8541-12a9cb93238c"); From 224584dcf528ec9f34aafea655a8cb030001b11e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 12:38:12 +0200 Subject: [PATCH 130/187] Refactor VnfInfo to include mgmt and data VirtualLinkConnectivity. --- .../composer/nsd/compose/VnfInfo.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java index ce5c60c..b315aab 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java @@ -1,16 +1,30 @@ package it.cnit.blueprint.composer.nsd.compose; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; -import lombok.AllArgsConstructor; +import java.util.ArrayList; +import java.util.List; import lombok.Data; +import lombok.RequiredArgsConstructor; @Data -@AllArgsConstructor -public class VnfInfo -{ +@RequiredArgsConstructor +public class VnfInfo { - private String vfndId; - private VnfProfile vnfProfile; - private VnfToLevelMapping vnfToLevelMapping; + private final String vfndId; + private final VnfProfile vnfProfile; + private final VnfToLevelMapping vnfToLevelMapping; + private List mgmtVlcList = new ArrayList<>(); + private List dataVlcList = new ArrayList<>(); + + public void setCpdLists(String mgmtVlProfileId) { + for (NsVirtualLinkConnectivity vlc : vnfProfile.getNsVirtualLinkConnectivity()) { + if (vlc.getVirtualLinkProfileId().equals(mgmtVlProfileId)) { + mgmtVlcList.add(vlc); + } else { + dataVlcList.add(vlc); + } + } + } } From f9b51fb73ee27c3cc9d629eb2b964b2c2896fb60 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 15:09:32 +0200 Subject: [PATCH 131/187] Fix setVlcList method and add clean up method. --- .../blueprint/composer/nsd/compose/VnfInfo.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java index b315aab..2192667 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java @@ -15,16 +15,23 @@ public class VnfInfo { private final String vfndId; private final VnfProfile vnfProfile; private final VnfToLevelMapping vnfToLevelMapping; - private List mgmtVlcList = new ArrayList<>(); - private List dataVlcList = new ArrayList<>(); + private List mgmtVlcList; + private List dataVlcList; - public void setCpdLists(String mgmtVlProfileId) { + public void setVlcLists(List mgmtVlProfileIds) { + mgmtVlcList = new ArrayList<>(); + dataVlcList = new ArrayList<>(); for (NsVirtualLinkConnectivity vlc : vnfProfile.getNsVirtualLinkConnectivity()) { - if (vlc.getVirtualLinkProfileId().equals(mgmtVlProfileId)) { + if (mgmtVlProfileIds.contains(vlc.getVirtualLinkProfileId())) { mgmtVlcList.add(vlc); } else { dataVlcList.add(vlc); } + // TODO exceptions if no data vlc } } + + public void cleanUpVlc(NsVirtualLinkConnectivity vlcToRemove) { + vnfProfile.getNsVirtualLinkConnectivity().remove(vlcToRemove); + } } From 7da6700485583d5a9731e7e8c07f03eeb9bfd5c7 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 15:10:32 +0200 Subject: [PATCH 132/187] Fix after changes to VnfInfo. --- .../composer/nsd/compose/ConnectComposer.java | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index f3a18fa..d38058c 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -1,17 +1,14 @@ package it.cnit.blueprint.composer.nsd.compose; -import it.cnit.blueprint.composer.rest.ConnectInput; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.rest.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; -import it.nextworks.nfvmano.libs.ifa.descriptors.vnfd.Vnfd; -import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -52,30 +49,29 @@ private VirtualLinkToLevelMapping getNonMgmtVlMap(NsLevel expNsLvl, VlInfo expMg } } - private void addConnectVnfToVl(VnfInfo vnfInfo, Map cpds, - VlInfo dataVlInfo, VlInfo mgmtVlInfo, Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl) + private void addConnectVnfToVl(VnfInfo vnfInfo, VlInfo dataVlInfo, VlInfo mgmtVlInfo, Nsd expNsd, + NsDf expNsDf, NsLevel expNsLvl) throws NotExistingEntityException { // Modify expNsd addVnf(vnfInfo, expNsd, expNsDf, expNsLvl); log.debug( "Added VnfProfile='{}' in service (if not present).", vnfInfo.getVnfProfile().getVnfProfileId()); - connectVnfToVL( - vnfInfo.getVnfProfile(), cpds.get("data0").getCpdId().get(0), dataVlInfo.getVlProfile()); + connectVnfToVL(vnfInfo.getVnfProfile(), vnfInfo.getDataVlcList().get(0).getCpdId().get(0), + dataVlInfo.getVlProfile()); log.debug( "Created connection between vnfProfile='{}' and vlProfile='{}'", vnfInfo.getVnfProfile().getVnfProfileId(), dataVlInfo.getVlProfile().getVirtualLinkProfileId()); - if (cpds.get("mgmt") != null) { - connectVnfToVL( - vnfInfo.getVnfProfile(), cpds.get("mgmt").getCpdId().get(0), mgmtVlInfo.getVlProfile()); - } else { - log.warn("Could not find a management Cp for srcVnf. Skip."); + for (int i = 1; i < vnfInfo.getDataVlcList().size(); i++) { + vnfInfo.cleanUpVlc(vnfInfo.getDataVlcList().get(i)); } - for (Entry cpd : cpds.entrySet()) { - if (!cpd.getKey().equals("data0") && !cpd.getKey().equals("mgmt")) { - vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity().remove(cpd.getValue()); - } + if (!vnfInfo.getMgmtVlcList().isEmpty()) { + connectVnfToVL(vnfInfo.getVnfProfile(), vnfInfo.getMgmtVlcList().get(0).getCpdId().get(0), + mgmtVlInfo.getVlProfile()); + } else { + log.warn("Could not find a management Vlc for {}. Skip.", + vnfInfo.getVnfProfile().getVnfProfileId()); } } @@ -93,8 +89,9 @@ public void composeWithStrategy( NsLevel ctxNsLvl) throws InvalidNsdException { log.info("Compose with CONNECT."); - // Retrieve ctx VNFs - List vnfToConnect = new ArrayList<>(); + List mgmtVlProfileIds = Arrays.asList( + ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), + expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); try { if (connectInput.isEmpty()) { // select all VNFs @@ -102,8 +99,7 @@ public void composeWithStrategy( for (VnfToLevelMapping vnfMap : ctxNsLvl.getVnfToLevelMapping()) { String vnfpId = vnfMap.getVnfProfileId(); VnfInfo vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); - Map cpds = - getMgmtDataCpds(vnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); + vnfInfo.setVlcLists(mgmtVlProfileIds); VlInfo vlInfo; if (first) { vlInfo = ranVlInfo; @@ -116,18 +112,17 @@ public void composeWithStrategy( expNsDf, expNsLvl); } - addConnectVnfToVl(vnfInfo, cpds, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); + addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } } else { // only VNFs in connectInput for (Entry entry : connectInput.entrySet()) { String vnfpId = getVnfProfileByDescId(entry.getKey(), ctxNsDf).getVnfProfileId(); VnfInfo vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); - Map cpds = - getMgmtDataCpds(vnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); + vnfInfo.setVlcLists(mgmtVlProfileIds); String vlpId = getVlProfileByDescId(entry.getValue(), ctxNsDf).getVirtualLinkProfileId(); VlInfo vlInfo = retrieveVlInfo(vlpId, ctxNsd, ctxNsDf, ctxNsLvl); - addConnectVnfToVl(vnfInfo, cpds, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); + addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } } } catch (NotExistingEntityException | VnfNotFoundInLvlMapping | VlNotFoundInLvlMapping e) { From 982a49a4bb1cdbbce2974ffb28a2f7de9e981697 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 15:15:55 +0200 Subject: [PATCH 133/187] Add exception throw if data cpd is not found. --- .../it/cnit/blueprint/composer/nsd/compose/VnfInfo.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java index 2192667..529bfbe 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java @@ -1,5 +1,7 @@ package it.cnit.blueprint.composer.nsd.compose; +import it.cnit.blueprint.composer.rest.InvalidNsdException; +import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; @@ -18,7 +20,7 @@ public class VnfInfo { private List mgmtVlcList; private List dataVlcList; - public void setVlcLists(List mgmtVlProfileIds) { + public void setVlcLists(List mgmtVlProfileIds) throws NotExistingEntityException { mgmtVlcList = new ArrayList<>(); dataVlcList = new ArrayList<>(); for (NsVirtualLinkConnectivity vlc : vnfProfile.getNsVirtualLinkConnectivity()) { @@ -27,7 +29,10 @@ public void setVlcLists(List mgmtVlProfileIds) { } else { dataVlcList.add(vlc); } - // TODO exceptions if no data vlc + } + if (dataVlcList.isEmpty()) { + throw new NotExistingEntityException( + "No data cpd found for vnfProfile: " + vnfProfile.getVnfProfileId()); } } From d078e7fede34e1e92bde7b1b0367611c7a51e9c0 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 17:37:12 +0200 Subject: [PATCH 134/187] Use the new Vlc lists with Passthrough composer. Remove old method. --- .../composer/nsd/compose/NsdComposer.java | 43 ++++--------------- .../nsd/compose/PassThroughComposer.java | 30 +++++++------ 2 files changed, 26 insertions(+), 47 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index b76bbf9..7c13703 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -18,7 +18,6 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -52,10 +51,12 @@ protected VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) return vnfProfile; } - protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) + protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) throws NotExistingEntityException { for (VnfProfile vp : nsDf.getVnfProfile()) { - if (vp.getVnfdId().equals(vnfdId)) return vp; + if (vp.getVnfdId().equals(vnfdId)) { + return vp; + } } throw new NotExistingEntityException("VNF profile for VNFD ID " + vnfdId + " not found"); } @@ -104,10 +105,12 @@ protected VirtualLinkProfile getVlProfile(String vlProfileId, NsDf nsDf) protected VirtualLinkProfile getVlProfileByDescId(String vldId, NsDf nsDf) throws NotExistingEntityException { - for (VirtualLinkProfile vl : nsDf.getVirtualLinkProfile()) { - if (vl.getVirtualLinkDescId().equals(vldId)) return vl; + for (VirtualLinkProfile vl : nsDf.getVirtualLinkProfile()) { + if (vl.getVirtualLinkDescId().equals(vldId)) { + return vl; } - throw new NotExistingEntityException("VL profile for VLD ID " + vldId + " not found"); + } + throw new NotExistingEntityException("VL profile for VLD ID " + vldId + " not found"); } protected VirtualLinkProfile getVlProfile(NsVirtualLinkDesc vld, NsDf nsDf) @@ -293,34 +296,6 @@ protected void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile } - protected Map getMgmtDataCpds(VnfInfo vnfInfo, - VlInfo expMgmtVlinfo, VlInfo ctxMgmtVlInfo) - throws InvalidNsdException { - Map cpdIdMap = new HashMap<>(); - int dataCount = 0; - for (NsVirtualLinkConnectivity vlc : vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity()) { - if (vlc.getVirtualLinkProfileId() - .equals(expMgmtVlinfo.getVlProfile().getVirtualLinkProfileId()) - || vlc.getVirtualLinkProfileId() - .equals(ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId())) { - cpdIdMap.put("mgmt", vlc); - } else { - cpdIdMap.put("data" + dataCount, vlc); - dataCount++; - } - } - if (!cpdIdMap.containsKey("mgmt")) { - cpdIdMap.put("mgmt", null); - } - Optional dataKey = cpdIdMap.keySet().stream().filter(k -> k.startsWith("data")) - .findFirst(); - if (!dataKey.isPresent()) { - throw new InvalidNsdException( - "No data cpd found for vnfProfile: '" + vnfInfo.getVnfProfile().getVnfProfileId() + "'."); - } - return cpdIdMap; - } - public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws InvalidNsdException { NsVirtualLinkDesc ranVld; try { diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index 7e8dedd..71ba683 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -9,8 +9,9 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; +import java.util.Arrays; +import java.util.List; import java.util.Map; -import java.util.Map.Entry; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; @@ -36,15 +37,20 @@ public void composeWithStrategy( Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) throws InvalidNsdException { log.info("Compose with PASS_THROUGH."); + List mgmtVlProfileIds = Arrays.asList( + ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), + expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); + // Retrieve ctx VNF String ctxVnfpId = ctxNsLvl.getVnfToLevelMapping().get(0).getVnfProfileId(); VnfInfo ctxVnfInfo; try { ctxVnfInfo = retrieveVnfInfoByProfileId(ctxVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); log.debug("Found VnfInfo for vnfpId='{}' in context.", ctxVnfpId); - } catch (VnfNotFoundInLvlMapping e) { + ctxVnfInfo.setVlcLists(mgmtVlProfileIds); + } catch (VnfNotFoundInLvlMapping | NotExistingEntityException e) { log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); + throw new InvalidNsdException(e.getMessage(), e); } // Retrieve non-management VLs from ctx @@ -52,8 +58,7 @@ public void composeWithStrategy( Map ctxVnfCpds; VlInfo ctxNonMgmtVl; try { - ctxVnfCpds = getMgmtDataCpds(ctxVnfInfo, expMgmtVlInfo, ctxMgmtVlInfo); - ctxNonMgmtVl = retrieveVlInfo(ctxVnfCpds.get("data0").getVirtualLinkProfileId(), + ctxNonMgmtVl = retrieveVlInfo(ctxVnfInfo.getDataVlcList().get(0).getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); } catch (InvalidNsdException | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); @@ -104,14 +109,16 @@ public void composeWithStrategy( ranVnfProfile.getVnfProfileId(), ctxNonMgmtVl.getVlProfile().getVirtualLinkProfileId()); // Connect ctxVnf with RAN VL - connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxVnfCpds.get("data1").getCpdId().get(0), + connectVnfToVL(ctxVnfInfo.getVnfProfile(), + ctxVnfInfo.getDataVlcList().get(1).getCpdId().get(0), ranVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", ctxVnfInfo.getVnfProfile().getVnfProfileId(), ranVlInfo.getVlProfile().getVirtualLinkProfileId()); // Connect ctxVnf to expNsd mgmt VL - if (ctxVnfCpds.get("mgmt") != null) { - connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxVnfCpds.get("mgmt").getCpdId().get(0), + if (!ctxVnfInfo.getMgmtVlcList().isEmpty()) { + connectVnfToVL(ctxVnfInfo.getVnfProfile(), + ctxVnfInfo.getMgmtVlcList().get(0).getCpdId().get(0), expMgmtVlInfo.getVlProfile()); log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", ctxVnfInfo.getVnfProfile().getVnfProfileId(), @@ -120,11 +127,8 @@ public void composeWithStrategy( log.warn("Could not find a management Cp for ctxVnf. Skip."); } // Cleanup unused cpds of ctxVnf (if any) - for (Entry cpd : ctxVnfCpds.entrySet()) { - if (!cpd.getKey().equals("data0") && !cpd.getKey().equals("data1") && !cpd.getKey() - .equals("mgmt")) { - ctxVnfInfo.getVnfProfile().getNsVirtualLinkConnectivity().remove(cpd.getValue()); - } + for (int i = 2; i < ctxVnfInfo.getDataVlcList().size(); i++) { + ctxVnfInfo.cleanUpVlc(ctxVnfInfo.getDataVlcList().get(i)); } } catch (NotExistingEntityException e) { log.error(e.getMessage()); From f33ff9d562cdaae7d7133dadd7331af3aae694f3 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 17:54:02 +0200 Subject: [PATCH 135/187] Remove blank line. --- .../blueprint/composer/nsd/compose/PassThroughComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index 71ba683..370bda5 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -40,7 +40,7 @@ public void composeWithStrategy( List mgmtVlProfileIds = Arrays.asList( ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); - + // Retrieve ctx VNF String ctxVnfpId = ctxNsLvl.getVnfToLevelMapping().get(0).getVnfProfileId(); VnfInfo ctxVnfInfo; From 03657a8d4258aad5fc323520918c8e954c1b0da4 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 17:54:11 +0200 Subject: [PATCH 136/187] Method refactor for better readability. --- .../composer/nsd/compose/ConnectComposer.java | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index d38058c..d0f48cd 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -12,7 +12,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Optional; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; @@ -30,23 +29,17 @@ public ConnectComposer(NsdGraphService nsdGraphService) { super(nsdGraphService); } - private VirtualLinkToLevelMapping getNonMgmtVlMap(NsLevel expNsLvl, VlInfo expMgmtVlInfo, - VlInfo ranVlInfo) throws NotExistingEntityException { - Optional optLvlMap = - expNsLvl.getVirtualLinkToLevelMapping().stream() - .filter( - m -> - !m.getVirtualLinkProfileId() - .equals(expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()) - && !m.getVirtualLinkProfileId() - .equals(ranVlInfo.getVlProfile().getVirtualLinkProfileId())) - .findFirst(); - if (optLvlMap.isPresent()) { - return optLvlMap.get(); - } else { - throw new NotExistingEntityException( - "Can't find a non-mgmt VL in NsLevel " + expNsLvl.getNsLevelId()); + private String getNonMgmtVlProfileId(NsLevel expNsLvl, String mgmtVlpId, String ranVlpId) + throws NotExistingEntityException { + for (VirtualLinkToLevelMapping m : expNsLvl.getVirtualLinkToLevelMapping()) { + if (!m.getVirtualLinkProfileId().equals(mgmtVlpId) + && + !m.getVirtualLinkProfileId().equals(ranVlpId)) { + return m.getVirtualLinkProfileId(); + } } + throw new NotExistingEntityException( + "Can't find a non-mgmt VL in NsLevel " + expNsLvl.getNsLevelId()); } private void addConnectVnfToVl(VnfInfo vnfInfo, VlInfo dataVlInfo, VlInfo mgmtVlInfo, Nsd expNsd, @@ -105,12 +98,11 @@ public void composeWithStrategy( vlInfo = ranVlInfo; first = false; } else { - vlInfo = - retrieveVlInfo( - getNonMgmtVlMap(expNsLvl, expMgmtVlInfo, ranVlInfo).getVirtualLinkProfileId(), - expNsd, - expNsDf, - expNsLvl); + String nonMgmtVlpId = getNonMgmtVlProfileId( + expNsLvl, + expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), + ranVlInfo.getVlProfile().getVirtualLinkProfileId()); + vlInfo = retrieveVlInfo(nonMgmtVlpId, expNsd, expNsDf, expNsLvl); } addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } From 90ec48d39542b4b5649860b4ca496e83c880b423 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 18:16:16 +0200 Subject: [PATCH 137/187] Refactor methods to retrieve VNF and VL profiles. --- .../composer/nsd/compose/NsdComposer.java | 86 ++++--------------- 1 file changed, 15 insertions(+), 71 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 7c13703..b7e9d47 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -18,10 +18,8 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VirtualLinkToLevelMapping; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; -import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -36,19 +34,14 @@ public abstract class NsdComposer { protected NsdGraphService nsdGraphService; - // TODO refactor protected VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) throws NotExistingEntityException { - VnfProfile vnfProfile; - try { - vnfProfile = nsDf.getVnfProfile(vnfProfileId); - } catch (NotExistingEntityException e) { - String m = MessageFormatter - .format("VnfProfile='{}' not found in nsDf='{}'", vnfProfileId, nsDf.getNsDfId()) - .getMessage(); - throw new NotExistingEntityException(m); + for (VnfProfile vp : nsDf.getVnfProfile()) { + if (vp.getVnfProfileId().equals(vnfProfileId)) { + return vp; + } } - return vnfProfile; + throw new NotExistingEntityException("VNF profile not found for ID " + vnfProfileId); } protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) @@ -58,49 +51,17 @@ protected VnfProfile getVnfProfileByDescId(String vnfdId, NsDf nsDf) return vp; } } - throw new NotExistingEntityException("VNF profile for VNFD ID " + vnfdId + " not found"); - } - - protected VnfProfile getVnfProfileByDescIdOLd(String vnfdId, NsDf nsDf, NsLevel nsLvl) - throws NotExistingEntityException, VnfNotFoundInLvlMapping { - VnfProfile vnfProfile = null; - List filterVnfp = nsDf.getVnfProfile().stream() - .filter(p -> p.getVnfdId().equals(vnfdId)).collect(Collectors.toList()); - if (filterVnfp.isEmpty()) { - String m = MessageFormatter - .format("No VnfProfile with vnfdId='{}' found in nsDf='{}'", vnfdId, nsDf.getNsDfId()) - .getMessage(); - throw new NotExistingEntityException(m); - } - for (VnfProfile vnfp : filterVnfp) { - if (nsLvl.getVnfToLevelMapping().stream() - .anyMatch(m -> m.getVnfProfileId().equals(vnfp.getVnfProfileId()))) { - vnfProfile = vnfp; - break; - } - } - if (vnfProfile == null) { - String m = MessageFormatter - .format("No VnfProfile with vnfdId='{}' found in nsLvl='{}'", vnfdId, - nsLvl.getNsLevelId()) - .getMessage(); - throw new VnfNotFoundInLvlMapping(m); - } - return vnfProfile; + throw new NotExistingEntityException("VNF profile not found for VNFD ID " + vnfdId); } - protected VirtualLinkProfile getVlProfile(String vlProfileId, NsDf nsDf) + protected VirtualLinkProfile getVlProfileById(String vlProfileId, NsDf nsDf) throws NotExistingEntityException { - VirtualLinkProfile vlProfile; - try { - vlProfile = nsDf.getVirtualLinkProfile(vlProfileId); - } catch (NotExistingEntityException e) { - String m = MessageFormatter - .format("vlProfileId='{}' not found in nsDf='{}'.", vlProfileId, nsDf.getNsDfId()) - .getMessage(); - throw new NotExistingEntityException(m); + for (VirtualLinkProfile vp : nsDf.getVirtualLinkProfile()) { + if (vp.getVirtualLinkProfileId().equals(vlProfileId)) { + return vp; + } } - return vlProfile; + throw new NotExistingEntityException("VL profile not found for ID " + vlProfileId); } protected VirtualLinkProfile getVlProfileByDescId(String vldId, NsDf nsDf) @@ -110,24 +71,7 @@ protected VirtualLinkProfile getVlProfileByDescId(String vldId, NsDf nsDf) return vl; } } - throw new NotExistingEntityException("VL profile for VLD ID " + vldId + " not found"); - } - - protected VirtualLinkProfile getVlProfile(NsVirtualLinkDesc vld, NsDf nsDf) - throws NotExistingEntityException { - VirtualLinkProfile resultVlp; - Optional optVlp = nsDf.getVirtualLinkProfile().stream() - .filter(vlp -> vlp.getVirtualLinkDescId().equals(vld.getVirtualLinkDescId())).findFirst(); - if (optVlp.isPresent()) { - resultVlp = optVlp.get(); - } else { - String m = MessageFormatter - .format("vlProfile with VirtualLinkDescId='{}' not found in nsDf='{}'.", - vld.getVirtualLinkDescId(), nsDf.getNsDfId()) - .getMessage(); - throw new NotExistingEntityException(m); - } - return resultVlp; + throw new NotExistingEntityException("VL profile not found for VLD ID " + vldId); } protected VnfToLevelMapping getVnfLvlMapping(String vnfProfileId, NsLevel nsLvl) @@ -251,7 +195,7 @@ protected VlInfo retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel } VirtualLinkProfile vlProfile; try { - vlProfile = getVlProfile(vlProfileId, nsDf); + vlProfile = getVlProfileById(vlProfileId, nsDf); } catch (NotExistingEntityException e) { throw new InvalidNsdException(e.getMessage()); } @@ -268,7 +212,7 @@ protected VlInfo retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLeve throws InvalidNsdException, VlNotFoundInLvlMapping { VirtualLinkProfile vlProfile; try { - vlProfile = getVlProfile(vld, nsDf); + vlProfile = getVlProfileByDescId(vld.getVirtualLinkDescId(), nsDf); } catch (NotExistingEntityException e) { throw new InvalidNsdException(e.getMessage()); } From e0301cee468d4fdea6f70d707e63a25b86ca005c Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 18:25:05 +0200 Subject: [PATCH 138/187] refactor methods for retrieving Lvl mappings. Refactor VL descriptor get method. --- .../composer/nsd/compose/NsdComposer.java | 52 ++++++------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index b7e9d47..f60a4c7 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -76,50 +76,32 @@ protected VirtualLinkProfile getVlProfileByDescId(String vldId, NsDf nsDf) protected VnfToLevelMapping getVnfLvlMapping(String vnfProfileId, NsLevel nsLvl) throws NotExistingEntityException { - VnfToLevelMapping vnfLvlMap; - Optional optVnfLvlMap = nsLvl.getVnfToLevelMapping().stream() - .filter(m -> m.getVnfProfileId().equals(vnfProfileId)).findFirst(); - if (optVnfLvlMap.isPresent()) { - vnfLvlMap = optVnfLvlMap.get(); - } else { - String m = MessageFormatter - .format("vnfProfileId='{}' not found in nsLvl='{}'.", vnfProfileId, nsLvl.getNsLevelId()) - .getMessage(); - throw new NotExistingEntityException(m); + for (VnfToLevelMapping m: nsLvl.getVnfToLevelMapping()){ + if (m.getVnfProfileId().equals(vnfProfileId)){ + return m; + } } - return vnfLvlMap; + throw new NotExistingEntityException("Mapping not found for VNF profile ID " + vnfProfileId); } - protected NsVirtualLinkDesc getVlDescriptor(String vlDescId, Nsd nsd) + protected VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel nsLvl) throws NotExistingEntityException { - NsVirtualLinkDesc vlDesc; - Optional optVlDesc = nsd.getVirtualLinkDesc().stream() - .filter(nsdVlDesc -> nsdVlDesc.getVirtualLinkDescId().equals(vlDescId)).findFirst(); - if (optVlDesc.isPresent()) { - vlDesc = optVlDesc.get(); - } else { - String m = MessageFormatter - .format("vlDescId='{}' not found in nsd='{}'.", vlDescId, nsd.getNsdIdentifier()) - .getMessage(); - throw new NotExistingEntityException(m); + for (VirtualLinkToLevelMapping m: nsLvl.getVirtualLinkToLevelMapping()){ + if (m.getVirtualLinkProfileId().equals(vlProfileId)){ + return m; + } } - return vlDesc; + throw new NotExistingEntityException("Mapping not found for VL profile ID " + vlProfileId); } - protected VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel nsLvl) + protected NsVirtualLinkDesc getVlDescriptor(String vldId, Nsd nsd) throws NotExistingEntityException { - VirtualLinkToLevelMapping vlLvlMap; - Optional optVlLvlMap = nsLvl.getVirtualLinkToLevelMapping().stream() - .filter(m -> m.getVirtualLinkProfileId().equals(vlProfileId)).findFirst(); - if (optVlLvlMap.isPresent()) { - vlLvlMap = optVlLvlMap.get(); - } else { - String m = MessageFormatter - .format("vlProfileId='{}' not found in nsLvl='{}'.", vlProfileId, nsLvl.getNsLevelId()) - .getMessage(); - throw new NotExistingEntityException(m); + for (NsVirtualLinkDesc v: nsd.getVirtualLinkDesc()){ + if (v.getVirtualLinkDescId().equals(vldId)){ + return v; + } } - return vlLvlMap; + throw new NotExistingEntityException("Descriptor not found for VLD ID " + vldId); } protected void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { From 57c763e0416d3f18893a30b0fadfc0b4d3e4f82d Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 18:26:25 +0200 Subject: [PATCH 139/187] Reorder methods. --- .../composer/nsd/compose/NsdComposer.java | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index f60a4c7..99ba207 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -104,42 +104,6 @@ protected NsVirtualLinkDesc getVlDescriptor(String vldId, Nsd nsd) throw new NotExistingEntityException("Descriptor not found for VLD ID " + vldId); } - protected void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { - String vnfdId = vnfInfo.getVfndId(); - if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { - nsd.getVnfdId().add(vnfdId); - } - VnfProfile vnfProfile = vnfInfo.getVnfProfile(); - if (nsDf.getVnfProfile().stream() - .noneMatch(vp -> vp.getVnfProfileId().equals(vnfProfile.getVnfProfileId()))) { - nsDf.getVnfProfile().add(vnfProfile); - } - VnfToLevelMapping vnfLvlMap = vnfInfo.getVnfToLevelMapping(); - if (nsLevel.getVnfToLevelMapping().stream() - .noneMatch(lm -> lm.getVnfProfileId().equals(vnfProfile.getVnfProfileId()))) { - nsLevel.getVnfToLevelMapping().add(vnfLvlMap); - } - } - - protected void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { - NsVirtualLinkDesc vlDesc = vlInfo.getVlDescriptor(); - if (nsd.getVirtualLinkDesc().stream() - .noneMatch(nsdVld -> nsdVld.getVirtualLinkDescId().equals(vlDesc.getVirtualLinkDescId()))) { - nsd.getVirtualLinkDesc().add(vlDesc); - } - VirtualLinkProfile vlProfile = vlInfo.getVlProfile(); - if (nsDf.getVirtualLinkProfile().stream().noneMatch( - nsdfVlP -> nsdfVlP.getVirtualLinkProfileId().equals(vlProfile.getVirtualLinkProfileId()))) { - nsDf.getVirtualLinkProfile().add(vlProfile); - } - VirtualLinkToLevelMapping vlMap = vlInfo.getVlToLevelMapping(); - if (nsLevel.getVirtualLinkToLevelMapping().stream().noneMatch( - nslevelMap -> nslevelMap.getVirtualLinkProfileId() - .equals(vlMap.getVirtualLinkProfileId()))) { - nsLevel.getVirtualLinkToLevelMapping().add(vlMap); - } - } - protected VnfInfo retrieveVnfInfoByProfileId(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) throws InvalidNsdException, VnfNotFoundInLvlMapping { @@ -207,6 +171,42 @@ protected VlInfo retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLeve return new VlInfo(vlMap, vlProfile, vld); } + protected void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { + String vnfdId = vnfInfo.getVfndId(); + if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { + nsd.getVnfdId().add(vnfdId); + } + VnfProfile vnfProfile = vnfInfo.getVnfProfile(); + if (nsDf.getVnfProfile().stream() + .noneMatch(vp -> vp.getVnfProfileId().equals(vnfProfile.getVnfProfileId()))) { + nsDf.getVnfProfile().add(vnfProfile); + } + VnfToLevelMapping vnfLvlMap = vnfInfo.getVnfToLevelMapping(); + if (nsLevel.getVnfToLevelMapping().stream() + .noneMatch(lm -> lm.getVnfProfileId().equals(vnfProfile.getVnfProfileId()))) { + nsLevel.getVnfToLevelMapping().add(vnfLvlMap); + } + } + + protected void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { + NsVirtualLinkDesc vlDesc = vlInfo.getVlDescriptor(); + if (nsd.getVirtualLinkDesc().stream() + .noneMatch(nsdVld -> nsdVld.getVirtualLinkDescId().equals(vlDesc.getVirtualLinkDescId()))) { + nsd.getVirtualLinkDesc().add(vlDesc); + } + VirtualLinkProfile vlProfile = vlInfo.getVlProfile(); + if (nsDf.getVirtualLinkProfile().stream().noneMatch( + nsdfVlP -> nsdfVlP.getVirtualLinkProfileId().equals(vlProfile.getVirtualLinkProfileId()))) { + nsDf.getVirtualLinkProfile().add(vlProfile); + } + VirtualLinkToLevelMapping vlMap = vlInfo.getVlToLevelMapping(); + if (nsLevel.getVirtualLinkToLevelMapping().stream().noneMatch( + nslevelMap -> nslevelMap.getVirtualLinkProfileId() + .equals(vlMap.getVirtualLinkProfileId()))) { + nsLevel.getVirtualLinkToLevelMapping().add(vlMap); + } + } + protected void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vlp) throws NotExistingEntityException { Optional optVlConn = vnfp.getNsVirtualLinkConnectivity().stream() From 27c19a9b909a07a59285521f05e07e20e877c138 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 18:35:40 +0200 Subject: [PATCH 140/187] Refactor method to retrieve full vnfinfo safely. --- .../composer/nsd/compose/ConnectComposer.java | 2 +- .../composer/nsd/compose/NsdComposer.java | 38 ++++++++----------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index d0f48cd..4514404 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -117,7 +117,7 @@ public void composeWithStrategy( addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } } - } catch (NotExistingEntityException | VnfNotFoundInLvlMapping | VlNotFoundInLvlMapping e) { + } catch (NotExistingEntityException | VlNotFoundInLvlMapping e) { log.error(e.getMessage()); throw new InvalidNsdException("Nsd " + ctxNsd.getNsdIdentifier(), e); } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 99ba207..2474469 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -94,6 +94,16 @@ protected VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel throw new NotExistingEntityException("Mapping not found for VL profile ID " + vlProfileId); } + protected String getVnfDescId(String vnfdId, Nsd nsd) + throws NotExistingEntityException { + for (String id: nsd.getVnfdId()){ + if (id.equals(vnfdId)){ + return id; + } + } + throw new NotExistingEntityException("VNFD ID not found for ID " + vnfdId); + } + protected NsVirtualLinkDesc getVlDescriptor(String vldId, Nsd nsd) throws NotExistingEntityException { for (NsVirtualLinkDesc v: nsd.getVirtualLinkDesc()){ @@ -106,29 +116,11 @@ protected NsVirtualLinkDesc getVlDescriptor(String vldId, Nsd nsd) protected VnfInfo retrieveVnfInfoByProfileId(String vnfProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) - throws InvalidNsdException, VnfNotFoundInLvlMapping { - VnfToLevelMapping vnfLvlMap; - try { - vnfLvlMap = getVnfLvlMapping(vnfProfileId, nsLevel); - } catch (NotExistingEntityException e) { - throw new VnfNotFoundInLvlMapping(e.getMessage()); - } - VnfProfile vnfProfile; - try { - vnfProfile = getVnfProfileById(vnfProfileId, nsDf); - } catch (NotExistingEntityException e) { - throw new InvalidNsdException(e.getMessage()); - } - Optional optVnfdId = nsd.getVnfdId().stream() - .filter(id -> id.equals(vnfProfile.getVnfdId())).findFirst(); - if (!optVnfdId.isPresent()) { - String m = MessageFormatter - .format("vnfdId='{}' not found in nsd='{}'.", vnfProfile.getVnfdId(), - nsd.getNsdIdentifier()) - .getMessage(); - throw new InvalidNsdException(m); - } - return new VnfInfo(vnfProfile.getVnfdId(), vnfProfile, vnfLvlMap); + throws NotExistingEntityException { + VnfToLevelMapping vnfLvlMap = getVnfLvlMapping(vnfProfileId, nsLevel); + VnfProfile vnfProfile = getVnfProfileById(vnfProfileId, nsDf);; + String vnfdId = getVnfDescId(vnfProfile.getVnfdId(), nsd); + return new VnfInfo(vnfdId, vnfProfile, vnfLvlMap); } protected VlInfo retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) From 0d165d6f1ed24978bff14de64f9be8e1a661bfe9 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 18:51:40 +0200 Subject: [PATCH 141/187] Refactor vlinfo methods. --- .../composer/nsd/compose/ConnectComposer.java | 6 +- .../composer/nsd/compose/NsdComposer.java | 71 +++++++------------ .../nsd/compose/PassThroughComposer.java | 9 ++- 3 files changed, 31 insertions(+), 55 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index 4514404..ebc2c61 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -102,7 +102,7 @@ public void composeWithStrategy( expNsLvl, expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), ranVlInfo.getVlProfile().getVirtualLinkProfileId()); - vlInfo = retrieveVlInfo(nonMgmtVlpId, expNsd, expNsDf, expNsLvl); + vlInfo = retrieveVlInfoByProfileId(nonMgmtVlpId, expNsd, expNsDf, expNsLvl); } addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } @@ -113,11 +113,11 @@ public void composeWithStrategy( VnfInfo vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); vnfInfo.setVlcLists(mgmtVlProfileIds); String vlpId = getVlProfileByDescId(entry.getValue(), ctxNsDf).getVirtualLinkProfileId(); - VlInfo vlInfo = retrieveVlInfo(vlpId, ctxNsd, ctxNsDf, ctxNsLvl); + VlInfo vlInfo = retrieveVlInfoByProfileId(vlpId, ctxNsd, ctxNsDf, ctxNsLvl); addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } } - } catch (NotExistingEntityException | VlNotFoundInLvlMapping e) { + } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsdException("Nsd " + ctxNsd.getNsdIdentifier(), e); } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 2474469..d80ff41 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -76,8 +76,8 @@ protected VirtualLinkProfile getVlProfileByDescId(String vldId, NsDf nsDf) protected VnfToLevelMapping getVnfLvlMapping(String vnfProfileId, NsLevel nsLvl) throws NotExistingEntityException { - for (VnfToLevelMapping m: nsLvl.getVnfToLevelMapping()){ - if (m.getVnfProfileId().equals(vnfProfileId)){ + for (VnfToLevelMapping m : nsLvl.getVnfToLevelMapping()) { + if (m.getVnfProfileId().equals(vnfProfileId)) { return m; } } @@ -86,8 +86,8 @@ protected VnfToLevelMapping getVnfLvlMapping(String vnfProfileId, NsLevel nsLvl) protected VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel nsLvl) throws NotExistingEntityException { - for (VirtualLinkToLevelMapping m: nsLvl.getVirtualLinkToLevelMapping()){ - if (m.getVirtualLinkProfileId().equals(vlProfileId)){ + for (VirtualLinkToLevelMapping m : nsLvl.getVirtualLinkToLevelMapping()) { + if (m.getVirtualLinkProfileId().equals(vlProfileId)) { return m; } } @@ -96,8 +96,8 @@ protected VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel protected String getVnfDescId(String vnfdId, Nsd nsd) throws NotExistingEntityException { - for (String id: nsd.getVnfdId()){ - if (id.equals(vnfdId)){ + for (String id : nsd.getVnfdId()) { + if (id.equals(vnfdId)) { return id; } } @@ -106,8 +106,8 @@ protected String getVnfDescId(String vnfdId, Nsd nsd) protected NsVirtualLinkDesc getVlDescriptor(String vldId, Nsd nsd) throws NotExistingEntityException { - for (NsVirtualLinkDesc v: nsd.getVirtualLinkDesc()){ - if (v.getVirtualLinkDescId().equals(vldId)){ + for (NsVirtualLinkDesc v : nsd.getVirtualLinkDesc()) { + if (v.getVirtualLinkDescId().equals(vldId)) { return v; } } @@ -118,51 +118,28 @@ protected VnfInfo retrieveVnfInfoByProfileId(String vnfProfileId, Nsd nsd, NsDf NsLevel nsLevel) throws NotExistingEntityException { VnfToLevelMapping vnfLvlMap = getVnfLvlMapping(vnfProfileId, nsLevel); - VnfProfile vnfProfile = getVnfProfileById(vnfProfileId, nsDf);; + VnfProfile vnfProfile = getVnfProfileById(vnfProfileId, nsDf); String vnfdId = getVnfDescId(vnfProfile.getVnfdId(), nsd); return new VnfInfo(vnfdId, vnfProfile, vnfLvlMap); } - protected VlInfo retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) - throws InvalidNsdException, VlNotFoundInLvlMapping { - VirtualLinkToLevelMapping vlMap; - try { - vlMap = getVlLvlMapping(vlProfileId, nsLevel); - } catch (NotExistingEntityException e) { - throw new VlNotFoundInLvlMapping(e.getMessage()); - } - VirtualLinkProfile vlProfile; - try { - vlProfile = getVlProfileById(vlProfileId, nsDf); - } catch (NotExistingEntityException e) { - throw new InvalidNsdException(e.getMessage()); - } - NsVirtualLinkDesc vlDesc; - try { - vlDesc = getVlDescriptor(vlProfile.getVirtualLinkDescId(), nsd); - } catch (NotExistingEntityException e) { - throw new InvalidNsdException(e.getMessage()); - } + protected VlInfo retrieveVlInfoByProfileId(String vlProfileId, Nsd nsd, NsDf nsDf, + NsLevel nsLevel) + throws NotExistingEntityException { + VirtualLinkToLevelMapping vlMap = getVlLvlMapping(vlProfileId, nsLevel); + VirtualLinkProfile vlProfile = getVlProfileById(vlProfileId, nsDf); + NsVirtualLinkDesc vlDesc = getVlDescriptor(vlProfile.getVirtualLinkDescId(), nsd); return new VlInfo(vlMap, vlProfile, vlDesc); } - protected VlInfo retrieveVlInfo(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLevel) - throws InvalidNsdException, VlNotFoundInLvlMapping { - VirtualLinkProfile vlProfile; - try { - vlProfile = getVlProfileByDescId(vld.getVirtualLinkDescId(), nsDf); - } catch (NotExistingEntityException e) { - throw new InvalidNsdException(e.getMessage()); - } - VirtualLinkToLevelMapping vlMap; - try { - vlMap = getVlLvlMapping(vlProfile.getVirtualLinkProfileId(), nsLevel); - } catch (NotExistingEntityException e) { - throw new VlNotFoundInLvlMapping(e.getMessage()); - } + protected VlInfo retrieveVlInfoByDesc(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLevel) + throws NotExistingEntityException { + VirtualLinkProfile vlProfile = getVlProfileByDescId(vld.getVirtualLinkDescId(), nsDf); + VirtualLinkToLevelMapping vlMap = getVlLvlMapping(vlProfile.getVirtualLinkProfileId(), nsLevel); return new VlInfo(vlMap, vlProfile, vld); } + //TODO refactor from here protected void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { String vnfdId = vnfInfo.getVfndId(); if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { @@ -262,15 +239,15 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, VlInfo expMgmtVlInfo; VlInfo ctxMgmtVlInfo; try { - ranVlInfo = retrieveVlInfo(ranVld, expNsDf, expNsLvl); + ranVlInfo = retrieveVlInfoByDesc(ranVld, expNsDf, expNsLvl); log.debug("Found VlInfo for ranVld='{}' in expNsd.", ranVld.getVirtualLinkDescId()); - expMgmtVlInfo = retrieveVlInfo(expMgmtVld, expNsDf, expNsLvl); + expMgmtVlInfo = retrieveVlInfoByDesc(expMgmtVld, expNsDf, expNsLvl); log.debug("Found VlInfo for expMgmtVld='{}' in expNsd.", expMgmtVld.getVirtualLinkDescId()); - ctxMgmtVlInfo = retrieveVlInfo(ctxMgmtVld, ctxNsDf, ctxNsLvl); + ctxMgmtVlInfo = retrieveVlInfoByDesc(ctxMgmtVld, ctxNsDf, ctxNsLvl); log.debug("Found VlInfo for ctxMgmtVld='{}' in ctxNsd.", ctxMgmtVld.getVirtualLinkDescId()); - } catch (InvalidNsdException | VlNotFoundInLvlMapping e) { + } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsdException(e.getMessage()); } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index 370bda5..49b75e0 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -48,19 +48,18 @@ public void composeWithStrategy( ctxVnfInfo = retrieveVnfInfoByProfileId(ctxVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); log.debug("Found VnfInfo for vnfpId='{}' in context.", ctxVnfpId); ctxVnfInfo.setVlcLists(mgmtVlProfileIds); - } catch (VnfNotFoundInLvlMapping | NotExistingEntityException e) { + } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsdException(e.getMessage(), e); } // Retrieve non-management VLs from ctx // Assumption: select the first Vl attached to ctxVnf - Map ctxVnfCpds; VlInfo ctxNonMgmtVl; try { - ctxNonMgmtVl = retrieveVlInfo(ctxVnfInfo.getDataVlcList().get(0).getVirtualLinkProfileId(), + ctxNonMgmtVl = retrieveVlInfoByProfileId(ctxVnfInfo.getDataVlcList().get(0).getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); - } catch (InvalidNsdException | VlNotFoundInLvlMapping e) { + } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsdException(e.getMessage()); } @@ -74,7 +73,7 @@ public void composeWithStrategy( VnfInfo vnfInfo; try { vnfInfo = retrieveVnfInfoByProfileId(vnfLvl.getVnfProfileId(), expNsd, expNsDf, expNsLvl); - } catch (VnfNotFoundInLvlMapping e) { + } catch (NotExistingEntityException e) { log.error(e.getMessage()); throw new InvalidNsdException(e.getMessage()); } From c304036fc4cf72f8d3c0a61c7af40e92765d2ab6 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 18:53:52 +0200 Subject: [PATCH 142/187] Reorder instance params for vlinfo. --- .../it/cnit/blueprint/composer/nsd/compose/NsdComposer.java | 4 ++-- .../java/it/cnit/blueprint/composer/nsd/compose/VlInfo.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index d80ff41..6448285 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -129,14 +129,14 @@ protected VlInfo retrieveVlInfoByProfileId(String vlProfileId, Nsd nsd, NsDf nsD VirtualLinkToLevelMapping vlMap = getVlLvlMapping(vlProfileId, nsLevel); VirtualLinkProfile vlProfile = getVlProfileById(vlProfileId, nsDf); NsVirtualLinkDesc vlDesc = getVlDescriptor(vlProfile.getVirtualLinkDescId(), nsd); - return new VlInfo(vlMap, vlProfile, vlDesc); + return new VlInfo(vlDesc, vlProfile, vlMap); } protected VlInfo retrieveVlInfoByDesc(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel nsLevel) throws NotExistingEntityException { VirtualLinkProfile vlProfile = getVlProfileByDescId(vld.getVirtualLinkDescId(), nsDf); VirtualLinkToLevelMapping vlMap = getVlLvlMapping(vlProfile.getVirtualLinkProfileId(), nsLevel); - return new VlInfo(vlMap, vlProfile, vld); + return new VlInfo(vld, vlProfile, vlMap); } //TODO refactor from here diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlInfo.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlInfo.java index a958ce6..ce55914 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlInfo.java @@ -10,7 +10,7 @@ @AllArgsConstructor public class VlInfo { - private VirtualLinkToLevelMapping vlToLevelMapping; - private VirtualLinkProfile vlProfile; private NsVirtualLinkDesc vlDescriptor; + private VirtualLinkProfile vlProfile; + private VirtualLinkToLevelMapping vlToLevelMapping; } From 9f58662d691505d27af18f9ec7181f49bee7fa83 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 19:18:49 +0200 Subject: [PATCH 143/187] Fix variable name typo in vnfinfo. --- .../it/cnit/blueprint/composer/nsd/compose/NsdComposer.java | 2 +- .../java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 6448285..d19abb9 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -141,7 +141,7 @@ protected VlInfo retrieveVlInfoByDesc(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel //TODO refactor from here protected void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { - String vnfdId = vnfInfo.getVfndId(); + String vnfdId = vnfInfo.getVnfdId(); if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { nsd.getVnfdId().add(vnfdId); } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java index 529bfbe..aedfc07 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java @@ -14,7 +14,7 @@ @RequiredArgsConstructor public class VnfInfo { - private final String vfndId; + private final String vnfdId; private final VnfProfile vnfProfile; private final VnfToLevelMapping vnfToLevelMapping; private List mgmtVlcList; From b57fe93bbeb5c6557cbe9f5e48bf56bec6301929 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 19:32:33 +0200 Subject: [PATCH 144/187] Refactor connectVnfToVl. --- .../composer/nsd/compose/NsdComposer.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index d19abb9..dae9ee5 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -139,7 +139,6 @@ protected VlInfo retrieveVlInfoByDesc(NsVirtualLinkDesc vld, NsDf nsDf, NsLevel return new VlInfo(vld, vlProfile, vlMap); } - //TODO refactor from here protected void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { String vnfdId = vnfInfo.getVnfdId(); if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { @@ -178,17 +177,13 @@ protected void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel protected void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vlp) throws NotExistingEntityException { - Optional optVlConn = vnfp.getNsVirtualLinkConnectivity().stream() - .filter(vlConn -> vlConn.getCpdId().get(0).equals(cpdId)).findFirst(); - if (optVlConn.isPresent()) { - optVlConn.get().setVirtualLinkProfileId(vlp.getVirtualLinkProfileId()); - } else { - String m = MessageFormatter - .format("cpdId='{}' not found in vnfProfile='{}'.", cpdId, vnfp.getVnfProfileId()) - .getMessage(); - throw new NotExistingEntityException(m); + for (NsVirtualLinkConnectivity nsVlC : vnfp.getNsVirtualLinkConnectivity()) { + if (nsVlC.getCpdId().contains(cpdId)) { + nsVlC.setVirtualLinkProfileId(vlp.getVirtualLinkProfileId()); + return; + } } - + throw new NotExistingEntityException("VL connectivity not found for CPD ID " + cpdId); } public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws InvalidNsdException { From 005c572e30e88c3ef37346fa791cb74208993a79 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 19:36:11 +0200 Subject: [PATCH 145/187] Refactor addvnf and addVirtualLink. --- .../composer/nsd/compose/NsdComposer.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index dae9ee5..7937eca 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -144,33 +144,32 @@ protected void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { nsd.getVnfdId().add(vnfdId); } - VnfProfile vnfProfile = vnfInfo.getVnfProfile(); + VnfProfile vnfp = vnfInfo.getVnfProfile(); if (nsDf.getVnfProfile().stream() - .noneMatch(vp -> vp.getVnfProfileId().equals(vnfProfile.getVnfProfileId()))) { - nsDf.getVnfProfile().add(vnfProfile); + .noneMatch(vp -> vp.getVnfProfileId().equals(vnfp.getVnfProfileId()))) { + nsDf.getVnfProfile().add(vnfp); } - VnfToLevelMapping vnfLvlMap = vnfInfo.getVnfToLevelMapping(); + VnfToLevelMapping vnfMap = vnfInfo.getVnfToLevelMapping(); if (nsLevel.getVnfToLevelMapping().stream() - .noneMatch(lm -> lm.getVnfProfileId().equals(vnfProfile.getVnfProfileId()))) { - nsLevel.getVnfToLevelMapping().add(vnfLvlMap); + .noneMatch(lm -> lm.getVnfProfileId().equals(vnfp.getVnfProfileId()))) { + nsLevel.getVnfToLevelMapping().add(vnfMap); } } protected void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { - NsVirtualLinkDesc vlDesc = vlInfo.getVlDescriptor(); + NsVirtualLinkDesc vld = vlInfo.getVlDescriptor(); if (nsd.getVirtualLinkDesc().stream() - .noneMatch(nsdVld -> nsdVld.getVirtualLinkDescId().equals(vlDesc.getVirtualLinkDescId()))) { - nsd.getVirtualLinkDesc().add(vlDesc); + .noneMatch(nsdVld -> nsdVld.getVirtualLinkDescId().equals(vld.getVirtualLinkDescId()))) { + nsd.getVirtualLinkDesc().add(vld); } - VirtualLinkProfile vlProfile = vlInfo.getVlProfile(); - if (nsDf.getVirtualLinkProfile().stream().noneMatch( - nsdfVlP -> nsdfVlP.getVirtualLinkProfileId().equals(vlProfile.getVirtualLinkProfileId()))) { - nsDf.getVirtualLinkProfile().add(vlProfile); + VirtualLinkProfile vlp = vlInfo.getVlProfile(); + if (nsDf.getVirtualLinkProfile().stream() + .noneMatch(vp -> vp.getVirtualLinkProfileId().equals(vlp.getVirtualLinkProfileId()))) { + nsDf.getVirtualLinkProfile().add(vlp); } VirtualLinkToLevelMapping vlMap = vlInfo.getVlToLevelMapping(); - if (nsLevel.getVirtualLinkToLevelMapping().stream().noneMatch( - nslevelMap -> nslevelMap.getVirtualLinkProfileId() - .equals(vlMap.getVirtualLinkProfileId()))) { + if (nsLevel.getVirtualLinkToLevelMapping().stream() + .noneMatch(lm -> lm.getVirtualLinkProfileId().equals(vlMap.getVirtualLinkProfileId()))) { nsLevel.getVirtualLinkToLevelMapping().add(vlMap); } } From f681fdfe8d4505fcfa091b028fbc9a2ea2e32dd8 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 29 Apr 2020 19:43:32 +0200 Subject: [PATCH 146/187] Refactor getRanVlDesc. --- .../it/cnit/blueprint/composer/nsd/compose/NsdComposer.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 7937eca..d70a618 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -186,14 +186,12 @@ protected void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile } public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws InvalidNsdException { - NsVirtualLinkDesc ranVld; try { - ranVld = getVlDescriptor(ranSapd.getNsVirtualLinkDescId(), expNsd); + return getVlDescriptor(ranSapd.getNsVirtualLinkDescId(), expNsd); } catch (NotExistingEntityException e) { log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); + throw new InvalidNsdException("VLD not found for SAP " + ranSapd.getCpdId(), e); } - return ranVld; } @SneakyThrows(JsonProcessingException.class) From db66e040c79dabe4a4d8120eda3f3209f1f5fc6e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 3 May 2020 17:26:16 +0200 Subject: [PATCH 147/187] Improve exception handling and messages in NsdComposer. --- .../composer/nsd/compose/NsdComposer.java | 39 ++++++++++--------- .../composer/rest/ExperimentsController.java | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index d70a618..cca214f 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -19,12 +19,10 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; import java.util.Map; -import java.util.Optional; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.jgrapht.Graph; -import org.slf4j.helpers.MessageFormatter; @Slf4j @AllArgsConstructor @@ -220,28 +218,35 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, .buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("expG BEFORE composition :\n{}", nsdGraphService.export(expG)); if (!nsdGraphService.isConnected(expG)) { - String m = MessageFormatter.format( - "Network topology for NsLevel='{}' is not connected", expNsLvl.getNsLevelId()) - .getMessage(); - log.error(m); - throw new InvalidNsdException(m); + throw new InvalidNsdException( + "Network topology not connected for NsDf " + expNsDf.getNsDfId() + " and NsLevel " + + expNsLvl.getNsLevelId()); } VlInfo ranVlInfo; - VlInfo expMgmtVlInfo; - VlInfo ctxMgmtVlInfo; try { ranVlInfo = retrieveVlInfoByDesc(ranVld, expNsDf, expNsLvl); log.debug("Found VlInfo for ranVld='{}' in expNsd.", ranVld.getVirtualLinkDescId()); + } catch (NotExistingEntityException e) { + throw new InvalidNsdException("Error retrieving RAN VL info for VLD " + ranVld, e); + } + VlInfo expMgmtVlInfo; + try { expMgmtVlInfo = retrieveVlInfoByDesc(expMgmtVld, expNsDf, expNsLvl); log.debug("Found VlInfo for expMgmtVld='{}' in expNsd.", expMgmtVld.getVirtualLinkDescId()); + } catch (NotExistingEntityException e) { + throw new InvalidNsdException( + "Error retrieving Experiment Management VL info for VLD " + ranVld, e); + } + VlInfo ctxMgmtVlInfo; + try { ctxMgmtVlInfo = retrieveVlInfoByDesc(ctxMgmtVld, ctxNsDf, ctxNsLvl); log.debug("Found VlInfo for ctxMgmtVld='{}' in ctxNsd.", ctxMgmtVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); + throw new InvalidNsdException( + "Error retrieving Context Management VL info for VLD " + ranVld, e); } composeWithStrategy(connectInput, ranVlInfo, expMgmtVlInfo, ctxMgmtVlInfo, expNsd, expNsDf, expNsLvl, @@ -251,19 +256,15 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, try { expNsd.isValid(); } catch (MalformattedElementException e) { - String m = "Nsd looks not valid after composition"; - log.error(m, e); - throw new InvalidNsdException(m); + throw new InvalidNsdException("Nsd not valid after composition", e); } expG = nsdGraphService.buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("Graph AFTER composition with {}:\n{}", ctxNsd.getNsdIdentifier(), nsdGraphService.export(expG)); if (!nsdGraphService.isConnected(expG)) { - String m = MessageFormatter.format("Network topology not connected after composition", - expNsDf.getNsDfId(), expNsLvl.getNsLevelId()) - .getMessage(); - log.error(m); - throw new InvalidNsdException(m); + throw new InvalidNsdException( + "Network topology not connected for NsDf " + expNsDf.getNsDfId() + " and NsLevel " + + expNsLvl.getNsLevelId()); } log.info("Completed composition for nsDf='{}' and nsLvl='{}'", expNsDf.getNsDfId(), expNsLvl.getNsLevelId()); diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 776d4f5..e0d39bf 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -91,7 +91,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ } } catch (InvalidVsbException | InvalidNsdException | InvalidContextException e) { - log.error(e.getMessage()); + log.error(e.getMessage(), e); //TODO create and return a 422 response. } From ae3c5ae47ba5d259f5765099164d67af691bd1f0 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 3 May 2020 17:52:09 +0200 Subject: [PATCH 148/187] More specific exception handling in ConnectComposer. --- .../composer/nsd/compose/ConnectComposer.java | 67 +++++++++++++------ 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index ebc2c61..862f50b 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -85,41 +85,68 @@ public void composeWithStrategy( List mgmtVlProfileIds = Arrays.asList( ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); - try { - if (connectInput.isEmpty()) { - // select all VNFs - boolean first = true; - for (VnfToLevelMapping vnfMap : ctxNsLvl.getVnfToLevelMapping()) { - String vnfpId = vnfMap.getVnfProfileId(); - VnfInfo vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); + if (connectInput.isEmpty()) { + // select all VNFs + boolean first = true; + for (VnfToLevelMapping vnfMap : ctxNsLvl.getVnfToLevelMapping()) { + String vnfpId = vnfMap.getVnfProfileId(); + VnfInfo vnfInfo; + try { + vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); vnfInfo.setVlcLists(mgmtVlProfileIds); - VlInfo vlInfo; - if (first) { - vlInfo = ranVlInfo; - first = false; - } else { + } catch (NotExistingEntityException e) { + throw new InvalidNsdException( + "Error retrieving VNF info for VNF profile ID " + vnfpId, e); + } + VlInfo vlInfo; + if (first) { + vlInfo = ranVlInfo; + first = false; + } else { + try { String nonMgmtVlpId = getNonMgmtVlProfileId( expNsLvl, expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), ranVlInfo.getVlProfile().getVirtualLinkProfileId()); vlInfo = retrieveVlInfoByProfileId(nonMgmtVlpId, expNsd, expNsDf, expNsLvl); + } catch (NotExistingEntityException e) { + throw new InvalidNsdException("Error retrieving VL info for a non-management VL", e); } + } + try { addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); + } catch (NotExistingEntityException e) { + throw new InvalidNsdException( + "Error connecting VNF profile " + vnfInfo.getVnfProfile().getVnfProfileId(), e); } - } else { - // only VNFs in connectInput - for (Entry entry : connectInput.entrySet()) { + } + } else { + // only VNFs in connectInput + for (Entry entry : connectInput.entrySet()) { + VnfInfo vnfInfo; + try { String vnfpId = getVnfProfileByDescId(entry.getKey(), ctxNsDf).getVnfProfileId(); - VnfInfo vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); + vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); vnfInfo.setVlcLists(mgmtVlProfileIds); + } catch (NotExistingEntityException e) { + throw new InvalidNsdException( + "Error retrieving VNF info for VNFD ID " + entry.getKey(), e); + } + VlInfo vlInfo; + try { String vlpId = getVlProfileByDescId(entry.getValue(), ctxNsDf).getVirtualLinkProfileId(); - VlInfo vlInfo = retrieveVlInfoByProfileId(vlpId, ctxNsd, ctxNsDf, ctxNsLvl); + vlInfo = retrieveVlInfoByProfileId(vlpId, ctxNsd, ctxNsDf, ctxNsLvl); + } catch (NotExistingEntityException e) { + throw new InvalidNsdException( + "Error retrieving VL info for VLD ID " + entry.getValue(), e); + } + try { addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); + } catch (NotExistingEntityException e) { + throw new InvalidNsdException( + "Error connecting VNF profile " + vnfInfo.getVnfProfile().getVnfProfileId(), e); } } - } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsdException("Nsd " + ctxNsd.getNsdIdentifier(), e); } } } From 205649abf8fddbaa3b77cabd08d2d75669eee1f7 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 3 May 2020 18:20:45 +0200 Subject: [PATCH 149/187] Review Passthrough. Improve exceptions. --- .../nsd/compose/PassThroughComposer.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index 49b75e0..cd10625 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -42,6 +42,7 @@ public void composeWithStrategy( expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); // Retrieve ctx VNF + // Assumption: a PASS_TROUGH context has only one VnfD and VnfProfile. String ctxVnfpId = ctxNsLvl.getVnfToLevelMapping().get(0).getVnfProfileId(); VnfInfo ctxVnfInfo; try { @@ -49,19 +50,19 @@ public void composeWithStrategy( log.debug("Found VnfInfo for vnfpId='{}' in context.", ctxVnfpId); ctxVnfInfo.setVlcLists(mgmtVlProfileIds); } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage(), e); + throw new InvalidNsdException( + "Error retrieving VNF info for VNF profile ID " + ctxVnfpId, e); } // Retrieve non-management VLs from ctx // Assumption: select the first Vl attached to ctxVnf VlInfo ctxNonMgmtVl; try { - ctxNonMgmtVl = retrieveVlInfoByProfileId(ctxVnfInfo.getDataVlcList().get(0).getVirtualLinkProfileId(), + ctxNonMgmtVl = retrieveVlInfoByProfileId( + ctxVnfInfo.getDataVlcList().get(0).getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); + throw new InvalidNsdException("Error retrieving VL info for a non-management VL", e); } // Retrieve RAN closest VNF information from exp @@ -70,26 +71,25 @@ public void composeWithStrategy( String ranVnfCpd = null; VnfProfile ranVnfProfile = null; for (VnfToLevelMapping vnfLvl : expNsLvl.getVnfToLevelMapping()) { - VnfInfo vnfInfo; + VnfProfile vnfProfile; try { - vnfInfo = retrieveVnfInfoByProfileId(vnfLvl.getVnfProfileId(), expNsd, expNsDf, expNsLvl); + vnfProfile = getVnfProfileById(vnfLvl.getVnfProfileId(), expNsDf); } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); + throw new InvalidNsdException( + "Error retrieving VNF info for VNF profile ID " + vnfLvl.getVnfProfileId(), e); } - for (NsVirtualLinkConnectivity vlc : vnfInfo.getVnfProfile().getNsVirtualLinkConnectivity()) { + for (NsVirtualLinkConnectivity vlc : vnfProfile.getNsVirtualLinkConnectivity()) { if (vlc.getVirtualLinkProfileId() .equals(ranVlInfo.getVlProfile().getVirtualLinkProfileId())) { ranVnfCpd = vlc.getCpdId().get(0); - ranVnfProfile = vnfInfo.getVnfProfile(); + ranVnfProfile = vnfProfile; break; } } } if (ranVnfCpd == null) { - String m = "Can't find a VNF close to ranVlInfo"; - log.error(m); - throw new InvalidNsdException(m); + throw new InvalidNsdException( + "Can't find a VNF close to ranVlInfo in nsLevel " + expNsLvl.getNsLevelId()); } log.debug("ranVnfProfile: '{}'", ranVnfProfile.getVnfProfileId()); log.debug("ranVnfCpd: '{}'", ranVnfCpd); @@ -130,8 +130,7 @@ public void composeWithStrategy( ctxVnfInfo.cleanUpVlc(ctxVnfInfo.getDataVlcList().get(i)); } } catch (NotExistingEntityException e) { - log.error(e.getMessage()); - throw new InvalidNsdException(e.getMessage()); + throw new InvalidNsdException("Error in connecting VNF to VL.", e); } } } From 57557273642b2a1969df051841c722087988bc6a Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 3 May 2020 18:22:19 +0200 Subject: [PATCH 150/187] Remove unneeded custom exceptions. --- .../composer/nsd/compose/VlNotFoundInLvlMapping.java | 8 -------- .../composer/nsd/compose/VnfNotFoundInLvlMapping.java | 8 -------- 2 files changed, 16 deletions(-) delete mode 100644 src/main/java/it/cnit/blueprint/composer/nsd/compose/VlNotFoundInLvlMapping.java delete mode 100644 src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfNotFoundInLvlMapping.java diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlNotFoundInLvlMapping.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlNotFoundInLvlMapping.java deleted file mode 100644 index b4616a0..0000000 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlNotFoundInLvlMapping.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.composer.nsd.compose; - -public class VlNotFoundInLvlMapping extends Exception { - - public VlNotFoundInLvlMapping(String message) { - super(message); - } -} diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfNotFoundInLvlMapping.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfNotFoundInLvlMapping.java deleted file mode 100644 index 6c5bbb9..0000000 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfNotFoundInLvlMapping.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.composer.nsd.compose; - -public class VnfNotFoundInLvlMapping extends Exception { - - public VnfNotFoundInLvlMapping(String message) { - super(message); - } -} From 34a9128cae49de08d2c863d5609a2eb3b37d6306 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 3 May 2020 18:24:19 +0200 Subject: [PATCH 151/187] Remove leftover single quotes from messages. --- .../cnit/blueprint/composer/nsd/compose/ConnectComposer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index 862f50b..fa13ed4 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -48,12 +48,12 @@ private void addConnectVnfToVl(VnfInfo vnfInfo, VlInfo dataVlInfo, VlInfo mgmtVl // Modify expNsd addVnf(vnfInfo, expNsd, expNsDf, expNsLvl); log.debug( - "Added VnfProfile='{}' in service (if not present).", + "Added VnfProfile {} in service (if not present).", vnfInfo.getVnfProfile().getVnfProfileId()); connectVnfToVL(vnfInfo.getVnfProfile(), vnfInfo.getDataVlcList().get(0).getCpdId().get(0), dataVlInfo.getVlProfile()); log.debug( - "Created connection between vnfProfile='{}' and vlProfile='{}'", + "Created connection between vnfProfile {} and vlProfile {}", vnfInfo.getVnfProfile().getVnfProfileId(), dataVlInfo.getVlProfile().getVirtualLinkProfileId()); for (int i = 1; i < vnfInfo.getDataVlcList().size(); i++) { From 935f2c6d2641bba610d8280622f5f95f65615183 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 3 May 2020 18:27:15 +0200 Subject: [PATCH 152/187] Remove leftover single quotes from messages. --- .../composer/nsd/compose/NsdComposer.java | 14 +++++++------- .../nsd/compose/PassThroughComposer.java | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index cca214f..8f79b49 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -204,7 +204,7 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, .buildGraph(ctxNsd.getSapd(), ctxNsDf, ctxNsLvl); log.debug("ctxG graph:\n{}", nsdGraphService.export(ctxG)); - log.info("Composing '{}' with <{}, {}, {}>.", + log.info("Composing {} with <{}, {}, {}>.", expNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), ctxNsLvl.getNsLevelId()); log.debug("Nsd BEFORE composition:\n{}", OBJECT_MAPPER.writeValueAsString(expNsd)); @@ -212,7 +212,7 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, expNsd.setNsdName(expNsd.getNsdName() + " + " + ctxNsd.getNsdName()); for (NsDf expNsDf : expNsd.getNsDf()) { for (NsLevel expNsLvl : expNsDf.getNsInstantiationLevel()) { - log.info("Start composition for nsDf='{}' and nsLvl='{}'", + log.info("Start composition for nsDf {} and nsLvl {}", expNsDf.getNsDfId(), expNsLvl.getNsLevelId()); Graph expG = nsdGraphService .buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); @@ -226,14 +226,14 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, VlInfo ranVlInfo; try { ranVlInfo = retrieveVlInfoByDesc(ranVld, expNsDf, expNsLvl); - log.debug("Found VlInfo for ranVld='{}' in expNsd.", ranVld.getVirtualLinkDescId()); + log.debug("Found VlInfo for ranVld {} in expNsd.", ranVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { throw new InvalidNsdException("Error retrieving RAN VL info for VLD " + ranVld, e); } VlInfo expMgmtVlInfo; try { expMgmtVlInfo = retrieveVlInfoByDesc(expMgmtVld, expNsDf, expNsLvl); - log.debug("Found VlInfo for expMgmtVld='{}' in expNsd.", + log.debug("Found VlInfo for expMgmtVld {} in expNsd.", expMgmtVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { throw new InvalidNsdException( @@ -242,7 +242,7 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, VlInfo ctxMgmtVlInfo; try { ctxMgmtVlInfo = retrieveVlInfoByDesc(ctxMgmtVld, ctxNsDf, ctxNsLvl); - log.debug("Found VlInfo for ctxMgmtVld='{}' in ctxNsd.", + log.debug("Found VlInfo for ctxMgmtVld {} in ctxNsd.", ctxMgmtVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { throw new InvalidNsdException( @@ -266,13 +266,13 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, "Network topology not connected for NsDf " + expNsDf.getNsDfId() + " and NsLevel " + expNsLvl.getNsLevelId()); } - log.info("Completed composition for nsDf='{}' and nsLvl='{}'", + log.info("Completed composition for nsDf {} and nsLvl {}", expNsDf.getNsDfId(), expNsLvl.getNsLevelId()); } } log.debug("Nsd AFTER composition with {}:\n{}", ctxNsd.getNsdIdentifier(), OBJECT_MAPPER.writeValueAsString(expNsd)); - log.info("Completed composition of '{}' with <{}, {}, {}>.", + log.info("Completed composition of {} with <{}, {}, {}>.", expNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), ctxNsLvl.getNsLevelId()); } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index cd10625..6de831b 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -47,7 +47,7 @@ public void composeWithStrategy( VnfInfo ctxVnfInfo; try { ctxVnfInfo = retrieveVnfInfoByProfileId(ctxVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); - log.debug("Found VnfInfo for vnfpId='{}' in context.", ctxVnfpId); + log.debug("Found VnfInfo for vnfpId {} in context.", ctxVnfpId); ctxVnfInfo.setVlcLists(mgmtVlProfileIds); } catch (NotExistingEntityException e) { throw new InvalidNsdException( @@ -91,27 +91,27 @@ public void composeWithStrategy( throw new InvalidNsdException( "Can't find a VNF close to ranVlInfo in nsLevel " + expNsLvl.getNsLevelId()); } - log.debug("ranVnfProfile: '{}'", ranVnfProfile.getVnfProfileId()); - log.debug("ranVnfCpd: '{}'", ranVnfCpd); + log.debug("ranVnfProfile: {}", ranVnfProfile.getVnfProfileId()); + log.debug("ranVnfCpd: {}", ranVnfCpd); // Modify expNsd addVnf(ctxVnfInfo, expNsd, expNsDf, expNsLvl); - log.debug("Added VnfProfile='{}' in service (if not present).", + log.debug("Added VnfProfile {} in service (if not present).", ctxVnfInfo.getVnfProfile().getVnfProfileId()); addVirtualLink(ctxNonMgmtVl, expNsd, expNsDf, expNsLvl); - log.debug("Added VlProfile='{}' in service (if not present).", + log.debug("Added VlProfile {} in service (if not present).", ctxNonMgmtVl.getVlProfile().getVirtualLinkProfileId()); try { // Connect ranVnf to the new VL coming from ctx connectVnfToVL(ranVnfProfile, ranVnfCpd, ctxNonMgmtVl.getVlProfile()); - log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", + log.debug("Created connection between vnfProfile {} and vlProfile {}", ranVnfProfile.getVnfProfileId(), ctxNonMgmtVl.getVlProfile().getVirtualLinkProfileId()); // Connect ctxVnf with RAN VL connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxVnfInfo.getDataVlcList().get(1).getCpdId().get(0), ranVlInfo.getVlProfile()); - log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", + log.debug("Created connection between vnfProfile {} and vlProfile {}", ctxVnfInfo.getVnfProfile().getVnfProfileId(), ranVlInfo.getVlProfile().getVirtualLinkProfileId()); // Connect ctxVnf to expNsd mgmt VL @@ -119,7 +119,7 @@ public void composeWithStrategy( connectVnfToVL(ctxVnfInfo.getVnfProfile(), ctxVnfInfo.getMgmtVlcList().get(0).getCpdId().get(0), expMgmtVlInfo.getVlProfile()); - log.debug("Created connection between vnfProfile='{}' and vlProfile='{}'", + log.debug("Created connection between vnfProfile {} and vlProfile {}", ctxVnfInfo.getVnfProfile().getVnfProfileId(), expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); } else { From f660a793508f797495e0787c866382184bf03157 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Sun, 3 May 2020 18:28:10 +0200 Subject: [PATCH 153/187] Optimize import for VnfInfo. --- .../java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java index aedfc07..34cb5d7 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java @@ -1,6 +1,5 @@ package it.cnit.blueprint.composer.nsd.compose; -import it.cnit.blueprint.composer.rest.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkConnectivity; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; From 5fcd85d05b0c825acd031bbcdd8b928c7b929679 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 4 May 2020 17:06:27 +0200 Subject: [PATCH 154/187] Remove old request example. --- src/main/resources/post-request-example.json | 758 ------------------- 1 file changed, 758 deletions(-) delete mode 100644 src/main/resources/post-request-example.json diff --git a/src/main/resources/post-request-example.json b/src/main/resources/post-request-example.json deleted file mode 100644 index 37c1fab..0000000 --- a/src/main/resources/post-request-example.json +++ /dev/null @@ -1,758 +0,0 @@ -{ - "vsbRequest": { - "vsBlueprint": { - "blueprintId": "vsb_ares2t_tracker", - "version": "1.0", - "name": "ARES2T Tracker service", - "description": "Blueprint for 5G EVE Tracker service using 5G network to collect mobility data user devices.", - "parameters": [ - { - "parameterId": "number_of_tracked_devices", - "parameterName": "Number of tracked devices", - "parameterType": "number", - "parameterDescription": "Number of devices equipped with the 5G EVE Tracking Service (Mandatory)", - "applicabilityField": "Smart transport" - } - ], - "atomicComponents": [ - { - "componentId": "tracker_backend", - "serversNumber": 1, - "endPointsIds": [ - "cp_tracker_ext_in", - "cp_tracker_data", - "cp_tracker_mgt" - ] - }, - { - "componentId": "visualization_tool", - "serversNumber": 1, - "endPointsIds": [ - "cp_vis_data", - "cp_vis_mgt" - ] - } - ], - "endPoints": [ - { - "endPointId": "cp_tracker_ext_in", - "external": true, - "management": false, - "ranConnection": true - }, - { - "endPointId": "cp_tracker_data", - "external": false, - "management": false, - "ranConnection": false - }, - { - "endPointId": "cp_tracker_mgt", - "external": true, - "management": true, - "ranConnection": false - }, - { - "endPointId": "cp_vis_data", - "external": false, - "management": false, - "ranConnection": false - }, - { - "endPointId": "cp_vis_mgt", - "external": true, - "management": true, - "ranConnection": false - }, - { - "endPointId": "sap_tracking_mobile", - "external": true, - "management": false, - "ranConnection": true - }, - { - "endPointId": "sap_tracking_mgt", - "external": true, - "management": true, - "ranConnection": false - } - ], - "connectivityServices": [ - { - "endPointIds": [ - "sap_tracking_mobile", - "cp_tracker_ext_in" - ], - "external": true - }, - { - "endPointIds": [ - "cp_vis_data", - "cp_tracker_data" - ], - "external": false - }, - { - "endPointIds": [ - "sap_tracking_mgt", - "cp_vis_mgt", - "cp_tracker_mgt" - ], - "external": true - } - ], - "compatibleContextBlueprint": [ - "{{cb_id}}" - ], - "applicationMetrics": [ - { - "metricId": "tracked_devices", - "name": "Number of total tracked devices", - "metricCollectionType": "CUMULATIVE", - "unit": "devices", - "interval": "5s", - "topic": "/app/tracked_devices" - }, - { - "metricId": "processed_records", - "name": "Number of total processed records", - "metricCollectionType": "CUMULATIVE", - "unit": "records", - "interval": "5s", - "topic": "/app/processed_records" - }, - { - "metricId": "tracking_response_time", - "name": "Max response time in milliseconds", - "metricCollectionType": "GAUGE", - "unit": "ms", - "interval": "1s", - "topic": "/app/tracking_response_time" - }, - { - "metricId": "tracking_memory_usage", - "name": "Memory usage in %", - "metricCollectionType": "GAUGE", - "unit": "%", - "interval": "1s", - "topic": "/app/tracking_memory_usage" - } - ], - "compatibleSites": [ - "ITALY_TURIN" - ] - }, - "nsds": [ - { - "nsdIdentifier": "ns_ares2t_tracker", - "designer": "NXW", - "version": "1.0", - "nsdName": "ARES2T Tracker Service @ 5GEVE", - "nsdInvariantId": "ns_ares2t_tracker_v1.0", - "vnfdId": [ - "c84b227e-520e-43c0-a75e-e52781dd54dd", - "419b1884-aea1-4cad-8647-c2cec55287b9", - "51c420e3-c83d-4ce9-a5bf-0dbe339b351d" - ], - "sapd": [ - { - "cpdId": "sap_tracking_mobile", - "description": "SAP towards mobile equipment", - "layerProtocol": "IPV4", - "cpRole": "ROOT", - "addressData": [ - { - "addressType": "IP_ADDRESS", - "iPAddressAssignment": false, - "floatingIpActivated": true, - "iPAddressType": "IPv4", - "numberOfIpAddress": 1 - } - ], - "sapAddressAssignment": false, - "nsVirtualLinkDescId": "vl_tracking_mobile" - }, - { - "cpdId": "sap_tracking_mgt", - "description": "SAP for management", - "layerProtocol": "IPV4", - "cpRole": "ROOT", - "addressData": [ - { - "addressType": "IP_ADDRESS", - "iPAddressAssignment": false, - "floatingIpActivated": false, - "iPAddressType": "IPv4", - "numberOfIpAddress": 1 - } - ], - "sapAddressAssignment": false, - "nsVirtualLinkDescId": "vl_tracking_mgt" - } - ], - "virtualLinkDesc": [ - { - "virtualLinkDescId": "vl_tracking_mobile", - "virtualLinkDescProvider": "NXW", - "virtuaLinkDescVersion": "1.0", - "connectivityType": { - "layerProtocol": "IPV4" - }, - "virtualLinkDf": [ - { - "flavourId": "df_vl_tracking_mobile", - "qos": { - "latency": 0, - "packetDelayVariation": 0, - "packetLossRatio": 0, - "priority": 0 - }, - "serviceAvaibilityLevel": "LEVEL_1" - } - ], - "description": "Network to connect to the mobile user equipment" - }, - { - "virtualLinkDescId": "vl_tracking_mgt", - "virtualLinkDescProvider": "NXW", - "virtuaLinkDescVersion": "1.0", - "connectivityType": { - "layerProtocol": "IPV4" - }, - "virtualLinkDf": [ - { - "flavourId": "df_vl_tracking_mgt", - "qos": { - "latency": 0, - "packetDelayVariation": 0, - "packetLossRatio": 0, - "priority": 0 - }, - "serviceAvaibilityLevel": "LEVEL_1" - } - ], - "description": "Management network" - }, - { - "virtualLinkDescId": "vl_tracking_data", - "virtualLinkDescProvider": "NXW", - "virtuaLinkDescVersion": "1.0", - "connectivityType": { - "layerProtocol": "IPV4" - }, - "virtualLinkDf": [ - { - "flavourId": "df_vl_tracking_data", - "qos": { - "latency": 0, - "packetDelayVariation": 0, - "packetLossRatio": 0, - "priority": 0 - }, - "serviceAvaibilityLevel": "LEVEL_1" - } - ], - "description": "Internal network to connect the tracking service components" - } - ], - "nsDf": [ - { - "nsDfId": "ns_Ares2T_Tracking_df", - "flavourKey": "ns_Ares2T_Tracking_df_fk", - "vnfProfile": [ - { - "vnfProfileId": "vnfp_small_Ares2T_Tracker", - "vnfdId": "419b1884-aea1-4cad-8647-c2cec55287b9", - "flavourId": "vnf_df_Ares2T_Tracker", - "instantiationLevel": "vnf_il_Ares2T_Tracker", - "minNumberOfInstances": 1, - "maxNumberOfInstances": 1, - "nsVirtualLinkConnectivity": [ - { - "virtualLinkProfileId": "vlp_vl_tracking_mobile", - "cpdId": [ - "cp_tracker_ext_in" - ] - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_data", - "cpdId": [ - "cp_tracker_data" - ] - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_mgt", - "cpdId": [ - "cp_tracker_mgt" - ] - } - ] - }, - { - "vnfProfileId": "vnfp_big_Ares2T_Tracker", - "vnfdId": "c84b227e-520e-43c0-a75e-e52781dd54dd", - "flavourId": "vnf_df_Ares2T_Tracker", - "instantiationLevel": "vnf_il_Ares2T_Tracker", - "minNumberOfInstances": 1, - "maxNumberOfInstances": 1, - "nsVirtualLinkConnectivity": [ - { - "virtualLinkProfileId": "vlp_vl_tracking_mobile", - "cpdId": [ - "cp_tracker_ext_in" - ] - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_data", - "cpdId": [ - "cp_tracker_data" - ] - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_mgt", - "cpdId": [ - "cp_tracker_mgt" - ] - } - ] - }, - { - "vnfProfileId": "vnfp_Ares2T_Vis", - "vnfdId": "51c420e3-c83d-4ce9-a5bf-0dbe339b351d", - "flavourId": "vnf_df_Ares2T_Vis", - "instantiationLevel": "vnf_il_Ares2T_Vis", - "minNumberOfInstances": 1, - "maxNumberOfInstances": 1, - "nsVirtualLinkConnectivity": [ - { - "virtualLinkProfileId": "vlp_vl_tracking_data", - "cpdId": [ - "cp_vis_data" - ] - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_mgt", - "cpdId": [ - "cp_vis_mgt" - ] - } - ] - } - ], - "virtualLinkProfile": [ - { - "virtualLinkProfileId": "vlp_vl_tracking_mobile", - "virtualLinkDescId": "vl_tracking_mobile", - "flavourId": "df_vl_tracking_mobile", - "maxBitrateRequirements": { - "root": "1", - "leaf": "1" - }, - "minBitrateRequirements": { - "root": "1", - "leaf": "1" - } - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_data", - "virtualLinkDescId": "vl_tracking_data", - "flavourId": "df_vl_tracking_data", - "maxBitrateRequirements": { - "root": "1", - "leaf": "1" - }, - "minBitrateRequirements": { - "root": "1", - "leaf": "1" - } - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_mgt", - "virtualLinkDescId": "vl_tracking_mgt", - "flavourId": "df_vl_tracking_mgt", - "maxBitrateRequirements": { - "root": "1", - "leaf": "1" - }, - "minBitrateRequirements": { - "root": "1", - "leaf": "1" - } - } - ], - "nsInstantiationLevel": [ - { - "nsLevelId": "ns_ares2t_tracker_il_big", - "description": "Big instantiation level for the ARES2T tracking service", - "vnfToLevelMapping": [ - { - "vnfProfileId": "vnfp_big_Ares2T_Tracker", - "numberOfInstances": 1 - }, - { - "vnfProfileId": "vnfp_Ares2T_Vis", - "numberOfInstances": 1 - } - ], - "virtualLinkToLevelMapping": [ - { - "virtualLinkProfileId": "vlp_vl_tracking_mobile", - "bitRateRequirements": { - "root": "1", - "leaf": "1" - } - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_data", - "bitRateRequirements": { - "root": "1", - "leaf": "1" - } - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_mgt", - "bitRateRequirements": { - "root": "1", - "leaf": "1" - } - } - ] - }, - { - "nsLevelId": "ns_ares2t_tracker_il_small", - "description": "Small instantiation level for the ARES2T tracking service", - "vnfToLevelMapping": [ - { - "vnfProfileId": "vnfp_small_Ares2T_Tracker", - "numberOfInstances": 1 - }, - { - "vnfProfileId": "vnfp_Ares2T_Vis", - "numberOfInstances": 1 - } - ], - "virtualLinkToLevelMapping": [ - { - "virtualLinkProfileId": "vlp_vl_tracking_mobile", - "bitRateRequirements": { - "root": "1", - "leaf": "1" - } - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_data", - "bitRateRequirements": { - "root": "1", - "leaf": "1" - } - }, - { - "virtualLinkProfileId": "vlp_vl_tracking_mgt", - "bitRateRequirements": { - "root": "1", - "leaf": "1" - } - } - ] - } - ], - "defaultNsInstantiationLevelId": "ns_ares2t_tracker_il_small", - "dependencies": [] - } - ], - "security": { - "signature": "FC_NSD_SIGNATURE", - "algorithm": "FC_NSD_ALGORITHM", - "certificate": "FC_NSD_CERTIFICATE" - } - } - ], - "translationRules": [ - { - "nsdId": "ns_ares2t_tracker", - "nsdVersion": "1.0", - "nsFlavourId": "ns_Ares2T_Tracking_df", - "nsInstantiationLevelId": "ns_ares2t_tracker_il_small", - "input": [ - { - "parameterId": "number_of_tracked_devices", - "minValue": "1", - "maxValue": "100" - } - ] - }, - { - "nsdId": "ns_ares2t_tracker", - "nsdVersion": "1.0", - "nsFlavourId": "ns_Ares2T_Tracking_df", - "nsInstantiationLevelId": "ns_ares2t_tracker_il_big", - "input": [ - { - "parameterId": "number_of_tracked_devices", - "minValue": "101", - "maxValue": "1000" - } - ] - } - ] - }, - "contexts": [ - { - "nsd": { - "nsdIdentifier": "Netem_Delay_Generator", - "designer": "NXW", - "version": "1.0", - "nsdName": "NETEM Traffic Delay Generator Service", - "nsdInvariantId": "Netem_Delay_Generator_v1.0", - "vnfdId": [ - "396d1b6b-331b-4dd7-b48e-376517d3654a" - ], - "sapd": [ - { - "cpdId": "sap_dg_mgt", - "layerProtocol": "IPV4", - "cpRole": "ROOT", - "description": "SAP for management", - "addressData": [ - { - "addressType": "IP_ADDRESS", - "iPAddressAssignment": false, - "floatingIpActivated": false, - "management": false, - "iPAddressType": "IPv4", - "numberOfIpAddress": 1 - } - ], - "sapAddressAssignment": false, - "nsVirtualLinkDescId": "vl_dg_mgt" - }, - { - "cpdId": "sap_dg_in", - "layerProtocol": "IPV4", - "cpRole": "ROOT", - "description": "SAP for incoming traffic", - "addressData": [ - { - "addressType": "IP_ADDRESS", - "iPAddressAssignment": false, - "floatingIpActivated": true, - "management": false, - "iPAddressType": "IPv4", - "numberOfIpAddress": 1 - } - ], - "sapAddressAssignment": false, - "nsVirtualLinkDescId": "vl_dg_in" - }, - { - "cpdId": "sap_dg_out", - "layerProtocol": "IPV4", - "cpRole": "ROOT", - "description": "SAP for outgoing traffic", - "addressData": [ - { - "addressType": "IP_ADDRESS", - "iPAddressAssignment": false, - "floatingIpActivated": true, - "management": false, - "iPAddressType": "IPv4", - "numberOfIpAddress": 1 - } - ], - "sapAddressAssignment": false, - "nsVirtualLinkDescId": "vl_dg_out" - } - ], - "virtualLinkDesc": [ - { - "virtualLinkDescId": "vl_dg_mgt", - "virtualLinkDescProvider": "NXW", - "virtuaLinkDescVersion": "1.0", - "connectivityType": { - "layerProtocol": "IPV4", - "flowPattern": null - }, - "virtualLinkDf": [ - { - "flavourId": "df_vl_dg_mgt", - "qos": { - "latency": 0, - "packetDelayVariation": 0, - "packetLossRatio": 0, - "priority": 0 - }, - "serviceAvaibilityLevel": "LEVEL_1" - } - ], - "description": "Management network" - }, - { - "virtualLinkDescId": "vl_dg_in", - "virtualLinkDescProvider": "NXW", - "virtuaLinkDescVersion": "1.0", - "connectivityType": { - "layerProtocol": "IPV4", - "flowPattern": null - }, - "virtualLinkDf": [ - { - "flavourId": "df_vl_dg_in", - "qos": { - "latency": 0, - "packetDelayVariation": 0, - "packetLossRatio": 0, - "priority": 0 - }, - "serviceAvaibilityLevel": "LEVEL_1" - } - ], - "description": "Network to receive incoming traffic." - }, - { - "virtualLinkDescId": "vl_dg_out", - "virtualLinkDescProvider": "NXW", - "virtuaLinkDescVersion": "1.0", - "connectivityType": { - "layerProtocol": "IPV4", - "flowPattern": null - }, - "virtualLinkDf": [ - { - "flavourId": "df_vl_dg_out", - "qos": { - "latency": 0, - "packetDelayVariation": 0, - "packetLossRatio": 0, - "priority": 0 - }, - "serviceAvaibilityLevel": "LEVEL_1" - } - ], - "description": "Network to send outgoing delayed traffic." - } - ], - "nsDf": [ - { - "nsDfId": "ns_Netem_Delay_Generator_df", - "flavourKey": "ns_Netem_Delay_Generator_df_fk", - "vnfProfile": [ - { - "vnfProfileId": "vnfp_netem", - "vnfdId": "396d1b6b-331b-4dd7-b48e-376517d3654a", - "flavourId": "vnf_df_netem", - "instantiationLevel": "vnf_il_netem", - "minNumberOfInstances": 1, - "maxNumberOfInstances": 1, - "nsVirtualLinkConnectivity": [ - { - "virtualLinkProfileId": "vlp_vl_dg_out", - "cpdId": [ - "cp_dg_traffic_out" - ] - }, - { - "virtualLinkProfileId": "vlp_vl_dg_mgt", - "cpdId": [ - "cp_dg_mgt" - ] - }, - { - "virtualLinkProfileId": "vlp_vl_dg_in", - "cpdId": [ - "cp_dg_traffic_in" - ] - } - ] - } - ], - "virtualLinkProfile": [ - { - "virtualLinkProfileId": "vlp_vl_dg_out", - "virtualLinkDescId": "vl_dg_out", - "flavourId": "df_vl_dg_out", - "maxBitrateRequirements": { - "root": "1", - "leaf": "1" - }, - "minBitrateRequirements": { - "root": "1", - "leaf": "1" - } - }, - { - "virtualLinkProfileId": "vlp_vl_dg_mgt", - "virtualLinkDescId": "vl_dg_mgt", - "flavourId": "df_vl_dg_mgt", - "maxBitrateRequirements": { - "root": "1", - "leaf": "1" - }, - "minBitrateRequirements": { - "root": "1", - "leaf": "1" - } - }, - { - "virtualLinkProfileId": "vlp_vl_dg_in", - "virtualLinkDescId": "vl_dg_in", - "flavourId": "df_vl_dg_in", - "maxBitrateRequirements": { - "root": "1", - "leaf": "1" - }, - "minBitrateRequirements": { - "root": "1", - "leaf": "1" - } - } - ], - "nsInstantiationLevel": [ - { - "nsLevelId": "ns_Netem_Delay_Generator_il", - "description": "Default instantiation level for the network delay generator", - "vnfToLevelMapping": [ - { - "vnfProfileId": "vnfp_netem", - "numberOfInstances": 1 - } - ], - "virtualLinkToLevelMapping": [ - { - "virtualLinkProfileId": "vlp_vl_dg_out", - "bitRateRequirements": { - "root": "1", - "leaf": "1" - } - }, - { - "virtualLinkProfileId": "vlp_vl_dg_in", - "bitRateRequirements": { - "root": "1", - "leaf": "1" - } - }, - { - "virtualLinkProfileId": "vlp_vl_dg_mgt", - "bitRateRequirements": { - "root": "1", - "leaf": "1" - } - } - ] - } - ], - "defaultNsInstantiationLevelId": "ns_Netem_Delay_Generator_il" - } - ], - "security": { - "signature": "NSD_SIGNATURE", - "algorithm": "NSD_ALGORITHM", - "certificate": "NSD_CERTIFICATE" - } - }, - "strat": "PASSTHROUGH", - "virtualLinkIds": null, - "sapId": "sap_tracking_mobile" - } - ] -} \ No newline at end of file From 2870c7bff3b141ec908b11f5bc26dd853527fdb2 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 4 May 2020 17:07:48 +0200 Subject: [PATCH 155/187] Add validation checks on request and response. --- .../java/it/cnit/blueprint/composer/rest/ComposeRequest.java | 4 ++++ .../java/it/cnit/blueprint/composer/rest/ComposeResponse.java | 3 +++ src/main/java/it/cnit/blueprint/composer/rest/Context.java | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java index ee44b9c..66255d7 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java @@ -1,11 +1,15 @@ package it.cnit.blueprint.composer.rest; import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import lombok.Data; @Data public class ComposeRequest { + @NotNull private OnBoardVsBlueprintRequest vsbRequest; + @NotEmpty private Context[] contexts; } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java index eb0a21d..26928ab 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java @@ -3,6 +3,7 @@ import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import java.util.List; +import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; @@ -10,6 +11,8 @@ @AllArgsConstructor public class ComposeResponse { + @NotNull private Nsd expNsd; + @NotNull private List translationRules; } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/Context.java b/src/main/java/it/cnit/blueprint/composer/rest/Context.java index b2ab8b2..3ef4364 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/Context.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/Context.java @@ -2,13 +2,15 @@ import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; import java.util.Map; +import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; @Data -@AllArgsConstructor public class Context { + @NotNull private OnboardCtxBlueprintRequest ctxbRequest; + private Map connectInput; } From 96e98b147f5d9bbae7f2a6c7ab8a323cf12ba41b Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 4 May 2020 17:39:25 +0200 Subject: [PATCH 156/187] Add lombok annotations to request and response. --- .../java/it/cnit/blueprint/composer/rest/ComposeRequest.java | 5 +++++ .../it/cnit/blueprint/composer/rest/ComposeResponse.java | 4 ++++ src/main/java/it/cnit/blueprint/composer/rest/Context.java | 2 ++ 3 files changed, 11 insertions(+) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java index 66255d7..1d4a012 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java @@ -3,13 +3,18 @@ import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NonNull; @Data public class ComposeRequest { + @NonNull @NotNull private OnBoardVsBlueprintRequest vsbRequest; + + @NonNull @NotEmpty private Context[] contexts; } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java index 26928ab..9e15746 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java @@ -6,13 +6,17 @@ import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NonNull; @Data @AllArgsConstructor public class ComposeResponse { + @NonNull @NotNull private Nsd expNsd; + + @NonNull @NotNull private List translationRules; } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/Context.java b/src/main/java/it/cnit/blueprint/composer/rest/Context.java index 3ef4364..0615da8 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/Context.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/Context.java @@ -5,10 +5,12 @@ import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NonNull; @Data public class Context { + @NonNull @NotNull private OnboardCtxBlueprintRequest ctxbRequest; From 9a329385ee6ec94c3068eed8b311cc36e180fa84 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 4 May 2020 17:39:47 +0200 Subject: [PATCH 157/187] Add translation rules urls in properties. --- src/test/resources/url.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/resources/url.properties b/src/test/resources/url.properties index f929e77..6eb1f94 100644 --- a/src/test/resources/url.properties +++ b/src/test/resources/url.properties @@ -1,5 +1,6 @@ vsb_ares2t_tracker=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker.yaml vsb_ares2t_tracker_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker_nsds.yaml +vsb_ares2t_tracker_tr=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_ares2t_tracker/vsb_ares2t_tracker_tr.yaml expb_ares2t_tracker_delay_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/expb/expb_ares2t_tracker_delay/expb_ares2t_tracker_delay_nsds.yaml vsb_polito_smartcity=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/vsb/vsb_polito_smartcity/vsb_polito_smartcity.yaml @@ -7,6 +8,7 @@ vsb_polito_smartcity_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml ctx_delay=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay.yaml ctx_delay_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay_nsds.yaml +ctx_delay_tr=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_delay/ctx_delay_tr.yaml ctx_bg_traffic=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic.yaml ctx_bg_traffic_nsds=https://raw.githubusercontent.com/5GEVE/blueprint-yaml/master/ctx/ctx_bg_traffic/ctx_bg_traffic_nsds.yaml From db78aee362c868d437152c30cd366e591384592c Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 4 May 2020 17:40:00 +0200 Subject: [PATCH 158/187] First version of test. Preparing request. --- .../rest/ExperimentsControllerTest.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java diff --git a/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java new file mode 100644 index 0000000..88f0be7 --- /dev/null +++ b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java @@ -0,0 +1,71 @@ +package it.cnit.blueprint.composer.rest; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; +import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; +import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import java.io.InputStream; +import java.net.URL; +import java.util.Collections; +import java.util.List; +import java.util.Properties; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.junit.BeforeClass; +import org.junit.Test; + +@Slf4j +public class ExperimentsControllerTest { + + static ObjectMapper JSON_OM, YAML_OM; + static Properties urlProp; + + @BeforeClass + @SneakyThrows + public static void setUp() { + // Test Setup + urlProp = new Properties(); + InputStream input = ClassLoader.getSystemResourceAsStream("url.properties"); + urlProp.load(input); + JSON_OM = new ObjectMapper(new JsonFactory()).enable(SerializationFeature.INDENT_OUTPUT); + YAML_OM = new ObjectMapper(new YAMLFactory()); + } + + @Test + @SneakyThrows + public void composeExperiment() { + // Given + VsBlueprint vsb = YAML_OM + .readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker")), VsBlueprint.class); + List vsbNsd = YAML_OM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), + new TypeReference>() { + }); + List vsbTr = YAML_OM + .readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_tr")), + new TypeReference>() { + }); + OnBoardVsBlueprintRequest vsbRequest = new OnBoardVsBlueprintRequest(vsb, vsbNsd, vsbTr); + + CtxBlueprint ctxb = YAML_OM + .readValue(new URL(urlProp.getProperty("ctx_delay")), CtxBlueprint.class); + List ctxbNsd = YAML_OM.readValue(new URL(urlProp.getProperty("ctx_delay_nsds")), + new TypeReference>() { + }); + List ctxbTr = YAML_OM + .readValue(new URL(urlProp.getProperty("ctx_delay_tr")), + new TypeReference>() { + }); + OnboardCtxBlueprintRequest ctxbRequest = new OnboardCtxBlueprintRequest(ctxb, ctxbNsd, ctxbTr); + + ComposeRequest request = new ComposeRequest(vsbRequest, new Context[]{new Context(ctxbRequest)}); + log.debug("Response:\n{}", JSON_OM.writeValueAsString(request)); + + } +} \ No newline at end of file From 4a53d2af68e5b7d122183591945a79a04f7fdac4 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 4 May 2020 19:00:31 +0200 Subject: [PATCH 159/187] Remove old ConnectInput class. --- .../blueprint/composer/rest/ConnectInput.java | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java b/src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java deleted file mode 100644 index da9eb86..0000000 --- a/src/main/java/it/cnit/blueprint/composer/rest/ConnectInput.java +++ /dev/null @@ -1,16 +0,0 @@ -package it.cnit.blueprint.composer.rest; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class ConnectInput { - - private String srcVnfdId; - private String srcVldId; - private String dstVnfdId; - private String dstVldId; -} From 1a2e0e442e3553084d3c47d57dad094724b61146 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 4 May 2020 19:01:30 +0200 Subject: [PATCH 160/187] Cleanup App class. --- src/main/java/it/cnit/blueprint/composer/App.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/App.java b/src/main/java/it/cnit/blueprint/composer/App.java index 15ad333..50fe9b4 100644 --- a/src/main/java/it/cnit/blueprint/composer/App.java +++ b/src/main/java/it/cnit/blueprint/composer/App.java @@ -1,25 +1,17 @@ package it.cnit.blueprint.composer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.ConfigurableApplicationContext; @SpringBootApplication @EntityScan(basePackages = {"it.nextworks.nfvmano.libs.ifa", "it.cnit.blueprint.composer"}) @Slf4j public class App { - private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory()); - public static void main(String[] args) { - ConfigurableApplicationContext c = new SpringApplication(App.class).run(args); -// log.debug("Beans found: {}", (Object) c.getBeanDefinitionNames()); -// log.debug("nsd -> {}", c.getBean(ComposableNsd.class)); -// log.debug("exporter -> {}", c.getBean(ComposableNsd.class).graphExporter); + SpringApplication.run(App.class, args); } } From de467908ccccb2cd0eb146dc6c11e2b297feb323 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 4 May 2020 19:01:54 +0200 Subject: [PATCH 161/187] Add lombok constructors to request and response. --- .../it/cnit/blueprint/composer/rest/ComposeRequest.java | 6 +++--- .../it/cnit/blueprint/composer/rest/ComposeResponse.java | 5 ++--- src/main/java/it/cnit/blueprint/composer/rest/Context.java | 5 +++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java index 1d4a012..93cca1c 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java @@ -5,16 +5,16 @@ import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NonNull; +import lombok.NoArgsConstructor; @Data +@NoArgsConstructor +@AllArgsConstructor public class ComposeRequest { - @NonNull @NotNull private OnBoardVsBlueprintRequest vsbRequest; - @NonNull @NotEmpty private Context[] contexts; } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java index 9e15746..e769bb6 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java @@ -6,17 +6,16 @@ import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NonNull; +import lombok.NoArgsConstructor; @Data +@NoArgsConstructor @AllArgsConstructor public class ComposeResponse { - @NonNull @NotNull private Nsd expNsd; - @NonNull @NotNull private List translationRules; } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/Context.java b/src/main/java/it/cnit/blueprint/composer/rest/Context.java index 0615da8..a92471f 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/Context.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/Context.java @@ -5,12 +5,13 @@ import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NonNull; +import lombok.NoArgsConstructor; @Data +@NoArgsConstructor +@AllArgsConstructor public class Context { - @NonNull @NotNull private OnboardCtxBlueprintRequest ctxbRequest; From 7d8f13c2010e21b29ec6fa9ddaefec5dd998b3f6 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 4 May 2020 19:02:09 +0200 Subject: [PATCH 162/187] First working test for POST request. --- .../rest/ExperimentsControllerTest.java | 47 ++++++++++++++++--- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java index 88f0be7..bc5d000 100644 --- a/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java @@ -1,5 +1,7 @@ package it.cnit.blueprint.composer.rest; +import static org.junit.Assert.assertEquals; + import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -13,29 +15,51 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import java.io.InputStream; import java.net.URL; -import java.util.Collections; import java.util.List; import java.util.Properties; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import org.junit.BeforeClass; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest @Slf4j public class ExperimentsControllerTest { - static ObjectMapper JSON_OM, YAML_OM; + private ObjectMapper JSON_OM, YAML_OM; static Properties urlProp; - @BeforeClass + @Autowired + WebApplicationContext webApplicationContext; + + private MockMvc mvc; + + @Autowired + private ExperimentsController experimentsController; + + @Before @SneakyThrows - public static void setUp() { + public void setup() { // Test Setup urlProp = new Properties(); InputStream input = ClassLoader.getSystemResourceAsStream("url.properties"); urlProp.load(input); JSON_OM = new ObjectMapper(new JsonFactory()).enable(SerializationFeature.INDENT_OUTPUT); YAML_OM = new ObjectMapper(new YAMLFactory()); + mvc = MockMvcBuilders + .webAppContextSetup(webApplicationContext) + .build(); } @Test @@ -63,9 +87,18 @@ public void composeExperiment() { new TypeReference>() { }); OnboardCtxBlueprintRequest ctxbRequest = new OnboardCtxBlueprintRequest(ctxb, ctxbNsd, ctxbTr); + Context c = new Context(ctxbRequest, null); - ComposeRequest request = new ComposeRequest(vsbRequest, new Context[]{new Context(ctxbRequest)}); - log.debug("Response:\n{}", JSON_OM.writeValueAsString(request)); + ComposeRequest request = new ComposeRequest(vsbRequest, new Context[]{c}); + String body = JSON_OM.writeValueAsString(request); + log.info("Request body:\n{}", body); + // When + MvcResult result = mvc.perform(MockMvcRequestBuilders.post("/experiments").contentType( + MediaType.APPLICATION_JSON).content(body)).andReturn(); + assertEquals(200, result.getResponse().getStatus()); + ComposeResponse response = JSON_OM + .readValue(result.getResponse().getContentAsString(), ComposeResponse.class); + log.info("Response body:\n{}", JSON_OM.writeValueAsString(response)); } } \ No newline at end of file From 00f6ab64a40121260181c97012ae75ceae971738 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 11 May 2020 17:00:15 +0200 Subject: [PATCH 163/187] Fix findRanVld with a check on endpoint name. Fix error message. --- .../cnit/blueprint/composer/rest/ExperimentsController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index e0d39bf..1a40e25 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -109,7 +109,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) throws InvalidNsdException, InvalidVsbException { Optional ranEp = b.getEndPoints().stream() - .filter(VsbEndpoint::isRanConnection) + .filter(e -> e.isRanConnection() && e.getEndPointId().contains("sap")) .findFirst(); if (ranEp.isPresent()) { String epId = ranEp.get().getEndPointId(); @@ -120,7 +120,7 @@ private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) return connectComposer.getRanVlDesc(ranSapd.get(), nsd); } else { throw new InvalidNsdException( - "RAN Sap with id=" + epId + "not found in NSD " + nsd.getNsdIdentifier() + "."); + "RAN Sap with ID " + epId + " not found in NSD " + nsd.getNsdIdentifier()); } } else { throw new InvalidVsbException("No RAN endpoint found in VSB " + b.getBlueprintId() + "."); From c160930d3d30a08049ace2c0c78514de2584f857 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 11 May 2020 17:01:50 +0200 Subject: [PATCH 164/187] Fix error message and exception. --- .../it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index a64dbeb..9dc8262 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -178,9 +178,7 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { try { nsd.isValid(); } catch (MalformattedElementException e) { - String m = "Nsd looks not valid after composition"; - log.error(m, e); - throw new InvalidNsdException(m); + throw new InvalidNsdException("Nsd looks not valid after generation", e); } Graph g = nsdGraphService.buildGraph(nsd.getSapd(), nsDf, nsLevel); From ac881a74bbb1bae0f111673bf49f9300a3c657db Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 11 May 2020 17:25:55 +0200 Subject: [PATCH 165/187] Fix error message. --- .../it/cnit/blueprint/composer/nsd/compose/NsdComposer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 8f79b49..325c501 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -237,7 +237,8 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, expMgmtVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { throw new InvalidNsdException( - "Error retrieving Experiment Management VL info for VLD " + ranVld, e); + "Error retrieving Experiment Management VL info for VLD " + ranVld + .getVirtualLinkDescId(), e); } VlInfo ctxMgmtVlInfo; try { From 82911d57d1d2ba1e9f2c77c872dbe0fca6a904b1 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 11 May 2020 17:27:00 +0200 Subject: [PATCH 166/187] Fix bug on mgmt vld for experiment. Add exception for http 422. --- .../composer/rest/ExperimentsController.java | 8 +++++--- .../rest/UnprocessableEntityException.java | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/composer/rest/UnprocessableEntityException.java diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 1a40e25..4fc1da1 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -6,6 +6,7 @@ import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.CompositionStrategy; import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbLink; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; @@ -46,6 +47,7 @@ public OnboardExpBlueprintRequest retrieveExperiment() { @PostMapping("/experiments") public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequest) { + VsBlueprint vsb = composeRequest.getVsbRequest().getVsBlueprint(); Nsd expNsd = composeRequest.getVsbRequest().getNsds().get(0); expNsd.setNsdIdentifier(UUID.randomUUID().toString()); expNsd.setNsdInvariantId(UUID.randomUUID().toString()); @@ -58,15 +60,15 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ expNsd); for (Context ctx : composeRequest.getContexts()) { // - The Ctx has only 1 Nsd. - Nsd ctxNsd = ctx.getCtxbRequest().getNsds().get(0); CtxBlueprint ctxB = ctx.getCtxbRequest().getCtxBlueprint(); + Nsd ctxNsd = ctx.getCtxbRequest().getNsds().get(0); log.info("Current CtxB: {}", ctxB.getBlueprintId()); if (ctx.getConnectInput() == null) { ctx.setConnectInput(new HashMap<>()); } - NsVirtualLinkDesc expMgmtVld = findMgmtVld(ctxB, ctxNsd); + NsVirtualLinkDesc expMgmtVld = findMgmtVld(vsb, expNsd); NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); if (ctxB.getCompositionStrategy().equals(CompositionStrategy.CONNECT)) { log.info("Strategy is CONNECT"); @@ -92,7 +94,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ } } catch (InvalidVsbException | InvalidNsdException | InvalidContextException e) { log.error(e.getMessage(), e); - //TODO create and return a 422 response. + throw new UnprocessableEntityException(e.getMessage()); } List translationRules = null; diff --git a/src/main/java/it/cnit/blueprint/composer/rest/UnprocessableEntityException.java b/src/main/java/it/cnit/blueprint/composer/rest/UnprocessableEntityException.java new file mode 100644 index 0000000..b771905 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/UnprocessableEntityException.java @@ -0,0 +1,19 @@ +package it.cnit.blueprint.composer.rest; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) +public class UnprocessableEntityException extends RuntimeException { + + public UnprocessableEntityException() { + } + + public UnprocessableEntityException(String message) { + super(message); + } + + public UnprocessableEntityException(String message, Throwable cause) { + super(message, cause); + } +} From ff89e98b37ba6889917ac630ddcc07da7fbbb8e2 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 11 May 2020 18:10:51 +0200 Subject: [PATCH 167/187] Use ResponseStatusException. Remove old exception. --- .../composer/rest/ExperimentsController.java | 5 +++-- .../rest/UnprocessableEntityException.java | 19 ------------------- 2 files changed, 3 insertions(+), 21 deletions(-) delete mode 100644 src/main/java/it/cnit/blueprint/composer/rest/UnprocessableEntityException.java diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 4fc1da1..81eadd9 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -22,10 +22,12 @@ import lombok.extern.slf4j.Slf4j; import org.slf4j.helpers.MessageFormatter; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; @RestController @Slf4j @@ -93,8 +95,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ } } catch (InvalidVsbException | InvalidNsdException | InvalidContextException e) { - log.error(e.getMessage(), e); - throw new UnprocessableEntityException(e.getMessage()); + throw new ResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e); } List translationRules = null; diff --git a/src/main/java/it/cnit/blueprint/composer/rest/UnprocessableEntityException.java b/src/main/java/it/cnit/blueprint/composer/rest/UnprocessableEntityException.java deleted file mode 100644 index b771905..0000000 --- a/src/main/java/it/cnit/blueprint/composer/rest/UnprocessableEntityException.java +++ /dev/null @@ -1,19 +0,0 @@ -package it.cnit.blueprint.composer.rest; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseStatus; - -@ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) -public class UnprocessableEntityException extends RuntimeException { - - public UnprocessableEntityException() { - } - - public UnprocessableEntityException(String message) { - super(message); - } - - public UnprocessableEntityException(String message, Throwable cause) { - super(message, cause); - } -} From 65c749346119ef5c32848c3b9e81b036ff422888 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 11 May 2020 18:11:42 +0200 Subject: [PATCH 168/187] Do notinclude exception stack trace in prod. --- src/main/resources/application-prod.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 2860c02..b3d9199 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -1 +1,2 @@ management.endpoints.web.exposure.exclude=* +server.error.include-stacktrace=never From 303fd61094fdb1ad7cd438cee679a52d3147693e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 11 May 2020 18:47:12 +0200 Subject: [PATCH 169/187] Move exceptions to dedicated package. --- .../{rest => exceptions}/InvalidContextException.java | 2 +- .../composer/{rest => exceptions}/InvalidNsdException.java | 2 +- .../InvalidTranslationRuleException.java | 2 +- .../composer/{rest => exceptions}/InvalidVsbException.java | 2 +- .../blueprint/composer/nsd/compose/ConnectComposer.java | 2 +- .../cnit/blueprint/composer/nsd/compose/NsdComposer.java | 2 +- .../composer/nsd/compose/PassThroughComposer.java | 2 +- .../cnit/blueprint/composer/nsd/generate/NsdGenerator.java | 2 +- .../cnit/blueprint/composer/nsd/graph/NsdGraphService.java | 2 +- .../blueprint/composer/rest/ExperimentsController.java | 7 +++++-- .../cnit/blueprint/composer/rest/ServicesController.java | 1 + .../blueprint/composer/rules/TranslationRulesComposer.java | 1 + .../blueprint/composer/rest/ExperimentsControllerTest.java | 4 ++++ 13 files changed, 20 insertions(+), 11 deletions(-) rename src/main/java/it/cnit/blueprint/composer/{rest => exceptions}/InvalidContextException.java (74%) rename src/main/java/it/cnit/blueprint/composer/{rest => exceptions}/InvalidNsdException.java (82%) rename src/main/java/it/cnit/blueprint/composer/{rules => exceptions}/InvalidTranslationRuleException.java (76%) rename src/main/java/it/cnit/blueprint/composer/{rest => exceptions}/InvalidVsbException.java (73%) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/InvalidContextException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidContextException.java similarity index 74% rename from src/main/java/it/cnit/blueprint/composer/rest/InvalidContextException.java rename to src/main/java/it/cnit/blueprint/composer/exceptions/InvalidContextException.java index 2b3d081..a790eb5 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/InvalidContextException.java +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidContextException.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.composer.rest; +package it.cnit.blueprint.composer.exceptions; public class InvalidContextException extends Exception { diff --git a/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidNsdException.java similarity index 82% rename from src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java rename to src/main/java/it/cnit/blueprint/composer/exceptions/InvalidNsdException.java index 74cbead..343c158 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/InvalidNsdException.java +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidNsdException.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.composer.rest; +package it.cnit.blueprint.composer.exceptions; public class InvalidNsdException extends Exception { diff --git a/src/main/java/it/cnit/blueprint/composer/rules/InvalidTranslationRuleException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidTranslationRuleException.java similarity index 76% rename from src/main/java/it/cnit/blueprint/composer/rules/InvalidTranslationRuleException.java rename to src/main/java/it/cnit/blueprint/composer/exceptions/InvalidTranslationRuleException.java index 38ee5a3..0bdff85 100644 --- a/src/main/java/it/cnit/blueprint/composer/rules/InvalidTranslationRuleException.java +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidTranslationRuleException.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.composer.rules; +package it.cnit.blueprint.composer.exceptions; public class InvalidTranslationRuleException extends Exception { diff --git a/src/main/java/it/cnit/blueprint/composer/rest/InvalidVsbException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidVsbException.java similarity index 73% rename from src/main/java/it/cnit/blueprint/composer/rest/InvalidVsbException.java rename to src/main/java/it/cnit/blueprint/composer/exceptions/InvalidVsbException.java index 6d41ad7..d90069e 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/InvalidVsbException.java +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidVsbException.java @@ -1,4 +1,4 @@ -package it.cnit.blueprint.composer.rest; +package it.cnit.blueprint.composer.exceptions; public class InvalidVsbException extends Exception { diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index fa13ed4..869b5e9 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -1,7 +1,7 @@ package it.cnit.blueprint.composer.nsd.compose; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; -import it.cnit.blueprint.composer.rest.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 325c501..5f5a7a1 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; -import it.cnit.blueprint.composer.rest.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index 6de831b..6930407 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -1,7 +1,7 @@ package it.cnit.blueprint.composer.nsd.compose; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; -import it.cnit.blueprint.composer.rest.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index 9dc8262..8339969 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; -import it.cnit.blueprint.composer.rest.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.InvalidNsdException; import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsComponent; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java index 9b123cf..1b91af8 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java @@ -1,6 +1,6 @@ package it.cnit.blueprint.composer.nsd.graph; -import it.cnit.blueprint.composer.rest.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.InvalidNsdException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 81eadd9..68af40a 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -1,7 +1,10 @@ package it.cnit.blueprint.composer.rest; +import it.cnit.blueprint.composer.exceptions.InvalidContextException; +import it.cnit.blueprint.composer.exceptions.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.InvalidTranslationRuleException; +import it.cnit.blueprint.composer.exceptions.InvalidVsbException; import it.cnit.blueprint.composer.nsd.compose.NsdComposer; -import it.cnit.blueprint.composer.rules.InvalidTranslationRuleException; import it.cnit.blueprint.composer.rules.TranslationRulesComposer; import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.CompositionStrategy; @@ -81,7 +84,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ if (ctxNsd.getVnfdId().size() == 1) { log.debug("ctxNsd has only one vnfdId."); } else { - throw new InvalidContextException("More than one VNF found in Ctx for PASS_THROUGH"); + throw new InvalidContextException("More than one VNFD ID found for PASS_THROUGH"); } passThroughComposer .compose(ctx.getConnectInput(), ranVld, expMgmtVld, expNsd, ctxMgmtVld, ctxNsd); diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java index 79f3338..02dd06a 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java @@ -1,5 +1,6 @@ package it.cnit.blueprint.composer.rest; +import it.cnit.blueprint.composer.exceptions.InvalidNsdException; import it.cnit.blueprint.composer.nsd.generate.NsdGenerator; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; diff --git a/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java index 3944a84..b615190 100644 --- a/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java @@ -1,5 +1,6 @@ package it.cnit.blueprint.composer.rules; +import it.cnit.blueprint.composer.exceptions.InvalidTranslationRuleException; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; diff --git a/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java index bc5d000..1cc462a 100644 --- a/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; +import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; @@ -71,6 +72,7 @@ public void composeExperiment() { List vsbNsd = YAML_OM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), new TypeReference>() { }); + vsbNsd.get(0).getVirtualLinkDesc().get(0).setVirtualLinkDescId("pippo"); List vsbTr = YAML_OM .readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_tr")), new TypeReference>() { @@ -96,6 +98,8 @@ public void composeExperiment() { // When MvcResult result = mvc.perform(MockMvcRequestBuilders.post("/experiments").contentType( MediaType.APPLICATION_JSON).content(body)).andReturn(); + MockHttpServletResponse resp = result.getResponse(); + log.info("content {}", resp.getErrorMessage()); assertEquals(200, result.getResponse().getStatus()); ComposeResponse response = JSON_OM .readValue(result.getResponse().getContentAsString(), ComposeResponse.class); From d7c5eeafc0577bf244ceb91cf255df5e1679b9e1 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 11 May 2020 18:52:30 +0200 Subject: [PATCH 170/187] Rename exceptions. --- .../exceptions/InvalidNsdException.java | 12 ---------- .../InvalidTranslationRuleException.java | 8 ------- .../exceptions/InvalidVsbException.java | 8 ------- .../exceptions/NsdInvalidException.java | 12 ++++++++++ .../exceptions/TransRuleInvalidException.java | 8 +++++++ .../exceptions/VsbInvalidException.java | 8 +++++++ .../composer/nsd/compose/ConnectComposer.java | 16 +++++++------- .../composer/nsd/compose/NsdComposer.java | 22 +++++++++---------- .../nsd/compose/PassThroughComposer.java | 14 ++++++------ .../composer/nsd/generate/NsdGenerator.java | 6 ++--- .../composer/nsd/graph/NsdGraphService.java | 8 +++---- .../composer/rest/ExperimentsController.java | 22 +++++++++---------- .../composer/rest/ServicesController.java | 4 ++-- .../rules/TranslationRulesComposer.java | 8 +++---- 14 files changed, 78 insertions(+), 78 deletions(-) delete mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/InvalidNsdException.java delete mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/InvalidTranslationRuleException.java delete mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/InvalidVsbException.java create mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/NsdInvalidException.java create mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/TransRuleInvalidException.java create mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/VsbInvalidException.java diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidNsdException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidNsdException.java deleted file mode 100644 index 343c158..0000000 --- a/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidNsdException.java +++ /dev/null @@ -1,12 +0,0 @@ -package it.cnit.blueprint.composer.exceptions; - -public class InvalidNsdException extends Exception { - - public InvalidNsdException(String message) { - super(message); - } - - public InvalidNsdException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidTranslationRuleException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidTranslationRuleException.java deleted file mode 100644 index 0bdff85..0000000 --- a/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidTranslationRuleException.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.composer.exceptions; - -public class InvalidTranslationRuleException extends Exception { - - public InvalidTranslationRuleException(String message) { - super(message); - } -} diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidVsbException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidVsbException.java deleted file mode 100644 index d90069e..0000000 --- a/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidVsbException.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.composer.exceptions; - -public class InvalidVsbException extends Exception { - - public InvalidVsbException(String message) { - super(message); - } -} diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/NsdInvalidException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/NsdInvalidException.java new file mode 100644 index 0000000..adf98f6 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/NsdInvalidException.java @@ -0,0 +1,12 @@ +package it.cnit.blueprint.composer.exceptions; + +public class NsdInvalidException extends Exception { + + public NsdInvalidException(String message) { + super(message); + } + + public NsdInvalidException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/TransRuleInvalidException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/TransRuleInvalidException.java new file mode 100644 index 0000000..1a5ba16 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/TransRuleInvalidException.java @@ -0,0 +1,8 @@ +package it.cnit.blueprint.composer.exceptions; + +public class TransRuleInvalidException extends Exception { + + public TransRuleInvalidException(String message) { + super(message); + } +} diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/VsbInvalidException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/VsbInvalidException.java new file mode 100644 index 0000000..5c52f2a --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/VsbInvalidException.java @@ -0,0 +1,8 @@ +package it.cnit.blueprint.composer.exceptions; + +public class VsbInvalidException extends Exception { + + public VsbInvalidException(String message) { + super(message); + } +} diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index 869b5e9..7274f27 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -1,7 +1,7 @@ package it.cnit.blueprint.composer.nsd.compose; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; -import it.cnit.blueprint.composer.exceptions.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; @@ -80,7 +80,7 @@ public void composeWithStrategy( Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) - throws InvalidNsdException { + throws NsdInvalidException { log.info("Compose with CONNECT."); List mgmtVlProfileIds = Arrays.asList( ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), @@ -95,7 +95,7 @@ public void composeWithStrategy( vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); vnfInfo.setVlcLists(mgmtVlProfileIds); } catch (NotExistingEntityException e) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Error retrieving VNF info for VNF profile ID " + vnfpId, e); } VlInfo vlInfo; @@ -110,13 +110,13 @@ public void composeWithStrategy( ranVlInfo.getVlProfile().getVirtualLinkProfileId()); vlInfo = retrieveVlInfoByProfileId(nonMgmtVlpId, expNsd, expNsDf, expNsLvl); } catch (NotExistingEntityException e) { - throw new InvalidNsdException("Error retrieving VL info for a non-management VL", e); + throw new NsdInvalidException("Error retrieving VL info for a non-management VL", e); } } try { addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } catch (NotExistingEntityException e) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Error connecting VNF profile " + vnfInfo.getVnfProfile().getVnfProfileId(), e); } } @@ -129,7 +129,7 @@ public void composeWithStrategy( vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); vnfInfo.setVlcLists(mgmtVlProfileIds); } catch (NotExistingEntityException e) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Error retrieving VNF info for VNFD ID " + entry.getKey(), e); } VlInfo vlInfo; @@ -137,13 +137,13 @@ public void composeWithStrategy( String vlpId = getVlProfileByDescId(entry.getValue(), ctxNsDf).getVirtualLinkProfileId(); vlInfo = retrieveVlInfoByProfileId(vlpId, ctxNsd, ctxNsDf, ctxNsLvl); } catch (NotExistingEntityException e) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Error retrieving VL info for VLD ID " + entry.getValue(), e); } try { addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } catch (NotExistingEntityException e) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Error connecting VNF profile " + vnfInfo.getVnfProfile().getVnfProfileId(), e); } } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 5f5a7a1..af5d5c6 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; -import it.cnit.blueprint.composer.exceptions.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; @@ -183,19 +183,19 @@ protected void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile throw new NotExistingEntityException("VL connectivity not found for CPD ID " + cpdId); } - public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws InvalidNsdException { + public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws NsdInvalidException { try { return getVlDescriptor(ranSapd.getNsVirtualLinkDescId(), expNsd); } catch (NotExistingEntityException e) { log.error(e.getMessage()); - throw new InvalidNsdException("VLD not found for SAP " + ranSapd.getCpdId(), e); + throw new NsdInvalidException("VLD not found for SAP " + ranSapd.getCpdId(), e); } } @SneakyThrows(JsonProcessingException.class) public void compose(Map connectInput, NsVirtualLinkDesc ranVld, NsVirtualLinkDesc expMgmtVld, Nsd expNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) - throws InvalidNsdException { + throws NsdInvalidException { // We assume only one NsDf for the context NsDf ctxNsDf = ctxNsd.getNsDf().get(0); // We assume only one NsLevel for the context @@ -218,7 +218,7 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, .buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("expG BEFORE composition :\n{}", nsdGraphService.export(expG)); if (!nsdGraphService.isConnected(expG)) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Network topology not connected for NsDf " + expNsDf.getNsDfId() + " and NsLevel " + expNsLvl.getNsLevelId()); } @@ -228,7 +228,7 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, ranVlInfo = retrieveVlInfoByDesc(ranVld, expNsDf, expNsLvl); log.debug("Found VlInfo for ranVld {} in expNsd.", ranVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { - throw new InvalidNsdException("Error retrieving RAN VL info for VLD " + ranVld, e); + throw new NsdInvalidException("Error retrieving RAN VL info for VLD " + ranVld, e); } VlInfo expMgmtVlInfo; try { @@ -236,7 +236,7 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, log.debug("Found VlInfo for expMgmtVld {} in expNsd.", expMgmtVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Error retrieving Experiment Management VL info for VLD " + ranVld .getVirtualLinkDescId(), e); } @@ -246,7 +246,7 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, log.debug("Found VlInfo for ctxMgmtVld {} in ctxNsd.", ctxMgmtVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Error retrieving Context Management VL info for VLD " + ranVld, e); } composeWithStrategy(connectInput, ranVlInfo, expMgmtVlInfo, ctxMgmtVlInfo, @@ -257,13 +257,13 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, try { expNsd.isValid(); } catch (MalformattedElementException e) { - throw new InvalidNsdException("Nsd not valid after composition", e); + throw new NsdInvalidException("Nsd not valid after composition", e); } expG = nsdGraphService.buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("Graph AFTER composition with {}:\n{}", ctxNsd.getNsdIdentifier(), nsdGraphService.export(expG)); if (!nsdGraphService.isConnected(expG)) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Network topology not connected for NsDf " + expNsDf.getNsDfId() + " and NsLevel " + expNsLvl.getNsLevelId()); } @@ -283,6 +283,6 @@ public abstract void composeWithStrategy( VlInfo ctxMgmtVlInfo, Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl - ) throws InvalidNsdException; + ) throws NsdInvalidException; } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index 6930407..5e7bfeb 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -1,7 +1,7 @@ package it.cnit.blueprint.composer.nsd.compose; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; -import it.cnit.blueprint.composer.exceptions.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; @@ -35,7 +35,7 @@ public void composeWithStrategy( VlInfo ctxMgmtVlInfo, Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl) - throws InvalidNsdException { + throws NsdInvalidException { log.info("Compose with PASS_THROUGH."); List mgmtVlProfileIds = Arrays.asList( ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), @@ -50,7 +50,7 @@ public void composeWithStrategy( log.debug("Found VnfInfo for vnfpId {} in context.", ctxVnfpId); ctxVnfInfo.setVlcLists(mgmtVlProfileIds); } catch (NotExistingEntityException e) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Error retrieving VNF info for VNF profile ID " + ctxVnfpId, e); } @@ -62,7 +62,7 @@ public void composeWithStrategy( ctxVnfInfo.getDataVlcList().get(0).getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); } catch (NotExistingEntityException e) { - throw new InvalidNsdException("Error retrieving VL info for a non-management VL", e); + throw new NsdInvalidException("Error retrieving VL info for a non-management VL", e); } // Retrieve RAN closest VNF information from exp @@ -75,7 +75,7 @@ public void composeWithStrategy( try { vnfProfile = getVnfProfileById(vnfLvl.getVnfProfileId(), expNsDf); } catch (NotExistingEntityException e) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Error retrieving VNF info for VNF profile ID " + vnfLvl.getVnfProfileId(), e); } for (NsVirtualLinkConnectivity vlc : vnfProfile.getNsVirtualLinkConnectivity()) { @@ -88,7 +88,7 @@ public void composeWithStrategy( } } if (ranVnfCpd == null) { - throw new InvalidNsdException( + throw new NsdInvalidException( "Can't find a VNF close to ranVlInfo in nsLevel " + expNsLvl.getNsLevelId()); } log.debug("ranVnfProfile: {}", ranVnfProfile.getVnfProfileId()); @@ -130,7 +130,7 @@ public void composeWithStrategy( ctxVnfInfo.cleanUpVlc(ctxVnfInfo.getDataVlcList().get(i)); } } catch (NotExistingEntityException e) { - throw new InvalidNsdException("Error in connecting VNF to VL.", e); + throw new NsdInvalidException("Error in connecting VNF to VL.", e); } } } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index 8339969..319bb69 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; -import it.cnit.blueprint.composer.exceptions.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsComponent; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; @@ -55,7 +55,7 @@ public class NsdGenerator { private final NsdGraphService nsdGraphService; @SneakyThrows(JsonProcessingException.class) - public Nsd generate(Blueprint blueprint) throws InvalidNsdException { + public Nsd generate(Blueprint blueprint) throws NsdInvalidException { log.debug("blueprint {}:\n{}", blueprint.getBlueprintId(), OBJECT_MAPPER.writeValueAsString(blueprint)); @@ -178,7 +178,7 @@ public Nsd generate(Blueprint blueprint) throws InvalidNsdException { try { nsd.isValid(); } catch (MalformattedElementException e) { - throw new InvalidNsdException("Nsd looks not valid after generation", e); + throw new NsdInvalidException("Nsd looks not valid after generation", e); } Graph g = nsdGraphService.buildGraph(nsd.getSapd(), nsDf, nsLevel); diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java index 1b91af8..3b98b30 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java @@ -1,6 +1,6 @@ package it.cnit.blueprint.composer.nsd.graph; -import it.cnit.blueprint.composer.exceptions.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; @@ -30,7 +30,7 @@ public class NsdGraphService { private GraphExporter graphExporter; public Graph buildGraph(List sapdList, NsDf nsDf, NsLevel nsLevel) - throws InvalidNsdException { + throws NsdInvalidException { Graph g = new SimpleGraph<>(String.class); List vnfPVertices = new ArrayList<>(); List pnfPVertices = new ArrayList<>(); @@ -49,7 +49,7 @@ public Graph buildGraph(List sapdList, NsDf nsDf, N new String[]{vnfToLevelMapping.getVnfProfileId(), nsDf.getNsDfId(), nsLevel.getNsLevelId()}).getMessage(); log.error(message); - throw new InvalidNsdException(message); + throw new NsdInvalidException(message); } // TODO handle the number of instances to build the graph vnfPVertices.add(v); @@ -71,7 +71,7 @@ public Graph buildGraph(List sapdList, NsDf nsDf, N new String[]{vlToLevelMapping.getVirtualLinkProfileId(), nsDf.getNsDfId(), nsLevel.getNsLevelId()}).getMessage(); log.error(message); - throw new InvalidNsdException(message); + throw new NsdInvalidException(message); } vlPVertices.add(v); g.addVertex(v); diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 68af40a..baef1d6 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -1,9 +1,9 @@ package it.cnit.blueprint.composer.rest; import it.cnit.blueprint.composer.exceptions.InvalidContextException; -import it.cnit.blueprint.composer.exceptions.InvalidNsdException; -import it.cnit.blueprint.composer.exceptions.InvalidTranslationRuleException; -import it.cnit.blueprint.composer.exceptions.InvalidVsbException; +import it.cnit.blueprint.composer.exceptions.NsdInvalidException; +import it.cnit.blueprint.composer.exceptions.TransRuleInvalidException; +import it.cnit.blueprint.composer.exceptions.VsbInvalidException; import it.cnit.blueprint.composer.nsd.compose.NsdComposer; import it.cnit.blueprint.composer.rules.TranslationRulesComposer; import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; @@ -97,7 +97,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ } } - } catch (InvalidVsbException | InvalidNsdException | InvalidContextException e) { + } catch (VsbInvalidException | NsdInvalidException | InvalidContextException e) { throw new ResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e); } @@ -105,7 +105,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ try { translationRules = translationRulesComposer .compose(expNsd, composeRequest.getVsbRequest().getTranslationRules()); - } catch (InvalidTranslationRuleException e) { + } catch (TransRuleInvalidException e) { // TODO create proper error response. e.printStackTrace(); } @@ -113,7 +113,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ } private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) - throws InvalidNsdException, InvalidVsbException { + throws NsdInvalidException, VsbInvalidException { Optional ranEp = b.getEndPoints().stream() .filter(e -> e.isRanConnection() && e.getEndPointId().contains("sap")) .findFirst(); @@ -125,16 +125,16 @@ private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) if (ranSapd.isPresent()) { return connectComposer.getRanVlDesc(ranSapd.get(), nsd); } else { - throw new InvalidNsdException( + throw new NsdInvalidException( "RAN Sap with ID " + epId + " not found in NSD " + nsd.getNsdIdentifier()); } } else { - throw new InvalidVsbException("No RAN endpoint found in VSB " + b.getBlueprintId() + "."); + throw new VsbInvalidException("No RAN endpoint found in VSB " + b.getBlueprintId() + "."); } } private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) - throws InvalidVsbException, InvalidNsdException { + throws VsbInvalidException, NsdInvalidException { Optional optConnServ = b.getConnectivityServices().stream() .filter(VsbLink::isManagement) .findFirst(); @@ -146,11 +146,11 @@ private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) if (optVld.isPresent()) { return optVld.get(); } else { - throw new InvalidNsdException( + throw new NsdInvalidException( "Management Vld with id=" + name + "not found in NSD " + nsd.getNsdIdentifier() + "."); } } else { - throw new InvalidVsbException( + throw new VsbInvalidException( "No management connectivity service found in VSB " + b.getBlueprintId() + "."); } } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java index 02dd06a..c6848fb 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java @@ -1,6 +1,6 @@ package it.cnit.blueprint.composer.rest; -import it.cnit.blueprint.composer.exceptions.InvalidNsdException; +import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.cnit.blueprint.composer.nsd.generate.NsdGenerator; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; @@ -26,7 +26,7 @@ public Nsd generateService(@RequestBody VsBlueprint vsb) { Nsd nsd; try { nsd = nsdGenerator.generate(vsb); - } catch (InvalidNsdException e) { + } catch (NsdInvalidException e) { //TODO handle exception nsd = null; e.printStackTrace(); diff --git a/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java index b615190..230ae13 100644 --- a/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java @@ -1,6 +1,6 @@ package it.cnit.blueprint.composer.rules; -import it.cnit.blueprint.composer.exceptions.InvalidTranslationRuleException; +import it.cnit.blueprint.composer.exceptions.TransRuleInvalidException; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; @@ -18,7 +18,7 @@ public class TranslationRulesComposer { public List compose(Nsd expNsd, - List translationRules) throws InvalidTranslationRuleException { + List translationRules) throws TransRuleInvalidException { log.info("Compose and check translation rules for expNsd: '{}'", expNsd.getNsdIdentifier()); List newTranslationRules = new ArrayList<>(); for (VsdNsdTranslationRule tr : translationRules) { @@ -31,13 +31,13 @@ public List compose(Nsd expNsd, String m = MessageFormatter.format("Invalid translation rule. NsLevel='{}' not found", tr.getNsInstantiationLevelId()).getMessage(); log.error(m); - throw new InvalidTranslationRuleException(m); + throw new TransRuleInvalidException(m); } } else { String m = MessageFormatter.format("Invalid translation rule. NsDf='{}' not found", tr.getNsFlavourId()).getMessage(); log.error(m); - throw new InvalidTranslationRuleException(m); + throw new TransRuleInvalidException(m); } newTranslationRules.add(new VsdNsdTranslationRule(tr.getInput(), expNsd.getNsdIdentifier(), expNsd.getVersion(), tr.getNsFlavourId(), tr.getNsInstantiationLevelId())); From 9b30dc3176d54b8d562cfd951aeea853250d9ac0 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Mon, 11 May 2020 19:03:13 +0200 Subject: [PATCH 171/187] Add generic exception for invalid descriptors. --- .../DescriptorInvalidException.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/DescriptorInvalidException.java diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/DescriptorInvalidException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/DescriptorInvalidException.java new file mode 100644 index 0000000..07fc83b --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/DescriptorInvalidException.java @@ -0,0 +1,21 @@ +package it.cnit.blueprint.composer.exceptions; + +public class DescriptorInvalidException extends Exception { + + private String descId; + + public DescriptorInvalidException(String descId, String message) { + super(message); + this.descId = descId; + } + + public DescriptorInvalidException(String descId, String message, Throwable cause) { + super(message, cause); + this.descId = descId; + } + + @Override + public String getMessage() { + return String.join(" ", descId, "is invalid:", super.getMessage()); + } +} From bf39aed793cec0a88e1642995fed56cf43619d92 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 09:38:13 +0200 Subject: [PATCH 172/187] Use better exception for NsdInvalid. --- .../exceptions/NsdInvalidException.java | 10 +++++----- .../composer/nsd/compose/ConnectComposer.java | 15 ++++++++------- .../composer/nsd/compose/NsdComposer.java | 19 +++++++++++-------- .../nsd/compose/PassThroughComposer.java | 11 ++++++----- .../composer/nsd/generate/NsdGenerator.java | 5 +++-- .../composer/nsd/graph/NsdGraphService.java | 4 ++-- .../composer/rest/ExperimentsController.java | 8 ++++---- 7 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/NsdInvalidException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/NsdInvalidException.java index adf98f6..8506487 100644 --- a/src/main/java/it/cnit/blueprint/composer/exceptions/NsdInvalidException.java +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/NsdInvalidException.java @@ -1,12 +1,12 @@ package it.cnit.blueprint.composer.exceptions; -public class NsdInvalidException extends Exception { +public class NsdInvalidException extends DescriptorInvalidException { - public NsdInvalidException(String message) { - super(message); + public NsdInvalidException(String descId, String message) { + super(descId, message); } - public NsdInvalidException(String message, Throwable cause) { - super(message, cause); + public NsdInvalidException(String descId, String message, Throwable cause) { + super(descId, message, cause); } } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java index 7274f27..a3e7552 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -1,7 +1,7 @@ package it.cnit.blueprint.composer.nsd.compose; -import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.exceptions.NsdInvalidException; +import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsLevel; @@ -95,7 +95,7 @@ public void composeWithStrategy( vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); vnfInfo.setVlcLists(mgmtVlProfileIds); } catch (NotExistingEntityException e) { - throw new NsdInvalidException( + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), "Error retrieving VNF info for VNF profile ID " + vnfpId, e); } VlInfo vlInfo; @@ -110,13 +110,14 @@ public void composeWithStrategy( ranVlInfo.getVlProfile().getVirtualLinkProfileId()); vlInfo = retrieveVlInfoByProfileId(nonMgmtVlpId, expNsd, expNsDf, expNsLvl); } catch (NotExistingEntityException e) { - throw new NsdInvalidException("Error retrieving VL info for a non-management VL", e); + throw new NsdInvalidException(expNsd.getNsdIdentifier(), + "Error retrieving VL info for a non-management VL", e); } } try { addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } catch (NotExistingEntityException e) { - throw new NsdInvalidException( + throw new NsdInvalidException(expNsd.getNsdIdentifier(), "Error connecting VNF profile " + vnfInfo.getVnfProfile().getVnfProfileId(), e); } } @@ -129,7 +130,7 @@ public void composeWithStrategy( vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); vnfInfo.setVlcLists(mgmtVlProfileIds); } catch (NotExistingEntityException e) { - throw new NsdInvalidException( + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), "Error retrieving VNF info for VNFD ID " + entry.getKey(), e); } VlInfo vlInfo; @@ -137,13 +138,13 @@ public void composeWithStrategy( String vlpId = getVlProfileByDescId(entry.getValue(), ctxNsDf).getVirtualLinkProfileId(); vlInfo = retrieveVlInfoByProfileId(vlpId, ctxNsd, ctxNsDf, ctxNsLvl); } catch (NotExistingEntityException e) { - throw new NsdInvalidException( + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), "Error retrieving VL info for VLD ID " + entry.getValue(), e); } try { addConnectVnfToVl(vnfInfo, vlInfo, expMgmtVlInfo, expNsd, expNsDf, expNsLvl); } catch (NotExistingEntityException e) { - throw new NsdInvalidException( + throw new NsdInvalidException(expNsd.getNsdIdentifier(), "Error connecting VNF profile " + vnfInfo.getVnfProfile().getVnfProfileId(), e); } } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index af5d5c6..3bb7278 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; -import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.common.exceptions.NotExistingEntityException; import it.nextworks.nfvmano.libs.ifa.descriptors.common.elements.VirtualLinkProfile; @@ -188,7 +188,8 @@ public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws NsdInvali return getVlDescriptor(ranSapd.getNsVirtualLinkDescId(), expNsd); } catch (NotExistingEntityException e) { log.error(e.getMessage()); - throw new NsdInvalidException("VLD not found for SAP " + ranSapd.getCpdId(), e); + throw new NsdInvalidException(expNsd.getNsdIdentifier(), + "VLD not found for SAP " + ranSapd.getCpdId(), e); } } @@ -218,7 +219,7 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, .buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("expG BEFORE composition :\n{}", nsdGraphService.export(expG)); if (!nsdGraphService.isConnected(expG)) { - throw new NsdInvalidException( + throw new NsdInvalidException(expNsd.getNsdIdentifier(), "Network topology not connected for NsDf " + expNsDf.getNsDfId() + " and NsLevel " + expNsLvl.getNsLevelId()); } @@ -228,7 +229,8 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, ranVlInfo = retrieveVlInfoByDesc(ranVld, expNsDf, expNsLvl); log.debug("Found VlInfo for ranVld {} in expNsd.", ranVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { - throw new NsdInvalidException("Error retrieving RAN VL info for VLD " + ranVld, e); + throw new NsdInvalidException(expNsd.getNsdIdentifier(), + "Error retrieving RAN VL info for VLD " + ranVld, e); } VlInfo expMgmtVlInfo; try { @@ -236,7 +238,7 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, log.debug("Found VlInfo for expMgmtVld {} in expNsd.", expMgmtVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { - throw new NsdInvalidException( + throw new NsdInvalidException(expNsd.getNsdIdentifier(), "Error retrieving Experiment Management VL info for VLD " + ranVld .getVirtualLinkDescId(), e); } @@ -246,7 +248,7 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, log.debug("Found VlInfo for ctxMgmtVld {} in ctxNsd.", ctxMgmtVld.getVirtualLinkDescId()); } catch (NotExistingEntityException e) { - throw new NsdInvalidException( + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), "Error retrieving Context Management VL info for VLD " + ranVld, e); } composeWithStrategy(connectInput, ranVlInfo, expMgmtVlInfo, ctxMgmtVlInfo, @@ -257,13 +259,14 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, try { expNsd.isValid(); } catch (MalformattedElementException e) { - throw new NsdInvalidException("Nsd not valid after composition", e); + throw new NsdInvalidException(expNsd.getNsdIdentifier(), + "Nsd not valid after composition", e); } expG = nsdGraphService.buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("Graph AFTER composition with {}:\n{}", ctxNsd.getNsdIdentifier(), nsdGraphService.export(expG)); if (!nsdGraphService.isConnected(expG)) { - throw new NsdInvalidException( + throw new NsdInvalidException(expNsd.getNsdIdentifier(), "Network topology not connected for NsDf " + expNsDf.getNsDfId() + " and NsLevel " + expNsLvl.getNsLevelId()); } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java index 5e7bfeb..0364428 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -50,7 +50,7 @@ public void composeWithStrategy( log.debug("Found VnfInfo for vnfpId {} in context.", ctxVnfpId); ctxVnfInfo.setVlcLists(mgmtVlProfileIds); } catch (NotExistingEntityException e) { - throw new NsdInvalidException( + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), "Error retrieving VNF info for VNF profile ID " + ctxVnfpId, e); } @@ -62,7 +62,8 @@ public void composeWithStrategy( ctxVnfInfo.getDataVlcList().get(0).getVirtualLinkProfileId(), ctxNsd, ctxNsDf, ctxNsLvl); } catch (NotExistingEntityException e) { - throw new NsdInvalidException("Error retrieving VL info for a non-management VL", e); + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), + "Error retrieving VL info for a non-management VL", e); } // Retrieve RAN closest VNF information from exp @@ -75,7 +76,7 @@ public void composeWithStrategy( try { vnfProfile = getVnfProfileById(vnfLvl.getVnfProfileId(), expNsDf); } catch (NotExistingEntityException e) { - throw new NsdInvalidException( + throw new NsdInvalidException(expNsd.getNsdIdentifier(), "Error retrieving VNF info for VNF profile ID " + vnfLvl.getVnfProfileId(), e); } for (NsVirtualLinkConnectivity vlc : vnfProfile.getNsVirtualLinkConnectivity()) { @@ -88,7 +89,7 @@ public void composeWithStrategy( } } if (ranVnfCpd == null) { - throw new NsdInvalidException( + throw new NsdInvalidException(expNsd.getNsdIdentifier(), "Can't find a VNF close to ranVlInfo in nsLevel " + expNsLvl.getNsLevelId()); } log.debug("ranVnfProfile: {}", ranVnfProfile.getVnfProfileId()); @@ -130,7 +131,7 @@ public void composeWithStrategy( ctxVnfInfo.cleanUpVlc(ctxVnfInfo.getDataVlcList().get(i)); } } catch (NotExistingEntityException e) { - throw new NsdInvalidException("Error in connecting VNF to VL.", e); + throw new NsdInvalidException(expNsd.getNsdIdentifier(), "Error in connecting VNF to VL.", e); } } } diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index 319bb69..540e5ba 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; -import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsComponent; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsbEndpoint; @@ -178,7 +178,8 @@ public Nsd generate(Blueprint blueprint) throws NsdInvalidException { try { nsd.isValid(); } catch (MalformattedElementException e) { - throw new NsdInvalidException("Nsd looks not valid after generation", e); + throw new NsdInvalidException(nsd.getNsdIdentifier(), + "Nsd looks not valid after generation", e); } Graph g = nsdGraphService.buildGraph(nsd.getSapd(), nsDf, nsLevel); diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java index 3b98b30..f1e192a 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/NsdGraphService.java @@ -49,7 +49,7 @@ public Graph buildGraph(List sapdList, NsDf nsDf, N new String[]{vnfToLevelMapping.getVnfProfileId(), nsDf.getNsDfId(), nsLevel.getNsLevelId()}).getMessage(); log.error(message); - throw new NsdInvalidException(message); + throw new NsdInvalidException(nsDf.getNsDfId(), message); } // TODO handle the number of instances to build the graph vnfPVertices.add(v); @@ -71,7 +71,7 @@ public Graph buildGraph(List sapdList, NsDf nsDf, N new String[]{vlToLevelMapping.getVirtualLinkProfileId(), nsDf.getNsDfId(), nsLevel.getNsLevelId()}).getMessage(); log.error(message); - throw new NsdInvalidException(message); + throw new NsdInvalidException(nsDf.getNsDfId(), message); } vlPVertices.add(v); g.addVertex(v); diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index baef1d6..60fa448 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -125,8 +125,8 @@ private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) if (ranSapd.isPresent()) { return connectComposer.getRanVlDesc(ranSapd.get(), nsd); } else { - throw new NsdInvalidException( - "RAN Sap with ID " + epId + " not found in NSD " + nsd.getNsdIdentifier()); + throw new NsdInvalidException(nsd.getNsdIdentifier(), + "RAN Sap with ID " + epId + " not found"); } } else { throw new VsbInvalidException("No RAN endpoint found in VSB " + b.getBlueprintId() + "."); @@ -146,8 +146,8 @@ private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) if (optVld.isPresent()) { return optVld.get(); } else { - throw new NsdInvalidException( - "Management Vld with id=" + name + "not found in NSD " + nsd.getNsdIdentifier() + "."); + throw new NsdInvalidException(nsd.getNsdIdentifier(), + "Management Vld with id=" + name + "not found"); } } else { throw new VsbInvalidException( From 9e451ad33c799488d288f825de4a9f3819b6eab7 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 09:39:18 +0200 Subject: [PATCH 173/187] Rename exception for invalid context. --- .../composer/exceptions/ContextInvalidException.java | 8 ++++++++ .../composer/exceptions/InvalidContextException.java | 8 -------- .../blueprint/composer/rest/ExperimentsController.java | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/ContextInvalidException.java delete mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/InvalidContextException.java diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/ContextInvalidException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/ContextInvalidException.java new file mode 100644 index 0000000..8f536fa --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/ContextInvalidException.java @@ -0,0 +1,8 @@ +package it.cnit.blueprint.composer.exceptions; + +public class ContextInvalidException extends Exception { + + public ContextInvalidException(String message) { + super(message); + } +} diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidContextException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidContextException.java deleted file mode 100644 index a790eb5..0000000 --- a/src/main/java/it/cnit/blueprint/composer/exceptions/InvalidContextException.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.composer.exceptions; - -public class InvalidContextException extends Exception { - - public InvalidContextException(String message) { - super(message); - } -} diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 60fa448..f61a803 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -1,6 +1,6 @@ package it.cnit.blueprint.composer.rest; -import it.cnit.blueprint.composer.exceptions.InvalidContextException; +import it.cnit.blueprint.composer.exceptions.ContextInvalidException; import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.cnit.blueprint.composer.exceptions.TransRuleInvalidException; import it.cnit.blueprint.composer.exceptions.VsbInvalidException; @@ -84,7 +84,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ if (ctxNsd.getVnfdId().size() == 1) { log.debug("ctxNsd has only one vnfdId."); } else { - throw new InvalidContextException("More than one VNFD ID found for PASS_THROUGH"); + throw new ContextInvalidException("More than one VNFD ID found for PASS_THROUGH"); } passThroughComposer .compose(ctx.getConnectInput(), ranVld, expMgmtVld, expNsd, ctxMgmtVld, ctxNsd); @@ -93,11 +93,11 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ ctxB.getCompositionStrategy().name()) .getMessage(); log.error(m); - throw new InvalidContextException(m); + throw new ContextInvalidException(m); } } - } catch (VsbInvalidException | NsdInvalidException | InvalidContextException e) { + } catch (VsbInvalidException | NsdInvalidException | ContextInvalidException e) { throw new ResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e); } From 7a116b5748aa201dcaf9ef04916212ed751e48c5 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 09:44:06 +0200 Subject: [PATCH 174/187] Better exception for invalid Vsb. --- .../composer/exceptions/VsbInvalidException.java | 10 +++++++--- .../blueprint/composer/rest/ExperimentsController.java | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/VsbInvalidException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/VsbInvalidException.java index 5c52f2a..cfb116a 100644 --- a/src/main/java/it/cnit/blueprint/composer/exceptions/VsbInvalidException.java +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/VsbInvalidException.java @@ -1,8 +1,12 @@ package it.cnit.blueprint.composer.exceptions; -public class VsbInvalidException extends Exception { +public class VsbInvalidException extends DescriptorInvalidException { - public VsbInvalidException(String message) { - super(message); + public VsbInvalidException(String descId, String message) { + super(descId, message); + } + + public VsbInvalidException(String descId, String message, Throwable cause) { + super(descId, message, cause); } } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index f61a803..92b2d90 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -129,7 +129,8 @@ private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) "RAN Sap with ID " + epId + " not found"); } } else { - throw new VsbInvalidException("No RAN endpoint found in VSB " + b.getBlueprintId() + "."); + throw new VsbInvalidException(b.getBlueprintId(), + "No RAN endpoint found in VSB " + b.getBlueprintId() + "."); } } @@ -150,7 +151,7 @@ private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) "Management Vld with id=" + name + "not found"); } } else { - throw new VsbInvalidException( + throw new VsbInvalidException(b.getBlueprintId(), "No management connectivity service found in VSB " + b.getBlueprintId() + "."); } } From 9e6192e20918d8782a386ef65e64fd6d691c26fd Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 09:58:48 +0200 Subject: [PATCH 175/187] Fix setting of designer on composed NSD. --- .../it/cnit/blueprint/composer/rest/ExperimentsController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index 92b2d90..a26e3a3 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -56,7 +56,7 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ Nsd expNsd = composeRequest.getVsbRequest().getNsds().get(0); expNsd.setNsdIdentifier(UUID.randomUUID().toString()); expNsd.setNsdInvariantId(UUID.randomUUID().toString()); - expNsd.setDesigner(expNsd.getDesigner() + " + NSD Generator"); + expNsd.setDesigner(expNsd.getDesigner() + " + NSD Composer"); try { // Assumptions: From 24ef1890a929ad1aeadff2c788490dd3ff45cf18 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 09:59:19 +0200 Subject: [PATCH 176/187] Complete test with assert on body. Remove old debug code. --- .../composer/rest/ExperimentsControllerTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java index 1cc462a..838d07c 100644 --- a/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java @@ -72,7 +72,7 @@ public void composeExperiment() { List vsbNsd = YAML_OM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), new TypeReference>() { }); - vsbNsd.get(0).getVirtualLinkDesc().get(0).setVirtualLinkDescId("pippo"); +// vsbNsd.get(0).getVirtualLinkDesc().get(0).setVirtualLinkDescId("pippo"); List vsbTr = YAML_OM .readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_tr")), new TypeReference>() { @@ -99,10 +99,19 @@ public void composeExperiment() { MvcResult result = mvc.perform(MockMvcRequestBuilders.post("/experiments").contentType( MediaType.APPLICATION_JSON).content(body)).andReturn(); MockHttpServletResponse resp = result.getResponse(); - log.info("content {}", resp.getErrorMessage()); + + // Then assertEquals(200, result.getResponse().getStatus()); ComposeResponse response = JSON_OM .readValue(result.getResponse().getContentAsString(), ComposeResponse.class); log.info("Response body:\n{}", JSON_OM.writeValueAsString(response)); + Nsd actualNsd = response.getExpNsd(); + actualNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); + actualNsd.setNsdInvariantId("ae66294b-8dae-406c-af70-f8516e310965"); + InputStream in = getClass().getResourceAsStream( + "/expb_ares2t_tracker_delay_nsds_passthrough.yaml"); + Nsd expectedNsd = YAML_OM.readValue(in, Nsd[].class)[0]; + assertEquals(YAML_OM.writeValueAsString(expectedNsd), + YAML_OM.writeValueAsString(response.getExpNsd())); } } \ No newline at end of file From 667e9bb813c7002fb372cc9f65e38f4caed724a0 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 11:23:40 +0200 Subject: [PATCH 177/187] Add fail-on-unknown-properties for Jackson. Needed to return 400 errors. --- src/main/resources/application.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8eb6524..cb94a86 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -3,3 +3,4 @@ spring.profiles.active=prod spring.output.ansi.enabled=always springdoc.api-docs.path=/api-docs springdoc.swagger-ui.path=/swagger-ui.html +spring.jackson.deserialization.fail-on-unknown-properties=true \ No newline at end of file From a44c24039c66fc7ff94f5102ee37e42668e65852 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 11:34:16 +0200 Subject: [PATCH 178/187] Refactoring controller. --- .../composer/rest/ExperimentsController.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index a26e3a3..d5eb7c4 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -54,16 +54,19 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ VsBlueprint vsb = composeRequest.getVsbRequest().getVsBlueprint(); Nsd expNsd = composeRequest.getVsbRequest().getNsds().get(0); + List vsbTransRules = composeRequest.getVsbRequest() + .getTranslationRules(); expNsd.setNsdIdentifier(UUID.randomUUID().toString()); expNsd.setNsdInvariantId(UUID.randomUUID().toString()); expNsd.setDesigner(expNsd.getDesigner() + " + NSD Composer"); + Context[] contexts = composeRequest.getContexts(); + try { // Assumptions: // - The Vsb has only 1 Nsd. - NsVirtualLinkDesc ranVld = findRanVld(composeRequest.getVsbRequest().getVsBlueprint(), - expNsd); - for (Context ctx : composeRequest.getContexts()) { + NsVirtualLinkDesc ranVld = findRanVld(vsb, expNsd); + for (Context ctx : contexts) { // - The Ctx has only 1 Nsd. CtxBlueprint ctxB = ctx.getCtxbRequest().getCtxBlueprint(); Nsd ctxNsd = ctx.getCtxbRequest().getNsds().get(0); @@ -101,15 +104,14 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ throw new ResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e); } - List translationRules = null; + List expTransRules = null; try { - translationRules = translationRulesComposer - .compose(expNsd, composeRequest.getVsbRequest().getTranslationRules()); + expTransRules = translationRulesComposer.compose(expNsd, vsbTransRules); } catch (TransRuleInvalidException e) { // TODO create proper error response. e.printStackTrace(); } - return new ComposeResponse(expNsd, translationRules); + return new ComposeResponse(expNsd, expTransRules); } private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) From edb72a51d2c4c5600f85c60fa787c8defcac7ecc Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 11:53:24 +0200 Subject: [PATCH 179/187] Refactor. Add more tests to check error codes. --- .../rest/ExperimentsControllerTest.java | 89 ++++++++++++++++--- 1 file changed, 78 insertions(+), 11 deletions(-) diff --git a/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java index 838d07c..e84d1e8 100644 --- a/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java +++ b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java @@ -25,7 +25,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; -import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; @@ -46,9 +45,6 @@ public class ExperimentsControllerTest { private MockMvc mvc; - @Autowired - private ExperimentsController experimentsController; - @Before @SneakyThrows public void setup() { @@ -63,16 +59,13 @@ public void setup() { .build(); } - @Test @SneakyThrows - public void composeExperiment() { - // Given + private ComposeRequest getRequest() { VsBlueprint vsb = YAML_OM .readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker")), VsBlueprint.class); List vsbNsd = YAML_OM.readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_nsds")), new TypeReference>() { }); -// vsbNsd.get(0).getVirtualLinkDesc().get(0).setVirtualLinkDescId("pippo"); List vsbTr = YAML_OM .readValue(new URL(urlProp.getProperty("vsb_ares2t_tracker_tr")), new TypeReference>() { @@ -94,11 +87,21 @@ public void composeExperiment() { ComposeRequest request = new ComposeRequest(vsbRequest, new Context[]{c}); String body = JSON_OM.writeValueAsString(request); log.info("Request body:\n{}", body); + return request; + } + + @Test + @SneakyThrows + public void composeExperiment200() { + // Given + ComposeRequest request = getRequest(); // When - MvcResult result = mvc.perform(MockMvcRequestBuilders.post("/experiments").contentType( - MediaType.APPLICATION_JSON).content(body)).andReturn(); - MockHttpServletResponse resp = result.getResponse(); + MvcResult result = mvc.perform( + MockMvcRequestBuilders.post("/experiments") + .contentType(MediaType.APPLICATION_JSON) + .content(JSON_OM.writeValueAsString(request))) + .andReturn(); // Then assertEquals(200, result.getResponse().getStatus()); @@ -114,4 +117,68 @@ public void composeExperiment() { assertEquals(YAML_OM.writeValueAsString(expectedNsd), YAML_OM.writeValueAsString(response.getExpNsd())); } + + @Test + @SneakyThrows + public void composeExperiment400Wrong() { + // Given + ComposeRequest request = getRequest(); + + // When + // We pass only the VsbRequest as body to make the REST fail + MvcResult result = mvc.perform( + MockMvcRequestBuilders.post("/experiments") + .contentType(MediaType.APPLICATION_JSON) + .content(JSON_OM.writeValueAsString(request.getVsbRequest()))) + .andReturn(); + + // Then + assertEquals(400, result.getResponse().getStatus()); + if (result.getResolvedException() != null) { + log.info("Error message: {}", result.getResolvedException().getMessage()); + } + } + + @Test + @SneakyThrows + public void composeExperiment400Empty() { + // Given + + // When + // We pass only the VsbRequest as body to make the REST fail + MvcResult result = mvc.perform( + MockMvcRequestBuilders.post("/experiments") + .contentType(MediaType.APPLICATION_JSON) + .content("")) + .andReturn(); + + // Then + assertEquals(400, result.getResponse().getStatus()); + if (result.getResolvedException() != null) { + log.info("Error message: {}", result.getResolvedException().getMessage()); + } + } + + @Test + @SneakyThrows + public void composeExperiment422() { + // Given + ComposeRequest request = getRequest(); + + // When + // We change the request to make it unprocessable + request.getVsbRequest().getNsds().get(0).getVirtualLinkDesc().get(0) + .setVirtualLinkDescId("wrong-vld-id"); + MvcResult result = mvc.perform( + MockMvcRequestBuilders.post("/experiments") + .contentType(MediaType.APPLICATION_JSON) + .content(JSON_OM.writeValueAsString(request))) + .andReturn(); + + // Then + assertEquals(422, result.getResponse().getStatus()); + if (result.getResolvedException() != null) { + log.info("Error message: {}", result.getResolvedException().getMessage()); + } + } } \ No newline at end of file From dff29e4e4ccbbd36c3ae79fe8008e86816930f0f Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 11:55:52 +0200 Subject: [PATCH 180/187] Remove get mapping as not used. --- .../cnit/blueprint/composer/rest/ExperimentsController.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index d5eb7c4..e73f583 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -44,11 +44,6 @@ public class ExperimentsController { private final TranslationRulesComposer translationRulesComposer; - @GetMapping("/experiments") - public OnboardExpBlueprintRequest retrieveExperiment() { - return null; - } - @PostMapping("/experiments") public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequest) { From 5815de1224ef1348b57ef3a3a59532c709bd55b6 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 12:09:52 +0200 Subject: [PATCH 181/187] Add specific exception for composition errors. --- .../composer/exceptions/NsdCompositionException.java | 12 ++++++++++++ .../blueprint/composer/nsd/compose/NsdComposer.java | 7 ++++--- .../composer/rest/ExperimentsController.java | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/NsdCompositionException.java diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/NsdCompositionException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/NsdCompositionException.java new file mode 100644 index 0000000..3df1687 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/NsdCompositionException.java @@ -0,0 +1,12 @@ +package it.cnit.blueprint.composer.exceptions; + +public class NsdCompositionException extends DescriptorInvalidException { + + public NsdCompositionException(String descId, String message) { + super(descId, message); + } + + public NsdCompositionException(String descId, String message, Throwable cause) { + super(descId, message, cause); + } +} diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java index 3bb7278..d799457 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.cnit.blueprint.composer.exceptions.NsdCompositionException; import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; @@ -196,7 +197,7 @@ public NsVirtualLinkDesc getRanVlDesc(Sapd ranSapd, Nsd expNsd) throws NsdInvali @SneakyThrows(JsonProcessingException.class) public void compose(Map connectInput, NsVirtualLinkDesc ranVld, NsVirtualLinkDesc expMgmtVld, Nsd expNsd, NsVirtualLinkDesc ctxMgmtVld, Nsd ctxNsd) - throws NsdInvalidException { + throws NsdInvalidException, NsdCompositionException { // We assume only one NsDf for the context NsDf ctxNsDf = ctxNsd.getNsDf().get(0); // We assume only one NsLevel for the context @@ -259,14 +260,14 @@ public void compose(Map connectInput, NsVirtualLinkDesc ranVld, try { expNsd.isValid(); } catch (MalformattedElementException e) { - throw new NsdInvalidException(expNsd.getNsdIdentifier(), + throw new NsdCompositionException(expNsd.getNsdIdentifier(), "Nsd not valid after composition", e); } expG = nsdGraphService.buildGraph(expNsd.getSapd(), expNsDf, expNsLvl); log.debug("Graph AFTER composition with {}:\n{}", ctxNsd.getNsdIdentifier(), nsdGraphService.export(expG)); if (!nsdGraphService.isConnected(expG)) { - throw new NsdInvalidException(expNsd.getNsdIdentifier(), + throw new NsdCompositionException(expNsd.getNsdIdentifier(), "Network topology not connected for NsDf " + expNsDf.getNsDfId() + " and NsLevel " + expNsLvl.getNsLevelId()); } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index e73f583..fa9a77b 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -1,6 +1,7 @@ package it.cnit.blueprint.composer.rest; import it.cnit.blueprint.composer.exceptions.ContextInvalidException; +import it.cnit.blueprint.composer.exceptions.NsdCompositionException; import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.cnit.blueprint.composer.exceptions.TransRuleInvalidException; import it.cnit.blueprint.composer.exceptions.VsbInvalidException; @@ -97,6 +98,8 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ } } catch (VsbInvalidException | NsdInvalidException | ContextInvalidException e) { throw new ResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e); + } catch (NsdCompositionException e){ + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage(), e); } List expTransRules = null; From d70d6e27fb3c1cb81cd50442c776931db93fe030 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 12:24:23 +0200 Subject: [PATCH 182/187] Add exception for translation rules composition. Do not throw error on translation rules but return an empty list. --- .../TransRuleCompositionException.java | 8 +++++++ .../composer/rest/ExperimentsController.java | 8 ++++--- .../rules/TranslationRulesComposer.java | 22 ++++++++++++++++--- 3 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/TransRuleCompositionException.java diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/TransRuleCompositionException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/TransRuleCompositionException.java new file mode 100644 index 0000000..d9e8ff3 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/TransRuleCompositionException.java @@ -0,0 +1,8 @@ +package it.cnit.blueprint.composer.exceptions; + +public class TransRuleCompositionException extends Exception { + + public TransRuleCompositionException(String message) { + super(message); + } +} diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java index fa9a77b..036e72c 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -3,6 +3,7 @@ import it.cnit.blueprint.composer.exceptions.ContextInvalidException; import it.cnit.blueprint.composer.exceptions.NsdCompositionException; import it.cnit.blueprint.composer.exceptions.NsdInvalidException; +import it.cnit.blueprint.composer.exceptions.TransRuleCompositionException; import it.cnit.blueprint.composer.exceptions.TransRuleInvalidException; import it.cnit.blueprint.composer.exceptions.VsbInvalidException; import it.cnit.blueprint.composer.nsd.compose.NsdComposer; @@ -18,6 +19,7 @@ import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsVirtualLinkDesc; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Sapd; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Optional; @@ -105,9 +107,9 @@ public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequ List expTransRules = null; try { expTransRules = translationRulesComposer.compose(expNsd, vsbTransRules); - } catch (TransRuleInvalidException e) { - // TODO create proper error response. - e.printStackTrace(); + } catch (TransRuleInvalidException | TransRuleCompositionException e) { + log.warn("{}. Return empty translation rules.", e.getMessage()); + expTransRules = new ArrayList<>(); } return new ComposeResponse(expNsd, expTransRules); } diff --git a/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java index 230ae13..554697a 100644 --- a/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java +++ b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java @@ -1,7 +1,9 @@ package it.cnit.blueprint.composer.rules; +import it.cnit.blueprint.composer.exceptions.TransRuleCompositionException; import it.cnit.blueprint.composer.exceptions.TransRuleInvalidException; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsdNsdTranslationRule; +import it.nextworks.nfvmano.libs.ifa.common.exceptions.MalformattedElementException; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.NsDf; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import java.util.ArrayList; @@ -18,10 +20,16 @@ public class TranslationRulesComposer { public List compose(Nsd expNsd, - List translationRules) throws TransRuleInvalidException { + List translationRules) + throws TransRuleInvalidException, TransRuleCompositionException { log.info("Compose and check translation rules for expNsd: '{}'", expNsd.getNsdIdentifier()); List newTranslationRules = new ArrayList<>(); for (VsdNsdTranslationRule tr : translationRules) { + try { + tr.isValid(); + } catch (MalformattedElementException e) { + throw new TransRuleInvalidException("Invalid translation rule " + tr.toString()); + } Optional optNsDf = expNsd.getNsDf().stream() .filter(nsDf -> nsDf.getNsDfId().equals(tr.getNsFlavourId())).findFirst(); if (optNsDf.isPresent()) { @@ -39,8 +47,16 @@ public List compose(Nsd expNsd, log.error(m); throw new TransRuleInvalidException(m); } - newTranslationRules.add(new VsdNsdTranslationRule(tr.getInput(), expNsd.getNsdIdentifier(), - expNsd.getVersion(), tr.getNsFlavourId(), tr.getNsInstantiationLevelId())); + VsdNsdTranslationRule newTr = new VsdNsdTranslationRule(tr.getInput(), + expNsd.getNsdIdentifier(), expNsd.getVersion(), tr.getNsFlavourId(), + tr.getNsInstantiationLevelId()); + try { + newTr.isValid(); + } catch (MalformattedElementException e) { + throw new TransRuleCompositionException( + "Invalid translation rule after composition " + newTr.toString()); + } + newTranslationRules.add(newTr); } return newTranslationRules; } From 177d9a2f751c2cc621e507db745b1ddf1e1c5edd Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 12:31:03 +0200 Subject: [PATCH 183/187] Add NsdGenerationException. Review ServicesControlle. --- .../exceptions/NsdGenerationException.java | 12 ++++++++++++ .../composer/nsd/generate/NsdGenerator.java | 13 +++++++++---- .../composer/rest/ServicesController.java | 16 +++++++--------- 3 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 src/main/java/it/cnit/blueprint/composer/exceptions/NsdGenerationException.java diff --git a/src/main/java/it/cnit/blueprint/composer/exceptions/NsdGenerationException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/NsdGenerationException.java new file mode 100644 index 0000000..c655cb2 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/NsdGenerationException.java @@ -0,0 +1,12 @@ +package it.cnit.blueprint.composer.exceptions; + +public class NsdGenerationException extends DescriptorInvalidException { + + public NsdGenerationException(String descId, String message) { + super(descId, message); + } + + public NsdGenerationException(String descId, String message, Throwable cause) { + super(descId, message, cause); + } +} diff --git a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java index 540e5ba..16f72b2 100644 --- a/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.cnit.blueprint.composer.exceptions.NsdGenerationException; import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; import it.cnit.blueprint.composer.nsd.graph.ProfileVertex; @@ -55,7 +56,7 @@ public class NsdGenerator { private final NsdGraphService nsdGraphService; @SneakyThrows(JsonProcessingException.class) - public Nsd generate(Blueprint blueprint) throws NsdInvalidException { + public Nsd generate(Blueprint blueprint) throws NsdInvalidException, NsdGenerationException { log.debug("blueprint {}:\n{}", blueprint.getBlueprintId(), OBJECT_MAPPER.writeValueAsString(blueprint)); @@ -178,13 +179,17 @@ public Nsd generate(Blueprint blueprint) throws NsdInvalidException { try { nsd.isValid(); } catch (MalformattedElementException e) { - throw new NsdInvalidException(nsd.getNsdIdentifier(), - "Nsd looks not valid after generation", e); + throw new NsdGenerationException(nsd.getNsdIdentifier(), + "Nsd not valid after generation", e); } - Graph g = nsdGraphService.buildGraph(nsd.getSapd(), nsDf, nsLevel); log.debug("Graph AFTER generation with {}:\n{}", nsd.getNsdIdentifier(), nsdGraphService.export(g)); + if (!nsdGraphService.isConnected(g)) { + throw new NsdGenerationException(nsd.getNsdIdentifier(), + "Network topology not connected for NsDf " + nsDf.getNsDfId() + " and NsLevel " + + nsLevel.getNsLevelId()); + } return nsd; } diff --git a/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java index c6848fb..7a77bb4 100644 --- a/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java +++ b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java @@ -1,25 +1,23 @@ package it.cnit.blueprint.composer.rest; +import it.cnit.blueprint.composer.exceptions.NsdGenerationException; import it.cnit.blueprint.composer.exceptions.NsdInvalidException; import it.cnit.blueprint.composer.nsd.generate.NsdGenerator; import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; import lombok.AllArgsConstructor; +import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; @RestController @AllArgsConstructor public class ServicesController { - private NsdGenerator nsdGenerator; - - @GetMapping("/services") - public Nsd retrieveService() { - return null; - } + private final NsdGenerator nsdGenerator; @PostMapping("/services") public Nsd generateService(@RequestBody VsBlueprint vsb) { @@ -27,9 +25,9 @@ public Nsd generateService(@RequestBody VsBlueprint vsb) { try { nsd = nsdGenerator.generate(vsb); } catch (NsdInvalidException e) { - //TODO handle exception - nsd = null; - e.printStackTrace(); + throw new ResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e); + } catch (NsdGenerationException e) { + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage(), e); } return nsd; } From 39b4d9f3f267a0a6d2db604baa5a0bb89b99a8a6 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 12:43:00 +0200 Subject: [PATCH 184/187] Add tests for Services controller. --- .../composer/rest/ServicesControllerTest.java | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 src/test/java/it/cnit/blueprint/composer/rest/ServicesControllerTest.java diff --git a/src/test/java/it/cnit/blueprint/composer/rest/ServicesControllerTest.java b/src/test/java/it/cnit/blueprint/composer/rest/ServicesControllerTest.java new file mode 100644 index 0000000..0baabff --- /dev/null +++ b/src/test/java/it/cnit/blueprint/composer/rest/ServicesControllerTest.java @@ -0,0 +1,119 @@ +package it.cnit.blueprint.composer.rest; + +import static org.junit.Assert.assertEquals; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; +import java.io.InputStream; +import java.net.URL; +import java.util.Properties; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest +@Slf4j +public class ServicesControllerTest { + + private ObjectMapper JSON_OM, YAML_OM; + static Properties urlProp; + + @Autowired + WebApplicationContext webApplicationContext; + + private MockMvc mvc; + + @Before + @SneakyThrows + public void setup() { + // Test Setup + urlProp = new Properties(); + InputStream input = ClassLoader.getSystemResourceAsStream("url.properties"); + urlProp.load(input); + JSON_OM = new ObjectMapper(new JsonFactory()).enable(SerializationFeature.INDENT_OUTPUT); + YAML_OM = new ObjectMapper(new YAMLFactory()); + mvc = MockMvcBuilders + .webAppContextSetup(webApplicationContext) + .build(); + } + + @Test + @SneakyThrows + public void generateService200() { + // Given + VsBlueprint vsb = YAML_OM + .readValue(new URL(urlProp.getProperty("vsb_polito_smartcity")), VsBlueprint.class); + + // When + MvcResult result = mvc.perform( + MockMvcRequestBuilders.post("/services") + .contentType(MediaType.APPLICATION_JSON) + .content(JSON_OM.writeValueAsString(vsb))) + .andReturn(); + + // Then + assertEquals(200, result.getResponse().getStatus()); + Nsd actualNsd = JSON_OM.readValue(result.getResponse().getContentAsString(), Nsd.class); + Nsd expectedNsd = YAML_OM + .readValue(new URL(urlProp.getProperty("vsb_polito_smartcity_nsds")), Nsd[].class)[0]; + assertEquals(YAML_OM.writeValueAsString(expectedNsd), YAML_OM.writeValueAsString(actualNsd)); + } + + @Test + @SneakyThrows + public void composeExperiment400Wrong() { + // Given + VsBlueprint vsb = YAML_OM + .readValue(new URL(urlProp.getProperty("vsb_polito_smartcity")), VsBlueprint.class); + + // When + // We pass only the VsbRequest as body to make the REST fail + MvcResult result = mvc.perform( + MockMvcRequestBuilders.post("/services") + .contentType(MediaType.APPLICATION_JSON) + .content(JSON_OM.writeValueAsString(vsb.getCompatibleSites()))) + .andReturn(); + + // Then + assertEquals(400, result.getResponse().getStatus()); + if (result.getResolvedException() != null) { + log.info("Error message: {}", result.getResolvedException().getMessage()); + } + } + + @Test + @SneakyThrows + public void composeExperiment400Empty() { + // Given + + // When + // We pass only the VsbRequest as body to make the REST fail + MvcResult result = mvc.perform( + MockMvcRequestBuilders.post("/services") + .contentType(MediaType.APPLICATION_JSON) + .content("")) + .andReturn(); + + // Then + assertEquals(400, result.getResponse().getStatus()); + if (result.getResolvedException() != null) { + log.info("Error message: {}", result.getResolvedException().getMessage()); + } + } +} \ No newline at end of file From 9ab3bf8d05a829219e65b040b44d0cc5ab83354b Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 12:58:19 +0200 Subject: [PATCH 185/187] Ignore VSbGraphTest. --- src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java b/src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java index 9572c6a..115a385 100644 --- a/src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java +++ b/src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java @@ -9,6 +9,7 @@ import java.net.URL; import lombok.extern.slf4j.Slf4j; import org.jgrapht.io.ExportException; +import org.junit.Ignore; import org.junit.Test; @Slf4j @@ -16,6 +17,7 @@ public class VsbGraphTest { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory()); + @Ignore @Test public void Ares2tTrackerTestYAML() throws IOException, MalformattedElementException, ExportException { From a3a54d0994a336318c34f86f9c426dd5171220e4 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 13:00:55 +0200 Subject: [PATCH 186/187] Test Dockerfile and fix README.md. --- Dockerfile | 1 - README.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 610075d..7692150 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ FROM azul/zulu-openjdk-alpine:8-jre -# TODO check COPY ./target/*.jar /app.jar CMD java -jar app.jar diff --git a/README.md b/README.md index 5f5f1ce..8a2a30d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A REST API module to compose the NSD of a VSB and multiple CBs. ## Install -Some dependencies are not available in Maven repository. Check [pom.xml]. +Some dependencies are not available in Maven repository. Check `pom.xml`. Compile the project with: From fb74e27c51e3cde0bfaa3c22390f12ebc4fb2088 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 12 May 2020 13:01:44 +0200 Subject: [PATCH 187/187] Update version to 0.0.2 for release. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fa0a886..9123d63 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ it.cnit.blueprint composer - 0.0.2-SNAPSHOT + 0.0.2 A REST API module to compose NSDs.