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/Dockerfile b/Dockerfile index a4412d7..7692150 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,42 +1,3 @@ -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 azul/zulu-openjdk-alpine:8-jre +COPY ./target/*.jar /app.jar +CMD java -jar app.jar diff --git a/README.md b/README.md index 75dd634..8a2a30d 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,27 @@ -# 5geve-experiment-builder -A REST API module to compose VSB and CBs. -The project is designed to be deployed with Docker. -Check the pom.xml for details about plugins to ease docker image build. +# 5G EVE Experiment NSD composer +A REST API module to compose the NSD of a VSB and multiple CBs. -## 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= -``` 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 diff --git a/pom.xml b/pom.xml index 4de45ef..9123d63 100644 --- a/pom.xml +++ b/pom.xml @@ -11,17 +11,14 @@ it.cnit.blueprint - expbuilder - 0.0.1 - A REST API module to compose VSD and CDs. - https://github.com/TheWall89/5geve-experiment-builder - docker-build + composer + 0.0.2 + A REST API module to compose NSDs. UTF-8 8 8 - mpergolesi 1.3.0 @@ -129,88 +126,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 - - - - - - - @@ -273,29 +190,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 - - - diff --git a/src/main/java/it/cnit/blueprint/composer/App.java b/src/main/java/it/cnit/blueprint/composer/App.java new file mode 100644 index 0000000..50fe9b4 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/App.java @@ -0,0 +1,17 @@ +package it.cnit.blueprint.composer; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; + +@SpringBootApplication +@EntityScan(basePackages = {"it.nextworks.nfvmano.libs.ifa", "it.cnit.blueprint.composer"}) +@Slf4j +public class App { + + public static void main(String[] args) { + SpringApplication.run(App.class, args); + } + +} 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/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()); + } +} 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/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/exceptions/NsdInvalidException.java b/src/main/java/it/cnit/blueprint/composer/exceptions/NsdInvalidException.java new file mode 100644 index 0000000..8506487 --- /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 DescriptorInvalidException { + + public NsdInvalidException(String descId, String message) { + super(descId, message); + } + + public NsdInvalidException(String descId, String message, Throwable cause) { + super(descId, message, cause); + } +} 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/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..cfb116a --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/exceptions/VsbInvalidException.java @@ -0,0 +1,12 @@ +package it.cnit.blueprint.composer.exceptions; + +public class VsbInvalidException extends DescriptorInvalidException { + + 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/nsd/compose/ConnectComposer.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java new file mode 100644 index 0000000..a3e7552 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/ConnectComposer.java @@ -0,0 +1,153 @@ +package it.cnit.blueprint.composer.nsd.compose; + +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; +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 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; +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); + } + + 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, + 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(), vnfInfo.getDataVlcList().get(0).getCpdId().get(0), + dataVlInfo.getVlProfile()); + log.debug( + "Created connection between vnfProfile {} and vlProfile {}", + vnfInfo.getVnfProfile().getVnfProfileId(), + dataVlInfo.getVlProfile().getVirtualLinkProfileId()); + for (int i = 1; i < vnfInfo.getDataVlcList().size(); i++) { + vnfInfo.cleanUpVlc(vnfInfo.getDataVlcList().get(i)); + } + 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()); + } + } + + @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 NsdInvalidException { + log.info("Compose with CONNECT."); + List mgmtVlProfileIds = Arrays.asList( + ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), + expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); + 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); + } catch (NotExistingEntityException e) { + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), + "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 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(expNsd.getNsdIdentifier(), + "Error connecting VNF profile " + vnfInfo.getVnfProfile().getVnfProfileId(), e); + } + } + } else { + // only VNFs in connectInput + for (Entry entry : connectInput.entrySet()) { + VnfInfo vnfInfo; + try { + String vnfpId = getVnfProfileByDescId(entry.getKey(), ctxNsDf).getVnfProfileId(); + vnfInfo = retrieveVnfInfoByProfileId(vnfpId, ctxNsd, ctxNsDf, ctxNsLvl); + vnfInfo.setVlcLists(mgmtVlProfileIds); + } catch (NotExistingEntityException e) { + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), + "Error retrieving VNF info for VNFD ID " + entry.getKey(), e); + } + VlInfo vlInfo; + try { + String vlpId = getVlProfileByDescId(entry.getValue(), ctxNsDf).getVirtualLinkProfileId(); + vlInfo = retrieveVlInfoByProfileId(vlpId, ctxNsd, ctxNsDf, ctxNsLvl); + } catch (NotExistingEntityException e) { + 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(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 new file mode 100644 index 0000000..d799457 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/NsdComposer.java @@ -0,0 +1,292 @@ +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.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; +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; +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.VirtualLinkToLevelMapping; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; +import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.jgrapht.Graph; + +@Slf4j +@AllArgsConstructor +public abstract class NsdComposer { + + protected static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(new YAMLFactory()); + + protected NsdGraphService nsdGraphService; + + protected VnfProfile getVnfProfileById(String vnfProfileId, NsDf nsDf) + throws NotExistingEntityException { + for (VnfProfile vp : nsDf.getVnfProfile()) { + if (vp.getVnfProfileId().equals(vnfProfileId)) { + return vp; + } + } + throw new NotExistingEntityException("VNF profile not found for ID " + vnfProfileId); + } + + 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 not found for VNFD ID " + vnfdId); + } + + protected VirtualLinkProfile getVlProfileById(String vlProfileId, NsDf nsDf) + throws NotExistingEntityException { + for (VirtualLinkProfile vp : nsDf.getVirtualLinkProfile()) { + if (vp.getVirtualLinkProfileId().equals(vlProfileId)) { + return vp; + } + } + throw new NotExistingEntityException("VL profile not found for ID " + vlProfileId); + } + + 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 not found for VLD ID " + vldId); + } + + protected VnfToLevelMapping getVnfLvlMapping(String vnfProfileId, NsLevel nsLvl) + throws NotExistingEntityException { + for (VnfToLevelMapping m : nsLvl.getVnfToLevelMapping()) { + if (m.getVnfProfileId().equals(vnfProfileId)) { + return m; + } + } + throw new NotExistingEntityException("Mapping not found for VNF profile ID " + vnfProfileId); + } + + protected VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel nsLvl) + throws NotExistingEntityException { + for (VirtualLinkToLevelMapping m : nsLvl.getVirtualLinkToLevelMapping()) { + if (m.getVirtualLinkProfileId().equals(vlProfileId)) { + return m; + } + } + 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()) { + if (v.getVirtualLinkDescId().equals(vldId)) { + return v; + } + } + throw new NotExistingEntityException("Descriptor not found for VLD ID " + vldId); + } + + protected VnfInfo retrieveVnfInfoByProfileId(String vnfProfileId, Nsd nsd, NsDf nsDf, + NsLevel nsLevel) + 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 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(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(vld, vlProfile, vlMap); + } + + protected void addVnf(VnfInfo vnfInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { + String vnfdId = vnfInfo.getVnfdId(); + if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { + nsd.getVnfdId().add(vnfdId); + } + VnfProfile vnfp = vnfInfo.getVnfProfile(); + if (nsDf.getVnfProfile().stream() + .noneMatch(vp -> vp.getVnfProfileId().equals(vnfp.getVnfProfileId()))) { + nsDf.getVnfProfile().add(vnfp); + } + VnfToLevelMapping vnfMap = vnfInfo.getVnfToLevelMapping(); + if (nsLevel.getVnfToLevelMapping().stream() + .noneMatch(lm -> lm.getVnfProfileId().equals(vnfp.getVnfProfileId()))) { + nsLevel.getVnfToLevelMapping().add(vnfMap); + } + } + + protected void addVirtualLink(VlInfo vlInfo, Nsd nsd, NsDf nsDf, NsLevel nsLevel) { + NsVirtualLinkDesc vld = vlInfo.getVlDescriptor(); + if (nsd.getVirtualLinkDesc().stream() + .noneMatch(nsdVld -> nsdVld.getVirtualLinkDescId().equals(vld.getVirtualLinkDescId()))) { + nsd.getVirtualLinkDesc().add(vld); + } + 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(lm -> lm.getVirtualLinkProfileId().equals(vlMap.getVirtualLinkProfileId()))) { + nsLevel.getVirtualLinkToLevelMapping().add(vlMap); + } + } + + protected void connectVnfToVL(VnfProfile vnfp, String cpdId, VirtualLinkProfile vlp) + throws NotExistingEntityException { + 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 NsdInvalidException { + try { + return getVlDescriptor(ranSapd.getNsVirtualLinkDescId(), expNsd); + } catch (NotExistingEntityException e) { + log.error(e.getMessage()); + throw new NsdInvalidException(expNsd.getNsdIdentifier(), + "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 NsdInvalidException, NsdCompositionException { + // 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); + Graph ctxG = nsdGraphService + .buildGraph(ctxNsd.getSapd(), ctxNsDf, ctxNsLvl); + log.debug("ctxG graph:\n{}", nsdGraphService.export(ctxG)); + + log.info("Composing {} with <{}, {}, {}>.", + expNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), + ctxNsLvl.getNsLevelId()); + log.debug("Nsd BEFORE composition:\n{}", OBJECT_MAPPER.writeValueAsString(expNsd)); + + expNsd.setNsdName(expNsd.getNsdName() + " + " + ctxNsd.getNsdName()); + 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)) { + throw new NsdInvalidException(expNsd.getNsdIdentifier(), + "Network topology not connected for NsDf " + expNsDf.getNsDfId() + " and NsLevel " + + expNsLvl.getNsLevelId()); + } + + VlInfo ranVlInfo; + try { + ranVlInfo = retrieveVlInfoByDesc(ranVld, expNsDf, expNsLvl); + log.debug("Found VlInfo for ranVld {} in expNsd.", ranVld.getVirtualLinkDescId()); + } catch (NotExistingEntityException e) { + throw new NsdInvalidException(expNsd.getNsdIdentifier(), + "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 NsdInvalidException(expNsd.getNsdIdentifier(), + "Error retrieving Experiment Management VL info for VLD " + ranVld + .getVirtualLinkDescId(), e); + } + VlInfo ctxMgmtVlInfo; + try { + ctxMgmtVlInfo = retrieveVlInfoByDesc(ctxMgmtVld, ctxNsDf, ctxNsLvl); + log.debug("Found VlInfo for ctxMgmtVld {} in ctxNsd.", + ctxMgmtVld.getVirtualLinkDescId()); + } catch (NotExistingEntityException e) { + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), + "Error retrieving Context Management VL info for VLD " + ranVld, e); + } + composeWithStrategy(connectInput, ranVlInfo, expMgmtVlInfo, ctxMgmtVlInfo, + expNsd, expNsDf, expNsLvl, + ctxNsd, ctxNsDf, ctxNsLvl); + + // Nsd validation and logging + try { + expNsd.isValid(); + } catch (MalformattedElementException e) { + 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 NsdCompositionException(expNsd.getNsdIdentifier(), + "Network topology not connected for NsDf " + expNsDf.getNsDfId() + " and NsLevel " + + expNsLvl.getNsLevelId()); + } + 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 <{}, {}, {}>.", + expNsd.getNsdIdentifier(), ctxNsd.getNsdIdentifier(), ctxNsDf.getNsDfId(), + ctxNsLvl.getNsLevelId()); + } + + public abstract void composeWithStrategy( + Map connectInput, VlInfo ranVlInfo, VlInfo expMgmtVlInfo, + VlInfo ctxMgmtVlInfo, + Nsd expNsd, NsDf expNsDf, NsLevel expNsLvl, + Nsd ctxNsd, NsDf ctxNsDf, NsLevel ctxNsLvl + ) 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 new file mode 100644 index 0000000..0364428 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/PassThroughComposer.java @@ -0,0 +1,137 @@ +package it.cnit.blueprint.composer.nsd.compose; + +import it.cnit.blueprint.composer.nsd.graph.NsdGraphService; +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; +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.VnfProfile; +import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +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 +@Qualifier("PASS_THROUGH") +public class PassThroughComposer extends NsdComposer { + + public PassThroughComposer(NsdGraphService nsdGraphService) { + super(nsdGraphService); + } + + @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 NsdInvalidException { + log.info("Compose with PASS_THROUGH."); + List mgmtVlProfileIds = Arrays.asList( + ctxMgmtVlInfo.getVlProfile().getVirtualLinkProfileId(), + 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 { + ctxVnfInfo = retrieveVnfInfoByProfileId(ctxVnfpId, ctxNsd, ctxNsDf, ctxNsLvl); + log.debug("Found VnfInfo for vnfpId {} in context.", ctxVnfpId); + ctxVnfInfo.setVlcLists(mgmtVlProfileIds); + } catch (NotExistingEntityException e) { + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), + "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(), + ctxNsd, ctxNsDf, ctxNsLvl); + } catch (NotExistingEntityException e) { + throw new NsdInvalidException(ctxNsd.getNsdIdentifier(), + "Error retrieving VL info for a non-management VL", e); + } + + // 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 : expNsLvl.getVnfToLevelMapping()) { + VnfProfile vnfProfile; + try { + vnfProfile = getVnfProfileById(vnfLvl.getVnfProfileId(), expNsDf); + } catch (NotExistingEntityException e) { + throw new NsdInvalidException(expNsd.getNsdIdentifier(), + "Error retrieving VNF info for VNF profile ID " + vnfLvl.getVnfProfileId(), e); + } + for (NsVirtualLinkConnectivity vlc : vnfProfile.getNsVirtualLinkConnectivity()) { + if (vlc.getVirtualLinkProfileId() + .equals(ranVlInfo.getVlProfile().getVirtualLinkProfileId())) { + ranVnfCpd = vlc.getCpdId().get(0); + ranVnfProfile = vnfProfile; + break; + } + } + } + if (ranVnfCpd == null) { + throw new NsdInvalidException(expNsd.getNsdIdentifier(), + "Can't find a VNF close to ranVlInfo in nsLevel " + expNsLvl.getNsLevelId()); + } + 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).", + ctxVnfInfo.getVnfProfile().getVnfProfileId()); + addVirtualLink(ctxNonMgmtVl, expNsd, expNsDf, expNsLvl); + 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 {}", + 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 {}", + ctxVnfInfo.getVnfProfile().getVnfProfileId(), + ranVlInfo.getVlProfile().getVirtualLinkProfileId()); + // Connect ctxVnf to expNsd mgmt VL + 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(), + expMgmtVlInfo.getVlProfile().getVirtualLinkProfileId()); + } else { + log.warn("Could not find a management Cp for ctxVnf. Skip."); + } + // Cleanup unused cpds of ctxVnf (if any) + for (int i = 2; i < ctxVnfInfo.getDataVlcList().size(); i++) { + ctxVnfInfo.cleanUpVlc(ctxVnfInfo.getDataVlcList().get(i)); + } + } catch (NotExistingEntityException e) { + throw new NsdInvalidException(expNsd.getNsdIdentifier(), "Error in connecting VNF to VL.", e); + } + } +} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlWrapper.java b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VlInfo.java similarity index 85% rename from src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlWrapper.java rename to src/main/java/it/cnit/blueprint/composer/nsd/compose/VlInfo.java index cbfeac2..ce55914 100644 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlWrapper.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; @@ -8,9 +8,9 @@ @Data @AllArgsConstructor -public class VlWrapper { +public class VlInfo { - private VirtualLinkToLevelMapping vlToLevelMapping; - private VirtualLinkProfile vlProfile; private NsVirtualLinkDesc vlDescriptor; + private VirtualLinkProfile vlProfile; + private VirtualLinkToLevelMapping vlToLevelMapping; } 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 new file mode 100644 index 0000000..34cb5d7 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/nsd/compose/VnfInfo.java @@ -0,0 +1,41 @@ +package it.cnit.blueprint.composer.nsd.compose; + +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; +import java.util.ArrayList; +import java.util.List; +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Data +@RequiredArgsConstructor +public class VnfInfo { + + private final String vnfdId; + private final VnfProfile vnfProfile; + private final VnfToLevelMapping vnfToLevelMapping; + private List mgmtVlcList; + private List dataVlcList; + + public void setVlcLists(List mgmtVlProfileIds) throws NotExistingEntityException { + mgmtVlcList = new ArrayList<>(); + dataVlcList = new ArrayList<>(); + for (NsVirtualLinkConnectivity vlc : vnfProfile.getNsVirtualLinkConnectivity()) { + if (mgmtVlProfileIds.contains(vlc.getVirtualLinkProfileId())) { + mgmtVlcList.add(vlc); + } else { + dataVlcList.add(vlc); + } + } + if (dataVlcList.isEmpty()) { + throw new NotExistingEntityException( + "No data cpd found for vnfProfile: " + vnfProfile.getVnfProfileId()); + } + } + + public void cleanUpVlc(NsVirtualLinkConnectivity vlcToRemove) { + vnfProfile.getNsVirtualLinkConnectivity().remove(vlcToRemove); + } +} 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..16f72b2 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/nsd/generate/NsdGenerator.java @@ -0,0 +1,197 @@ +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.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; +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; +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; +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.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; +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; +import org.springframework.web.context.WebApplicationContext; + +@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 final NsdGraphService nsdGraphService; + + @SneakyThrows(JsonProcessingException.class) + public Nsd generate(Blueprint blueprint) throws NsdInvalidException, NsdGenerationException { + + log.debug("blueprint {}:\n{}", blueprint.getBlueprintId(), + OBJECT_MAPPER.writeValueAsString(blueprint)); + + Nsd nsd = new Nsd(); + nsd.setNsdIdentifier(blueprint.getBlueprintId() + "_nsd"); + nsd.setDesigner("NSD generator"); + nsd.setNsdInvariantId(blueprint.getBlueprintId() + "_nsd"); + nsd.setVersion(blueprint.getVersion()); + nsd.setNsdName(blueprint.getName() + " NSD"); + nsd.setSecurity(new SecurityParameters( + "FC_NSD_SIGNATURE", + "FC_NSD_ALGORITHM", + "FC_NSD_CERTIFICATE" + )); + + NsDf nsDf = new NsDf(); + nsDf.setNsDfId(blueprint.getBlueprintId() + "_df"); + nsDf.setFlavourKey(blueprint.getBlueprintId() + "_df_fk"); + + NsLevel nsLevel = new NsLevel(); + nsLevel.setNsLevelId(blueprint.getBlueprintId() + "_il_default"); + nsLevel.setDescription("Default Instantiation Level"); + + for (VsbLink connService : blueprint.getConnectivityServices()) { + NsVirtualLinkDesc vld = new NsVirtualLinkDesc(); + vld.setVirtualLinkDescId(connService.getName()); + vld.setVirtualLinkDescProvider(nsd.getDesigner()); + vld.setVirtuaLinkDescVersion(nsd.getVersion()); + 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); + } + + List sapdList = new ArrayList<>(); + for (VsbEndpoint e : blueprint.getEndPoints()) { + if (e.isExternal() && e.getEndPointId().contains("sap")) { + Sapd sapd = new Sapd(); + sapd.setCpdId(e.getEndPointId()); + sapd.setLayerProtocol(LayerProtocol.IPV4); + sapd.setCpRole(CpRole.ROOT); + sapd.setSapAddressAssignment(false); + for (VsbLink cs : blueprint.getConnectivityServices()) { + for (String ep : cs.getEndPointIds()) { + if (ep.equals(sapd.getCpdId())) { + sapd.setNsVirtualLinkDescId(cs.getName()); + break; + } + } + } + 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 : blueprint.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 : blueprint.getConnectivityServices()) { + for (String csEp : cs.getEndPointIds()) { + if (csEp.equals(ep)) { + NsVirtualLinkConnectivity nsVLC = new NsVirtualLinkConnectivity(); + String vldId = cs.getName(); + 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); + } + } + } + } + } + vnfp.setNsVirtualLinkConnectivity(nsVirtualLinkConnectivities); + nsDf.getVnfProfile().add(vnfp); + nsLevel.getVnfToLevelMapping().add(new VnfToLevelMapping(vnfp.getVnfProfileId(), 1)); + } + + nsDf.setNsInstantiationLevel(Collections.singletonList(nsLevel)); + 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(); + } catch (MalformattedElementException 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/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 95% 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..680882b 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; @@ -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(); 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 76% 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 29e63fa..f1e192a 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.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; @@ -11,10 +11,12 @@ 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; 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; @@ -28,14 +30,14 @@ public class NsdGraphService { private GraphExporter graphExporter; public Graph buildGraph(List sapdList, NsDf nsDf, NsLevel nsLevel) - throws InvalidNsd { + throws NsdInvalidException { Graph g = new SimpleGraph<>(String.class); List vnfPVertices = new ArrayList<>(); List pnfPVertices = new ArrayList<>(); List vlPVertices = new ArrayList<>(); List sapVertices = new ArrayList<>(); - //vertices + // Vertices for (VnfToLevelMapping vnfToLevelMapping : nsLevel.getVnfToLevelMapping()) { VnfProfileVertex v; try { @@ -47,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 InvalidNsd(message); + throw new NsdInvalidException(nsDf.getNsDfId(), message); } // TODO handle the number of instances to build the graph vnfPVertices.add(v); @@ -69,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 InvalidNsd(message); + throw new NsdInvalidException(nsDf.getNsDfId(), message); } vlPVertices.add(v); g.addVertex(v); @@ -80,14 +82,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)); } } } @@ -98,7 +100,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)); } } } @@ -118,4 +120,22 @@ public String export(Graph graph) { return graphExporter.export(graph); } + public ProfileVertex getVertexById(Graph g, String vertexId) + 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."); + } + } + + public boolean isConnected(Graph g) { + ConnectivityInspector inspector = new ConnectivityInspector<>(g); + return inspector.isConnected(); + } + } 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/composer/nsd/graph/ProfileVertexNotFoundException.java b/src/main/java/it/cnit/blueprint/composer/nsd/graph/ProfileVertexNotFoundException.java new file mode 100644 index 0000000..b65856f --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/nsd/graph/ProfileVertexNotFoundException.java @@ -0,0 +1,8 @@ +package it.cnit.blueprint.composer.nsd.graph; + +public class ProfileVertexNotFoundException extends Exception { + + public ProfileVertexNotFoundException(String message) { + super(message); + } +} 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/composer/rest/ComposeRequest.java b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java new file mode 100644 index 0000000..93cca1c --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeRequest.java @@ -0,0 +1,20 @@ +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.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +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 new file mode 100644 index 0000000..e769bb6 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/ComposeResponse.java @@ -0,0 +1,21 @@ +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 javax.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@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 new file mode 100644 index 0000000..a92471f --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/Context.java @@ -0,0 +1,19 @@ +package it.cnit.blueprint.composer.rest; + +import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; +import java.util.Map; +import javax.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Context { + + @NotNull + private OnboardCtxBlueprintRequest ctxbRequest; + + 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 new file mode 100644 index 0000000..036e72c --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/ExperimentsController.java @@ -0,0 +1,160 @@ +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.TransRuleCompositionException; +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; +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; +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import lombok.AllArgsConstructor; +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 +@AllArgsConstructor +public class ExperimentsController { + + @Qualifier("PASS_THROUGH") + private final NsdComposer passThroughComposer; + @Qualifier("CONNECT") + private final NsdComposer connectComposer; + + private final TranslationRulesComposer translationRulesComposer; + + @PostMapping("/experiments") + public ComposeResponse composeExperiment(@RequestBody ComposeRequest composeRequest) { + + 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(vsb, expNsd); + for (Context ctx : contexts) { + // - The Ctx has only 1 Nsd. + 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(vsb, expNsd); + NsVirtualLinkDesc ctxMgmtVld = findMgmtVld(ctxB, ctxNsd); + if (ctxB.getCompositionStrategy().equals(CompositionStrategy.CONNECT)) { + log.info("Strategy is CONNECT"); + connectComposer + .compose(ctx.getConnectInput(), ranVld, expMgmtVld, expNsd, ctxMgmtVld, ctxNsd); + } 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 { + throw new ContextInvalidException("More than one VNFD ID found for PASS_THROUGH"); + } + passThroughComposer + .compose(ctx.getConnectInput(), ranVld, expMgmtVld, expNsd, ctxMgmtVld, ctxNsd); + } else { + String m = MessageFormatter.format("Composition strategy {} not supported.", + ctxB.getCompositionStrategy().name()) + .getMessage(); + log.error(m); + throw new ContextInvalidException(m); + } + + } + } 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; + try { + expTransRules = translationRulesComposer.compose(expNsd, vsbTransRules); + } catch (TransRuleInvalidException | TransRuleCompositionException e) { + log.warn("{}. Return empty translation rules.", e.getMessage()); + expTransRules = new ArrayList<>(); + } + return new ComposeResponse(expNsd, expTransRules); + } + + private NsVirtualLinkDesc findRanVld(Blueprint b, Nsd nsd) + throws NsdInvalidException, VsbInvalidException { + Optional ranEp = b.getEndPoints().stream() + .filter(e -> e.isRanConnection() && e.getEndPointId().contains("sap")) + .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 NsdInvalidException(nsd.getNsdIdentifier(), + "RAN Sap with ID " + epId + " not found"); + } + } else { + throw new VsbInvalidException(b.getBlueprintId(), + "No RAN endpoint found in VSB " + b.getBlueprintId() + "."); + } + } + + private NsVirtualLinkDesc findMgmtVld(Blueprint b, Nsd nsd) + throws VsbInvalidException, NsdInvalidException { + 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 NsdInvalidException(nsd.getNsdIdentifier(), + "Management Vld with id=" + name + "not found"); + } + } else { + throw new VsbInvalidException(b.getBlueprintId(), + "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 new file mode 100644 index 0000000..7a77bb4 --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rest/ServicesController.java @@ -0,0 +1,35 @@ +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 final NsdGenerator nsdGenerator; + + @PostMapping("/services") + public Nsd generateService(@RequestBody VsBlueprint vsb) { + Nsd nsd; + try { + nsd = nsdGenerator.generate(vsb); + } catch (NsdInvalidException e) { + throw new ResponseStatusException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e); + } catch (NsdGenerationException e) { + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage(), e); + } + return 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 new file mode 100644 index 0000000..554697a --- /dev/null +++ b/src/main/java/it/cnit/blueprint/composer/rules/TranslationRulesComposer.java @@ -0,0 +1,64 @@ +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; +import java.util.List; +import java.util.Optional; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.helpers.MessageFormatter; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +@AllArgsConstructor +public class TranslationRulesComposer { + + public List compose(Nsd expNsd, + 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()) { + 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 TransRuleInvalidException(m); + } + } else { + String m = MessageFormatter.format("Invalid translation rule. NsDf='{}' not found", + tr.getNsFlavourId()).getMessage(); + log.error(m); + throw new TransRuleInvalidException(m); + } + 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; + } + +} 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/main/java/it/cnit/blueprint/expbuilder/App.java b/src/main/java/it/cnit/blueprint/expbuilder/App.java deleted file mode 100644 index 9484402..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/App.java +++ /dev/null @@ -1,25 +0,0 @@ -package it.cnit.blueprint.expbuilder; - -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.expbuilder"}) -@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); - } - -} 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 deleted file mode 100644 index 5eb9f2e..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposer.java +++ /dev/null @@ -1,378 +0,0 @@ -package it.cnit.blueprint.expbuilder.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.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; -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 it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfProfile; -import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.VnfToLevelMapping; -import java.util.Optional; -import java.util.UUID; -import lombok.AllArgsConstructor; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.jgrapht.Graph; -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 { - - private NsdGraphService nsdGraphService; - - private VnfProfile getVnfProfile(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; - } - - private VirtualLinkProfile getVlProfile(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); - } - return vlProfile; - } - - private 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; - } - - private 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); - } - return vnfLvlMap; - } - - private 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; - - } - - private NsVirtualLinkDesc getVlDescriptor(String vlDescId, Nsd nsd) - 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); - } - return vlDesc; - } - - private VirtualLinkToLevelMapping getVlLvlMapping(String vlProfileId, NsLevel nsLvl) - 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); - } - return vlLvlMap; - } - - private void addVnf(Nsd nsd, NsDf nsDf, NsLevel nsLevel, VnfWrapper vnfWrapper) { - String vnfdId = vnfWrapper.getVfndId(); - if (nsd.getVnfdId().stream().noneMatch(id -> id.equals(vnfdId))) { - nsd.getVnfdId().add(vnfdId); - } - VnfProfile vnfProfile = vnfWrapper.getVnfProfile(); - if (nsDf.getVnfProfile().stream() - .noneMatch(vp -> vp.getVnfProfileId().equals(vnfProfile.getVnfProfileId()))) { - nsDf.getVnfProfile().add(vnfProfile); - } - VnfToLevelMapping vnfLvlMap = vnfWrapper.getVnfToLevelMapping(); - if (nsLevel.getVnfToLevelMapping().stream() - .noneMatch(lm -> lm.getVnfProfileId().equals(vnfProfile.getVnfProfileId()))) { - nsLevel.getVnfToLevelMapping().add(vnfLvlMap); - } - } - - private void addVirtualLink(Nsd nsd, NsDf nsDf, NsLevel nsLevel, VlWrapper vlWrapper) { - NsVirtualLinkDesc vlDesc = vlWrapper.getVlDescriptor(); - if (nsd.getVirtualLinkDesc().stream() - .noneMatch(nsdVld -> nsdVld.getVirtualLinkDescId().equals(vlDesc.getVirtualLinkDescId()))) { - nsd.getVirtualLinkDesc().add(vlDesc); - } - VirtualLinkProfile vlProfile = vlWrapper.getVlProfile(); - if (nsDf.getVirtualLinkProfile().stream().noneMatch( - nsdfVlP -> nsdfVlP.getVirtualLinkProfileId().equals(vlProfile.getVirtualLinkProfileId()))) { - nsDf.getVirtualLinkProfile().add(vlProfile); - } - VirtualLinkToLevelMapping vlMap = vlWrapper.getVlToLevelMapping(); - if (nsLevel.getVirtualLinkToLevelMapping().stream().noneMatch( - nslevelMap -> nslevelMap.getVirtualLinkProfileId() - .equals(vlMap.getVirtualLinkProfileId()))) { - nsLevel.getVirtualLinkToLevelMapping().add(vlMap); - } - } - - private VnfWrapper retrieveVnfInfo(String vnfProfileId, String cpdId, Nsd nsd, NsDf nsDf, - NsLevel nsLevel) throws InvalidNsd, InvalidCtxComposeInfo, VnfNotFoundInLvlMapping { - VnfToLevelMapping vnfLvlMap; - try { - vnfLvlMap = getVnfLvlMapping(vnfProfileId, nsLevel); - } catch (NotExistingEntityException e) { - throw new VnfNotFoundInLvlMapping(e.getMessage()); - } - VnfProfile vnfProfile; - try { - vnfProfile = getVnfProfile(vnfProfileId, nsDf); - } catch (NotExistingEntityException e) { - throw new InvalidNsd(e.getMessage()); - } - NsVirtualLinkConnectivity vlC; - try { - vlC = getVlConnectivity(cpdId, vnfProfile); - } catch (NotExistingEntityException e) { - throw new InvalidCtxComposeInfo(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); - } - - private VlWrapper retrieveVlInfo(String vlProfileId, Nsd nsd, NsDf nsDf, NsLevel nsLevel) - throws InvalidNsd, VlNotFoundInLvlMapping { - VirtualLinkToLevelMapping vlMap; - try { - vlMap = getVlLvlMapping(vlProfileId, nsLevel); - } catch (NotExistingEntityException e) { - throw new VlNotFoundInLvlMapping(e.getMessage()); - } - VirtualLinkProfile vlProfile; - try { - vlProfile = getVlProfile(vlProfileId, nsDf); - } catch (NotExistingEntityException e) { - throw new InvalidNsd(e.getMessage()); - } - NsVirtualLinkDesc vlDesc; - try { - vlDesc = getVlDescriptor(vlProfile.getVirtualLinkDescId(), nsd); - } catch (NotExistingEntityException e) { - throw new InvalidNsd(e.getMessage()); - } - return new VlWrapper(vlMap, vlProfile, vlDesc); - } - - @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 | InvalidCtxComposeInfo 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 | InvalidCtxComposeInfo 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()); - } - } - -} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlNotFoundInLvlMapping.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlNotFoundInLvlMapping.java deleted file mode 100644 index b82d590..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VlNotFoundInLvlMapping.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; - -public class VlNotFoundInLvlMapping extends Exception { - - public VlNotFoundInLvlMapping(String message) { - super(message); - } -} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfNotFoundInLvlMapping.java b/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfNotFoundInLvlMapping.java deleted file mode 100644 index cde36f0..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfNotFoundInLvlMapping.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; - -public class VnfNotFoundInLvlMapping extends Exception { - - public VnfNotFoundInLvlMapping(String message) { - super(message); - } -} 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 deleted file mode 100644 index 7f7462a..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/nsd/compose/VnfWrapper.java +++ /dev/null @@ -1,17 +0,0 @@ -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; -import lombok.Data; - -@Data -@AllArgsConstructor -public class VnfWrapper { - - private VnfToLevelMapping vnfToLevelMapping; - private VnfProfile vnfProfile; - private NsVirtualLinkConnectivity vlConnectivity; - private String vfndId; -} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java deleted file mode 100644 index 263f3f0..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/ComposeRequest.java +++ /dev/null @@ -1,12 +0,0 @@ -package it.cnit.blueprint.expbuilder.rest; - -import it.nextworks.nfvmano.catalogue.blueprint.messages.OnBoardVsBlueprintRequest; -import lombok.Data; - -@Data -public class ComposeRequest { - - public OnBoardVsBlueprintRequest vsbRequest; - public CtxComposeInfo[] contexts; - -} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/Controller.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/Controller.java deleted file mode 100644 index 55cab5e..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/Controller.java +++ /dev/null @@ -1,38 +0,0 @@ -package it.cnit.blueprint.expbuilder.rest; - -import it.cnit.blueprint.expbuilder.nsd.compose.NsdComposer; -import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardExpBlueprintRequest; -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 Controller { - - private final NsdComposer nsdComposer; - - @GetMapping("/experiment") - public OnboardExpBlueprintRequest retrieveExperiment() { - return null; - } - - @PostMapping("/experiment") - public OnboardExpBlueprintRequest composeExperiment(@RequestBody ComposeRequest composeRequest) { - try { - nsdComposer.compose(composeRequest.getVsbRequest().getNsds().get(0), - composeRequest.getContexts()); - } catch (InvalidCtxComposeInfo e) { - //TODO create and return a 422 response. - e.printStackTrace(); - } catch (InvalidNsd e) { - e.printStackTrace(); - //TODO create and return a 422 response. - } - //TODO - return new OnboardExpBlueprintRequest(); - } - -} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java deleted file mode 100644 index 6563ddf..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/CtxComposeInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package it.cnit.blueprint.expbuilder.rest; - -import it.nextworks.nfvmano.catalogue.blueprint.messages.OnboardCtxBlueprintRequest; -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class CtxComposeInfo { - - private OnboardCtxBlueprintRequest ctxBReq; - private VnfConnection[] ctxConnections; - private VnfConnection[] vsConnections; - -} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidCtxComposeInfo.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidCtxComposeInfo.java deleted file mode 100644 index cb670d9..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidCtxComposeInfo.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.expbuilder.rest; - -public class InvalidCtxComposeInfo extends Exception { - - public InvalidCtxComposeInfo(String message) { - super(message); - } -} diff --git a/src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidNsd.java b/src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidNsd.java deleted file mode 100644 index 6042caf..0000000 --- a/src/main/java/it/cnit/blueprint/expbuilder/rest/InvalidNsd.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.cnit.blueprint.expbuilder.rest; - -public class InvalidNsd extends Exception { - - public InvalidNsd(String message) { - super(message); - } -} 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; - -} 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 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c2eac03..cb94a86 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,6 @@ +server.port=8086 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 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 diff --git a/src/test/java/it/cnit/blueprint/expbuilder/VsbGraphTest.java b/src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java similarity index 90% rename from src/test/java/it/cnit/blueprint/expbuilder/VsbGraphTest.java rename to src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java index f9b783d..115a385 100644 --- a/src/test/java/it/cnit/blueprint/expbuilder/VsbGraphTest.java +++ b/src/test/java/it/cnit/blueprint/composer/VsbGraphTest.java @@ -1,14 +1,15 @@ -package it.cnit.blueprint.expbuilder; +package it.cnit.blueprint.composer; 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; 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 { 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 new file mode 100644 index 0000000..844bf80 --- /dev/null +++ b/src/test/java/it/cnit/blueprint/composer/nsd/compose/NsdComposerTest.java @@ -0,0 +1,273 @@ +package it.cnit.blueprint.composer.nsd.compose; + +import static org.junit.Assert.assertEquals; + +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.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.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.HashMap; +import java.util.Optional; +import java.util.Properties; +import lombok.SneakyThrows; +import org.junit.BeforeClass; +import org.junit.Test; + +public class NsdComposerTest { + + static Properties urlProp; + static ObjectMapper oM; + static NsdGraphService nsdGraphService; + static NsdComposer passThroughComposer; + static NsdComposer connectComposer; + + @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()); + passThroughComposer = new PassThroughComposer(nsdGraphService); + connectComposer = new ConnectComposer(nsdGraphService); + } + + @Test + @SneakyThrows + public void composeTrackerWithDelayPassThrough() { + + // Given + 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")) + .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_mgmt")).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); + NsVirtualLinkDesc ctxMgmtVld; + Optional optCtxVld = ctxNsd.getVirtualLinkDesc().stream() + .filter(v -> v.getVirtualLinkDescId().equals("vl_dg_mgmt")).findFirst(); + if (optCtxVld.isPresent()) { + ctxMgmtVld = optCtxVld.get(); + } else { + throw new Exception(); + } + + // When + passThroughComposer + .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"); + vsbNsd.setDesigner(vsbNsd.getDesigner() + " + NSD Composer"); + + // Then + 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)); + } + + @Test + @SneakyThrows + public void composeTrackerWithDelayConnect() { + + // Given + 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")) + .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_mgmt")).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_mgmt")).findFirst(); + if (optCtxVld.isPresent()) { + ctxMgmtVld = optCtxVld.get(); + } else { + throw new Exception(); + } + + // When + 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"); + vsbNsd.setDesigner(vsbNsd.getDesigner() + " + NSD Composer"); + + // Then + 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)); + } + + @Test + @SneakyThrows + public void composeTrackerWithBackgroundConnect() { + // Given + 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")) + .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_mgmt")).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("vl_bg_traffic_mgmt")).findFirst(); + if (optCtxVld.isPresent()) { + ctxMgmtVld = optCtxVld.get(); + } else { + throw new Exception(); + } + + // When + 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"); + vsbNsd.setDesigner(vsbNsd.getDesigner() + " + NSD Composer"); + + // Then + 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)); + + } + + @Test + @SneakyThrows + public void composeTrackerWithBackgroundAndDelay() { + + // Given + 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")) + .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_mgmt")).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_mgmt")).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("vl_bg_traffic_mgmt")).findFirst(); + if (optCtxVld.isPresent()) { + bgMgmtVld = optCtxVld.get(); + } else { + throw new Exception(); + } + + // When + passThroughComposer + .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"); + vsbNsd.setDesigner(vsbNsd.getDesigner() + " + NSD Composer"); + + // 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/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..9dd5a38 --- /dev/null +++ b/src/test/java/it/cnit/blueprint/composer/nsd/generate/NsdGeneratorTest.java @@ -0,0 +1,73 @@ +package it.cnit.blueprint.composer.nsd.generate; + +import static org.junit.Assert.assertEquals; + +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; +import java.net.URL; +import java.util.Properties; +import lombok.SneakyThrows; +import org.junit.BeforeClass; +import org.junit.Test; + + +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(nsdGraphService); + } + + + @Test + @SneakyThrows + public void generateVsbPolitoSmartCity() { + + // Given + VsBlueprint vsb = oM + .readValue(new URL(urlProp.getProperty("vsb_polito_smartcity")), VsBlueprint.class); + + //When + Nsd actualNsd = nsdGenerator.generate(vsb); + + //Then + Nsd expectedNsd = oM + .readValue(new URL(urlProp.getProperty("vsb_polito_smartcity_nsds")), Nsd[].class)[0]; + assertEquals(oM.writeValueAsString(expectedNsd), oM.writeValueAsString(actualNsd)); + } + + @Test + @SneakyThrows + public void generateBgTrafficCtxB() { + + // Given + CtxBlueprint ctxB = oM + .readValue(new URL(urlProp.getProperty("ctx_bg_traffic")), CtxBlueprint.class); + + //When + Nsd actualNsd = nsdGenerator.generate(ctxB); + + //Then + Nsd expectedNsd = oM + .readValue(new URL(urlProp.getProperty("ctx_bg_traffic_nsds")), Nsd[].class)[0]; + assertEquals(oM.writeValueAsString(expectedNsd), oM.writeValueAsString(actualNsd)); + } +} \ No newline at end of file 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 65% 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 39e4394..0e9b1fc 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,22 +1,26 @@ -package it.cnit.blueprint.expbuilder.nsd.graph; +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 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; 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 lombok.extern.slf4j.Slf4j; +import org.jgrapht.Graph; import org.junit.BeforeClass; import org.junit.Test; -import org.slf4j.LoggerFactory; +@Slf4j public class NsdGraphServiceTest { static Properties prop; @@ -32,20 +36,19 @@ 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 @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 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"); @@ -62,12 +65,13 @@ 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 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"); @@ -84,12 +88,13 @@ 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 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"); @@ -106,12 +111,13 @@ 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 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"); @@ -124,4 +130,41 @@ public void buildGraphAres2TDelayExperimentSmall() { assertEquals(expected, actual); } + @Test + @SneakyThrows + public void isConnectedAres2TTrackerSmallTest() { + + // Given + Nsd nsd = oM.readValue(new URL(prop.getProperty("vsb_ares2t_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_ares2t_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)); + } } 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..e84d1e8 --- /dev/null +++ b/src/test/java/it/cnit/blueprint/composer/rest/ExperimentsControllerTest.java @@ -0,0 +1,184 @@ +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; +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.List; +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 ExperimentsControllerTest { + + 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(); + } + + @SneakyThrows + 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>() { + }); + 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); + Context c = new Context(ctxbRequest, null); + + 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(JSON_OM.writeValueAsString(request))) + .andReturn(); + + // 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())); + } + + @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 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 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 deleted file mode 100644 index d5ccd83..0000000 --- a/src/test/java/it/cnit/blueprint/expbuilder/nsd/compose/NsdComposerTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package it.cnit.blueprint.expbuilder.nsd.compose; - -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.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 java.io.InputStream; -import java.net.URL; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; -import lombok.SneakyThrows; -import org.junit.BeforeClass; -import org.junit.Test; -import org.slf4j.LoggerFactory; - -public class NsdComposerTest { - - static Properties prop; - static ObjectMapper oM; - static NsdGraphService nsdGraphService; - static NsdComposer nsdComposer; - - @BeforeClass - @SneakyThrows - public static void setUp() { - // Test Setup - prop = new Properties(); - InputStream input = ClassLoader.getSystemResourceAsStream("url.properties"); - prop.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); - } - - @Test - @SneakyThrows - 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); - - // When - nsdComposer.compose(trackerNsd, new CtxComposeInfo[]{ctxComposeInfo}); - // Setting ID manually for test purpose - trackerNsd.setNsdIdentifier("58886b95-cd29-4b7b-aca0-e884caaa5c68"); - trackerNsd.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)); - } -} \ No newline at end of file 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 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..cd31cfc --- /dev/null +++ b/src/test/resources/expb_ares2t_tracker_bg_traffic_nsds_connect.yaml @@ -0,0 +1,291 @@ +# expb_ares2t_tracker_nsds.yaml +--- +- nsdIdentifier: "2dd7b5b1-9f39-4978-a035-6654d7bc9068" + designer: "NXW + NSD Composer" + 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_mgmt" + 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_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" + 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_mgmt" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - 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" + 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_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" + 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_mgmt" + cpdId: + - "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_tracking_mobile" + cpdId: + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "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" + cpdId: + - "cp_vis_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "cp_vis_mgmt" + - virtualLinkProfileId: "vlp_vl_tracking_user" + cpdId: + - "cp_vis_user" + - 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_mgmt" + 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_mgmt" + 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_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" + 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_mgmt" + bitRateRequirements: + 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" + 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_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" + 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_bg_traffic_nsds.yaml b/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml new file mode 100644 index 0000000..ae3f83c --- /dev/null +++ b/src/test/resources/expb_ares2t_tracker_delay_bg_traffic_nsds.yaml @@ -0,0 +1,345 @@ +# expb_ares2t_tracker_nsds.yaml +--- +- 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" + 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_mgmt" + 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_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" + 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_mgmt" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - 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" + 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_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" + 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_mgmt" + cpdId: + - "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" + cpdId: + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "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" + cpdId: + - "cp_vis_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "cp_vis_mgmt" + - virtualLinkProfileId: "vlp_vl_tracking_user" + cpdId: + - "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" + cpdId: + - "cp_dg_traffic_out" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "cp_dg_mgmt" + - 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_mgmt" + 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_mgmt" + 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_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" + 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_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" + 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_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" + 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" diff --git a/src/test/resources/expb_ares2t_tracker_delay_nsds.yaml b/src/test/resources/expb_ares2t_tracker_delay_nsds.yaml deleted file mode 100644 index b4b4630..0000000 --- a/src/test/resources/expb_ares2t_tracker_delay_nsds.yaml +++ /dev/null @@ -1,255 +0,0 @@ -# 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 - 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 - - virtualLinkDescId: vl_dg_out - virtualLinkDescProvider: NXW - virtuaLinkDescVersion: '1.0' - connectivityType: - layerProtocol: IPV4 - 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 - 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 - 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 - 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 - dependencies: [] - security: - signature: FC_NSD_SIGNATURE - algorithm: FC_NSD_ALGORITHM - certificate: FC_NSD_CERTIFICATE 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..f255af8 --- /dev/null +++ b/src/test/resources/expb_ares2t_tracker_delay_nsds_connect.yaml @@ -0,0 +1,290 @@ +# expb_ares2t_tracker_nsds.yaml +--- +- 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" + 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_mgmt" + 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_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" + 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_mgmt" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - 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" + 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_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" + 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_mgmt" + cpdId: + - "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_tracking_mobile" + cpdId: + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "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" + cpdId: + - "cp_vis_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "cp_vis_mgmt" + - virtualLinkProfileId: "vlp_vl_tracking_user" + cpdId: + - "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_tracking_mobile" + cpdId: + - "cp_dg_traffic_out" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "cp_dg_mgmt" + - 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_mgmt" + cpdId: + - "cp_dg_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_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" + 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_mgmt" + bitRateRequirements: + 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" + 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_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" + 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_passthrough.yaml b/src/test/resources/expb_ares2t_tracker_delay_nsds_passthrough.yaml new file mode 100644 index 0000000..6b3b297 --- /dev/null +++ b/src/test/resources/expb_ares2t_tracker_delay_nsds_passthrough.yaml @@ -0,0 +1,308 @@ +# expb_ares2t_tracker_nsds.yaml +--- +- 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" + 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_mgmt" + 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_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" + 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_mgmt" + virtualLinkDescProvider: "NXW" + virtuaLinkDescVersion: "1.0" + connectivityType: + layerProtocol: "IPV4" + flowPattern: null + virtualLinkDf: + - 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" + 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_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" + 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_mgmt" + cpdId: + - "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" + cpdId: + - "cp_tracker_ext_in" + - virtualLinkProfileId: "vlp_vl_tracking_data" + cpdId: + - "cp_tracker_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "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" + cpdId: + - "cp_vis_data" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "cp_vis_mgmt" + - virtualLinkProfileId: "vlp_vl_tracking_user" + cpdId: + - "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" + cpdId: + - "cp_dg_traffic_out" + - virtualLinkProfileId: "vlp_vl_tracking_mgmt" + cpdId: + - "cp_dg_mgmt" + - virtualLinkProfileId: "vlp_vl_tracking_mobile" + cpdId: + - "cp_dg_traffic_in" + 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_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" + 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 + 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_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" + 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 + 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_mgmt" + bitRateRequirements: + root: "1" + leaf: "1" + - virtualLinkProfileId: "vlp_vl_tracking_user" + 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" 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..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,24 +1,28 @@ 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" ]; -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" ]; - 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" ]; + 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 -- -1971191929 [ label="vnfp_big_Ares2T_Tracker_exp_cp_tracker_mgmt" ]; + 1392640733 -- -1971465616 [ label="vnfp_Ares2T_Vis_exp_cp_vis_data" ]; + 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 -- -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 df12351..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,24 +1,28 @@ 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" ]; -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" ]; - -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" ]; + 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 -- -1971191929 [ label="vnfp_small_Ares2T_Tracker_exp_cp_tracker_mgmt" ]; + 1392640733 -- -1971465616 [ label="vnfp_Ares2T_Vis_exp_cp_vis_data" ]; + 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 -- -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_il_big.dot b/src/test/resources/ns_ares2t_tracker_il_big.dot index 5db50fe..214330e 100644 --- a/src/test/resources/ns_ares2t_tracker_il_big.dot +++ b/src/test/resources/ns_ares2t_tracker_il_big.dot @@ -1,19 +1,23 @@ 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" ]; -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" ]; - -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" ]; + 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 -- -1844537179 [ label="vnfp_big_Ares2T_Tracker_cp_tracker_mgmt" ]; + 1169940735 -- -1844810866 [ label="vnfp_Ares2T_Vis_cp_vis_data" ]; + 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 0118ee0..4272c09 100644 --- a/src/test/resources/ns_ares2t_tracker_il_small.dot +++ b/src/test/resources/ns_ares2t_tracker_il_small.dot @@ -1,19 +1,23 @@ 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" ]; -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" ]; - 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" ]; + 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 -- -1844537179 [ label="vnfp_small_Ares2T_Tracker_cp_tracker_mgmt" ]; + 1169940735 -- -1844810866 [ label="vnfp_Ares2T_Vis_cp_vis_data" ]; + 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/url.properties b/src/test/resources/url.properties index c5f94b9..6eb1f94 100644 --- a/src/test/resources/url.properties +++ b/src/test/resources/url.properties @@ -1,3 +1,14 @@ -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 +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 +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_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