Objective
Have the processor running locally is to use the IDE to run the code, while having the database running in a container. This way, code changes can be conveniently tested and debugged.
Check out the code
Check out the latest code from Gerrit: https://gerrit.onap.org/r/#/admin/projects/ccsdk/cds
Build it locally
In the checked out directory, type
mvn clean install -DskipTests=true -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dadditionalparam=-Xdoclint:none
Spin up a Docker container with the database
The Blueprints Processor project uses a database to store information about the blueprints and therefore it needs to be online before attempting to run it.
One way to create the database is by using the docker-compose.yaml
file present on the distribution module.
Navigate to the docker-compose file in the distribution module:
cd ms/blueprintsprocessor/distribution/src/main/dc
And run docker-composer:
docker-compose up -d db
This should spin up a container of the MariaDB image in the background. To check if it has worked, this command can be used:
docker-compose logs -f
The phrase mysqld: ready for connections
indicates that the database was started correctly.
From now on, the Docker container will be available on the computer; if it ever gets stopped, it can be started again by the command:
docker start <id of mariadb container>
Set permissions on the local file system
Blueprints processor uses the local file system for some operations and, therefore, need some existing and accessible paths to run properly.
Execute the following commands to create the needed directories, and grant access to the current user to modify them:
mkdir -p -m 755 /opt/app/onap/blueprints/archive
mkdir -p -m 755 /opt/app/onap/blueprints/deploy
mkdir -p -m 755 /opt/app/onap/scripts
sudo chown -R $(id -u):$(id -g) /opt/app/onap/
Import the project on the IDE
For this page, the chosen IDE is IntelliJ, but the instructions present here can be adapted to be used in other IDEs as well.
Go to File | Open
and choose the pom.xml
file of the cds directory:
Override some application properties
After the project is compiled, a Run Configuration profile overriding some application properties with custom values needs to be created, to reflect the local environment characteristics.
Navigate to the main class of the Blueprints Processor, the BlueprintProcessorApplication class: cds/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintProcessorApplication.java
.
Right-click inside it, at any point, to load the context menu and select create BlueprintProcessorApplication configuration from context:
The following window will open:
Unfold the environment section and click in the VM options expansion icon, to add the custom values to be applied to some application properties:
Add the following in that field:
-DappName=ControllerBluePrints -Dms_name=org.onap.ccsdk.apps.controllerblueprints -DappVersion=1.0.0 -Dspring.config.location=opt/app/onap/config/ -Dspring.datasource.url=jdbc:mysql://127.0.0.1:3306/sdnctl -Dspring.datasource.username=sdnctl -Dspring.datasource.password=sdnctl -Dcontrollerblueprints.loadInitialData=true -Dblueprintsprocessor.restclient.sdncodl.url=http://localhost:8282/ -Dblueprintsprocessor.db.primary.url=jdbc:mysql://localhost:3306/sdnctl -Dblueprintsprocessor.db.primary.username=sdnctl -Dblueprintsprocessor.db.primary.password=sdnctl -Dblueprintsprocessor.db.primary.driverClassName=org.mariadb.jdbc.Driver -Dblueprintsprocessor.db.primary.hibernateHbm2ddlAuto=update -Dblueprintsprocessor.db.primary.hibernateDDLAuto=none -Dblueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy -Dblueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.MySQL5InnoDBDialect -Dblueprints.processor.functions.python.executor.executionPath=./components/scripts/python/ccsdk_blueprints -Dblueprints.processor.functions.python.executor.modulePaths=./components/scripts/python/ccsdk_blueprints,./components/scripts/python/ccsdk_netconf,./components/scripts/python/ccsdk_restconf -Dblueprintsprocessor.restconfEnabled=true -Dblueprintsprocessor.restclient.sdncodl.type=basic-auth -Dblueprintsprocessor.restclient.sdncodl.url=http://localhost:8282/ -Dblueprintsprocessor.restclient.sdncodl.username=admin -Dblueprintsprocessor.restclient.sdncodl.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -Dblueprintsprocessor.grpcEnable=false -Dblueprintsprocessor.grpcPort=9111 -Dblueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy -Dblueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive -Dblueprintsprocessor.blueprintWorkingPath=/opt/app/onap/blueprints/work -Dsecurity.user.password={bcrypt}$2a$10$duaUzVUVW0YPQCSIbGEkQOXwafZGwQ/b32/Ys4R1iwSSawFgz7QNu -Dsecurity.user.name=ccsdkapps -Dblueprintsprocessor.messageclient.self-service-api.kafkaEnable=false -Dblueprintsprocessor.messageclient.self-service-api.topic=producer.t -Dblueprintsprocessor.messageclient.self-service-api.type=kafka-basic-auth -Dblueprintsprocessor.messageclient.self-service-api.bootstrapServers=127.0.0.1:9092 -Dblueprintsprocessor.messageclient.self-service-api.consumerTopic=receiver.t -Dblueprintsprocessor.messageclient.self-service-api.groupId=receiver-id -Dblueprintsprocessor.messageclient.self-service-api.clientId=default-client-id -Dspring.profiles.active=dev -Dblueprintsprocessor.httpPort=8080 -Dserver.port=55555
Add the following to Blueprint's application-dev.properties file:
blueprintsprocessor.grpcclient.remote-python.type=token-auth blueprintprocessor.remoteScriptCommand.enabled=true |
---|
Run the application
Select either run or debug for this Run Configuration to start the Blueprints Processor:
. ____ _ __ _ _
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.3.RELEASE)
17:01:48.364 INFO o.o.c.c.b.BlueprintProcessorApplication - Starting BlueprintProcessorApplication
17:01:48.367 INFO o.o.c.c.b.BlueprintProcessorApplication - The following profiles are active: dev
17:01:48.412 INFO o.s.b.d.env.DevToolsPropertyDefaultsPostProcessor - Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
17:01:48.412 INFO o.s.b.d.env.DevToolsPropertyDefaultsPostProcessor - For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
17:01:50.309 INFO o.s.d.r.config.RepositoryConfigurationDelegate - Bootstrapping Spring Data repositories in DEFAULT mode.
17:01:50.445 INFO o.s.d.r.config.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 130ms. Found 3 repository interfaces.
17:01:51.050 INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type (...)
17:01:52.084 INFO o.s.orm.jpa.LocalContainerEntityManagerFactoryBean - Initialized JPA EntityManagerFactory for persistence unit 'default'
17:01:52.124 INFO o.s.b.d.autoconfigure.OptionalLiveReloadServer - LiveReload server is running on port 35729
17:01:52.873 INFO c.o.c.c.b.db.BlueprintProcessorCatalogServiceImpl - BlueprintProcessorCatalogServiceImpl initialized
17:01:53.316 INFO o.s.b.actuate.endpoint.web.EndpointLinksResolver - Exposing 2 endpoint(s) beneath base path '/actuator'
17:01:53.421 INFO o.o.c.c.b.db.primary.PrimaryDatabaseConfiguration - Initialised Primary Transaction Manager for url jdbc:mysql://localhost:3306/sdnctl
17:01:54.098 INFO o.s.boot.web.embedded.netty.NettyWebServer - Netty started on port(s): 8080
17:01:54.100 INFO o.o.c.c.b.BlueprintProcessorApplication - Started BlueprintProcessorApplication in 6.064 seconds (JVM running for 6.804)
Testing the application
There are two main features of the Blueprints Processor that can be of interest of a developer: blueprint upload and blueprint process.
To upload custom blueprints, the endpoint api/v1/execution-service/upload
is used.
To process, the endpoint is api/v1/execution-service/process
.
Postman is a software that can be used to send these request, and an example of them is present on https://www.getpostman.com/collections/b99863b0cde7565a32fc.