From 04798df78d921a3fc32997286167f2917aece225 Mon Sep 17 00:00:00 2001 From: "waqas.ikram" Date: Mon, 23 Jan 2023 16:12:33 +0000 Subject: Adding SO CNFM docker package Change-Id: Ic57fccfbe9b78992667c8e0fa32a8695775beb1a Issue-ID: SO-4068 Signed-off-by: waqas.ikram --- packages/docker/pom.xml | 32 ++++++++++- .../docker/docker-files/Dockerfile.so-cnfm-app | 50 ++++++++++++++++ so-cnfm/so-cnfm-lcm/pom.xml | 1 + .../so-cnfm-lcm/so-cnfm-lcm-application/pom.xml | 66 ++++++++++++++++++++++ .../java/org/onap/so/cnfm/lcm/app/Application.java | 53 +++++++++++++++++ .../lcm/app/AsyncThreadExecutorConfiguration.java | 64 +++++++++++++++++++++ .../DefaultToShortClassNameBeanNameGenerator.java | 36 ++++++++++++ .../app/DisabledBasicHttpSecurityConfigurer.java | 45 +++++++++++++++ .../src/main/resources/application-aaf.yaml | 13 +++++ .../src/main/resources/application-basic.yaml | 13 +++++ .../src/main/resources/application.yaml | 56 ++++++++++++++++++ 11 files changed, 427 insertions(+), 2 deletions(-) create mode 100644 packages/docker/src/main/docker/docker-files/Dockerfile.so-cnfm-app create mode 100644 so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/pom.xml create mode 100644 so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/Application.java create mode 100644 so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/AsyncThreadExecutorConfiguration.java create mode 100644 so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/DefaultToShortClassNameBeanNameGenerator.java create mode 100644 so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/DisabledBasicHttpSecurityConfigurer.java create mode 100644 so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application-aaf.yaml create mode 100644 so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application-basic.yaml create mode 100644 so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application.yaml diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index ee1bbd9..2df3f49 100755 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -99,7 +99,30 @@ - + + ${docker.image.prefix}/so-cnfm-as-lcm + + try + docker-files/Dockerfile.so-cnfm-app + + ${project.version} + ${project.version}-${maven.build.timestamp} + ${project.docker.latesttag.version} + + + + + + + org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm:so-cnfm-lcm-application + + app.jar + + + + + + @@ -131,7 +154,7 @@ push - ${docker.image.prefix}/so-cnf-adapter + ${docker.image.prefix}/so-cnf-adapter,${docker.image.prefix}/so-cnfm-as-lcm @@ -153,5 +176,10 @@ so-cnf-adapter-application ${project.version} + + org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm + so-cnfm-lcm-application + ${project.version} + \ No newline at end of file diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-cnfm-app b/packages/docker/src/main/docker/docker-files/Dockerfile.so-cnfm-app new file mode 100644 index 0000000..eb85e3b --- /dev/null +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-cnfm-app @@ -0,0 +1,50 @@ +FROM onap/so/base-image:1.0 + +ARG http_proxy +ENV HTTP_PROXY=$http_proxy +ENV http_proxy=$HTTP_PROXY +ARG https_proxy +ENV HTTPS_PROXY=$https_proxy +ENV https_proxy=$HTTPS_PROXY +ARG KUBECTL_VERSION=v1.21.1 +ARG HELM_VERSION=v3.5.2 + +USER root +RUN mkdir -p /app/config +RUN mkdir -p /app/certificates +RUN mkdir -p /app/logs +RUN mkdir -p /app/ca-certificates +RUN mkdir -p /app/csar +RUN mkdir -p /app/kube-configs + +COPY maven/app.jar /app +COPY configs/logging/logback-spring.xml /app +COPY scripts/start-app.sh /app +COPY scripts/wait-for.sh /app +COPY ca-certificates/onap-ca.crt /app/ca-certificates/onap-ca.crt +RUN chown -R so:so /app + + +ENV TAR_FILE="helm-${HELM_VERSION}-linux-amd64.tar.gz" + +RUN wget https://get.helm.sh/${TAR_FILE} && \ + tar xvf ${TAR_FILE} && \ + chmod +x linux-amd64/helm && \ + mv linux-amd64/helm /usr/local/bin && \ + rm -rf linux-amd64 && \ + rm ${TAR_FILE} + +RUN wget https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \ + chmod +x kubectl && \ + mv kubectl /usr/local/bin/kubectl + +USER so + +# Springboot configuration (required) +VOLUME /app/config + +# Root certificates (optional) +VOLUME /app/ca-certificates + +WORKDIR /app +ENTRYPOINT ["/app/start-app.sh"] diff --git a/so-cnfm/so-cnfm-lcm/pom.xml b/so-cnfm/so-cnfm-lcm/pom.xml index 0b1dd81..82474e2 100644 --- a/so-cnfm/so-cnfm-lcm/pom.xml +++ b/so-cnfm/so-cnfm-lcm/pom.xml @@ -16,5 +16,6 @@ so-cnfm-lcm-database-service so-cnfm-lcm-bpmn-flows so-cnfm-lcm-service + so-cnfm-lcm-application \ No newline at end of file diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/pom.xml b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/pom.xml new file mode 100644 index 0000000..812bd6d --- /dev/null +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + + org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm + so-cnfm-lcm + 1.9.0-SNAPSHOT + + + so-cnfm-lcm-application + SO CNFM LCM Application + + + ${project.artifactId}-${project.version} + + + org.springframework.boot + spring-boot-maven-plugin + + org.onap.so.cnfm.lcm.app.Application + + + + + repackage + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + original + + + + + org.jacoco + jacoco-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + DEBUG + + 2 + suites + false + 1 + + + + + + + + org.onap.so.adapters.so-cnf-adapter.so-cnfm.lcm + so-cnfm-lcm-service + ${project.version} + + + \ No newline at end of file diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/Application.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/Application.java new file mode 100644 index 0000000..ef383bf --- /dev/null +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/Application.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.cnfm.lcm.app; + +import org.onap.so.security.SoBasicHttpSecurityConfigurer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ComponentScan.Filter; +import org.springframework.context.annotation.FilterType; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@SpringBootApplication(scanBasePackages = {"org.onap.so"}) +@ComponentScan(basePackages = {"org.onap"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, + excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class), + @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = SoBasicHttpSecurityConfigurer.class)}) +public class Application { + private static final Logger logger = LoggerFactory.getLogger(Application.class); + + /** + * Entry point for the Spring boot application + * + * @param args arguments for the application + */ + public static void main(final String[] args) { + new SpringApplication(Application.class).run(args); + logger.info("SO CNFM LCM Application started successfully!"); + + } + +} diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/AsyncThreadExecutorConfiguration.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/AsyncThreadExecutorConfiguration.java new file mode 100644 index 0000000..249856e --- /dev/null +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/AsyncThreadExecutorConfiguration.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.cnfm.lcm.app; + +import static org.slf4j.LoggerFactory.getLogger; +import java.util.concurrent.Executor; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Configuration +@EnableAsync +public class AsyncThreadExecutorConfiguration { + private static final Logger logger = getLogger(AsyncThreadExecutorConfiguration.class); + + @Value("${mso.async.core-pool-size:20}") + private int corePoolSize; + + @Value("${mso.async.max-pool-size:30}") + private int maxPoolSize; + + @Value("${mso.async.queue-capacity:50}") + private int queueCapacity; + + @Bean + @Primary + public Executor asyncExecutor() { + logger.info("Setting ThreadPoolTaskExecutor for async calls ..."); + final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(corePoolSize); + executor.setMaxPoolSize(maxPoolSize); + executor.setQueueCapacity(queueCapacity); + executor.setThreadNamePrefix("Async Process-"); + executor.initialize(); + return executor; + } + + +} diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/DefaultToShortClassNameBeanNameGenerator.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/DefaultToShortClassNameBeanNameGenerator.java new file mode 100644 index 0000000..dbf5e02 --- /dev/null +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/DefaultToShortClassNameBeanNameGenerator.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.cnfm.lcm.app; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.AnnotationBeanNameGenerator; +import org.springframework.util.ClassUtils; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class DefaultToShortClassNameBeanNameGenerator extends AnnotationBeanNameGenerator { + + @Override + protected String buildDefaultBeanName(final BeanDefinition definition) { + return ClassUtils.getShortName(definition.getBeanClassName()); + } +} diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/DisabledBasicHttpSecurityConfigurer.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/DisabledBasicHttpSecurityConfigurer.java new file mode 100644 index 0000000..b2da420 --- /dev/null +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/java/org/onap/so/cnfm/lcm/app/DisabledBasicHttpSecurityConfigurer.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.cnfm.lcm.app; + +import static org.slf4j.LoggerFactory.getLogger; +import org.onap.so.security.HttpSecurityConfigurer; +import org.slf4j.Logger; +import org.springframework.context.annotation.Primary; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.stereotype.Component; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + */ +@Primary +@Component("basic") +public class DisabledBasicHttpSecurityConfigurer implements HttpSecurityConfigurer { + + private static final Logger logger = getLogger(DisabledBasicHttpSecurityConfigurer.class); + + @Override + public void configure(final HttpSecurity http) throws Exception { + logger.debug("Disabling basic auth settings ... "); + http.csrf().disable().authorizeRequests().antMatchers("/**").permitAll().and().httpBasic().disable(); + } +} + diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application-aaf.yaml b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application-aaf.yaml new file mode 100644 index 0000000..cd60460 --- /dev/null +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application-aaf.yaml @@ -0,0 +1,13 @@ +# Copyright © 2023 Nordix Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. \ No newline at end of file diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application-basic.yaml b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application-basic.yaml new file mode 100644 index 0000000..cd60460 --- /dev/null +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application-basic.yaml @@ -0,0 +1,13 @@ +# Copyright © 2023 Nordix Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. \ No newline at end of file diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application.yaml b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application.yaml new file mode 100644 index 0000000..606e5d4 --- /dev/null +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-application/src/main/resources/application.yaml @@ -0,0 +1,56 @@ +# Copyright © 2023 Nordix Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +aai: + auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 + version: v19 + endpoint: https://aai.onap:8443 +spring: + datasource: + hikari: + camunda: + jdbcUrl: jdbc:mariadb://${DB_HOST}:${DB_PORT}/camundabpmn + username: ${DB_USERNAME} + password: ${DB_PASSWORD} + driver-class-name: org.mariadb.jdbc.Driver + pool-name: bpmn-pool + registerMbeans: true + cnfm: + jdbcUrl: jdbc:mariadb://${DB_HOST}:${DB_PORT}/cnfm + username: ${DB_ADMIN_USERNAME} + password: ${DB_ADMIN_PASSWORD} + driver-class-name: org.mariadb.jdbc.Driver + pool-name: cnfm-pool + registerMbeans: true + servlet: + multipart: + enabled: true +cnfm: + kube-configs-dir: /app/kube-configs +server: + port: 9888 + tomcat: + max-threads: 50 +camunda: + bpm: + history-level: full + job-execution: + max-pool-size: 30 + core-pool-size: 3 + deployment-aware: true +sdc: + username: mso + password: 76966BDD3C7414A03F7037264FF2E6C8EEC6C28F2B67F2840A1ED857C0260FEE731D73F47F828E5527125D29FD25D3E0DE39EE44C058906BF1657DE77BF897EECA93BDC07FA64F + key: 566B754875657232314F5548556D3665 + endpoint: http://sdc-be.onap:8080 + \ No newline at end of file -- cgit 1.2.3-korg