Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'development' for 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWall89 committed May 12, 2020
2 parents dd495ad + fb74e27 commit de6f4e9
Show file tree
Hide file tree
Showing 73 changed files with 3,345 additions and 1,918 deletions.
Empty file removed .maven-dockerignore
Empty file.
2 changes: 0 additions & 2 deletions .maven-dockerinclude

This file was deleted.

45 changes: 3 additions & 42 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
68 changes: 12 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:<version> \
--target dev \
--build-arg JAR_FILE=5geve-experiment-builder-<version>.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
Expand All @@ -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:<version> \
--target prod \
--build-arg JAR_FILE=5geve-experiment-builder-<version>.jar \
--build-arg BUILD_DATE=<date> \
--build-arg REPOSITORY=mpergolesi \
--build-arg DESCRIPTION="A REST API module to compose VSD and CDs." \
--build-arg VERSION=<version> \
--build-arg VCS_URL=<vcs-url> \
--build-arg VCS_REF=<vcs-ref> \
--build-arg COMMAND=<command>
```
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3.7'
services:
exp-nsd-composer:
build:
context: .
container_name: exp-nsd-composer
ports:
- 8086:8086
112 changes: 3 additions & 109 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>it.cnit.blueprint</groupId>
<artifactId>expbuilder</artifactId>
<version>0.0.1</version>
<description>A REST API module to compose VSD and CDs.</description>
<url>https://github.com/TheWall89/5geve-experiment-builder</url>
<packaging>docker-build</packaging>
<artifactId>composer</artifactId>
<version>0.0.2</version>
<description>A REST API module to compose NSDs.</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<docker.repository>mpergolesi</docker.repository>
<jgrapht.version>1.3.0</jgrapht.version>
</properties>

Expand Down Expand Up @@ -129,88 +126,8 @@
</exclusion>
</exclusions>
</dependency>

</dependencies>

<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<alias>expbuilder-dev</alias>
<name>${docker.repository}/${project.name}:${project.version}</name>
<build>
<dockerFileDir>${project.basedir}</dockerFileDir>
<args>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</args>
<buildOptions>
<target>dev</target>
</buildOptions>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>prod</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<alias>expbuilder-prod</alias>
<name>${docker.repository}/${project.name}:${project.version}</name>
<build>
<dockerFileDir>${project.basedir}</dockerFileDir>
<args>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
<!-- Labels -->
<BUILD_DATE>${maven.build.timestamp}</BUILD_DATE>
<REPOSITORY>${project.name}</REPOSITORY>
<DESCRIPTION>${project.description}</DESCRIPTION>
<VERSION>${project.version}</VERSION>
<!--suppress UnresolvedMavenProperty -->
<VCS_URL>${git.remote.origin.url}</VCS_URL>
<!--suppress UnresolvedMavenProperty -->
<VCS_REF>${git.commit.id}</VCS_REF>
<COMMAND>java -jar ${project.build.finalName}.jar</COMMAND>
</args>
<buildOptions>
<target>prod</target>
</buildOptions>
</build>
</image>
</images>
</configuration>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<injectAllReactorProjects>true</injectAllReactorProjects>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -273,29 +190,6 @@
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- maven-docker-plugin,
see https://github.com/fabric8io/docker-maven-plugin -->
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.28.0</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.5</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<!-- *NOTE*: The default phase of revision is initialize, but in case you want to change it, you can do so by adding the phase here -->
<phase>initialize</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/it/cnit/blueprint/composer/App.java
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package it.cnit.blueprint.composer.exceptions;

public class ContextInvalidException extends Exception {

public ContextInvalidException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package it.cnit.blueprint.composer.exceptions;

public class TransRuleCompositionException extends Exception {

public TransRuleCompositionException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package it.cnit.blueprint.composer.exceptions;

public class TransRuleInvalidException extends Exception {

public TransRuleInvalidException(String message) {
super(message);
}
}
Loading

0 comments on commit de6f4e9

Please sign in to comment.