diff options
75 files changed, 3341 insertions, 3374 deletions
diff --git a/deliveries/pom.xml b/deliveries/pom.xml index e36697432..f096c2b62 100755 --- a/deliveries/pom.xml +++ b/deliveries/pom.xml @@ -5,7 +5,7 @@ <parent>
<groupId>org.onap.vid</groupId>
<artifactId>vid-parent</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<packaging>pom</packaging>
diff --git a/deliveries/src/main/docker/docker-files/Dockerfile b/deliveries/src/main/docker/docker-files/Dockerfile index 33c3ac1a1..a115b5f02 100755 --- a/deliveries/src/main/docker/docker-files/Dockerfile +++ b/deliveries/src/main/docker/docker-files/Dockerfile @@ -1,13 +1,14 @@ FROM tomcat:8.0-jre8
+
# add vim and uncomment alias to speedup troubleshooting purpose
RUN apt-get update && apt-get install -y \
openjdk-8-jdk vim net-tools
-RUN sed -i 's/# alias/alias/g' /root/.bashrc
+COPY conf.d/ /etc/onap/vid/conf.d/
-RUN mkdir -p ${ROOT_DIR}/etc
+RUN sed -i 's/# alias/alias/g' /root/.bashrc
-ENV JAVA_OPTS="-Xmx1536m -Xms1536m"
+ENV JAVA_OPTS="-Xmx1536m -Xms1536m -Dlogback.configurationFile=/etc/onap/vid/conf.d/logback.xml"
ENV ROOT_DIR /opt/app/vid
@@ -86,4 +87,4 @@ ADD maven/artifacts/vid.war /tmp/vid/stage/ RUN chmod +x /tmp/vid/localize.sh
-CMD ["/tmp/vid/localize.sh"]
+CMD ["/tmp/vid/localize.sh"]
\ No newline at end of file diff --git a/epsdk-app-onap/src/main/resources/logback.xml b/deliveries/src/main/docker/docker-files/conf.d/logback.xml index 14b534da6..09d241456 100755 --- a/epsdk-app-onap/src/main/resources/logback.xml +++ b/deliveries/src/main/docker/docker-files/conf.d/logback.xml @@ -1,371 +1,371 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START==========================================
- ONAP Portal SDK
- ===================================================================
- Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- ===================================================================
-
- Unless otherwise specified, all software contained herein is licensed
- under the Apache License, Version 2.0 (the “License”);
- you may not use this software 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.
-
- Unless otherwise specified, all documentation contained herein is licensed
- under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
- you may not use this documentation except in compliance with the License.
- You may obtain a copy of the License at
-
- https://creativecommons.org/licenses/by/4.0/
-
- Unless required by applicable law or agreed to in writing, documentation
- 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.
-
- ============LICENSE_END============================================
-
- ECOMP is a trademark and service mark of AT&T Intellectual Property.
- -->
-<configuration scan="true" scanPeriod="3 seconds" debug="true">
- <!--
- Logback files for the ONAP Portal SDK Application "epsdk-app-os"
- are created in directory ${catalina.base}/logs/epsdk_app_os;
- e.g., apache-tomcat-8.0.35/logs/epsdk_app_os/application.log
- -->
- <!--<jmxConfigurator /> -->
-
- <!-- specify the component name -->
- <property name="componentName" value="ep_sdk_app"></property>
-
- <!-- specify the base path of the log directory -->
- <property name="logDirPrefix" value="${catalina.base}/logs"></property>
-
- <!-- The directories where logs are written -->
- <property name="logDirectory" value="${logDirPrefix}/${componentName}" />
- <!-- Can easily relocate debug logs by modifying this path. -->
- <property name="debugLogDirectory" value="${logDirPrefix}/${componentName}" />
-
- <!-- log file names -->
- <property name="generalLogName" value="application" />
- <property name="errorLogName" value="error" />
- <property name="metricsLogName" value="metrics" />
- <property name="auditLogName" value="audit" />
- <property name="debugLogName" value="debug" />
- <!--
- These loggers are not used in code (yet).
- <property name="securityLogName" value="security" />
- <property name="policyLogName" value="policy" />
- <property name="performanceLogName" value="performance" />
- <property name="serverLogName" value="server" />
- -->
-
- <!-- 1610 Logging Fields Format Revisions -->
- <property name="auditLoggerPattern"
- value="%X{AuditLogBeginTimestamp}|%X{AuditLogEndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}| %msg%n" />
-
- <property name="metricsLoggerPattern"
- value="%X{MetricsLogBeginTimestamp}|%X{MetricsLogEndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{TargetVisualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}| %msg%n" />
-
- <property name="errorLoggerPattern"
- value="%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ClassName}|%X{AlertSeverity}|%X{ErrorCode}|%X{ErrorDescription}| %msg%n" />
-
- <property name="defaultLoggerPattern"
- value="%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%X{ClassName}| %msg%n" />
-
- <!-- use %class so library logging calls yield their class name -->
- <property name="applicationLoggerPattern"
- value="%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%class{36}| %msg%n" />
-
- <!-- Example evaluator filter applied against console appender -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>${defaultLoggerPattern}</pattern>
- </encoder>
- </appender>
-
- <!-- ============================================================================ -->
- <!-- EELF Appenders -->
- <!-- ============================================================================ -->
-
- <!-- The EELFAppender is used to record events to the general application
- log -->
-
-
- <appender name="EELF"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${generalLogName}.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!-- daily rollover -->
- <fileNamePattern>${logDirectory}/${generalLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
- <maxHistory>30</maxHistory>
- <totalSizeCap>3GB</totalSizeCap>
-
- </rollingPolicy>
- <encoder>
- <pattern>${applicationLoggerPattern}</pattern>
- </encoder>
- <filter class="org.onap.portalapp.util.CustomLoggingFilter" />
- </appender>
-
- <appender name="asyncEELF" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <!-- Class name is part of caller data -->
- <includeCallerData>true</includeCallerData>
- <appender-ref ref="EELF" />
- </appender>
-
- <!-- EELF Security Appender. This appender is used to record security events
- to the security log file. Security events are separate from other loggers
- in EELF so that security log records can be captured and managed in a secure
- way separate from the other logs. This appender is set to never discard any
- events. -->
- <!--
- <appender name="EELFSecurity"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${securityLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${securityLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFSecurity" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <discardingThreshold>0</discardingThreshold>
- <appender-ref ref="EELFSecurity" />
- </appender>
- -->
-
- <!-- EELF Performance Appender. This appender is used to record performance
- records. -->
- <!--
- <appender name="EELFPerformance"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${performanceLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${performanceLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <outputPatternAsHeader>true</outputPatternAsHeader>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
- <appender name="asyncEELFPerformance" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFPerformance" />
- </appender>
- -->
-
- <!-- EELF Server Appender. This appender is used to record Server related
- logging events. The Server logger and appender are specializations of the
- EELF application root logger and appender. This can be used to segregate Server
- events from other components, or it can be eliminated to record these events
- as part of the application root log. -->
- <!--
- <appender name="EELFServer"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${serverLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${serverLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
- <appender name="asyncEELFServer" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFServer" />
- </appender>
- -->
-
- <!-- EELF Policy Appender. This appender is used to record Policy engine
- related logging events. The Policy logger and appender are specializations
- of the EELF application root logger and appender. This can be used to segregate
- Policy engine events from other components, or it can be eliminated to record
- these events as part of the application root log. -->
- <!--
- <appender name="EELFPolicy"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${policyLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${policyLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
- <appender name="asyncEELFPolicy" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFPolicy" />
- </appender>
- -->
-
- <!-- EELF Audit Appender. This appender is used to record audit engine
- related logging events. The audit logger and appender are specializations
- of the EELF application root logger and appender. This can be used to segregate
- Policy engine events from other components, or it can be eliminated to record
- these events as part of the application root log. -->
-
- <appender name="EELFAudit"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${auditLogName}.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!-- daily rollover -->
- <fileNamePattern>${logDirectory}/${auditLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
- <maxHistory>30</maxHistory>
- <totalSizeCap>3GB</totalSizeCap>
-
- </rollingPolicy>
- <encoder>
- <pattern>${auditLoggerPattern}</pattern>
- </encoder>
- </appender>
- <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFAudit" />
- </appender>
-
- <appender name="EELFMetrics"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${metricsLogName}.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!-- daily rollover -->
- <fileNamePattern>${logDirectory}/${metricsLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
- <maxHistory>30</maxHistory>
- <totalSizeCap>3GB</totalSizeCap>
-
- </rollingPolicy>
- <encoder>
- <pattern>${metricsLoggerPattern}</pattern>
- </encoder>
- </appender>
-
-
- <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFMetrics"/>
- </appender>
-
- <appender name="EELFError"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${errorLogName}.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!-- daily rollover -->
- <fileNamePattern>${logDirectory}/${errorLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
- <maxHistory>30</maxHistory>
- <totalSizeCap>3GB</totalSizeCap>
-
- </rollingPolicy>
- <encoder>
- <pattern>${errorLoggerPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFError"/>
- </appender>
-
- <appender name="EELFDebug"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${debugLogDirectory}/${debugLogName}.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!-- daily rollover -->
- <fileNamePattern>${logDirectory}/${debugLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
-
- <!-- keep 30 days' worth of history capped at 3GB total size -->
- <maxHistory>30</maxHistory>
- <totalSizeCap>3GB</totalSizeCap>
-
- </rollingPolicy>
- <encoder>
- <pattern>${defaultLoggerPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFDebug" />
- </appender>
-
-
-
-
- <logger name="org.onap.eelf" level="info" additivity="false">
- <appender-ref ref="asyncEELF" />
- </logger>
-
- <logger name="org.onap.eelf.audit" level="info" additivity="false">
- <appender-ref ref="asyncEELFAudit" />
- </logger>
-
- <logger name="org.onap.eelf.debug" level="debug" additivity="false">
- <appender-ref ref="asyncEELFDebug" />
- </logger>
-
- <logger name="org.onap.eelf.error" level="info" additivity="false">
- <appender-ref ref="asyncEELFError" />
- </logger>
-
- <logger name="org.onap.eelf.metrics" level="info" additivity="false">
- <appender-ref ref="asyncEELFMetrics" />
- </logger>
-
-
- <root level="DEBUG">
- <appender-ref ref="asyncEELF" />
- </root>
-
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START========================================== + ONAP Portal SDK + =================================================================== + Copyright © 2017 AT&T Intellectual Property. All rights reserved. + =================================================================== + + Unless otherwise specified, all software contained herein is licensed + under the Apache License, Version 2.0 (the “License”); + you may not use this software 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. + + Unless otherwise specified, all documentation contained herein is licensed + under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + you may not use this documentation except in compliance with the License. + You may obtain a copy of the License at + + https://creativecommons.org/licenses/by/4.0/ + + Unless required by applicable law or agreed to in writing, documentation + 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. + + ============LICENSE_END============================================ + + ECOMP is a trademark and service mark of AT&T Intellectual Property. + --> +<configuration scan="true" scanPeriod="3 seconds" debug="true"> + <!-- + Logback files for the ONAP Portal SDK Application "epsdk-app-os" + are created in directory ${catalina.base}/logs/epsdk_app_os; + e.g., apache-tomcat-8.0.35/logs/epsdk_app_os/application.log + --> + <!--<jmxConfigurator /> --> + + <!-- specify the component name --> + <property name="componentName" value="ep_sdk_app"></property> + + <!-- specify the base path of the log directory --> + <property name="logDirPrefix" value="${catalina.base}/logs"></property> + + <!-- The directories where logs are written --> + <property name="logDirectory" value="${logDirPrefix}/${componentName}" /> + <!-- Can easily relocate debug logs by modifying this path. --> + <property name="debugLogDirectory" value="${logDirPrefix}/${componentName}" /> + + <!-- log file names --> + <property name="generalLogName" value="application" /> + <property name="errorLogName" value="error" /> + <property name="metricsLogName" value="metrics" /> + <property name="auditLogName" value="audit" /> + <property name="debugLogName" value="debug" /> + <!-- + These loggers are not used in code (yet). + <property name="securityLogName" value="security" /> + <property name="policyLogName" value="policy" /> + <property name="performanceLogName" value="performance" /> + <property name="serverLogName" value="server" /> + --> + + <!-- 1610 Logging Fields Format Revisions --> + <property name="auditLoggerPattern" + value="%X{AuditLogBeginTimestamp}|%X{AuditLogEndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}| %msg%n" /> + + <property name="metricsLoggerPattern" + value="%X{MetricsLogBeginTimestamp}|%X{MetricsLogEndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{TargetVisualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}| %msg%n" /> + + <property name="errorLoggerPattern" + value="%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ClassName}|%X{AlertSeverity}|%X{ErrorCode}|%X{ErrorDescription}| %msg%n" /> + + <property name="defaultLoggerPattern" + value="%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%X{ClassName}| %msg%n" /> + + <!-- use %class so library logging calls yield their class name --> + <property name="applicationLoggerPattern" + value="%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%class{36}| %msg%n" /> + + <!-- Example evaluator filter applied against console appender --> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${defaultLoggerPattern}</pattern> + </encoder> + </appender> + + <!-- ============================================================================ --> + <!-- EELF Appenders --> + <!-- ============================================================================ --> + + <!-- The EELFAppender is used to record events to the general application + log --> + + + <appender name="EELF" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${generalLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- daily rollover --> + <fileNamePattern>${logDirectory}/${generalLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern> + + <!-- keep 30 days' worth of history capped at 3GB total size --> + <maxHistory>30</maxHistory> + <totalSizeCap>3GB</totalSizeCap> + + </rollingPolicy> + <encoder> + <pattern>${applicationLoggerPattern}</pattern> + </encoder> + <filter class="org.onap.portalapp.util.CustomLoggingFilter" /> + </appender> + + <appender name="asyncEELF" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <!-- Class name is part of caller data --> + <includeCallerData>true</includeCallerData> + <appender-ref ref="EELF" /> + </appender> + + <!-- EELF Security Appender. This appender is used to record security events + to the security log file. Security events are separate from other loggers + in EELF so that security log records can be captured and managed in a secure + way separate from the other logs. This appender is set to never discard any + events. --> + <!-- + <appender name="EELFSecurity" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${securityLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${securityLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncEELFSecurity" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <discardingThreshold>0</discardingThreshold> + <appender-ref ref="EELFSecurity" /> + </appender> + --> + + <!-- EELF Performance Appender. This appender is used to record performance + records. --> + <!-- + <appender name="EELFPerformance" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${performanceLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${performanceLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <outputPatternAsHeader>true</outputPatternAsHeader> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFPerformance" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFPerformance" /> + </appender> + --> + + <!-- EELF Server Appender. This appender is used to record Server related + logging events. The Server logger and appender are specializations of the + EELF application root logger and appender. This can be used to segregate Server + events from other components, or it can be eliminated to record these events + as part of the application root log. --> + <!-- + <appender name="EELFServer" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${serverLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${serverLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFServer" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFServer" /> + </appender> + --> + + <!-- EELF Policy Appender. This appender is used to record Policy engine + related logging events. The Policy logger and appender are specializations + of the EELF application root logger and appender. This can be used to segregate + Policy engine events from other components, or it can be eliminated to record + these events as part of the application root log. --> + <!-- + <appender name="EELFPolicy" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${policyLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${policyLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFPolicy" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFPolicy" /> + </appender> + --> + + <!-- EELF Audit Appender. This appender is used to record audit engine + related logging events. The audit logger and appender are specializations + of the EELF application root logger and appender. This can be used to segregate + Policy engine events from other components, or it can be eliminated to record + these events as part of the application root log. --> + + <appender name="EELFAudit" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${auditLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- daily rollover --> + <fileNamePattern>${logDirectory}/${auditLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern> + + <!-- keep 30 days' worth of history capped at 3GB total size --> + <maxHistory>30</maxHistory> + <totalSizeCap>3GB</totalSizeCap> + + </rollingPolicy> + <encoder> + <pattern>${auditLoggerPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFAudit" /> + </appender> + + <appender name="EELFMetrics" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${metricsLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- daily rollover --> + <fileNamePattern>${logDirectory}/${metricsLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern> + + <!-- keep 30 days' worth of history capped at 3GB total size --> + <maxHistory>30</maxHistory> + <totalSizeCap>3GB</totalSizeCap> + + </rollingPolicy> + <encoder> + <pattern>${metricsLoggerPattern}</pattern> + </encoder> + </appender> + + + <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFMetrics"/> + </appender> + + <appender name="EELFError" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${errorLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- daily rollover --> + <fileNamePattern>${logDirectory}/${errorLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern> + + <!-- keep 30 days' worth of history capped at 3GB total size --> + <maxHistory>30</maxHistory> + <totalSizeCap>3GB</totalSizeCap> + + </rollingPolicy> + <encoder> + <pattern>${errorLoggerPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFError"/> + </appender> + + <appender name="EELFDebug" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${debugLogDirectory}/${debugLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- daily rollover --> + <fileNamePattern>${logDirectory}/${debugLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern> + + <!-- keep 30 days' worth of history capped at 3GB total size --> + <maxHistory>30</maxHistory> + <totalSizeCap>3GB</totalSizeCap> + + </rollingPolicy> + <encoder> + <pattern>${defaultLoggerPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFDebug" /> + </appender> + + + + + <logger name="org.onap.eelf" level="info" additivity="false"> + <appender-ref ref="asyncEELF" /> + </logger> + + <logger name="org.onap.eelf.audit" level="info" additivity="false"> + <appender-ref ref="asyncEELFAudit" /> + </logger> + + <logger name="org.onap.eelf.debug" level="debug" additivity="false"> + <appender-ref ref="asyncEELFDebug" /> + </logger> + + <logger name="org.onap.eelf.error" level="info" additivity="false"> + <appender-ref ref="asyncEELFError" /> + </logger> + + <logger name="org.onap.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="asyncEELFMetrics" /> + </logger> + + + <root level="DEBUG"> + <appender-ref ref="asyncEELF" /> + </root> + +</configuration> diff --git a/epsdk-app-onap/src/main/resources/logback_template.xml b/deliveries/src/main/docker/docker-files/conf.d/logback_template.xml index 8753dd8e9..bbc58cf2f 100755 --- a/epsdk-app-onap/src/main/resources/logback_template.xml +++ b/deliveries/src/main/docker/docker-files/conf.d/logback_template.xml @@ -1,341 +1,341 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="3 seconds" debug="true">
- <!-- specify the component name -->
- <property name="componentName" value="vid"></property>
-
- <!-- specify the base path of the log directory -->
- <property name="logDirPrefix" value="${VID_LOG_DIR}"></property>
-
- <!-- The directories where logs are written -->
- <property name="logDirectory" value="${logDirPrefix}/${componentName}" />
- <!-- Can easily relocate debug logs by modifying this path. -->
- <property name="debugLogDirectory" value="${logDirPrefix}/${componentName}" />
-
- <!-- log file names -->
- <property name="generalLogName" value="application" />
- <property name="errorLogName" value="error" />
- <property name="metricsLogName" value="metrics" />
- <property name="auditLogName" value="audit" />
- <property name="debugLogName" value="debug" />
- <!--
- These loggers are not used in code (yet).
- <property name="securityLogName" value="security" />
- <property name="policyLogName" value="policy" />
- <property name="performanceLogName" value="performance" />
- <property name="serverLogName" value="server" />
- -->
-
- <property name="defaultPattern" value="%date{ISO8601}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" />
- <property name="debugLoggerPattern" value="%date{ISO8601}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" />
- <!-- <property name="debugLoggerPattern" value="%date{ISO8601}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|[%caller{3}]|%msg%n" />-->
-
- <!-- Example evaluator filter applied against console appender -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
- <!-- ============================================================================ -->
- <!-- EELF Appenders -->
- <!-- ============================================================================ -->
-
- <!-- The EELFAppender is used to record events to the general application
- log -->
-
-
- <appender name="EELF"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${generalLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${generalLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- <filter class="org.onap.portalapp.util.CustomLoggingFilter" />
- </appender>
-
- <appender name="asyncEELF" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELF" />
- </appender>
-
- <!-- EELF Security Appender. This appender is used to record security events
- to the security log file. Security events are separate from other loggers
- in EELF so that security log records can be captured and managed in a secure
- way separate from the other logs. This appender is set to never discard any
- events. -->
- <!--
- <appender name="EELFSecurity"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${securityLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${securityLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFSecurity" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <discardingThreshold>0</discardingThreshold>
- <appender-ref ref="EELFSecurity" />
- </appender>
- -->
-
- <!-- EELF Performance Appender. This appender is used to record performance
- records. -->
- <!--
- <appender name="EELFPerformance"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${performanceLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${performanceLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <outputPatternAsHeader>true</outputPatternAsHeader>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
- <appender name="asyncEELFPerformance" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFPerformance" />
- </appender>
- -->
-
- <!-- EELF Server Appender. This appender is used to record Server related
- logging events. The Server logger and appender are specializations of the
- EELF application root logger and appender. This can be used to segregate Server
- events from other components, or it can be eliminated to record these events
- as part of the application root log. -->
- <!--
- <appender name="EELFServer"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${serverLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${serverLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
- <appender name="asyncEELFServer" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFServer" />
- </appender>
- -->
-
- <!-- EELF Policy Appender. This appender is used to record Policy engine
- related logging events. The Policy logger and appender are specializations
- of the EELF application root logger and appender. This can be used to segregate
- Policy engine events from other components, or it can be eliminated to record
- these events as part of the application root log. -->
- <!--
- <appender name="EELFPolicy"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${policyLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${policyLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
- <appender name="asyncEELFPolicy" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFPolicy" />
- </appender>
- -->
-
- <!-- EELF Audit Appender. This appender is used to record audit engine
- related logging events. The audit logger and appender are specializations
- of the EELF application root logger and appender. This can be used to segregate
- Policy engine events from other components, or it can be eliminated to record
- these events as part of the application root log. -->
-
- <appender name="EELFAudit"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${auditLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
- <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFAudit" />
- </appender>
-
- <appender name="EELFMetrics"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${metricsLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} -
- %msg%n"</pattern> -->
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
-
- <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFMetrics"/>
- </appender>
-
- <appender name="EELFError"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${errorLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFError"/>
- </appender>
-
- <appender name="EELFDebug"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${debugLogDirectory}/${debugLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${debugLoggerPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFDebug" />
- <includeCallerData>true</includeCallerData>
- </appender>
-
-
- <!-- ============================================================================ -->
- <!-- EELF loggers -->
- <!-- ============================================================================ -->
- <logger name="com.att.eelf" level="debug" additivity="false">
- <appender-ref ref="asyncEELF" />
- </logger>
-
- <!--
- <logger name="com.att.eelf.security" level="info" additivity="false">
- <appender-ref ref="asyncEELFSecurity" />
- </logger>
- <logger name="com.att.eelf.perf" level="info" additivity="false">
- <appender-ref ref="asyncEELFPerformance" />
- </logger>
- <logger name="com.att.eelf.server" level="info" additivity="false">
- <appender-ref ref="asyncEELFServer" />
- </logger>
- <logger name="com.att.eelf.policy" level="info" additivity="false">
- <appender-ref ref="asyncEELFPolicy" />
- </logger>
- -->
-
- <logger name="com.att.eelf.audit" level="info" additivity="false">
- <appender-ref ref="asyncEELFAudit" />
- </logger>
-
- <logger name="com.att.eelf.metrics" level="info" additivity="false">
- <appender-ref ref="asyncEELFMetrics" />
- </logger>
-
- <logger name="com.att.eelf.error" level="info" additivity="false">
- <appender-ref ref="asyncEELFError" />
- </logger>
-
- <logger name="com.att.eelf.debug" level="debug" additivity="false">
- <appender-ref ref="asyncEELFDebug" />
- </logger>
-
-
- <root level="${VID_LOG_LEVEL}">
- <appender-ref ref="asyncEELF" />
- </root>
-
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?> +<configuration scan="true" scanPeriod="3 seconds" debug="true"> + <!-- specify the component name --> + <property name="componentName" value="vid"></property> + + <!-- specify the base path of the log directory --> + <property name="logDirPrefix" value="${VID_LOG_DIR}"></property> + + <!-- The directories where logs are written --> + <property name="logDirectory" value="${logDirPrefix}/${componentName}" /> + <!-- Can easily relocate debug logs by modifying this path. --> + <property name="debugLogDirectory" value="${logDirPrefix}/${componentName}" /> + + <!-- log file names --> + <property name="generalLogName" value="application" /> + <property name="errorLogName" value="error" /> + <property name="metricsLogName" value="metrics" /> + <property name="auditLogName" value="audit" /> + <property name="debugLogName" value="debug" /> + <!-- + These loggers are not used in code (yet). + <property name="securityLogName" value="security" /> + <property name="policyLogName" value="policy" /> + <property name="performanceLogName" value="performance" /> + <property name="serverLogName" value="server" /> + --> + + <property name="defaultPattern" value="%date{ISO8601}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" /> + <property name="debugLoggerPattern" value="%date{ISO8601}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" /> + <!-- <property name="debugLoggerPattern" value="%date{ISO8601}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|[%caller{3}]|%msg%n" />--> + + <!-- Example evaluator filter applied against console appender --> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <!-- ============================================================================ --> + <!-- EELF Appenders --> + <!-- ============================================================================ --> + + <!-- The EELFAppender is used to record events to the general application + log --> + + + <appender name="EELF" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${generalLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${generalLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + <filter class="org.onap.portalapp.util.CustomLoggingFilter" /> + </appender> + + <appender name="asyncEELF" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELF" /> + </appender> + + <!-- EELF Security Appender. This appender is used to record security events + to the security log file. Security events are separate from other loggers + in EELF so that security log records can be captured and managed in a secure + way separate from the other logs. This appender is set to never discard any + events. --> + <!-- + <appender name="EELFSecurity" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${securityLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${securityLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncEELFSecurity" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <discardingThreshold>0</discardingThreshold> + <appender-ref ref="EELFSecurity" /> + </appender> + --> + + <!-- EELF Performance Appender. This appender is used to record performance + records. --> + <!-- + <appender name="EELFPerformance" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${performanceLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${performanceLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <outputPatternAsHeader>true</outputPatternAsHeader> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFPerformance" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFPerformance" /> + </appender> + --> + + <!-- EELF Server Appender. This appender is used to record Server related + logging events. The Server logger and appender are specializations of the + EELF application root logger and appender. This can be used to segregate Server + events from other components, or it can be eliminated to record these events + as part of the application root log. --> + <!-- + <appender name="EELFServer" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${serverLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${serverLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFServer" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFServer" /> + </appender> + --> + + <!-- EELF Policy Appender. This appender is used to record Policy engine + related logging events. The Policy logger and appender are specializations + of the EELF application root logger and appender. This can be used to segregate + Policy engine events from other components, or it can be eliminated to record + these events as part of the application root log. --> + <!-- + <appender name="EELFPolicy" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${policyLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${policyLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFPolicy" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFPolicy" /> + </appender> + --> + + <!-- EELF Audit Appender. This appender is used to record audit engine + related logging events. The audit logger and appender are specializations + of the EELF application root logger and appender. This can be used to segregate + Policy engine events from other components, or it can be eliminated to record + these events as part of the application root log. --> + + <appender name="EELFAudit" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${auditLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFAudit" /> + </appender> + + <appender name="EELFMetrics" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${metricsLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - + %msg%n"</pattern> --> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + + <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFMetrics"/> + </appender> + + <appender name="EELFError" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${errorLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFError"/> + </appender> + + <appender name="EELFDebug" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${debugLogDirectory}/${debugLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${debugLoggerPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFDebug" /> + <includeCallerData>true</includeCallerData> + </appender> + + + <!-- ============================================================================ --> + <!-- EELF loggers --> + <!-- ============================================================================ --> + <logger name="com.att.eelf" level="debug" additivity="false"> + <appender-ref ref="asyncEELF" /> + </logger> + + <!-- + <logger name="com.att.eelf.security" level="info" additivity="false"> + <appender-ref ref="asyncEELFSecurity" /> + </logger> + <logger name="com.att.eelf.perf" level="info" additivity="false"> + <appender-ref ref="asyncEELFPerformance" /> + </logger> + <logger name="com.att.eelf.server" level="info" additivity="false"> + <appender-ref ref="asyncEELFServer" /> + </logger> + <logger name="com.att.eelf.policy" level="info" additivity="false"> + <appender-ref ref="asyncEELFPolicy" /> + </logger> + --> + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="asyncEELFAudit" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="asyncEELFMetrics" /> + </logger> + + <logger name="com.att.eelf.error" level="info" additivity="false"> + <appender-ref ref="asyncEELFError" /> + </logger> + + <logger name="com.att.eelf.debug" level="debug" additivity="false"> + <appender-ref ref="asyncEELFDebug" /> + </logger> + + + <root level="${VID_LOG_LEVEL}"> + <appender-ref ref="asyncEELF" /> + </root> + +</configuration> diff --git a/deliveries/src/main/scripts/localize_logback.sh b/deliveries/src/main/scripts/localize_logback.sh index a0f177337..90ce883cc 100755 --- a/deliveries/src/main/scripts/localize_logback.sh +++ b/deliveries/src/main/scripts/localize_logback.sh @@ -1,7 +1,8 @@ #!/bin/bash -FINAL_CONFIG_FILE=$1/classes/logback.xml -TEMPLATE_CONFIG_FILE=$1/classes/logback_template.xml +BASE_DIR=/etc/onap/vid/conf.d +FINAL_CONFIG_FILE=${BASE_DIR}/logback.xml +TEMPLATE_CONFIG_FILE=${BASE_DIR}/logback_template.xml echo "Localizing the VID logback configuration" diff --git a/deliveries/src/main/scripts/localize_war.sh b/deliveries/src/main/scripts/localize_war.sh index 99cb177ed..53a928e84 100755 --- a/deliveries/src/main/scripts/localize_war.sh +++ b/deliveries/src/main/scripts/localize_war.sh @@ -1,6 +1,6 @@ #!/bin/bash -source /tmp/vid/localize_logback.sh $1 || { +source /tmp/vid/localize_logback.sh || { echo "ERROR: Localizing logback.xml failed" exit 1 } diff --git a/docs/administration.rst b/docs/administration.rst index 7227e702d..1eec480ce 100644 --- a/docs/administration.rst +++ b/docs/administration.rst @@ -23,4 +23,7 @@ Actions | ``curl -X POST 'http://vid.api.simpledemo.onap.org:8080/vid/change-management/vnf_workflow_relation' -H 'Accept-Encoding: gzip, deflate' -H 'Content-Type:application/json' -d '{"workflowsDetails":[{"workflowName":"VNF In Place Software Update","vnfDetails":{"UUID":"X-X-X-X","invariantUUID":"Y-Y-Y-Y"}}, {"workflowName":"VNF Scale Out","vnfDetails":{"UUID":"X-X-X-X","invariantUUID":"Y-Y-Y-Y"}}]}'`` - | **VoLTE E2E services deployment support** - | VID supports VoLTE E2E services deployment. In order to trigger the E2E flow, the service category in the model (as SDC generates it) has to be set to "E2E Service".
\ No newline at end of file + | VID supports VoLTE E2E services deployment. In order to trigger the E2E flow, the service category in the model (as SDC generates it) has to be set to "E2E Service". + +- | **Role management support** + | VID supports role management for its users with AAF integration. This feature is turned off by default. In order to activate it, update "role_management_activated" value in system.properties to "true".
\ No newline at end of file diff --git a/docs/configuration.rst b/docs/configuration.rst index 6357d5aac..ab757387c 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -18,6 +18,9 @@ system.properties file ``db.password`` The password for the VID database +``role_management_activated`` + Role management activation flag, "false" by defauly. Change to "true" in order to activate this feature. + ``aai.server.url.base`` Base URL for the A&AI server diff --git a/docs/installation.rst b/docs/installation.rst index e7a1585a4..f9d12e8b8 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -17,7 +17,7 @@ Please follow the instructions given below, for installing VID using a Docker im docker pull mariadb:10 docker login -u docker -p docker nexus3.onap.org:10001 - docker pull nexus3.onap.org:10001/onap/vid:1.2.1 + docker pull nexus3.onap.org:10001/onap/vid:3.2.1 2. Install by running following command (Use the path for the lf_config folder under the VID git repository as CONFIG_PATH) @@ -27,7 +27,7 @@ Please follow the instructions given below, for installing VID using a Docker im docker run --name vid-mariadb -e MYSQL_DATABASE=vid_openecomp_epsdk -e MYSQL_USER=vidadmin -e MYSQL_PASSWORD=YOUR_PASSWORD -e MYSQL_ROOT_PASSWORD=ROOT_PASSWORD -v CONFIG_PATH/vid-my.cnf:/etc/mysql/my.cnf -v /var/lib/mysql -d mariadb:10 #start VID server - docker run -e VID_MYSQL_DBNAME=vid_openecomp_epsdk -e VID_MYSQL_PASS=YOUR_PASSWORD --name vid-server -p 8080:8080 --link vid-mariadb:vid-mariadb-docker-instance -d nexus3.onap.org:10001/onap/vid:1.2.1 + docker run -e VID_MYSQL_DBNAME=vid_openecomp_epsdk -e VID_MYSQL_PASS=YOUR_PASSWORD --name vid-server -p 8080:8080 --link vid-mariadb:vid-mariadb-docker-instance -d nexus3.onap.org:10001/onap/vid:3.2.1 Or use docker-compose: diff --git a/docs/offeredapis.rst b/docs/offeredapis.rst index 4408bf6f0..c39e2c27c 100644 --- a/docs/offeredapis.rst +++ b/docs/offeredapis.rst @@ -17,7 +17,7 @@ Offered APIs +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | - statusCode Either 200 or 500 | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | - The message contains additional detail in the case of an error, and is empty in the case of success. | +| | | | - detailedMsg of the result, in case of failure particular error message | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -25,11 +25,11 @@ Offered APIs +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | { | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “statusCode”:200, | +| | | | “statusCode”: 200, | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “message”:“health check succeeded”, | +| | | | “detailedMsg”: “health check succeeded”, | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “date”:null | +| | | | “date”: current date | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | } | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -47,7 +47,7 @@ Offered APIs +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | - statusCode Either 200 or 500 | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | - message contains additional detail in the case of an error, and is empty in the case of success. | +| | | | - detailedMsg of the result, in case of failure particular error message | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | - date string indicating the current date & time | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -57,9 +57,9 @@ Offered APIs +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | { | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “statusCode”:200, | +| | | | “statusCode”: 200, | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “message”:“health check succeeded”, | +| | | | “detailedMsg”: “health check succeeded”, | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | “date”: current date | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -69,79 +69,33 @@ Offered APIs +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Change management | GET | change-management/workflow {vnfStringsList} | Get Workflow details for the VNFs list | +| Commit Version | GET | /commitInfo | Displays info about the last commit of the running build | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | Expected HTTP Code 200 | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Change management | GET | change-management/mso | Get MSO Change Management details | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | [{“requestId”:“”,“requestScope”:“vnf”,“requestStatus”:{“percentProgress”:, | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “requestState”:“FAILED”, | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “statusMessage”:“Service request FAILED schema validation. No valid vnf-id is specified”, | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “finishTime”:“Fri, 20 May 2016 13:36:53 GMT”}, | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “requestType”:“updateInstance”, | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “startTime”:“Fri, 20 May 2016 13:36:53 GMT”, | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | “instanceReferences”:{“vnfInstanceName”:“ZRDM1PCRF01”,“vfModuleInstanceName”:“ZRDM1PCRF01-PCRF::base::module-0”,“volumeGroupInstanceId”:“1cc27274-1376-4168-af5d-3e35d1365a4c”}}, {…}…] | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | | +| | | | return response entity: | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | Expected HTTP Code 200 | +| | | | - commitId full id of the commit | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | | +| | | | - commitMessageShort short message from the commit | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Change management | POST | change-management/workflow/{vnfName} | Post workflow request for vnf | +| | | | - commitTime time of the commit | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | Request body: | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | | +| | | | Expected: | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | requestDetails:{ | +| | | | { | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | vnfName: vnfNAME | +| | | | “commitId”: id of the last commit | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | vnfInstanceId: ID | +| | | | “commitMessageShort”: short message of the last commit | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | RelatedInstanceList:[ ] | +| | | | “commitTime”: time of the last commit | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | } | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | requestType: | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | Expected HTTP Code 200 | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Change management | GET | change-management/scheduler | Get Scheduler Change Management Details | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | | | | +---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | Expected | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | HTTP Code 200 | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | response: Scheduler details in json | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | Explicit HTTP Error Codes | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | 404, 406 | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| | | | | -+---------------------+----------+-------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
\ No newline at end of file diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 89e1919df..962fe1b07 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -3,6 +3,67 @@ VID Release Notes ================= +Version: 3.2.2 +-------------- + +:Release Date: 2018-11-30 + +New Features +------------ +1. PNF plug & play services instantiation. +2. HTTPS support. +3. Manual vNF Scale Out enhancements. + +**Epics** + +- [`VID-159`_] - AAF integration +- [`VID-194`_] - PNF Use case support +- [`VID-248`_] - Support scaling use case +- [`VID-254`_] - Usability +- [`VID-258`_] - Security + +.. _VID-159: /browse/VID-159 +.. _VID-194: /browse/VID-194 +.. _VID-248: /browse/VID-248 +.. _VID-254: /browse/VID-254 +.. _VID-258: /browse/VID-258 + +**Stories** + +- [`VID-166`_] - Improve CSIT coverage +- [`VID-203`_] - PNF Plug & Play use case with vCPE flow +- [`VID-236`_] - Align OOM templates +- [`VID-249`_] - Change Manual Scaling Use Case to use the same SO API that Policy is using in Auto Scaling +- [`VID-250`_] - Remove Controller Type from the VID GUI and from the request sent to SO +- [`VID-256`_] - Add tutorials/user guides +- [`VID-257`_] - AAF integration +- [`VID-260`_] - Use HTTPS for external interfaces +- [`VID-261`_] - Use HTTPS for internal interfaces + +.. _VID-166: /browse/VID-166 +.. _VID-203: /browse/VID-203 +.. _VID-236: /browse/VID-236 +.. _VID-249: /browse/VID-249 +.. _VID-250: /browse/VID-250 +.. _VID-256: /browse/VID-256 +.. _VID-257: /browse/VID-257 +.. _VID-260: /browse/VID-260 +.. _VID-261: /browse/VID-261 + +**Security Notes** + +VID code has been formally scanned during build time using NexusIQ and all Critical vulnerabilities have been addressed, items that remain open have been assessed for risk and determined to be false positive. The VID open Critical security vulnerabilities and their risk assessment have been documented as part of the `project <https://wiki.onap.org/pages/viewpage.action?pageId=45300871>`_. + +Quick Links: + +- `VID project page <https://wiki.onap.org/display/DW/Virtual+Infrastructure+Deployment+Project>`_ +- `Passing Badge information for VID <https://bestpractices.coreinfrastructure.org/en/projects/1658>`_ +- `Project Vulnerability Review Table for VID <https://wiki.onap.org/pages/viewpage.action?pageId=45300871>`_ + +**Other** + +In order to work properly, VID needs a working instance of SDC, A&AI and SO. + Version: 2.0.0 -------------- diff --git a/epsdk-app-onap/pom.xml b/epsdk-app-onap/pom.xml index 9b0136f0c..85731d1b9 100755 --- a/epsdk-app-onap/pom.xml +++ b/epsdk-app-onap/pom.xml @@ -319,6 +319,10 @@ <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>com.lowagie</groupId>
+ <artifactId>itext</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
diff --git a/epsdk-app-onap/src/main/resources/vid-data.sql b/epsdk-app-onap/src/main/resources/vid-data.sql index e2af216e6..9c48f853b 100755 --- a/epsdk-app-onap/src/main/resources/vid-data.sql +++ b/epsdk-app-onap/src/main/resources/vid-data.sql @@ -625,6 +625,12 @@ REPLACE INTO `fn_restricted_url` VALUES ('serviceModels.htm','menu_servicemodels --
INSERT INTO `fn_role` VALUES (1,'System Administrator','Y',1) ON DUPLICATE KEY UPDATE ROLE_NAME='System Administrator', ACTIVE_YN='Y', PRIORITY=1;
INSERT INTO `fn_role` VALUES (16,'Standard User','Y',5) ON DUPLICATE KEY UPDATE ROLE_NAME='Standard User', ACTIVE_YN='Y', PRIORITY=5;
+INSERT INTO `fn_role` VALUES (17,'Demonstration___vFWCL','Y',5) ON DUPLICATE KEY UPDATE ROLE_NAME='Demonstration___vFWCL', ACTIVE_YN='Y', PRIORITY=5;
+INSERT INTO `fn_role` VALUES (18,'Demonstration___vFW','Y',5) ON DUPLICATE KEY UPDATE ROLE_NAME='Demonstration___vFW', ACTIVE_YN='Y', PRIORITY=5;
+INSERT INTO `fn_role` VALUES (19,'Demonstration___vCPE','Y',5) ON DUPLICATE KEY UPDATE ROLE_NAME='Demonstration___vCPE', ACTIVE_YN='Y', PRIORITY=5;
+INSERT INTO `fn_role` VALUES (20,'Demonstration___vIMS','Y',5) ON DUPLICATE KEY UPDATE ROLE_NAME='Demonstration___vIMS', ACTIVE_YN='Y', PRIORITY=5;
+INSERT INTO `fn_role` VALUES (21,'Demonstration___vLB','Y',5) ON DUPLICATE KEY UPDATE ROLE_NAME='Demonstration___vLB', ACTIVE_YN='Y', PRIORITY=5;
+INSERT INTO `fn_role` VALUES (22,'Demonstration___gNB','Y',5) ON DUPLICATE KEY UPDATE ROLE_NAME='Demonstration___gNB', ACTIVE_YN='Y', PRIORITY=5;
--
-- Dumping data for table `fn_role_composite`
@@ -735,3 +741,10 @@ INSERT IGNORE `fn_user_role` VALUES (2,1,NULL,1); INSERT IGNORE `fn_user_role` VALUES (3,1,NULL,1);
INSERT IGNORE `fn_user_role` VALUES (4,1,NULL,1);
INSERT IGNORE `fn_user_role` VALUES (5,1,NULL,1);
+INSERT IGNORE `fn_user_role` VALUES (1,17,NULL,1);
+INSERT IGNORE `fn_user_role` VALUES (1,18,NULL,1);
+INSERT IGNORE `fn_user_role` VALUES (1,19,NULL,1);
+INSERT IGNORE `fn_user_role` VALUES (1,20,NULL,1);
+INSERT IGNORE `fn_user_role` VALUES (1,21,NULL,1);
+INSERT IGNORE `fn_user_role` VALUES (1,22,NULL,1);
+
@@ -3,6 +3,7 @@ <modelVersion>4.0.0</modelVersion>
<groupId>org.onap.vid</groupId>
<artifactId>vid-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>vid</name>
@@ -268,5 +269,4 @@ <version>4.5.3</version>
</dependency>
</dependencies>
- <version>4.0.0-SNAPSHOT</version>
</project>
diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml index 479510368..658bf71d5 100755 --- a/vid-app-common/pom.xml +++ b/vid-app-common/pom.xml @@ -1,583 +1,595 @@ -<?xml version="1.0"?>
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
-
- <!-- This is the Maven project object model (POM) file for VID web application
- based on the ECOMP SDK distribution. This file stands alone; it does not
- inherit from a parent maven module. -->
- <groupId>org.onap.vid</groupId>
- <artifactId>vid-app-common</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <packaging>war</packaging>
- <name>VID Common</name>
- <description>VID Common code for opensource version</description>
-
- <properties>
- <encoding>UTF-8</encoding>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <epsdk.version>2.4.0</epsdk.version>
- <springframework.version>4.2.9.RELEASE</springframework.version>
- <hibernate.version>4.3.11.Final</hibernate.version>
- <!-- Skip assembling the zip by default -->
- <skipassembly>true</skipassembly>
- <!-- Tests usually require some setup that maven cannot do, so skip. -->
- <skiptests>false</skiptests>
- <nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/vid/${project.version}</sitePath>
- </properties>
-
-
- <!-- this should be commented for local debugging -->
- <!-- <deployenv>local</deployenv> -->
-
- <repositories>
- <repository>
- <id>ecomp-releases</id>
- <name>VID Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
- </repository>
- <repository>
- <id>ecomp-snapshots</id>
- <name>VID Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
- </repository>
- <repository>
- <id>ecomp-staging</id>
- <name>VID Staging Repository</name>
- <url>${nexusproxy}${stagingNexusPath}</url>
- </repository>
- <repository>
- <!-- Snapshots repository has ECOMP snapshot artifacts -->
- <id>oss-snapshots</id>
- <name>oss Central - Snapshots</name>
- <url>https://oss.sonatype.org/service/local/repositories/releases/content/</url>
- </repository>
-
- </repositories>
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>VID Release Repository</name>
- <url>${nexusproxy}/${releaseNexusPath}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>VID Snapshot Repository</name>
- <url>${nexusproxy}/${snapshotNexusPath}</url>
- </snapshotRepository>
- <!-- added for javadoc -->
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
-
- <build>
- <finalName>vid-common</finalName>
-
- <plugins>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>0.7.9</version>
- <executions>
- <execution>
- <id>default-prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- <execution>
- <id>default-report</id>
- <goals>
- <goal>report</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat6-maven-plugin</artifactId>
- <version>2.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
- <version>2.2</version>
- </plugin>
-
- <!-- Generate POJOs from MSO json schema -->
- <plugin>
- <groupId>org.jsonschema2pojo</groupId>
- <artifactId>jsonschema2pojo-maven-plugin</artifactId>
- <version>0.4.23</version>
- <configuration>
- <sourceDirectory>${basedir}/src/main/resources/json/mso</sourceDirectory>
- <targetPackage>org.onap.vid.domain.mso</targetPackage>
- <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.19.1</version>
- <configuration>
- <skipTests>${skiptests}</skipTests>
- <includes>
- <include>**/Test*.java</include>
- <include>**/*Test.java</include>
- <include>**/*TestCase.java</include>
- </includes>
- <excludes>
- <exclude>**/selenium/*.java</exclude>
- <exclude>**/integrationTest/*.java</exclude>
- </excludes>
- <additionalClasspathElements>
- <additionalClasspathElement>${basedir}/war</additionalClasspathElement>
- </additionalClasspathElements>
- <systemPropertyVariables>
- <container.classpath>classpath:</container.classpath>
- </systemPropertyVariables>
- </configuration>
- </plugin>
-
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <skipAssembly>${skipassembly}</skipAssembly>
- <descriptors>
- <descriptor>${basedir}/distribution.xml</descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>3.0.0</version>
- <configuration>
- <!-- Build a jar with all the Java classes -->
- <attachClasses>true</attachClasses>
- <!-- Do not put any jars in the war -->
- <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.6</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-webdav-jackrabbit</artifactId>
- <version>2.10</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>pl.project13.maven</groupId>
- <artifactId>git-commit-id-plugin</artifactId>
- <version>2.2.4</version>
- <executions>
- <execution>
- <id>get-the-git-infos</id>
- <goals>
- <goal>revision</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
- <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
- <dateFormatTimeZone>${user.timezone}</dateFormatTimeZone>
- <generateGitPropertiesFile>true</generateGitPropertiesFile>
- <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
- <includeOnlyProperties>
- <includeOnlyProperty>^git.commit.id$</includeOnlyProperty>
- <includeOnlyProperty>^git.commit.message.short$</includeOnlyProperty>
- <includeOnlyProperty>^git.commit.time$</includeOnlyProperty>
- </includeOnlyProperties>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
- <docletArtifact>
- <groupId>org.umlgraph</groupId>
- <artifactId>umlgraph</artifactId>
- <version>5.6</version>
- </docletArtifact>
- <additionalparam>-views</additionalparam>
- <useStandardDocletOptions>true</useStandardDocletOptions>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-
- <dependencies>
-
- <dependency>
- <groupId>com.opencsv</groupId>
- <artifactId>opencsv</artifactId>
- <version>4.1</version>
- </dependency>
-
- <!-- HTTP client -->
-
- <dependency>
- <groupId>io.joshworks.unirest</groupId>
- <artifactId>unirest-java</artifactId>
- <version>0.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.3.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpasyncclient</artifactId>
- <version>4.0.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpmime</artifactId>
- <version>4.3.6</version>
- </dependency>
- <dependency>
- <groupId>com.xebialabs.restito</groupId>
- <artifactId>restito</artifactId>
- <version>0.9.3</version>
- <scope>test</scope>
- </dependency>
-
- <!-- Helpers -->
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- <version>1.18.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>io.vavr</groupId>
- <artifactId>vavr</artifactId>
- <version>0.9.2</version>
- </dependency>
-
- <!-- SDK overlay war -->
- <dependency>
- <groupId>org.onap.portal.sdk</groupId>
- <artifactId>epsdk-app-overlay</artifactId>
- <version>${epsdk.version}</version>
- <type>war</type>
- </dependency>
- <dependency>
- <groupId>org.onap.portal.sdk</groupId>
- <artifactId>epsdk-app-common</artifactId>
- <version>${epsdk.version}</version>
- <type>jar</type>
- </dependency>
-
- <dependency>
- <groupId>org.onap.portal.sdk</groupId>
- <artifactId>epsdk-core</artifactId>
- <version>${epsdk.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.portal.sdk</groupId>
- <artifactId>epsdk-analytics</artifactId>
- <version>${epsdk.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.portal.sdk</groupId>
- <artifactId>epsdk-workflow</artifactId>
- <version>${epsdk.version}</version>
- </dependency>
- <dependency>
- <groupId>com.att.eelf</groupId>
- <artifactId>eelf-core</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>1.2.3</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.2.3</version>
- </dependency>
-
- <!-- Mapper -->
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- <version>2.6.3</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- <version>2.8.6</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.6.7.1</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.9.13</version>
- </dependency>
- <dependency>
- <groupId>com.mchange</groupId>
- <artifactId>c3p0</artifactId>
- <version>0.9.5.2</version>
- </dependency>
- <dependency>
- <groupId>io.searchbox</groupId>
- <artifactId>jest</artifactId>
- <version>2.0.0</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.1.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- <!--<scope>test</scope>-->
- </dependency>
- <dependency>
- <groupId>com.google.code.bean-matchers</groupId>
- <artifactId>bean-matchers</artifactId>
- <version>0.11</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20160212</version>
- </dependency>
- <dependency>
- <groupId>org.quartz-scheduler</groupId>
- <artifactId>quartz</artifactId>
- <version>2.2.1</version>
- <exclusions>
- <!-- exclude 0.9.1.1 to avoid dupe of com.mchange:c3p0:0.9.2.1 -->
- <exclusion>
- <groupId>c3p0</groupId>
- <artifactId>c3p0</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <!-- bridge to implement commons-logging using slf4j -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>1.7.12</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>${springframework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${springframework.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${springframework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-tx</artifactId>
- <version>${springframework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>${springframework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- <version>${springframework.version}</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-client</artifactId>
- <version>2.23.1</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.connectors</groupId>
- <artifactId>jersey-jetty-connector</artifactId>
- <version>2.23.1</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-json-provider</artifactId>
- <version>2.6.3</version>
- </dependency>
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.9.3</version>
- </dependency>
- <dependency>
- <groupId>com.googlecode.json-simple</groupId>
- <artifactId>json-simple</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.seleniumhq.selenium</groupId>
- <artifactId>selenium-java</artifactId>
- <version>2.53.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.seleniumhq.selenium</groupId>
- <artifactId>selenium-api</artifactId>
- <version>2.53.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>6.8</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.seleniumhq.selenium</groupId>
- <artifactId>selenium-firefox-driver</artifactId>
- <version>2.53.1</version>
- </dependency>
- <dependency>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- <version>1.4.01</version>
- </dependency>
- <dependency>
- <groupId>org.yaml</groupId>
- <artifactId>snakeyaml</artifactId>
- <version>1.16</version>
- </dependency>
- <dependency>
- <groupId>org.skyscreamer</groupId>
- <artifactId>jsonassert</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>org.onap.sdc.sdc-tosca</groupId>
- <artifactId>sdc-tosca</artifactId>
- <version>1.4.1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>net.javacrumbs.json-unit</groupId>
- <artifactId>json-unit</artifactId>
- <version>1.23.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-text</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <version>2.0.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.togglz</groupId>
- <artifactId>togglz-spring-core</artifactId>
- <version>2.5.0.Final</version>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>3.10.0</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0"?> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + + <!-- This is the Maven project object model (POM) file for VID web application + based on the ECOMP SDK distribution. This file stands alone; it does not + inherit from a parent maven module. --> + <groupId>org.onap.vid</groupId> + <artifactId>vid-app-common</artifactId> + <version>4.0.0-SNAPSHOT</version> + <packaging>war</packaging> + <name>VID Common</name> + <description>VID Common code for opensource version</description> + + <properties> + <encoding>UTF-8</encoding> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <epsdk.version>2.4.0</epsdk.version> + <springframework.version>4.2.9.RELEASE</springframework.version> + <hibernate.version>4.3.11.Final</hibernate.version> + <!-- Skip assembling the zip by default --> + <skipassembly>true</skipassembly> + <!-- Tests usually require some setup that maven cannot do, so skip. --> + <skiptests>false</skiptests> + <nexusproxy>https://nexus.onap.org</nexusproxy> + <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath> + <releaseNexusPath>/content/repositories/releases/</releaseNexusPath> + <stagingNexusPath>/content/repositories/staging/</stagingNexusPath> + <sitePath>/content/sites/site/org/onap/vid/${project.version}</sitePath> + </properties> + + + <!-- this should be commented for local debugging --> + <!-- <deployenv>local</deployenv> --> + + <repositories> + <repository> + <id>ecomp-releases</id> + <name>VID Release Repository</name> + <url>${nexusproxy}${releaseNexusPath}</url> + </repository> + <repository> + <id>ecomp-snapshots</id> + <name>VID Snapshot Repository</name> + <url>${nexusproxy}${snapshotNexusPath}</url> + </repository> + <repository> + <id>ecomp-staging</id> + <name>VID Staging Repository</name> + <url>${nexusproxy}${stagingNexusPath}</url> + </repository> + <repository> + <!-- Snapshots repository has ECOMP snapshot artifacts --> + <id>oss-snapshots</id> + <name>oss Central - Snapshots</name> + <url>https://oss.sonatype.org/service/local/repositories/releases/content/</url> + </repository> + + </repositories> + <distributionManagement> + <repository> + <id>ecomp-releases</id> + <name>VID Release Repository</name> + <url>${nexusproxy}/${releaseNexusPath}</url> + </repository> + <snapshotRepository> + <id>ecomp-snapshots</id> + <name>VID Snapshot Repository</name> + <url>${nexusproxy}/${snapshotNexusPath}</url> + </snapshotRepository> + <!-- added for javadoc --> + <site> + <id>ecomp-site</id> + <url>dav:${nexusproxy}${sitePath}</url> + </site> + </distributionManagement> + + <build> + <finalName>vid-common</finalName> + + <plugins> + <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>nexus-staging-maven-plugin</artifactId> + <version>1.6.7</version> + <extensions>true</extensions> + <configuration> + <nexusUrl>${nexusproxy}</nexusUrl> + <stagingProfileId>176c31dfe190a</stagingProfileId> + <serverId>ecomp-staging</serverId> + </configuration> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <version>0.7.9</version> + <executions> + <execution> + <id>default-prepare-agent</id> + <goals> + <goal>prepare-agent</goal> + </goals> + </execution> + <execution> + <id>default-report</id> + <goals> + <goal>report</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.tomcat.maven</groupId> + <artifactId>tomcat6-maven-plugin</artifactId> + <version>2.2</version> + </plugin> + <plugin> + <groupId>org.apache.tomcat.maven</groupId> + <artifactId>tomcat7-maven-plugin</artifactId> + <version>2.2</version> + </plugin> + + <!-- Generate POJOs from MSO json schema --> + <plugin> + <groupId>org.jsonschema2pojo</groupId> + <artifactId>jsonschema2pojo-maven-plugin</artifactId> + <version>0.4.23</version> + <configuration> + <sourceDirectory>${basedir}/src/main/resources/json/mso</sourceDirectory> + <targetPackage>org.onap.vid.domain.mso</targetPackage> + <outputDirectory>${project.build.directory}/generated-sources</outputDirectory> + </configuration> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.19.1</version> + <configuration> + <skipTests>${skiptests}</skipTests> + <includes> + <include>**/Test*.java</include> + <include>**/*Test.java</include> + <include>**/*TestCase.java</include> + </includes> + <excludes> + <exclude>**/selenium/*.java</exclude> + <exclude>**/integrationTest/*.java</exclude> + </excludes> + <additionalClasspathElements> + <additionalClasspathElement>${basedir}/war</additionalClasspathElement> + </additionalClasspathElements> + <systemPropertyVariables> + <container.classpath>classpath:</container.classpath> + </systemPropertyVariables> + </configuration> + </plugin> + + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <skipAssembly>${skipassembly}</skipAssembly> + <descriptors> + <descriptor>${basedir}/distribution.xml</descriptor> + </descriptors> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>3.0.0</version> + <configuration> + <!-- Build a jar with all the Java classes --> + <attachClasses>true</attachClasses> + <!-- Do not put any jars in the war --> + <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <version>3.6</version> + <dependencies> + <dependency> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-webdav-jackrabbit</artifactId> + <version>2.10</version> + </dependency> + </dependencies> + </plugin> + <plugin> + <groupId>pl.project13.maven</groupId> + <artifactId>git-commit-id-plugin</artifactId> + <version>2.2.4</version> + <executions> + <execution> + <id>get-the-git-infos</id> + <goals> + <goal>revision</goal> + </goals> + </execution> + </executions> + <configuration> + <dotGitDirectory>${project.basedir}/.git</dotGitDirectory> + <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat> + <dateFormatTimeZone>${user.timezone}</dateFormatTimeZone> + <generateGitPropertiesFile>true</generateGitPropertiesFile> + <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename> + <includeOnlyProperties> + <includeOnlyProperty>^git.commit.id$</includeOnlyProperty> + <includeOnlyProperty>^git.commit.message.short$</includeOnlyProperty> + <includeOnlyProperty>^git.commit.time$</includeOnlyProperty> + </includeOnlyProperties> + </configuration> + </plugin> + </plugins> + </build> + + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.10.4</version> + <configuration> + <failOnError>false</failOnError> + <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet> + <docletArtifact> + <groupId>org.umlgraph</groupId> + <artifactId>umlgraph</artifactId> + <version>5.6</version> + </docletArtifact> + <additionalparam>-views</additionalparam> + <useStandardDocletOptions>true</useStandardDocletOptions> + </configuration> + </plugin> + </plugins> + </reporting> + + <dependencies> + + <dependency> + <groupId>com.opencsv</groupId> + <artifactId>opencsv</artifactId> + <version>4.1</version> + </dependency> + + <!-- HTTP client --> + + <dependency> + <groupId>io.joshworks.unirest</groupId> + <artifactId>unirest-java</artifactId> + <version>0.2.1</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.3.6</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpasyncclient</artifactId> + <version>4.0.2</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpmime</artifactId> + <version>4.3.6</version> + </dependency> + <dependency> + <groupId>com.xebialabs.restito</groupId> + <artifactId>restito</artifactId> + <version>0.9.3</version> + <scope>test</scope> + </dependency> + + <!-- Helpers --> + <dependency> + <groupId>io.vavr</groupId> + <artifactId>vavr</artifactId> + <version>0.9.2</version> + </dependency> + + <!-- SDK overlay war --> + <dependency> + <groupId>org.onap.portal.sdk</groupId> + <artifactId>epsdk-app-overlay</artifactId> + <version>${epsdk.version}</version> + <type>war</type> + </dependency> + <dependency> + <groupId>org.onap.portal.sdk</groupId> + <artifactId>epsdk-app-common</artifactId> + <version>${epsdk.version}</version> + <type>jar</type> + </dependency> + + <dependency> + <groupId>org.onap.portal.sdk</groupId> + <artifactId>epsdk-core</artifactId> + <version>${epsdk.version}</version> + </dependency> + <dependency> + <groupId>org.onap.portal.sdk</groupId> + <artifactId>epsdk-analytics</artifactId> + <version>${epsdk.version}</version> + <exclusions> + <exclusion> + <groupId>com.lowagie</groupId> + <artifactId>itext</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.portal.sdk</groupId> + <artifactId>epsdk-workflow</artifactId> + <version>${epsdk.version}</version> + </dependency> + <dependency> + <groupId>com.att.eelf</groupId> + <artifactId>eelf-core</artifactId> + <version>1.0.0</version> + <exclusions> + <exclusion> + <artifactId>powermock-api-mockito</artifactId> + <groupId>org.powermock</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>1.2.3</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.2.3</version> + </dependency> + + <!-- Mapper --> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>2.6.3</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>2.8.6</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.6.7.1</version> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-mapper-asl</artifactId> + <version>1.9.13</version> + </dependency> + <dependency> + <groupId>com.mchange</groupId> + <artifactId>c3p0</artifactId> + <version>0.9.5.2</version> + </dependency> + <dependency> + <groupId>io.searchbox</groupId> + <artifactId>jest</artifactId> + <version>2.0.0</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + <!--<scope>test</scope>--> + </dependency> + <dependency> + <groupId>com.google.code.bean-matchers</groupId> + <artifactId>bean-matchers</artifactId> + <version>0.11</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20160212</version> + </dependency> + <dependency> + <groupId>org.quartz-scheduler</groupId> + <artifactId>quartz</artifactId> + <version>2.2.1</version> + <exclusions> + <!-- exclude 0.9.1.1 to avoid dupe of com.mchange:c3p0:0.9.2.1 --> + <exclusion> + <groupId>c3p0</groupId> + <artifactId>c3p0</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- bridge to implement commons-logging using slf4j --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>1.7.12</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>${springframework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${springframework.version}</version> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> + <version>${springframework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-tx</artifactId> + <version>${springframework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${springframework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-webmvc</artifactId> + <version>${springframework.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + <version>2.23.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.connectors</groupId> + <artifactId>jersey-jetty-connector</artifactId> + <version>2.23.1</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.jaxrs</groupId> + <artifactId>jackson-jaxrs-json-provider</artifactId> + <version>2.6.3</version> + </dependency> + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + <version>1.9.3</version> + </dependency> + <dependency> + <groupId>com.googlecode.json-simple</groupId> + <artifactId>json-simple</artifactId> + <version>1.1.1</version> + </dependency> + <dependency> + <groupId>org.seleniumhq.selenium</groupId> + <artifactId>selenium-java</artifactId> + <version>2.53.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.seleniumhq.selenium</groupId> + <artifactId>selenium-api</artifactId> + <version>2.53.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.8</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>2.23.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.seleniumhq.selenium</groupId> + <artifactId>selenium-firefox-driver</artifactId> + <version>2.53.1</version> + </dependency> + <dependency> + <groupId>xml-apis</groupId> + <artifactId>xml-apis</artifactId> + <version>1.4.01</version> + </dependency> + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + <version>1.16</version> + </dependency> + <dependency> + <groupId>org.skyscreamer</groupId> + <artifactId>jsonassert</artifactId> + <version>1.5.0</version> + </dependency> + <dependency> + <groupId>org.onap.sdc.sdc-tosca</groupId> + <artifactId>sdc-tosca</artifactId> + <version>1.4.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>net.javacrumbs.json-unit</groupId> + <artifactId>json-unit</artifactId> + <version>1.23.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-text</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>java-hamcrest</artifactId> + <version>2.0.0.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.togglz</groupId> + <artifactId>togglz-spring-core</artifactId> + <version>2.5.0.Final</version> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <version>3.10.0</version> + <scope>compile</scope> + </dependency> + </dependencies> +</project> diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java index c1964c161..baf92b880 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java @@ -8,16 +8,17 @@ import org.codehaus.jackson.map.ObjectMapper; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.vid.aai.model.AaiGetAicZone.AicZones; import org.onap.vid.aai.model.*; import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.*; import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList; import org.onap.vid.aai.model.AaiGetPnfs.Pnf; import org.onap.vid.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone; -import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse; import org.onap.vid.aai.model.Relationship; import org.onap.vid.aai.model.RelationshipData; import org.onap.vid.aai.model.RelationshipList; +import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse; import org.onap.vid.aai.util.AAIRestInterface; import org.onap.vid.aai.util.VidObjectMapperType; import org.onap.vid.exceptions.GenericUncheckedException; @@ -26,7 +27,6 @@ import org.onap.vid.model.probes.ErrorMetadata; import org.onap.vid.model.probes.ExternalComponentStatus; import org.onap.vid.model.probes.HttpRequestMetadata; import org.onap.vid.utils.Logging; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.web.util.UriUtils; import javax.inject.Inject; @@ -37,7 +37,10 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.UUID; import static java.util.Collections.emptyList; import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; @@ -297,6 +300,10 @@ public class AaiClient implements AaiClientInterface { @Override public Response getVersionByInvariantId(List<String> modelInvariantId) { + if (modelInvariantId.isEmpty()) { + throw new GenericUncheckedException("Zero invariant-ids provided to getVersionByInvariantId; request is rejected as this will cause full models listing"); + } + StringBuilder sb = new StringBuilder(); for (String id : modelInvariantId){ sb.append(MODEL_INVARIANT_ID); @@ -413,9 +420,7 @@ public class AaiClient implements AaiClientInterface { } else { logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscribers() resp=" + resp.getStatusInfo().toString()); if (resp.getStatus() != HttpStatus.SC_OK) { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI"); - String rawData = resp.readEntity(String.class); - subscriberDataResponse = new AaiResponse<>(null, rawData, resp.getStatus()); + subscriberDataResponse = processFailureResponse(resp,responseBody); } else { subscriberDataResponse = processOkResponse(resp, classType, responseBody, omType, propagateExceptions); } @@ -423,6 +428,17 @@ public class AaiClient implements AaiClientInterface { return subscriberDataResponse; } + private AaiResponse processFailureResponse(Response resp, String responseBody) { + logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI"); + String rawData; + if (responseBody != null) { + rawData = responseBody; + } else { + rawData = resp.readEntity(String.class); + } + return new AaiResponse<>(null, rawData, resp.getStatus()); + } + private AaiResponse processOkResponse(Response resp, Class classType, String responseBody, VidObjectMapperType omType, boolean propagateExceptions) { AaiResponse subscriberDataResponse; String finalResponse = null; diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java new file mode 100644 index 000000000..6e25e2715 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2018 Nokia Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.aai; + +import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.ACCEPT; +import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.CONTENT_TYPE; +import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.FROM_APP_ID_HEADER; +import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.REQUEST_ID; +import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.TRANSACTION_ID_HEADER; + +import io.joshworks.restclient.http.HttpResponse; +import io.vavr.collection.HashMap; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.Collections; +import java.util.Map; +import javax.ws.rs.core.MediaType; +import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.vid.aai.model.AaiNodeQueryResponse; +import org.onap.vid.aai.model.ResourceType; +import org.onap.vid.aai.util.AAIProperties; +import org.onap.vid.client.SyncRestClientInterface; +import org.onap.vid.model.SubscriberList; + +public class AaiOverTLSClient implements AaiOverTLSClientInterface { + + private final AaiOverTLSPropertySupplier propertySupplier; + private SyncRestClientInterface syncRestClient; + private boolean useClientCert; + private static final String CALLER_APP_ID = "VidAaiController"; + private String urlBase; + + public AaiOverTLSClient(SyncRestClientInterface syncRestClient, AaiOverTLSPropertySupplier propertySupplier) { + this(syncRestClient, propertySupplier, SystemProperties.getProperty(AAIProperties.AAI_SERVER_URL)); + } + + AaiOverTLSClient(SyncRestClientInterface syncRestClient, AaiOverTLSPropertySupplier propertySupplier, String baseUrl) { + this.syncRestClient = syncRestClient; + this.propertySupplier = propertySupplier; + this.urlBase = baseUrl; + } + + @Override + public void setUseClientCert(boolean useClientCert) { + this.useClientCert = useClientCert; + } + + @Override + public HttpResponse<AaiNodeQueryResponse> searchNodeTypeByName(String name, ResourceType type) { + String uri = urlBase + String.format(URIS.NODE_TYPE_BY_NAME, type.getAaiFormat(), type.getNameFilter(), name); + return syncRestClient.get(uri, getRequestHeaders(), Collections.emptyMap(), AaiNodeQueryResponse.class); + } + + @Override + public HttpResponse<SubscriberList> getAllSubscribers() { + String uri = urlBase + String.format(URIS.SUBSCRIBERS, 0); + return syncRestClient.get(uri, getRequestHeaders(), Collections.emptyMap(), SubscriberList.class); + } + + private Map<String, String> getRequestHeaders() { + Map<String, String> result = HashMap.of( + TRANSACTION_ID_HEADER, propertySupplier.getRandomUUID(), + FROM_APP_ID_HEADER, CALLER_APP_ID, + CONTENT_TYPE, MediaType.APPLICATION_JSON, + REQUEST_ID, propertySupplier.getRequestId(), + ACCEPT, MediaType.APPLICATION_JSON) + .toJavaMap(); + result.putAll(getAuthorizationHeader()); + return result; + } + + private Map<String, String> getAuthorizationHeader() { + if (!useClientCert) { + String vidUsername = propertySupplier.getUsername(); + String vidPassword = propertySupplier.getPassword(); + String encoded = Base64.getEncoder() + .encodeToString((vidUsername + ":" + vidPassword).getBytes(StandardCharsets.UTF_8)); + return HashMap.of("Authorization", "Basic " + encoded).toJavaMap(); + } + return HashMap.<String, String>empty().toJavaMap(); + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java new file mode 100644 index 000000000..ad43746ca --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2018 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.aai; + +import io.joshworks.restclient.http.HttpResponse; +import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.vid.aai.model.AaiNodeQueryResponse; +import org.onap.vid.aai.model.ResourceType; +import org.onap.vid.model.SubscriberList; + +public interface AaiOverTLSClientInterface { + + class URIS { + + static final String SUBSCRIBERS = "business/customers?subscriber-type=INFRA&depth=%s"; + static final String NODE_TYPE_BY_NAME = "search/nodes-query?search-node-type=%s&filter=%s:EQUALS:%s"; + } + + class HEADERS { + static final String TRANSACTION_ID_HEADER = "X-TransactionId"; + static final String FROM_APP_ID_HEADER = "X-FromAppId"; + static final String CONTENT_TYPE = "Content-Type"; + static final String REQUEST_ID = SystemProperties.ECOMP_REQUEST_ID; + static final String ACCEPT = "Accept"; + } + + void setUseClientCert(boolean useClientCert); + + HttpResponse<AaiNodeQueryResponse> searchNodeTypeByName(String name, ResourceType type); + + HttpResponse<SubscriberList> getAllSubscribers(); + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSPropertySupplier.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSPropertySupplier.java new file mode 100644 index 000000000..33b44b159 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSPropertySupplier.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2018 Nokia Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.aai; + +import java.util.UUID; +import org.eclipse.jetty.util.security.Password; +import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.vid.aai.util.AAIProperties; +import org.onap.vid.utils.Logging; + +public class AaiOverTLSPropertySupplier { + + public String getUsername() { + return SystemProperties.getProperty(AAIProperties.AAI_VID_USERNAME); + } + + public String getPassword() { + return Password.deobfuscate(SystemProperties.getProperty(AAIProperties.AAI_VID_PASSWD_X)); + } + + public String getRequestId() { + return Logging.extractOrGenerateRequestId(); + } + + public String getRandomUUID(){ + return UUID.randomUUID().toString(); + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/exceptions/InvalidAAIResponseException.java b/vid-app-common/src/main/java/org/onap/vid/aai/exceptions/InvalidAAIResponseException.java index f80cae504..0e403697b 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/exceptions/InvalidAAIResponseException.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/exceptions/InvalidAAIResponseException.java @@ -1,3 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.vid.aai.exceptions; import org.onap.vid.aai.AaiResponse; @@ -10,4 +31,8 @@ public class InvalidAAIResponseException extends GenericUncheckedException { public InvalidAAIResponseException(AaiResponse aaiResponse) { super(String.format("errorCode: %d, raw: %s", aaiResponse.getHttpCode(), aaiResponse.getErrorMessage())); } + + public InvalidAAIResponseException(int statusCode, String message) { + super(String.format("errorCode: %d, raw: %s", statusCode, message)); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstance.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstance.java deleted file mode 100644 index 381f9bc25..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstance.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.onap.vid.aai.model; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ServiceInstance { - - @JsonProperty("service-instance-id") - public String serviceInstanceId; - - @JsonProperty("service-instance-name") - public String serviceInstanceName; - - @JsonProperty("persona-model-id") - public String personaModelId; - - @JsonProperty("persona-model-version") - public String personaModelVersion; - - @JsonProperty("resource-version") - public String resourceVersion; - - @JsonProperty("orchestration-status") - public String orchestrationStatus; - - -} diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstances.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstances.java deleted file mode 100644 index 0fced4c57..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstances.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.onap.vid.aai.model; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ServiceInstances { - - @JsonProperty("service-instance") - public List<ServiceInstance> serviceInstance; - -} diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceSubscription.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceSubscription.java deleted file mode 100644 index 91582e816..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceSubscription.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.onap.vid.aai.model; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ServiceSubscription { - - @JsonProperty("service-type") - public String serviceType; - - @JsonProperty("resource-version") - public String resourceVersion; - - @JsonProperty("service-instances") - public ServiceInstances serviceInstances; - - -} diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/Services.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/Services.java deleted file mode 100644 index 3ba4b22d0..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/Services.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.onap.vid.aai.model; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class Services { - @JsonProperty("global-customer-id") - public String globalCustomerId; - - @JsonProperty("subscriber-name") - public String subscriberName; - - @JsonProperty("subscriber-type") - public String subscriberType; - - @JsonProperty("resource-version") - public String resourceVersion; - - @JsonProperty("service-subscriptions") - public List<ServiceSubscription> serviceSubscriptions; - - -} diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/ServiceBuilder.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/ServiceBuilder.java new file mode 100644 index 000000000..73bef7636 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/ServiceBuilder.java @@ -0,0 +1,72 @@ +package org.onap.vid.asdc.beans; + +import java.util.Collection; + +public class ServiceBuilder { + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private Service.LifecycleState lifecycleState; + private String distributionStatus; + private Collection<Artifact> artifacts; + private Collection<SubResource> resources; + + public ServiceBuilder setUuid(String uuid) { + this.uuid = uuid; + return this; + } + + public ServiceBuilder setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + return this; + } + + public ServiceBuilder setName(String name) { + this.name = name; + return this; + } + + public ServiceBuilder setVersion(String version) { + this.version = version; + return this; + } + + public ServiceBuilder setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + return this; + } + + public ServiceBuilder setCategory(String category) { + this.category = category; + return this; + } + + public ServiceBuilder setLifecycleState(Service.LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + return this; + } + + public ServiceBuilder setDistributionStatus(String distributionStatus) { + this.distributionStatus = distributionStatus; + return this; + } + + public ServiceBuilder setArtifacts(Collection<Artifact> artifacts) { + this.artifacts = artifacts; + return this; + } + + public ServiceBuilder setResources(Collection<SubResource> resources) { + this.resources = resources; + return this; + } + + public Service build() { + return new Service(uuid, invariantUUID, category, version, name, distributionStatus, toscaModelURL, lifecycleState, artifacts, resources); + } +} + + diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java index 17fb29b59..57d80ce9d 100644 --- a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java +++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java @@ -1,7 +1,6 @@ package org.onap.vid.asdc.parser; -import org.onap.vid.asdc.beans.Service; -import org.onap.vid.model.*; +import org.apache.commons.lang3.StringUtils; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; import org.onap.sdc.tosca.parser.impl.FilterType; @@ -11,6 +10,8 @@ import org.onap.sdc.toscaparser.api.Group; import org.onap.sdc.toscaparser.api.*; import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.sdc.toscaparser.api.parameters.Input; +import org.onap.vid.asdc.beans.Service; +import org.onap.vid.model.*; import java.nio.file.Path; import java.util.*; @@ -417,7 +418,22 @@ public class ToscaParserImpl2 { private boolean isInputMatchesToGroup(List<Property> annotationProperties, org.onap.vid.model.Group group){ for(Property property: annotationProperties){ if(property.getName().equals(VF_MODULE_LABEL)){ - return getPropertyValueAsString(property).equals(group.getProperties().getVfModuleLabel()); + final Object values = property.getValue(); + final String vfModuleLabel = group.getProperties().getVfModuleLabel(); + if (values instanceof List) { + if (listContainsAsString((List) values, vfModuleLabel)) return true; + } else { + return getPropertyValueAsString(property).equals(vfModuleLabel); + } + } + } + return false; + } + + private boolean listContainsAsString(List list, String value) { + for (Object v : list) { + if (StringUtils.equals(v.toString(), value)) { + return true; } } return false; @@ -428,7 +444,7 @@ public class ToscaParserImpl2 { } private String removeSquareBrackets(String stringWithSquareBrackets){ - return stringWithSquareBrackets.substring(1, stringWithSquareBrackets.length()-1); + return stringWithSquareBrackets.replaceAll("(^\\[|\\]$)", ""); } private GroupProperties extractVfModuleProperties(Group group, ISdcCsarHelper csarHelper){ @@ -507,7 +523,10 @@ public class ToscaParserImpl2 { for (Property property : properties) { //special handling to necessary sub-property "ecomp_generated_naming" if(property.getName().equals("nf_naming")){ - propertiesMap.put(removeSquareBrackets(((LinkedHashMap)(property.getValue())).keySet().toString()) ,((LinkedHashMap)(property.getValue())).get("ecomp_generated_naming").toString()); + final Object ecompGeneratedNaming = ((Map) (property.getValue())).get("ecomp_generated_naming"); + if (ecompGeneratedNaming != null) { + propertiesMap.put("ecomp_generated_naming", ecompGeneratedNaming.toString()); + } } propertiesMap.put(property.getName(), property.getValue().toString()); } diff --git a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java index a3ff5f923..9e50c4456 100644 --- a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java @@ -25,42 +25,33 @@ import io.joshworks.restclient.http.JsonNode; import io.joshworks.restclient.http.RestClient; import io.joshworks.restclient.http.exceptions.RestClientException; import io.joshworks.restclient.http.mapper.ObjectMapper; -import org.apache.http.impl.client.CloseableHttpClient; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import io.joshworks.restclient.request.GetRequest; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLContexts; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.eclipse.jetty.util.security.Password; +import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import org.apache.http.conn.ssl.SSLContexts; -import io.vavr.CheckedFunction1; -import lombok.SneakyThrows; -import lombok.val; +import org.eclipse.jetty.util.security.Password; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.vid.properties.VidProperties; -import java.security.UnrecoverableKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.KeyManagementException; -import java.security.cert.CertificateException; -import javax.net.ssl.SSLException; -import java.security.KeyStoreException; -import java.text.SimpleDateFormat; import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLException; +import java.io.File; import java.io.FileInputStream; -import java.security.KeyStore; -import java.text.DateFormat; -import java.io.InputStream; import java.io.IOException; -import java.util.Date; +import java.io.InputStream; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; import java.util.Map; -import java.io.File; -import org.onap.portalsdk.core.util.SystemProperties; -import org.onap.vid.properties.VidProperties; public class SyncRestClient implements SyncRestClientInterface { - - private static final String CANNOT_INITIALIZE_CUSTOM_HTTP_CLIENT = "Cannot initialize custom http client from current configuration. Using default one."; - private static final String TRY_TO_CALL_OVER_HTTP = "SSL Handshake problem occured. Will try to retry over Http."; private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SyncRestClient.class); - private static final DateFormat DATE_FORMAT = new SimpleDateFormat("HH:mm:ss:SSSS"); private static final String[] SUPPORTED_SSL_VERSIONS = {"TLSv1", "TLSv1.2"}; private static final String HTTPS_SCHEMA = "https://"; private static final String HTTP_SCHEMA = "http://"; @@ -91,13 +82,13 @@ public class SyncRestClient implements SyncRestClientInterface { @Override public <T> HttpResponse<T> post(String url, Map<String, String> headers, Object body, Class<T> responseClass) { return callWithRetryOverHttp(url, - url2 -> restClient.post(url2).headers(headers).body(body).asObject(responseClass)); + url2 -> restClient.post(url2).headers(headers).body(body).asObject(responseClass)); } @Override public HttpResponse<JsonNode> get(String url, Map<String, String> headers, Map<String, String> routeParams) { return callWithRetryOverHttp(url, url2 -> { - val getRequest = restClient.get(url2).headers(headers); + GetRequest getRequest = restClient.get(url2).headers(headers); routeParams.forEach(getRequest::routeParam); return getRequest.asJson(); }); @@ -105,9 +96,9 @@ public class SyncRestClient implements SyncRestClientInterface { @Override public <T> HttpResponse<T> get(String url, Map<String, String> headers, Map<String, String> routeParams, - Class<T> responseClass) { + Class<T> responseClass) { return callWithRetryOverHttp(url, url2 -> { - val getRequest = restClient.get(url2).headers(headers); + GetRequest getRequest = restClient.get(url2).headers(headers); routeParams.forEach(getRequest::routeParam); return getRequest.asObject(responseClass); }); @@ -115,9 +106,9 @@ public class SyncRestClient implements SyncRestClientInterface { @Override public HttpResponse<InputStream> getStream(String url, Map<String, String> headers, - Map<String, String> routeParams) { + Map<String, String> routeParams) { return callWithRetryOverHttp(url, url2 -> { - val getRequest = restClient.get(url2).headers(headers); + GetRequest getRequest = restClient.get(url2).headers(headers); routeParams.forEach(getRequest::routeParam); return getRequest.asBinary(); }); @@ -131,7 +122,7 @@ public class SyncRestClient implements SyncRestClientInterface { @Override public <T> HttpResponse<T> put(String url, Map<String, String> headers, Object body, Class<T> responseClass) { return callWithRetryOverHttp(url, - url2 -> restClient.put(url2).headers(headers).body(body).asObject(responseClass)); + url2 -> restClient.put(url2).headers(headers).body(body).asObject(responseClass)); } @Override @@ -154,81 +145,100 @@ public class SyncRestClient implements SyncRestClientInterface { restClient.shutdown(); } - @SneakyThrows - private <T> HttpResponse<T> callWithRetryOverHttp(String url, - CheckedFunction1<String, HttpResponse<T>> httpRequest) { + private <T> HttpResponse<T> callWithRetryOverHttp(String url, HttpRequest<T> httpRequest) { + try { + return callWithRetryOverHttpThrows(url, httpRequest); + } catch (IOException e) { + throw new SyncRestClientException("IOException while calling rest service", e); + } + } + + private <T> HttpResponse<T> callWithRetryOverHttpThrows(String url, HttpRequest<T> httpRequest) throws IOException { try { return httpRequest.apply(url); } catch (RestClientException e) { - if (e.getCause() instanceof SSLException) { - logger.warn(EELFLoggerDelegate.debugLogger, - DATE_FORMAT.format(new Date()) + TRY_TO_CALL_OVER_HTTP, e); + if (causedBySslHandshakeError(e)) { + logger.warn(EELFLoggerDelegate.debugLogger, "SSL Handshake problem occured. Will try to retry over Http.", e); return httpRequest.apply(url.replaceFirst(HTTPS_SCHEMA, HTTP_SCHEMA)); } throw e; } } + private boolean causedBySslHandshakeError(RestClientException exception) { + return exception.getCause() instanceof SSLException; + } + private ObjectMapper defaultObjectMapper() { - val objectMapper = new org.codehaus.jackson.map.ObjectMapper(); + org.codehaus.jackson.map.ObjectMapper objectMapper = new org.codehaus.jackson.map.ObjectMapper(); return new ObjectMapper() { @Override - @SneakyThrows public <T> T readValue(String value, Class<T> aClass) { - return objectMapper.readValue(value, aClass); + try { + return objectMapper.readValue(value, aClass); + } catch (IOException e) { + throw new SyncRestClientException("IOException while reading value", e); + } } @Override - @SneakyThrows public String writeValue(Object value) { - return objectMapper.writeValueAsString(value); + try { + return objectMapper.writeValueAsString(value); + } catch (IOException e) { + throw new SyncRestClientException("IOException while writing value", e); + } } }; } private CloseableHttpClient defaultHttpClient() { try { - val trustStorePath = SystemProperties.getProperty(VidProperties.VID_TRUSTSTORE_FILENAME); - val trustStorePass = SystemProperties.getProperty(VidProperties.VID_TRUSTSTORE_PASSWD_X); - val decryptedTrustStorePass = Password.deobfuscate(trustStorePass); + String trustStorePath = SystemProperties.getProperty(VidProperties.VID_TRUSTSTORE_FILENAME); + String trustStorePass = SystemProperties.getProperty(VidProperties.VID_TRUSTSTORE_PASSWD_X); + String decryptedTrustStorePass = Password.deobfuscate(trustStorePass); - val trustStore = loadTruststore(trustStorePath, decryptedTrustStorePass); - val sslContext = trustOwnCACerts(decryptedTrustStorePass, trustStore); - val sslSf = allowTLSProtocols(sslContext); + KeyStore trustStore = loadTruststore(trustStorePath, decryptedTrustStorePass); + SSLContext sslContext = trustOwnCACerts(decryptedTrustStorePass, trustStore); + SSLConnectionSocketFactory sslSf = allowTLSProtocols(sslContext); return HttpClients.custom().setSSLSocketFactory(sslSf).build(); } catch (IOException | CertificateException | UnrecoverableKeyException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) { - logger.warn(EELFLoggerDelegate.debugLogger, - DATE_FORMAT.format(new Date()) + CANNOT_INITIALIZE_CUSTOM_HTTP_CLIENT, e); + logger.warn(EELFLoggerDelegate.debugLogger, "Cannot initialize custom http client from current configuration. Using default one.", e); return HttpClients.createDefault(); } } private SSLConnectionSocketFactory allowTLSProtocols(SSLContext sslcontext) { return new SSLConnectionSocketFactory( - sslcontext, - SUPPORTED_SSL_VERSIONS, - null, - SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + sslcontext, + SUPPORTED_SSL_VERSIONS, + null, + SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); } private SSLContext trustOwnCACerts(String trustStorePass, KeyStore trustStore) - throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { + throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { return SSLContexts.custom() - .useTLS() - .loadKeyMaterial(trustStore, trustStorePass.toCharArray()) - .loadTrustMaterial(trustStore, new TrustSelfSignedStrategy()) - .build(); + .useTLS() + .loadKeyMaterial(trustStore, trustStorePass.toCharArray()) + .loadTrustMaterial(trustStore, new TrustSelfSignedStrategy()) + .build(); } private KeyStore loadTruststore(String trustStorePath, String trustStorePass) - throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException { - val trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); + throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException { + KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); try (FileInputStream instream = new FileInputStream(new File(trustStorePath))) { trustStore.load(instream, trustStorePass.toCharArray()); } return trustStore; } + @FunctionalInterface + private interface HttpRequest<T> { + HttpResponse<T> apply(String url) throws IOException; + } + } diff --git a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClientException.java b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClientException.java new file mode 100644 index 000000000..2a4f093b1 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClientException.java @@ -0,0 +1,7 @@ +package org.onap.vid.client; + +public class SyncRestClientException extends RuntimeException { + public SyncRestClientException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java b/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java index 12cc68e61..86e832ba7 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java @@ -25,7 +25,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.dao.FnAppDoaImpl; import org.onap.vid.model.GitRepositoryState; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -38,6 +38,9 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; +import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; +import static org.springframework.http.HttpStatus.OK; + /** * Controller for user profile view. The view is restricted to authenticated * users. The view name resolves to page user_profile.jsp which uses Angular. @@ -47,158 +50,86 @@ import java.util.Properties; @RequestMapping("/") public class HealthCheckController extends UnRestrictedBaseController { - /** - * The logger. - */ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(HealthCheckController.class); - - /** - * The Constant dateFormat. - */ - final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); - - private static final String HEALTH_CHECK_PATH = "/healthCheck"; + private static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); private static final String GIT_PROPERTIES_FILENAME = "git.properties"; + private FnAppDoaImpl fnAppDoaImpl; - /** - * Model for JSON response with health-check results. - */ - public class HealthStatus { - // Either 200 or 500 - public int statusCode; - - // Additional detail in case of error, empty in case of success. - public String message; - - public String date; - - public HealthStatus(int code, String msg) { - this.statusCode = code; - this.message = msg; - } - - public HealthStatus(int code, String date, String msg) { - this.statusCode = code; - this.message = msg; - this.date = date; - } - - public int getStatusCode() { - return statusCode; - } - - public void setStatusCode(int code) { - this.statusCode = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String msg) { - this.message = msg; - } - - public String getDate() { - return date; - } - - public void setDate(String date) { - this.date = date; - } - + @Autowired + public HealthCheckController(FnAppDoaImpl fnAppDoaImpl) { + this.fnAppDoaImpl = fnAppDoaImpl; } - @SuppressWarnings("unchecked") - public int getProfileCount(String driver, String URL, String username, String password) { - FnAppDoaImpl doa = new FnAppDoaImpl(); - int count = doa.getProfileCount(driver, URL, username, password); - return count; - } - - /** * Obtain the HealthCheck Status from the System.Properties file. * Used by IDNS for redundancy * * @return ResponseEntity The response entity - * @throws IOException Signals that an I/O exception has occurred. */ @RequestMapping(value = "/healthCheck", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public HealthStatus gethealthCheckStatusforIDNS() { - - String driver = SystemProperties.getProperty("db.driver"); - String URL = SystemProperties.getProperty("db.connectionURL"); - String username = SystemProperties.getProperty("db.userName"); - String password = SystemProperties.getProperty("db.password"); - - LOGGER.debug(EELFLoggerDelegate.debugLogger, "driver ::" + driver); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "URL::" + URL); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "username::" + username); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "password::" + password); - - - HealthStatus healthStatus = null; - try { - LOGGER.debug(EELFLoggerDelegate.debugLogger, "Performing health check"); - int count = getProfileCount(driver, URL, username, password); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "count:::" + count); - healthStatus = new HealthStatus(200, "health check succeeded"); - } catch (Exception ex) { - - LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex); - healthStatus = new HealthStatus(500, "health check failed: " + ex.toString()); - } - return healthStatus; + public HealthStatus getHealthCheckStatusForIDNS() { + return createCorrespondingStatus(); } /** * Obtain the HealthCheck Status from the System.Properties file. * * @return ResponseEntity The response entity - * @throws IOException Signals that an I/O exception has occurred. - * Project : */ @RequestMapping(value = "rest/healthCheck/{User-Agent}/{X-ECOMP-RequestID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public HealthStatus getHealthCheck( @PathVariable("User-Agent") String UserAgent, @PathVariable("X-ECOMP-RequestID") String ECOMPRequestID) { + LOGGER.debug(EELFLoggerDelegate.debugLogger, "User-Agent ", UserAgent); + LOGGER.debug(EELFLoggerDelegate.debugLogger, "X-ECOMP-RequestID ", ECOMPRequestID); + return createCorrespondingStatus(); + } - String driver = SystemProperties.getProperty("db.driver"); - String URL = SystemProperties.getProperty("db.connectionURL"); - String username = SystemProperties.getProperty("db.userName"); - String password = SystemProperties.getProperty("db.password"); - - LOGGER.debug(EELFLoggerDelegate.debugLogger, "driver ::" + driver); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "URL::" + URL); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "username::" + username); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "password::" + password); - + @RequestMapping(value = "/commitInfo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public GitRepositoryState getCommitInfo() throws IOException { + Properties properties = new Properties(); + properties.load(getClass().getClassLoader().getResourceAsStream(GIT_PROPERTIES_FILENAME)); + return new GitRepositoryState(properties); + } - HealthStatus healthStatus = null; + private HealthStatus createCorrespondingStatus() { + logData(); try { - LOGGER.debug(EELFLoggerDelegate.debugLogger, "Performing health check"); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "User-Agent" + UserAgent); - LOGGER.debug(EELFLoggerDelegate.debugLogger, "X-ECOMP-RequestID" + ECOMPRequestID); + int count = fnAppDoaImpl.getProfileCount(getUrl(), getUsername(), getPassword()); + LOGGER.debug(EELFLoggerDelegate.debugLogger, "count:::", count); + return okStatus(); + } catch (Exception ex) { + String errorMsg = ex.getMessage(); + LOGGER.error(EELFLoggerDelegate.errorLogger, errorMsg); + return errorStatus(errorMsg); + } + } + private void logData() { + LOGGER.debug(EELFLoggerDelegate.debugLogger, "Performing health check"); + LOGGER.debug(EELFLoggerDelegate.debugLogger, "URL::", getUrl()); + LOGGER.debug(EELFLoggerDelegate.debugLogger, "username::", getUsername()); + } - int count = getProfileCount(driver, URL, username, password); + private HealthStatus okStatus() { + return new HealthStatus(OK, dateFormat.format(new Date()), "health check succeeded"); + } - LOGGER.debug(EELFLoggerDelegate.debugLogger, "count:::" + count); - healthStatus = new HealthStatus(200, dateFormat.format(new Date()), "health check succeeded"); - } catch (Exception ex) { + private HealthStatus errorStatus(String msg) { + return new HealthStatus(INTERNAL_SERVER_ERROR, dateFormat.format( + new Date()), "health check failed: " + msg); + } - LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex); - healthStatus = new HealthStatus(500, dateFormat.format(new Date()), "health check failed: " + ex.toString()); - } - return healthStatus; + private String getUrl() { + return SystemProperties.getProperty("db.connectionURL"); } - @RequestMapping(value = "/commitInfo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public GitRepositoryState getCommitInfo() throws IOException { - Properties properties = new Properties(); - properties.load(getClass().getClassLoader().getResourceAsStream(GIT_PROPERTIES_FILENAME)); - return new GitRepositoryState(properties); + private String getUsername() { + return SystemProperties.getProperty("db.userName"); + } + + private String getPassword() { + return SystemProperties.getProperty("db.password"); } } diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthStatus.java b/vid-app-common/src/main/java/org/onap/vid/controllers/HealthStatus.java new file mode 100644 index 000000000..6056c2898 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/controllers/HealthStatus.java @@ -0,0 +1,31 @@ +package org.onap.vid.controllers; + +import org.springframework.http.HttpStatus; + +/** + * Model for JSON response with health-check results. + */ +public final class HealthStatus { + + private final int statusCode; + private final String detailedMsg; + private final String date; + + public HealthStatus(HttpStatus code, String date, String detailedMsg) { + this.statusCode = code.value(); + this.detailedMsg = detailedMsg; + this.date = date; + } + + public int getStatusCode() { + return statusCode; + } + + public String getDetailedMsg() { + return detailedMsg; + } + + public String getDate() { + return date; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/VidController.java b/vid-app-common/src/main/java/org/onap/vid/controllers/VidController.java index 6d6ffb31b..b9d67b6df 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controllers/VidController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controllers/VidController.java @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright 2018 Nokia + * ================================================================================ * 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. @@ -40,122 +42,73 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import java.util.List; -//import org.onap.vid.model.Service; - @RestController public class VidController extends RestrictedBaseController { - private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidController.class); - - private final VidService service; + private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidController.class); - @Autowired - public VidController(VidService vidService) { - service = vidService; - } - - @Autowired - private AaiService aaiService; - - @Autowired - RoleProvider roleProvider; + private final VidService vidService; + private final AaiService aaiService; + private final RoleProvider roleProvider; + private final PombaService pombaService; @Autowired - private PombaService pombaService; - -// /** -// * Gets the services. -// * -// * @param request the request -// * @return the services -// * @throws VidServiceUnavailableException the vid service unavailable exception -// */ -// @RequestMapping(value={"/rest/models/services"}, method = RequestMethod.GET) -// public SecureServices getServices(HttpServletRequest request) throws VidServiceUnavailableException { -// try { -// AaiService aaiService = new AaiServiceImpl(); -// LOG.info("Start API for browse ASDC was called"); -// SecureServices secureServices = new SecureServices(); -// Map<String, String[]> requestParams = request.getParameterMap(); -// List<Role> roles = roleProvider.getUserRoles(request); -// secureServices.setServices(aaiService.getServicesByDistributionStatus()); -// secureServices.setServices(service.getServices(requestParams)); -// secureServices.setReadOnly(roleProvider.userPermissionIsReadOnly(roles)); -// return secureServices; -// } catch (AsdcCatalogException e) { -// LOG.error("Failed to retrieve service definitions from SDC", e); -// throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e); -// } catch (Throwable t) { -// LOG.debug("Unexpected error while retrieving service definitions from SDC: " + t.getMessage() + ":", t); -// t.printStackTrace(); -// throw new VidServiceUnavailableException("Unexpected error while retrieving service definitions from SDC: " + t.getMessage(), t); -// } -// } - - /** - * Gets the services. - * - * @param request the request - * @return the services - * @throws VidServiceUnavailableException the vid service unavailable exception - */ - @RequestMapping(value={"/rest/models/services"}, method = RequestMethod.GET) - public SecureServices getServices(HttpServletRequest request) throws VidServiceUnavailableException { - try { - LOG.info("Start API for browse ASDC was called"); - SecureServices secureServices = new SecureServices(); - List<Role> roles = roleProvider.getUserRoles(request); - secureServices.setServices(aaiService.getServicesByDistributionStatus()); - //Disable roles until AAF integration finishes - //secureServices.setReadOnly(roleProvider.userPermissionIsReadOnly(roles)); - secureServices.setReadOnly(false); - return secureServices; - } - catch (Exception t) { - LOG.debug("Unexpected error while retrieving service definitions from A&AI: " + t.getMessage() + ":", t); - throw new VidServiceUnavailableException("Unexpected error while retrieving service definitions from A&AI: " + t.getMessage(), t); - } - } + public VidController(VidService vidService, AaiService aaiService, RoleProvider roleProvider, + PombaService pombaService) { + this.vidService = vidService; + this.aaiService = aaiService; + this.roleProvider = roleProvider; + this.pombaService = pombaService; + } + /** + * @param request the request + * @return the services + */ + @RequestMapping(value = {"/rest/models/services"}, method = RequestMethod.GET) + public SecureServices getServices(HttpServletRequest request) { + LOG.info("Start API for browse ASDC was called"); + SecureServices secureServices = new SecureServices(); + List<Role> roles = roleProvider.getUserRoles(request); + secureServices.setServices(aaiService.getServicesByDistributionStatus()); + secureServices.setReadOnly(roleProvider.userPermissionIsReadOnly(roles)); + return secureServices; + } - /** - * Gets the services. - * - * @param uuid the uuid - * @return the services - * @throws VidServiceUnavailableException the vid service unavailable exception - */ - @RequestMapping(value={"/rest/models/services/{uuid}"}, method = RequestMethod.GET) - public ServiceModel getServices(@PathVariable("uuid") String uuid, HttpServletRequest request) throws VidServiceUnavailableException { - try { - return service.getService(uuid); - } catch (AsdcCatalogException e) { - LOG.error("Failed to retrieve service definitions from SDC. Error: "+e.getMessage() , e); - throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e); - } - } + /** + * @param uuid the uuid + * @return the services + * @throws VidServiceUnavailableException the vid service unavailable exception + */ + @RequestMapping(value = {"/rest/models/services/{uuid}"}, method = RequestMethod.GET) + public ServiceModel getService(@PathVariable("uuid") String uuid) throws VidServiceUnavailableException { + try { + return vidService.getService(uuid); + } catch (AsdcCatalogException e) { + LOG.error("Failed to retrieve service definitions from SDC. Error: " + e.getMessage(), e); + throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e); + } + } - @RequestMapping(value = "/rest/models/reset", method = RequestMethod.POST) - @ResponseStatus(HttpStatus.ACCEPTED) - public void invalidateServiceModelCache(HttpServletRequest request) { - service.invalidateServiceCache(); - } + @RequestMapping(value = "/rest/models/reset", method = RequestMethod.POST) + @ResponseStatus(HttpStatus.ACCEPTED) + public void invalidateServiceModelCache() { + vidService.invalidateServiceCache(); + } - /** - * Gets the services view. - * - * @param request the request - * @return the services view - * @throws VidServiceUnavailableException the vid service unavailable exception - */ - @RequestMapping(value={"/serviceModels"}, method=RequestMethod.GET) - public ModelAndView getServicesView(HttpServletRequest request) { + /** + * @return the services view + * @throws VidServiceUnavailableException the vid service unavailable exception + */ + // FIX ME: Circular view path [serviceModels]: would dispatch back to the current handler URL [/serviceModels] again. + @RequestMapping(value = {"/serviceModels"}, method = RequestMethod.GET) + public ModelAndView getServicesView() { return new ModelAndView("serviceModels"); } @RequestMapping(value = {"/rest/models/services/verifyService"}, method = RequestMethod.POST) - public void verifyServiceInstance(HttpServletRequest request, @RequestBody PombaRequest pombaRequest) { - pombaService.verify(pombaRequest); + public void verifyServiceInstance(@RequestBody PombaRequest pombaRequest) { + pombaService.verify(pombaRequest); } } diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java index 0f4b536a1..56dce9ac7 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java +++ b/vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java @@ -21,9 +21,14 @@ package org.onap.vid.controllers; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.core.JsonProcessingException; +import io.joshworks.restclient.http.mapper.ObjectMapper; +import java.io.IOException; import org.onap.vid.aai.AaiClient; import org.onap.vid.aai.AaiClientInterface; +import org.onap.vid.aai.AaiOverTLSClient; +import org.onap.vid.aai.AaiOverTLSClientInterface; +import org.onap.vid.aai.AaiOverTLSPropertySupplier; import org.onap.vid.aai.AaiResponseTranslator; import org.onap.vid.aai.PombaClientImpl; import org.onap.vid.aai.PombaClientInterface; @@ -48,7 +53,6 @@ import org.onap.vid.services.VidService; import org.onap.vid.services.VidServiceImpl; import org.onap.vid.scheduler.SchedulerRestInterface; import org.onap.vid.scheduler.SchedulerRestInterfaceIfc; -import org.onap.vid.services.*; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -66,8 +70,8 @@ public class WebConfig { * @return the object mapper */ @Bean - public ObjectMapper getObjectMapper() { - return new ObjectMapper(); + public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() { + return new com.fasterxml.jackson.databind.ObjectMapper(); } @@ -161,4 +165,62 @@ public class WebConfig { public SchedulerRestInterfaceIfc getSchedulerRestInterface(){ return new SchedulerRestInterface(); } + + @Bean(name = "aaiClientForFasterXmlMapping") + public AaiOverTLSClientInterface getAaiClientForFasterXmlMapping(){ + ObjectMapper objectMapper = new ObjectMapper() { + + com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper(); + + @Override + public <T> T readValue(String s, Class<T> aClass) { + try { + return om.readValue(s, aClass); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public String writeValue(Object o) { + try { + return om.writeValueAsString(o); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + }; + + return new AaiOverTLSClient(new SyncRestClient(objectMapper), new AaiOverTLSPropertySupplier()); + } + + + @Bean(name = "aaiClientForCodehausMapping") + public AaiOverTLSClientInterface getAaiClientForCodehausMapping() { + + ObjectMapper objectMapper = new ObjectMapper() { + + org.codehaus.jackson.map.ObjectMapper om = new org.codehaus.jackson.map.ObjectMapper(); + + @Override + public <T> T readValue(String s, Class<T> aClass) { + try { + return om.readValue(s, aClass); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public String writeValue(Object o) { + try { + return om.writeValueAsString(o); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + }; + + return new AaiOverTLSClient(new SyncRestClient(objectMapper), new AaiOverTLSPropertySupplier()); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/dao/ConnectionFactory.java b/vid-app-common/src/main/java/org/onap/vid/dao/ConnectionFactory.java new file mode 100644 index 000000000..bd7a67b5a --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/dao/ConnectionFactory.java @@ -0,0 +1,20 @@ +package org.onap.vid.dao; + +import org.springframework.stereotype.Component; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +import static com.google.common.base.Preconditions.checkNotNull; + +@Component +public class ConnectionFactory { + + public Connection getConnection(String url, String username, String password) throws SQLException { + checkNotNull(url); + checkNotNull(username); + checkNotNull(password); + return DriverManager.getConnection(url, username, password); + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java b/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java index 65fc5217f..e3fdc95f2 100644 --- a/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java @@ -7,9 +7,9 @@ * 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. @@ -21,94 +21,38 @@ package org.onap.vid.dao; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; import java.sql.*; - +@Repository public class FnAppDoaImpl { - /** The logger. */ - static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnAppDoaImpl.class); - - public int getProfileCount(String driver, String URL, String username, String password) { - Connection dbc = null; - PreparedStatement pst = null; - ResultSet rs = null; - String q = null; - int count = 0; - try { - dbc = getConnection(URL,username,password); - logger.debug(EELFLoggerDelegate.debugLogger, "getConnection:::"+ dbc); - q = "select count(*) from fn_app"; - pst = dbc.prepareStatement(q); - rs = pst.executeQuery(); - - if (rs.next()) - count = rs.getInt(1); - } catch(Exception ex) { - logger.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex); - } finally { - cleanup(rs,pst,dbc); - } - logger.debug(EELFLoggerDelegate.debugLogger, "count:::"+ count); - return count; - } - - public static Connection getConnection(String url, String username, String password) throws SQLException { - java.sql.Connection con=null; - - if( url!=null && username!=null && password!=null ){ - con = DriverManager.getConnection(url, username, password); - } - - logger.info("Connection Successful"); - - return con; - - } - - public static void cleanup(ResultSet rs, PreparedStatement st, Connection c) { - if (rs != null) { - closeResultSet(rs); - } - if (st != null) { - closePreparedStatement(st); - } - if (c != null) { - rollbackAndCloseConnection(c); - } - } - - private static void rollbackAndCloseConnection(Connection c) { - try { - c.rollback(); - } catch (Exception e) { - if (logger != null) - logger.error("Error when trying to rollback connection", e); + static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnAppDoaImpl.class); + + private ConnectionFactory connectionFactory; + + @Autowired + public FnAppDoaImpl(ConnectionFactory connectionFactory) { + this.connectionFactory = connectionFactory; + } + + public int getProfileCount(String URL, String username, String password) throws SQLException { + String q = "select count(*) from fn_app"; + int count = 0; + try (Connection dbc = connectionFactory.getConnection(URL, username, password); + PreparedStatement pst = dbc.prepareStatement(q); ResultSet rs = pst.executeQuery()) { + logger.debug(EELFLoggerDelegate.debugLogger, "getConnection:::", dbc); + if (rs.next()) { + count = rs.getInt(1); + } + } catch (SQLException ex) { + logger.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex); + throw ex; } - try { - c.close(); - } catch (Exception e) { - if (logger != null) - logger.error("Error when trying to close connection", e); - } - } - - private static void closePreparedStatement(PreparedStatement st) { - try { - st.close(); - } catch (Exception e) { - if (logger != null) - logger.error("Error when trying to close statement", e); - } - } - private static void closeResultSet(ResultSet rs) { - try { - rs.close(); - } catch (Exception e) { - if (logger != null) - logger.error("Error when trying to close result set", e); - } - } + logger.debug(EELFLoggerDelegate.debugLogger, "count:::", count); + return count; + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoException.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoException.java new file mode 100644 index 000000000..02d54c354 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoException.java @@ -0,0 +1,7 @@ +package org.onap.vid.mso; + +public class MsoException extends RuntimeException { + public MsoException(Throwable cause) { + super(cause); + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java index 834f80885..7c8ab89c1 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java @@ -20,13 +20,15 @@ */ package org.onap.vid.mso; +import com.fasterxml.jackson.core.JsonProcessingException; import io.joshworks.restclient.http.HttpResponse; import io.joshworks.restclient.http.mapper.ObjectMapper; -import lombok.SneakyThrows; import org.onap.vid.aai.util.CustomJacksonJaxBJsonProvider; import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.mso.rest.RequestDetails; +import java.io.IOException; + /** * Created by pickjonathan on 21/06/2017. */ @@ -123,16 +125,22 @@ public interface MsoInterface { return new ObjectMapper() { CustomJacksonJaxBJsonProvider mapper = new CustomJacksonJaxBJsonProvider(); - @SneakyThrows @Override public <T> T readValue(String s, Class<T> aClass) { - return mapper.getMapper().readValue(s, aClass); + try { + return mapper.getMapper().readValue(s, aClass); + } catch (IOException e) { + throw new MsoException(e); + } } - @SneakyThrows @Override public String writeValue(Object o) { - return mapper.getMapper().writeValueAsString(o); + try { + return mapper.getMapper().writeValueAsString(o); + } catch (JsonProcessingException e) { + throw new MsoException(e); + } } }; } diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java index 45835d459..b83f751fe 100644 --- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java @@ -1,7 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.vid.roles; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.joshworks.restclient.http.HttpResponse; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.web.support.UserUtils; import org.onap.vid.aai.AaiResponse; @@ -16,8 +38,6 @@ import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; import java.util.*; -//import org.codehaus.jackson.map.ObjectMapper; - /** * Created by Oren on 7/1/17. */ @@ -40,21 +60,21 @@ public class RoleProvider { public void init() { LOG.debug(EELFLoggerDelegate.debugLogger, "Role provider => init method started"); - AaiResponse<SubscriberList> subscribersResponse = aaiService.getFullSubscriberList(); - subscribers = subscribersResponse.getT(); + HttpResponse<SubscriberList> subscribersResponse = aaiService.getFullSubscriberList(); + subscribers = subscribersResponse.getBody(); LOG.debug(EELFLoggerDelegate.debugLogger, "Role provider => init method finished"); } - public List<Role> getUserRoles(HttpServletRequest request) throws JsonProcessingException { + public List<Role> getUserRoles(HttpServletRequest request) { String logPrefix = "Role Provider (" + UserUtils.getUserId(request) + ") ==>"; LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "Entering to get user role for user " + UserUtils.getUserId(request)); List<Role> roleList = new ArrayList<>(); - //Disable roles until AAF integration finishes - /*HashMap roles = UserUtils.getRoles(request); + + Map roles = UserUtils.getRoles(request); for (Object role : roles.keySet()) { - org.openecomp.portalsdk.core.domain.Role sdkRol = (org.openecomp.portalsdk.core.domain.Role) roles.get(role); + org.onap.portalsdk.core.domain.Role sdkRol = (org.onap.portalsdk.core.domain.Role) roles.get(role); LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "Role " + sdkRol.getName() + " is being proccessed"); try { @@ -67,11 +87,11 @@ public class RoleProvider { roleList.add(createRoleFromStringArr(roleParts, logPrefix)); String msg = String.format(logPrefix + " User %s got permissions %s", UserUtils.getUserId(request), Arrays.toString(roleParts)); LOG.debug(EELFLoggerDelegate.debugLogger, msg); - } catch (RoleParsingException e) { + } catch (Exception e) { LOG.error(logPrefix + " Failed to parse permission"); } - }*/ + } return roleList; } diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java index f3e0bfdab..d2ee32cbc 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java @@ -1,5 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.vid.services; +import io.joshworks.restclient.http.HttpResponse; import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.AaiResponseTranslator; import org.onap.vid.aai.SubscriberFilteredResults; @@ -28,7 +50,7 @@ public interface AaiService { AaiResponse getServiceInstanceSearchResults(String subscriberId, String instanceIdentifier, RoleValidator roleProvider, List<String> owningEntities, List<String> projects); - AaiResponse<SubscriberList> getFullSubscriberList(); + HttpResponse<SubscriberList> getFullSubscriberList(); AaiResponse getServices(RoleValidator roleValidator); diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java index 4de2cc740..c5bee2448 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java @@ -1,5 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.vid.services; +import io.joshworks.restclient.http.HttpResponse; import org.apache.http.HttpStatus; import org.codehaus.jackson.JsonNode; import org.onap.vid.aai.*; @@ -30,6 +52,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Qualifier; /** * Created by Oren on 7/4/17. @@ -45,6 +68,10 @@ public class AaiServiceImpl implements AaiService { private AaiClientInterface aaiClient; @Autowired + @Qualifier("aaiClientForCodehausMapping") + private AaiOverTLSClientInterface aaiOverTLSClient; + + @Autowired private AaiResponseTranslator aaiResponseTranslator; private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AaiServiceImpl.class); @@ -162,11 +189,13 @@ public class AaiServiceImpl implements AaiService { @Override public SubscriberFilteredResults getFullSubscriberList(RoleValidator roleValidator) { - AaiResponse<SubscriberList> subscriberResponse = aaiClient.getAllSubscribers(); - - return new SubscriberFilteredResults(roleValidator, subscriberResponse.getT(), - subscriberResponse.getErrorMessage(), - subscriberResponse.getHttpCode()); + HttpResponse<SubscriberList> allSubscribers = aaiOverTLSClient.getAllSubscribers(); + return new SubscriberFilteredResults( + roleValidator, + allSubscribers.getBody(), + allSubscribers.getStatusText(), + allSubscribers.getStatus() + ); } @Override @@ -175,8 +204,8 @@ public class AaiServiceImpl implements AaiService { } @Override - public AaiResponse<SubscriberList> getFullSubscriberList() { - return aaiClient.getAllSubscribers(); + public HttpResponse<SubscriberList> getFullSubscriberList() { + return aaiOverTLSClient.getAllSubscribers(); } @Override diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java index 7259301a8..df8e92d66 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java @@ -1,10 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.vid.services; import com.google.common.collect.ImmutableMap; +import io.joshworks.restclient.http.HttpResponse; +import java.io.IOException; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.hibernate.SessionFactory; import org.onap.vid.aai.AaiClientInterface; +import org.onap.vid.aai.AaiOverTLSClientInterface; import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.exceptions.InvalidAAIResponseException; import org.onap.vid.aai.model.AaiNodeQueryResponse; @@ -35,6 +60,7 @@ import org.onap.vid.utils.DaoUtils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.service.DataAccessService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import java.sql.Timestamp; @@ -50,7 +76,7 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu private static final int MAX_RETRIES_GETTING_COUNTER = 100; private static final int MAX_RETRIES_GETTING_FREE_NAME_FROM_AAI = 10000; - public static final String NAME_FOR_CHECK_AAI_STATUS = "NAME_FOR_CHECK_AAI_STATUS"; + private static final String NAME_FOR_CHECK_AAI_STATUS = "NAME_FOR_CHECK_AAI_STATUS"; private final DataAccessService dataAccessService; @@ -60,60 +86,62 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu private SessionFactory sessionFactory; - private AaiClientInterface aaiClient; + private AaiOverTLSClientInterface aaiOverTLSClient; private int maxRetriesGettingFreeNameFromAai = MAX_RETRIES_GETTING_FREE_NAME_FROM_AAI; - private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AsyncInstantiationBusinessLogicImpl.class); + private static final EELFLoggerDelegate logger = EELFLoggerDelegate + .getLogger(AsyncInstantiationBusinessLogicImpl.class); private Map<String, JobStatus> msoStateToJobStatusMap = ImmutableMap.<String, JobStatus>builder() - .put("inprogress", JobStatus.IN_PROGRESS) - .put("failed", JobStatus.FAILED) - .put("pause", JobStatus.PAUSE) - .put("paused", JobStatus.PAUSE) - .put("complete", JobStatus.COMPLETED) - .put("pending", JobStatus.IN_PROGRESS) - .put("pendingmanualtask", JobStatus.PAUSE) - .put("unlocked", JobStatus.IN_PROGRESS) - .build(); + .put("inprogress", JobStatus.IN_PROGRESS) + .put("failed", JobStatus.FAILED) + .put("pause", JobStatus.PAUSE) + .put("paused", JobStatus.PAUSE) + .put("complete", JobStatus.COMPLETED) + .put("pending", JobStatus.IN_PROGRESS) + .put("pendingmanualtask", JobStatus.PAUSE) + .put("unlocked", JobStatus.IN_PROGRESS) + .build(); @Autowired public AsyncInstantiationBusinessLogicImpl(DataAccessService dataAccessService, - JobAdapter jobAdapter, - JobsBrokerService jobService, - SessionFactory sessionFactory, - AaiClientInterface aaiClient) { + JobAdapter jobAdapter, + JobsBrokerService jobService, + SessionFactory sessionFactory, + @Qualifier("aaiClientForFasterXmlMapping") AaiOverTLSClientInterface aaiOverTLSClient) { this.dataAccessService = dataAccessService; this.jobAdapter = jobAdapter; this.jobService = jobService; this.sessionFactory = sessionFactory; - this.aaiClient = aaiClient; + this.aaiOverTLSClient = aaiOverTLSClient; } @Override public List<ServiceInfo> getAllServicesInfo() { - return dataAccessService.getList(ServiceInfo.class, filterByCreationDateAndNotDeleted(), orderByCreatedDateAndStatus(), null); + return dataAccessService + .getList(ServiceInfo.class, filterByCreationDateAndNotDeleted(), orderByCreatedDateAndStatus(), null); } private String filterByCreationDateAndNotDeleted() { LocalDateTime minus3Months = LocalDateTime.now().minusMonths(3); Timestamp filterDate = Timestamp.valueOf(minus3Months); return " where" + - " hidden = false" + - " and deleted_at is null" + // don't fetch deleted - " and created >= '" + filterDate + "' "; + " hidden = false" + + " and deleted_at is null" + // don't fetch deleted + " and created >= '" + filterDate + "' "; } private String orderByCreatedDateAndStatus() { return " createdBulkDate DESC ,\n" + - " (CASE jobStatus\n" + - " WHEN 'COMPLETED' THEN 0\n" + - " WHEN 'FAILED' THEN 0\n" + - " WHEN 'IN_PROGRESS' THEN 1\n" + - " WHEN 'PAUSE' THEN 2\n" + - " WHEN 'PENDING' THEN 3\n" + - " WHEN 'STOPPED' THEN 3 END),\n" + - " statusModifiedDate "; + " (CASE jobStatus\n" + + " WHEN 'COMPLETED' THEN 0\n" + + " WHEN 'FAILED' THEN 0\n" + + " WHEN 'IN_PROGRESS' THEN 1\n" + + " WHEN 'PAUSE' THEN 2\n" + + " WHEN 'PENDING' THEN 3\n" + + " WHEN 'STOPPED' THEN 3 END),\n" + + " statusModifiedDate "; } @Override @@ -125,77 +153,87 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu for (int i = 0; i < bulkSize; i++) { Job job = jobAdapter.createJob(JobType.ServiceInstantiation, request, templateId, userId, i); UUID jobId = jobService.add(job); - auditVidStatus(jobId,job.getStatus()); + auditVidStatus(jobId, job.getStatus()); uuids.add(jobId); - dataAccessService.saveDomainObject(createServiceInfo(userId, request, jobId, templateId, createdBulkDate), DaoUtils.getPropsMap()); + dataAccessService.saveDomainObject(createServiceInfo(userId, request, jobId, templateId, createdBulkDate), + DaoUtils.getPropsMap()); } return uuids; } - private ServiceInfo createServiceInfo(String userId, ServiceInstantiation serviceInstantiation, UUID jobId, UUID templateId, Date createdBulkDate) { + private ServiceInfo createServiceInfo(String userId, ServiceInstantiation serviceInstantiation, UUID jobId, + UUID templateId, Date createdBulkDate) { return new ServiceInfo( - userId, Job.JobStatus.PENDING, serviceInstantiation.isPause(), jobId, templateId, - serviceInstantiation.getOwningEntityId(), - serviceInstantiation.getOwningEntityName(), - serviceInstantiation.getProjectName(), - serviceInstantiation.getAicZoneId(), - serviceInstantiation.getAicZoneName(), - serviceInstantiation.getTenantId(), - serviceInstantiation.getTenantName(), - serviceInstantiation.getLcpCloudRegionId(), - null, - serviceInstantiation.getSubscriptionServiceType(), - serviceInstantiation.getSubscriberName(), - null, - serviceInstantiation.getInstanceName(), - serviceInstantiation.getModelInfo().getModelInvariantId(), - serviceInstantiation.getModelInfo().getModelName(), - serviceInstantiation.getModelInfo().getModelVersion(), - createdBulkDate + userId, Job.JobStatus.PENDING, serviceInstantiation.isPause(), jobId, templateId, + serviceInstantiation.getOwningEntityId(), + serviceInstantiation.getOwningEntityName(), + serviceInstantiation.getProjectName(), + serviceInstantiation.getAicZoneId(), + serviceInstantiation.getAicZoneName(), + serviceInstantiation.getTenantId(), + serviceInstantiation.getTenantName(), + serviceInstantiation.getLcpCloudRegionId(), + null, + serviceInstantiation.getSubscriptionServiceType(), + serviceInstantiation.getSubscriberName(), + null, + serviceInstantiation.getInstanceName(), + serviceInstantiation.getModelInfo().getModelInvariantId(), + serviceInstantiation.getModelInfo().getModelName(), + serviceInstantiation.getModelInfo().getModelVersion(), + createdBulkDate ); } @Override - public RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateServiceInstantiationRequest(UUID jobId, ServiceInstantiation payload, String userId) { + public RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateServiceInstantiationRequest(UUID jobId, + ServiceInstantiation payload, String userId) { - ServiceInstantiationRequestDetails.ServiceInstantiationOwningEntity owningEntity = new ServiceInstantiationRequestDetails.ServiceInstantiationOwningEntity(payload.getOwningEntityId(), payload.getOwningEntityName()); + ServiceInstantiationRequestDetails.ServiceInstantiationOwningEntity owningEntity = new ServiceInstantiationRequestDetails.ServiceInstantiationOwningEntity( + payload.getOwningEntityId(), payload.getOwningEntityName()); SubscriberInfo subscriberInfo = new SubscriberInfo(); subscriberInfo.setGlobalSubscriberId(payload.getGlobalSubscriberId()); String serviceInstanceName = null; - if(payload.isUserProvidedNaming()) { + if (payload.isUserProvidedNaming()) { serviceInstanceName = getUniqueName(payload.getInstanceName(), ResourceType.SERVICE_INSTANCE); String finalServiceInstanceName = serviceInstanceName; updateServiceInfo(jobId, x -> x.setServiceInstanceName(finalServiceInstanceName)); } ServiceInstantiationRequestDetails.RequestInfo requestInfo = new ServiceInstantiationRequestDetails.RequestInfo( - serviceInstanceName, - payload.getProductFamilyId(), - "VID", - payload.isRollbackOnFailure(), - userId); + serviceInstanceName, + payload.getProductFamilyId(), + "VID", + payload.isRollbackOnFailure(), + userId); List<ServiceInstantiationRequestDetails.ServiceInstantiationService> serviceInstantiationService = new LinkedList<>(); - List<Map<String, String>> unFilteredInstanceParams = payload.getInstanceParams() != null ? payload.getInstanceParams() : new LinkedList<>(); + List<Map<String, String>> unFilteredInstanceParams = + payload.getInstanceParams() != null ? payload.getInstanceParams() : new LinkedList<>(); List<Map<String, String>> filteredInstanceParams = removeUnNeededParams(unFilteredInstanceParams); ServiceInstantiationRequestDetails.ServiceInstantiationService serviceInstantiationService1 = new ServiceInstantiationRequestDetails.ServiceInstantiationService( - payload.getModelInfo(), - serviceInstanceName, - filteredInstanceParams, - createServiceInstantiationVnfList(payload) + payload.getModelInfo(), + serviceInstanceName, + filteredInstanceParams, + createServiceInstantiationVnfList(payload) ); serviceInstantiationService.add(serviceInstantiationService1); - ServiceInstantiationRequestDetails.RequestParameters requestParameters = new ServiceInstantiationRequestDetails.RequestParameters(payload.getSubscriptionServiceType(), false, serviceInstantiationService); + ServiceInstantiationRequestDetails.RequestParameters requestParameters = new ServiceInstantiationRequestDetails.RequestParameters( + payload.getSubscriptionServiceType(), false, serviceInstantiationService); - ServiceInstantiationRequestDetails.Project project = payload.getProjectName() != null ? new ServiceInstantiationRequestDetails.Project(payload.getProjectName()) : null; + ServiceInstantiationRequestDetails.Project project = + payload.getProjectName() != null ? new ServiceInstantiationRequestDetails.Project(payload.getProjectName()) + : null; - ServiceInstantiationRequestDetails requestDetails = new ServiceInstantiationRequestDetails(payload.getModelInfo(), owningEntity, subscriberInfo, - project, requestInfo, requestParameters); + ServiceInstantiationRequestDetails requestDetails = new ServiceInstantiationRequestDetails( + payload.getModelInfo(), owningEntity, subscriberInfo, + project, requestInfo, requestParameters); - RequestDetailsWrapper<ServiceInstantiationRequestDetails> requestDetailsWrapper = new RequestDetailsWrapper(requestDetails); + RequestDetailsWrapper<ServiceInstantiationRequestDetails> requestDetailsWrapper = new RequestDetailsWrapper( + requestDetails); debugRequestDetails(requestDetailsWrapper, logger); return requestDetailsWrapper; } @@ -204,10 +242,11 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu List<String> keysToRemove = new ArrayList<>(); if (instanceParams != null && !instanceParams.isEmpty()) { for (String key : instanceParams.get(0).keySet()) { - for (String paramToIgnore : PARAMS_TO_IGNORE) + for (String paramToIgnore : PARAMS_TO_IGNORE) { if ((key.equalsIgnoreCase(paramToIgnore))) { keysToRemove.add(key); } + } } for (String key : keysToRemove) { instanceParams.get(0).remove(key); @@ -220,7 +259,8 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu return instanceParams; } - private ServiceInstantiationRequestDetails.ServiceInstantiationVnfList createServiceInstantiationVnfList(ServiceInstantiation payload) { + private ServiceInstantiationRequestDetails.ServiceInstantiationVnfList createServiceInstantiationVnfList( + ServiceInstantiation payload) { CloudConfiguration cloudConfiguration = new CloudConfiguration(); cloudConfiguration.setTenantId(payload.getTenantId()); cloudConfiguration.setLcpCloudRegionId(payload.getLcpCloudRegionId()); @@ -230,16 +270,17 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu for (Vnf vnf : vnfs.values()) { Map<String, Map<String, VfModule>> vfModules = vnf.getVfModules(); List<VfModule> convertedUnFilteredVfModules = convertVfModuleMapToList(vfModules); - List<VfModule> filteredVfModules = filterInstanceParamsFromVfModuleAndUniqueNames(convertedUnFilteredVfModules, vnf.isUserProvidedNaming()); + List<VfModule> filteredVfModules = filterInstanceParamsFromVfModuleAndUniqueNames( + convertedUnFilteredVfModules, vnf.isUserProvidedNaming()); ServiceInstantiationRequestDetails.ServiceInstantiationVnf serviceInstantiationVnf = new ServiceInstantiationRequestDetails.ServiceInstantiationVnf( - vnf.getModelInfo(), - cloudConfiguration, - vnf.getPlatformName(), - vnf.getLineOfBusiness(), - payload.getProductFamilyId(), - removeUnNeededParams(vnf.getInstanceParams()), - filteredVfModules, - vnf.isUserProvidedNaming() ? getUniqueName(vnf.getInstanceName(), ResourceType.GENERIC_VNF) : null + vnf.getModelInfo(), + cloudConfiguration, + vnf.getPlatformName(), + vnf.getLineOfBusiness(), + payload.getProductFamilyId(), + removeUnNeededParams(vnf.getInstanceParams()), + filteredVfModules, + vnf.isUserProvidedNaming() ? getUniqueName(vnf.getInstanceName(), ResourceType.GENERIC_VNF) : null ); vnfList.add(serviceInstantiationVnf); } @@ -251,27 +292,29 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu return vfModules.values().stream().flatMap(vfModule -> vfModule.values().stream()).collect(Collectors.toList()); } - private List<VfModule> filterInstanceParamsFromVfModuleAndUniqueNames(List<VfModule> unFilteredVfModules, boolean isUserProvidedNaming) { + private List<VfModule> filterInstanceParamsFromVfModuleAndUniqueNames(List<VfModule> unFilteredVfModules, + boolean isUserProvidedNaming) { return unFilteredVfModules.stream().map(vfModule -> - new VfModule( - vfModule.getModelInfo(), - getUniqueNameIfNeeded(isUserProvidedNaming, vfModule.getInstanceName(), ResourceType.VF_MODULE), - getUniqueNameIfNeeded(isUserProvidedNaming, vfModule.getVolumeGroupInstanceName(), ResourceType.VOLUME_GROUP), - removeUnNeededParams(vfModule.getInstanceParams()))) - .collect(Collectors.toList()); + new VfModule( + vfModule.getModelInfo(), + getUniqueNameIfNeeded(isUserProvidedNaming, vfModule.getInstanceName(), ResourceType.VF_MODULE), + getUniqueNameIfNeeded(isUserProvidedNaming, vfModule.getVolumeGroupInstanceName(), + ResourceType.VOLUME_GROUP), + removeUnNeededParams(vfModule.getInstanceParams()))) + .collect(Collectors.toList()); } private String getUniqueNameIfNeeded(boolean isUserProvidedNaming, String name, ResourceType resourceType) { return isUserProvidedNaming && !StringUtils.isEmpty(name) ? - getUniqueName(name, resourceType) : null; + getUniqueName(name, resourceType) : null; } @Override public String getServiceInstantiationPath(ServiceInstantiation serviceInstantiationRequest) { //in case pause flag is true - use assign , else - use create. return MsoBusinessLogicImpl.validateEndpointPath( - serviceInstantiationRequest.isPause() ? - "mso.restapi.serviceInstanceAssign" : "mso.restapi.serviceInstanceCreate" + serviceInstantiationRequest.isPause() ? + "mso.restapi.serviceInstanceAssign" : "mso.restapi.serviceInstanceCreate" ); } @@ -290,7 +333,7 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu @Override public ServiceInfo updateServiceInfoAndAuditStatus(UUID jobUuid, JobStatus jobStatus) { - auditVidStatus(jobUuid,jobStatus); + auditVidStatus(jobUuid, jobStatus); return updateServiceInfo(jobUuid, x -> setServiceInfoStatus(x, jobStatus)); } @@ -300,9 +343,12 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu } public ServiceInfo getServiceInfoByJobId(UUID jobUUID) { - List<ServiceInfo> serviceInfoList = dataAccessService.getList(ServiceInfo.class, String.format(" where jobId = '%s' ", jobUUID), null, null); + List<ServiceInfo> serviceInfoList = dataAccessService + .getList(ServiceInfo.class, String.format(" where jobId = '%s' ", jobUUID), null, null); if (serviceInfoList.size() != 1) { - throw new GenericUncheckedException("Failed to retrieve job with uuid " + jobUUID + " from ServiceInfo table. Instances found: " + serviceInfoList.size()); + throw new GenericUncheckedException( + "Failed to retrieve job with uuid " + jobUUID + " from ServiceInfo table. Instances found: " + + serviceInfoList.size()); } return serviceInfoList.get(0); } @@ -310,43 +356,46 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu public List<JobAuditStatus> getAuditStatuses(UUID jobUUID, JobAuditStatus.SourceStatus source) { return dataAccessService.getList( JobAuditStatus.class, - String.format(" where SOURCE = '%s' and JOB_ID = '%s'",source, jobUUID), + String.format(" where SOURCE = '%s' and JOB_ID = '%s'", source, jobUUID), " CREATED_DATE ", null); } - private JobAuditStatus getLatestAuditStatus(UUID jobUUID, JobAuditStatus.SourceStatus source){ - List<JobAuditStatus> list = getAuditStatuses(jobUUID,source); - return !list.isEmpty() ? list.get(list.size()-1) : null; + private JobAuditStatus getLatestAuditStatus(UUID jobUUID, JobAuditStatus.SourceStatus source) { + List<JobAuditStatus> list = getAuditStatuses(jobUUID, source); + return !list.isEmpty() ? list.get(list.size() - 1) : null; } @Override - public void auditVidStatus(UUID jobUUID, JobStatus jobStatus){ + public void auditVidStatus(UUID jobUUID, JobStatus jobStatus) { JobAuditStatus vidStatus = new JobAuditStatus(jobUUID, jobStatus.toString(), JobAuditStatus.SourceStatus.VID); auditStatus(vidStatus); } @Override - public void auditMsoStatus(UUID jobUUID, AsyncRequestStatus.Request msoRequestStatus){ - auditMsoStatus(jobUUID, msoRequestStatus.requestStatus.getRequestState(), msoRequestStatus.requestId, msoRequestStatus.requestStatus.getStatusMessage()); + public void auditMsoStatus(UUID jobUUID, AsyncRequestStatus.Request msoRequestStatus) { + auditMsoStatus(jobUUID, msoRequestStatus.requestStatus.getRequestState(), msoRequestStatus.requestId, + msoRequestStatus.requestStatus.getStatusMessage()); } @Override - public void auditMsoStatus(UUID jobUUID, String jobStatus, String requestId, String additionalInfo){ + public void auditMsoStatus(UUID jobUUID, String jobStatus, String requestId, String additionalInfo) { JobAuditStatus msoStatus = new JobAuditStatus(jobUUID, jobStatus, JobAuditStatus.SourceStatus.MSO, - requestId != null ? UUID.fromString(requestId) : null, - additionalInfo); + requestId != null ? UUID.fromString(requestId) : null, + additionalInfo); auditStatus(msoStatus); } - private void auditStatus(JobAuditStatus jobAuditStatus){ - JobAuditStatus latestStatus = getLatestAuditStatus(jobAuditStatus.getJobId(),jobAuditStatus.getSource()); - if (latestStatus == null || !latestStatus.equals(jobAuditStatus)) + private void auditStatus(JobAuditStatus jobAuditStatus) { + JobAuditStatus latestStatus = getLatestAuditStatus(jobAuditStatus.getJobId(), jobAuditStatus.getSource()); + if (latestStatus == null || !latestStatus.equals(jobAuditStatus)) { dataAccessService.saveDomainObject(jobAuditStatus, DaoUtils.getPropsMap()); + } } public Job.JobStatus calcStatus(AsyncRequestStatus asyncRequestStatus) { - String msoRequestState = asyncRequestStatus.request.requestStatus.getRequestState().toLowerCase().replaceAll("[^a-z]+", ""); + String msoRequestState = asyncRequestStatus.request.requestStatus.getRequestState().toLowerCase() + .replaceAll("[^a-z]+", ""); JobStatus jobStatus = msoStateToJobStatusMap.get(msoRequestState); return (jobStatus != null ? jobStatus : JobStatus.IN_PROGRESS); } @@ -355,11 +404,11 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu public void handleFailedInstantiation(UUID jobUUID) { ServiceInfo serviceInfo = updateServiceInfoAndAuditStatus(jobUUID, JobStatus.FAILED); List<ServiceInfo> serviceInfoList = dataAccessService.getList( - ServiceInfo.class, - String.format(" where templateId = '%s' and jobStatus = '%s'", - serviceInfo.getTemplateId(), - JobStatus.PENDING), - null, null); + ServiceInfo.class, + String.format(" where templateId = '%s' and jobStatus = '%s'", + serviceInfo.getTemplateId(), + JobStatus.PENDING), + null, null); serviceInfoList.forEach(si -> updateServiceInfoAndAuditStatus(si.getJobId(), JobStatus.STOPPED)); } @@ -374,9 +423,9 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu public void hideServiceInfo(UUID jobUUID) { ServiceInfo serviceInfo = getServiceInfoByJobId(jobUUID); if (!serviceInfo.getJobStatus().isFinal()) { - String message = String.format( "jobId %s: Service status does not allow hide service, status = %s", - serviceInfo.getJobId(), - serviceInfo.getJobStatus()); + String message = String.format("jobId %s: Service status does not allow hide service, status = %s", + serviceInfo.getJobId(), + serviceInfo.getJobStatus()); logger.error(EELFLoggerDelegate.errorLogger, message); throw new OperationNotAllowedException(message); } @@ -387,31 +436,29 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu @Override public int - getCounterForName(String name) { String hqlSelectNC = "from NameCounter where name = :name"; String hqlUpdateCounter = "update NameCounter set counter = :newCounter " + - "where name= :name " + - "and counter= :prevCounter"; + "where name= :name " + + "and counter= :prevCounter"; Integer counter = null; GenericUncheckedException lastException = null; - for (int i = 0; i< MAX_RETRIES_GETTING_COUNTER && counter==null; i++) { + for (int i = 0; i < MAX_RETRIES_GETTING_COUNTER && counter == null; i++) { try { counter = calcCounter(name, hqlSelectNC, hqlUpdateCounter); - } - catch (GenericUncheckedException exception) { + } catch (GenericUncheckedException exception) { lastException = exception; //do nothing, we will try again in the loop } } - if (counter!=null) { + if (counter != null) { return counter; } - throw lastException!=null ? new DbFailureUncheckedException(lastException) : - new DbFailureUncheckedException("Failed to get counter for "+name+" due to unknown error"); + throw lastException != null ? new DbFailureUncheckedException(lastException) : + new DbFailureUncheckedException("Failed to get counter for " + name + " due to unknown error"); } @@ -419,14 +466,14 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu Integer counter; counter = DaoUtils.tryWithSessionAndTransaction(sessionFactory, session -> { NameCounter nameCounter = (NameCounter) session.createQuery(hqlSelectNC) - .setText("name", name) - .uniqueResult(); + .setText("name", name) + .uniqueResult(); if (nameCounter != null) { int updatedRows = session.createQuery(hqlUpdateCounter) - .setText("name", nameCounter.getName()) - .setInteger("prevCounter", nameCounter.getCounter()) - .setInteger("newCounter", nameCounter.getCounter() + 1) - .executeUpdate(); + .setText("name", nameCounter.getName()) + .setInteger("prevCounter", nameCounter.getCounter()) + .setInteger("newCounter", nameCounter.getCounter() + 1) + .executeUpdate(); if (updatedRows == 1) { return nameCounter.getCounter() + 1; } @@ -459,7 +506,7 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu //Prevents unnecessary increasing of the counter while AAI doesn't response isNameFreeInAai(NAME_FOR_CHECK_AAI_STATUS, resourceType); - for (int i=0; i<getMaxRetriesGettingFreeNameFromAai(); i++) { + for (int i = 0; i < getMaxRetriesGettingFreeNameFromAai(); i++) { int counter = getCounterForName(name); String newName = formatNameAndCounter(name, counter); if (isNameFreeInAai(newName, resourceType)) { @@ -467,7 +514,7 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu } } - throw new MaxRetriesException("find unused name for "+name, getMaxRetriesGettingFreeNameFromAai()); + throw new MaxRetriesException("find unused name for " + name, getMaxRetriesGettingFreeNameFromAai()); } //the method is protected so we can call it in the UT @@ -476,11 +523,17 @@ public class AsyncInstantiationBusinessLogicImpl implements AsyncInstantiationBu } private boolean isNameFreeInAai(String name, ResourceType resourceType) throws InvalidAAIResponseException { - AaiResponse<AaiNodeQueryResponse> aaiResponse = aaiClient.searchNodeTypeByName(name, resourceType); - if (aaiResponse.getHttpCode() > 399 || aaiResponse.getT() == null) { - throw new InvalidAAIResponseException(aaiResponse); + HttpResponse<AaiNodeQueryResponse> aaiResponse = aaiOverTLSClient + .searchNodeTypeByName(name, resourceType); + if (aaiResponse.getStatus() > 399 || aaiResponse.getBody() == null) { + try { + String message = IOUtils.toString(aaiResponse.getRawBody(), "UTF-8"); + throw new InvalidAAIResponseException(aaiResponse.getStatus(), message); + } catch (IOException e) { + throw new InvalidAAIResponseException(aaiResponse.getStatus(), aaiResponse.getStatusText()); + } } - return CollectionUtils.isEmpty(aaiResponse.getT().resultData); + return CollectionUtils.isEmpty(aaiResponse.getBody().resultData); } } diff --git a/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java index 635cb4855..500f5ac7f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java @@ -1,7 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.vid.services; +import io.joshworks.restclient.http.HttpResponse; import jline.internal.Log; import org.onap.vid.aai.AaiClientInterface; +import org.onap.vid.aai.AaiOverTLSClientInterface; import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.ServiceSubscription; import org.onap.vid.aai.Services; @@ -9,6 +32,7 @@ import org.onap.vid.model.ModelConstants; import org.onap.vid.model.Subscriber; import org.onap.vid.model.SubscriberList; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -17,9 +41,14 @@ import java.util.HashMap; public class RoleGenaratorServiceImpl implements RoleGeneratorService { public static final String ROLE_ID_COLUMN = "ROLE_ID"; + @Autowired AaiClientInterface client; + @Autowired + @Qualifier("aaiClientForCodehausMapping") + AaiOverTLSClientInterface aaiOverTLSClient; + public static final String DB_NAME = "vid_portal"; public static final String TBL_NAME = "fn_role"; public static final String TEMP_DELIMITER ="***"; @@ -30,11 +59,11 @@ public class RoleGenaratorServiceImpl implements RoleGeneratorService { String query = "USE " + DB_NAME + ";\r\n" + "SET SQL_SAFE_UPDATES = 0;\r\n"; try { - AaiResponse<SubscriberList> subscribers = client.getAllSubscribers(); + HttpResponse<SubscriberList> allSubscribers = aaiOverTLSClient.getAllSubscribers(); if (firstRun) { - query += replaceRolesToTempDelimiter("subscriber",buildSubscribersValuesForMappingsTable(subscribers.getT())); + query += replaceRolesToTempDelimiter("subscriber",buildSubscribersValuesForMappingsTable(allSubscribers.getBody())); } - query += addAvailableRolesCombination(firstRun, subscribers); + query += addAvailableRolesCombination(firstRun, allSubscribers.getBody()); } catch (Exception e) { @@ -43,10 +72,10 @@ public class RoleGenaratorServiceImpl implements RoleGeneratorService { return query; } - private String addAvailableRolesCombination(Boolean firstRun, AaiResponse<SubscriberList> subscribers) { + private String addAvailableRolesCombination(Boolean firstRun, SubscriberList subscribers) { String query, availableRoles=""; HashMap<String,String> servicesNames = new HashMap<String,String>(); - for (Subscriber subscriber: subscribers.getT().customer) { + for (Subscriber subscriber: subscribers.customer) { AaiResponse<Services> subscriberResponse = client.getSubscriberData(subscriber.globalCustomerId); for(ServiceSubscription service: subscriberResponse.getT().serviceSubscriptions.serviceSubscription) { servicesNames.put(service.serviceType,""); diff --git a/vid-app-common/src/main/resources/1712_ADIOD.zip b/vid-app-common/src/main/resources/1712_ADIOD.zip Binary files differnew file mode 100644 index 000000000..281ee8aa3 --- /dev/null +++ b/vid-app-common/src/main/resources/1712_ADIOD.zip diff --git a/vid-app-common/src/main/resources/sdcservices.json b/vid-app-common/src/main/resources/sdcservices.json index 1d9d160e3..e300597e5 100644 --- a/vid-app-common/src/main/resources/sdcservices.json +++ b/vid-app-common/src/main/resources/sdcservices.json @@ -71,6 +71,20 @@ "resources": null }, { + "uuid": "90fe6842-aa76-4b68-8329-5c86ff564407", + "invariantUUID": "0311f998-9268-4fd6-bbba-afff15087b72", + "name": "4-27_vMME_Service", + "version": "1.0", + "toscaModelURL": "./1712_ADIOD.zip", + "category": "Mobility", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rg276b", + "lastUpdaterFullName": null, + "distributionStatus": "DISTRIBUTED", + "artifacts": null, + "resources": null + }, + { "uuid": "73e1322a-8a9a-49dc-9558-b0c5c5770e4a", "invariantUUID": "f430728a-4530-42be-a577-1206b9484cef", "name": "4-27_vMME_Service", diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js index 6029ed2d7..c6c9edf6e 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js @@ -94,14 +94,14 @@ _.forEach(newVNFName.vfModules, function (mdl, key) { mdl.scale = false; //defaults to not scale unless user changes it - if(mdl.properties && mdl.properties.max_vf_module_instances) { + if(mdl.properties && mdl.properties.maxCountInstances) { //how many vf modules of the same customizationId belong to that vnf instance mdl.currentCount = _.filter(vm.vfModules, function(item){ return modulesAaiIds.indexOf(item.id) > -1 && item.properties["model-customization-id"] === mdl.customizationUuid; }).length; - mdl.scalable = mdl.properties.max_vf_module_instances.value - mdl.currentCount > 0; + mdl.scalable = mdl.properties.maxCountInstances - mdl.currentCount > 0; }else{ mdl.scalable = false; } diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java index 76d1d4aff..201ec0981 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java @@ -33,6 +33,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse; import org.onap.vid.aai.model.AaiNodeQueryResponse; +import org.onap.vid.aai.model.PortDetailsTranslator; import org.onap.vid.aai.model.ResourceType; import org.onap.vid.aai.util.AAIRestInterface; import org.onap.vid.aai.util.HttpsAuthClient; @@ -71,13 +72,12 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalToIgnoringCase; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; import static org.testng.Assert.*; @ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class}) @@ -88,19 +88,19 @@ public class AaiClientTest { private ServletContext servletContext; @BeforeMethod - public void initMocks(){ + public void initMocks() { aaiClientMock = mock(AaiClient.class); aaiClientMock.logger = mock(EELFLoggerDelegate.class); servletContext = mock(ServletContext.class); when(servletContext.getRealPath(any(String.class))).thenReturn(""); - when(aaiClientMock.doAaiGet(any(String.class),any(Boolean.class))).thenReturn(null); + when(aaiClientMock.doAaiGet(any(String.class), any(Boolean.class))).thenReturn(null); } @DataProvider public static Object[][] logicalLinkData() { - return new Object[][] { + return new Object[][]{ {"", "network/logical-links/logical-link/"}, {"link", "network/logical-links/logical-link/link"} }; @@ -111,21 +111,26 @@ public class AaiClientTest { when(aaiClientMock.getLogicalLink(any(String.class))).thenCallRealMethod(); aaiClientMock.getLogicalLink(link); - Mockito.verify(aaiClientMock).doAaiGet(argThat(equalToIgnoringCase(expectedUrl)),any(Boolean.class)); + Mockito.verify(aaiClientMock).doAaiGet(argThat(s -> equalsIgnoreCase(s, expectedUrl)), any(Boolean.class)); } @DataProvider public static Object[][] subscribersResults() { - return new Object[][] { - {new SubscriberList(new ArrayList<Subscriber>() {{ add(new Subscriber()); add(new Subscriber()); }}), true}, - {new SubscriberList(new ArrayList<Subscriber>() {{ add(new Subscriber()); }}), true}, + return new Object[][]{ + {new SubscriberList(new ArrayList<Subscriber>() {{ + add(new Subscriber()); + add(new Subscriber()); + }}), true}, + {new SubscriberList(new ArrayList<Subscriber>() {{ + add(new Subscriber()); + }}), true}, {new SubscriberList(new ArrayList<Subscriber>()), false} }; } @Test(dataProvider = "subscribersResults") - public void testProbeAaiGetAllSubscribers_returnsTwoToZeroSubscribers_ResultsAsExpected(SubscriberList subscribers, boolean isAvailable){ - ExternalComponentStatus expectedStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.AAI,isAvailable, new HttpRequestMetadata( + public void testProbeAaiGetAllSubscribers_returnsTwoToZeroSubscribers_ResultsAsExpected(SubscriberList subscribers, boolean isAvailable) { + ExternalComponentStatus expectedStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, isAvailable, new HttpRequestMetadata( HttpMethod.GET, 200, "url", @@ -138,9 +143,9 @@ public class AaiClientTest { HttpMethod.GET, "url", new AaiResponse<>(subscribers, null, 200), "rawData")); Mockito.when(aaiClientMock.probeAaiGetAllSubscribers()).thenCallRealMethod(); - ExternalComponentStatus result = aaiClientMock.probeAaiGetAllSubscribers(); - assertThat(statusDataReflected(result),is(statusDataReflected(expectedStatus))); - assertThat(requestMetadataReflected(result.getMetadata()),is(requestMetadataReflected(expectedStatus.getMetadata()))); + ExternalComponentStatus result = aaiClientMock.probeAaiGetAllSubscribers(); + assertThat(statusDataReflected(result), is(statusDataReflected(expectedStatus))); + assertThat(requestMetadataReflected(result.getMetadata()), is(requestMetadataReflected(expectedStatus.getMetadata()))); } //serialize fields except of fields we cannot know ahead of time @@ -159,12 +164,12 @@ public class AaiClientTest { @DataProvider public static Object[][] rawData() { return new Object[][]{ - {"errorMessage", }, {""}, {null} + {"errorMessage",}, {""}, {null} }; } @Test(dataProvider = "rawData") - public void testProbeAaiGetFullSubscribersWithNullResponse_returnsNotAvailableWithErrorRawData(String rawData){ + public void testProbeAaiGetFullSubscribersWithNullResponse_returnsNotAvailableWithErrorRawData(String rawData) { Mockito.when(aaiClientMock.getAllSubscribers(true)).thenReturn( new AaiResponseWithRequestInfo<>(HttpMethod.GET, "url", null, rawData)); @@ -175,7 +180,7 @@ public class AaiClientTest { @DataProvider public static Object[][] exceptions() { - return new Object[][] { + return new Object[][]{ {"NullPointerException", "errorMessage", new ExceptionWithRequestInfo(HttpMethod.GET, "url", "errorMessage", null, new NullPointerException())}, @@ -188,7 +193,7 @@ public class AaiClientTest { } @Test(dataProvider = "exceptions") - public void testProbeAaiGetFullSubscribersWithNullResponse_returnsNotAvailableWithErrorRawData(String description, String expectedRawData, Exception exception){ + public void testProbeAaiGetFullSubscribersWithNullResponse_returnsNotAvailableWithErrorRawData(String description, String expectedRawData, Exception exception) { Mockito.when(aaiClientMock.getAllSubscribers(true)).thenThrow(exception); ExternalComponentStatus result = callProbeAaiGetAllSubscribersAndAssertNotAvailable(); if (exception instanceof ExceptionWithRequestInfo) { @@ -200,7 +205,7 @@ public class AaiClientTest { private ExternalComponentStatus callProbeAaiGetAllSubscribersAndAssertNotAvailable() { Mockito.when(aaiClientMock.probeAaiGetAllSubscribers()).thenCallRealMethod(); - ExternalComponentStatus result = aaiClientMock.probeAaiGetAllSubscribers(); + ExternalComponentStatus result = aaiClientMock.probeAaiGetAllSubscribers(); assertFalse(result.isAvailable()); return result; } @@ -209,7 +214,7 @@ public class AaiClientTest { @Test public void getTenants_Arguments_Are_Null_Or_Empty() { - when(aaiClientMock.getTenants(any(String.class), any(String.class))).thenCallRealMethod(); + when(aaiClientMock.getTenants(any(), any())).thenCallRealMethod(); AaiResponse response = aaiClientMock.getTenants("", ""); @@ -227,7 +232,7 @@ public class AaiClientTest { when(aaiClientMock.getTenants(any(String.class), any(String.class))).thenCallRealMethod(); Response generalEmptyResponse = mock(Response.class); - when(aaiClientMock.doAaiGet(any(String.class),any(Boolean.class))).thenReturn(generalEmptyResponse); + when(aaiClientMock.doAaiGet(any(String.class), any(Boolean.class))).thenReturn(generalEmptyResponse); AaiResponse response = aaiClientMock.getTenants("subscriberId", "serviceType"); @@ -263,14 +268,14 @@ public class AaiClientTest { }); - when(aaiClientMock.doAaiGet(any(String.class),any(Boolean.class))).thenReturn(generalEmptyResponse); + when(aaiClientMock.doAaiGet(any(String.class), any(Boolean.class))).thenReturn(generalEmptyResponse); AaiResponse<GetTenantsResponse[]> response = aaiClientMock.getTenants("subscriberId", "serviceType"); - Assert.assertTrue(response.t.length> 0); + Assert.assertTrue(response.t.length > 0); } - final String tenantResponseRaw ="" + + final String tenantResponseRaw = "" + "{" + "\"service-type\": \"VIRTUAL USP\"," + "\"resource-version\": \"1494001841964\"," + @@ -301,7 +306,7 @@ public class AaiClientTest { @DataProvider public static Object[][] resourceTypesProvider() { - return new Object[][] { + return new Object[][]{ {"service-instance", ResourceType.SERVICE_INSTANCE}, {"generic-vnf", ResourceType.GENERIC_VNF}, {"vf-module", ResourceType.VF_MODULE} @@ -313,9 +318,9 @@ public class AaiClientTest { String link = "/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Nimbus/service-instances/service-instance/7131d483-b450-406f-8e30-0c650645fc67"; String json = "{\"result-data\": [{" + - "\"resource-type\": \""+resourceType+"\"," + - "\"resource-link\": \""+ link+ "\"" + - "}]}"; + "\"resource-type\": \"" + resourceType + "\"," + + "\"resource-link\": \"" + link + "\"" + + "}]}"; AaiNodeQueryResponse nodeQueryResponse = new ObjectMapper().readValue(json, AaiNodeQueryResponse.class); assertThat(nodeQueryResponse.resultData.get(0).resourceLink, equalTo(link)); @@ -323,7 +328,7 @@ public class AaiClientTest { } @Test - public void aaiNodeQueryEmptyResponseDeserializationTest() throws IOException{ + public void aaiNodeQueryEmptyResponseDeserializationTest() throws IOException { String json = "{}"; AaiNodeQueryResponse nodeQueryResponse = new ObjectMapper().readValue(json, AaiNodeQueryResponse.class); assertNull(nodeQueryResponse.resultData); @@ -331,7 +336,7 @@ public class AaiClientTest { @DataProvider public static Object[][] nameAndResourceTypeProvider() { - return new Object[][] { + return new Object[][]{ {"SRIOV_SVC", ResourceType.SERVICE_INSTANCE, "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:SRIOV_SVC"}, {"b1707vidnf", ResourceType.GENERIC_VNF, "search/nodes-query?search-node-type=generic-vnf&filter=vnf-name:EQUALS:b1707vidnf"}, {"connectivity_test", ResourceType.VF_MODULE, "search/nodes-query?search-node-type=vf-module&filter=vf-module-name:EQUALS:connectivity_test"}, @@ -460,6 +465,25 @@ public class AaiClientTest { assertFalse(propagateExceptions, "calling doAaiGet when propagateExceptions is 'true' must result with an exception (in this test)"); } + @Test + public void shouldProperlyReadResponseOnceWhenSubscribersAreNotPresent() { + AAIRestInterface restInterface = mock(AAIRestInterface.class); + PortDetailsTranslator portDetailsTranslator = mock(PortDetailsTranslator.class); + Response response = mock(Response.class); + when(response.getStatus()).thenReturn(404); + when(response.readEntity(String.class)).thenReturn("sampleEntity"); + when(response.getStatusInfo()).thenReturn(Response.Status.NOT_FOUND); + ResponseWithRequestInfo responseWithRequestInfo = new ResponseWithRequestInfo(response, "test", HttpMethod.GET); + when(restInterface.RestGet(eq("VidAaiController"), any(String.class), + eq("business/customers?subscriber-type=INFRA&depth=0"), eq(false), eq(true))).thenReturn(responseWithRequestInfo); + AaiClient aaiClient = new AaiClient(restInterface, portDetailsTranslator); + + + aaiClient.getAllSubscribers(true); + + verify(response).readEntity(String.class); + } + @FunctionalInterface public interface UncheckedBiConsumer<T, U> extends BiConsumer<T, U> { @Override diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java new file mode 100644 index 000000000..d4f59e7da --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java @@ -0,0 +1,199 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2018 Nokia Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.aai; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.xebialabs.restito.semantics.Action; +import io.joshworks.restclient.http.HttpResponse; +import io.joshworks.restclient.http.mapper.ObjectMapper; +import org.assertj.core.api.Assertions; +import org.glassfish.grizzly.http.util.HttpStatus; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.vid.aai.model.AaiNodeQueryResponse; +import org.onap.vid.aai.model.ResourceType; +import org.onap.vid.client.SyncRestClient; +import org.onap.vid.model.SubscriberList; +import org.onap.vid.testUtils.StubServerUtil; + +import java.io.IOException; + +@RunWith(MockitoJUnitRunner.class) +public class AaiOverTLSClientServerTest { + + @Mock + private AaiOverTLSPropertySupplier propertySupplier; + + private static StubServerUtil serverUtil; + + private String searchNodesQueryResponsePayload = + "{\n" + + "\"result-data\": [\n" + + " {\n" + + "\"resource-type\": \"generic-vnf\",\n" + + "\"resource-link\": \"/aai/v13/network/generic-vnfs/generic-vnf/6eac8e69-c98d-4ac5-ab90-69fe0cabda76\"\n" + + "},\n" + + " {\n" + + "\"resource-type\": \"generic-vnf\",\n" + + "\"resource-link\": \"/aai/v13/network/generic-vnfs/generic-vnf/e3766bc5-40a7-4dbe-9d4a-1d8c8f284913\"\n" + + "},\n" + + " {\n" + + "\"resource-type\": \"generic-vnf\",\n" + + "\"resource-link\": \"/aai/v13/network/generic-vnfs/generic-vnf/6aa153ee-6637-4b49-beb5-a5e756e00393\"\n" + + "},\n" + + " {\n" + + "\"resource-type\": \"generic-vnf\",\n" + + "\"resource-link\": \"/aai/v13/network/generic-vnfs/generic-vnf/5a981c30-de25-4ea9-98fa-ed398f13ea41\"\n" + + "},\n" + + " {\n" + + "\"resource-type\": \"generic-vnf\",\n" + + "\"resource-link\": \"/aai/v13/network/generic-vnfs/generic-vnf/b0ef2271-8ac0-4268-b9a5-09cb50c20c85\"\n" + + "}\n" + + "],\n" + + "}"; + + private String subscribersResponsePayload = + "{\n" + + "\"customer\": [\n" + + " {\n" + + "\"global-customer-id\": \"DemoCust_752df078-d8e9-4731-abf6-8ae7348075bb\",\n" + + "\"subscriber-name\": \"DemoCust_752df078-d8e9-4731-abf6-8ae7348075bb\",\n" + + "\"subscriber-type\": \"INFRA\",\n" + + "\"resource-version\": \"1536158347585\"\n" + + "},\n" + + " {\n" + + "\"global-customer-id\": \"DemoCust_62bf43a3-4888-4c82-ae98-3ebc3d782761\",\n" + + "\"subscriber-name\": \"DemoCust_62bf43a3-4888-4c82-ae98-3ebc3d782761\",\n" + + "\"subscriber-type\": \"INFRA\",\n" + + "\"resource-version\": \"1536240894581\"\n" + + "},\n" + + " {\n" + + "\"global-customer-id\": \"DemoCust_e84256d6-ef3e-4a28-9741-9987019c3a8f\",\n" + + "\"subscriber-name\": \"DemoCust_e84256d6-ef3e-4a28-9741-9987019c3a8f\",\n" + + "\"subscriber-type\": \"INFRA\",\n" + + "\"resource-version\": \"1536330956393\"\n" + + "},\n" + + " {\n" + + "\"global-customer-id\": \"ETE_Customer_377bb124-2638-4025-a315-cdae04f52bce\",\n" + + "\"subscriber-name\": \"ETE_Customer_377bb124-2638-4025-a315-cdae04f52bce\",\n" + + "\"subscriber-type\": \"INFRA\",\n" + + "\"resource-version\": \"1536088625538\"\n" + + "}\n" + + "],\n" + + "}"; + + @BeforeClass + public static void setUpClass(){ + serverUtil = new StubServerUtil(); + serverUtil.runServer(); + } + + @AfterClass + public static void tearDown(){ + serverUtil.stopServer(); + } + + @Test + public void shouldSearchNodeTypeByName() throws IOException, ParseException { + ObjectMapper objectMapper = getFasterXmlObjectMapper(); + AaiOverTLSClient aaiOverTLSClient = new AaiOverTLSClient(new SyncRestClient(objectMapper), propertySupplier, serverUtil.constructTargetUrl("http", "")); + + serverUtil.prepareGetCall("/search/nodes-query", new JSONParser().parse(searchNodesQueryResponsePayload), Action.status(HttpStatus.OK_200)); + + HttpResponse<AaiNodeQueryResponse> aaiNodeQueryResponseHttpResponse = aaiOverTLSClient + .searchNodeTypeByName("any", ResourceType.GENERIC_VNF); + + AaiNodeQueryResponse body = aaiNodeQueryResponseHttpResponse.getBody(); + Assertions.assertThat(body.resultData.size()).isEqualTo(5); + Assertions.assertThat(aaiNodeQueryResponseHttpResponse.getStatus()).isEqualTo(200); + } + + @Test + public void shouldGetSubscribers() throws ParseException, JsonProcessingException { + ObjectMapper objectMapper = getCodehausObjectMapper(); + AaiOverTLSClient aaiOverTLSClient = new AaiOverTLSClient(new SyncRestClient(objectMapper), propertySupplier, serverUtil.constructTargetUrl("http", "")); + + serverUtil.prepareGetCall("/business/customers", new JSONParser().parse(subscribersResponsePayload), Action.status(HttpStatus.OK_200)); + + HttpResponse<SubscriberList> allSubscribers = aaiOverTLSClient.getAllSubscribers(); + + SubscriberList subscriberList = allSubscribers.getBody(); + Assertions.assertThat(subscriberList.customer.size()).isEqualTo(4); + Assertions.assertThat(allSubscribers.getStatus()).isEqualTo(200); + } + + private ObjectMapper getCodehausObjectMapper() { + return new ObjectMapper() { + + org.codehaus.jackson.map.ObjectMapper om = new org.codehaus.jackson.map.ObjectMapper(); + + @Override + public <T> T readValue(String s, Class<T> aClass) { + try { + return om.readValue(s, aClass); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public String writeValue(Object o) { + try { + return om.writeValueAsString(o); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + }; + } + + private ObjectMapper getFasterXmlObjectMapper() { + return new ObjectMapper() { + + com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper(); + + @Override + public <T> T readValue(String s, Class<T> aClass) { + try { + return om.readValue(s, aClass); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public String writeValue(Object o) { + try { + return om.writeValueAsString(o); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + }; + } + +} diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java new file mode 100644 index 000000000..f281e84b6 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2018 Nokia Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.aai; + +import com.google.common.collect.ImmutableMap; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.vid.aai.model.AaiNodeQueryResponse; +import org.onap.vid.aai.model.ResourceType; +import org.onap.vid.client.SyncRestClient; +import org.onap.vid.model.SubscriberList; + +import java.util.Collections; +import java.util.Map; + +import static org.mockito.ArgumentMatchers.contains; +import static org.mockito.ArgumentMatchers.eq; + +@RunWith(MockitoJUnitRunner.class) +public class AaiOverTLSClientTest { + + private static final String SEARCH_NODES_QUERY_SEARCH_NODE_TYPE = "search/nodes-query?search-node-type=generic-vnf&filter=vnf-name:EQUALS:name"; + private static final String SUBSCRIBERS = "business/customers?subscriber-type=INFRA&depth=0"; + private AaiOverTLSClient aaiRestClient; + + @Mock + private SyncRestClient syncRestClient; + @Mock + private AaiOverTLSPropertySupplier propertySupplier; + + @Before + public void setUp() { + aaiRestClient = new AaiOverTLSClient(syncRestClient, propertySupplier); + } + + @Test + public void testSearchNodeTypeByName() { + mockPropertyReader(); + + aaiRestClient.searchNodeTypeByName("name", ResourceType.GENERIC_VNF); + Mockito.verify(syncRestClient).get(contains(SEARCH_NODES_QUERY_SEARCH_NODE_TYPE), + eq(getHeaders()), eq(Collections.emptyMap()), eq(AaiNodeQueryResponse.class)); + } + + @Test + public void testGetAllSubscribers(){ + mockPropertyReader(); + + aaiRestClient.getAllSubscribers(); + Mockito.verify(syncRestClient).get(contains(SUBSCRIBERS), + eq(getHeaders()), eq(Collections.emptyMap()), eq(SubscriberList.class)); + } + + private void mockPropertyReader() { + Mockito.when(propertySupplier.getPassword()).thenReturn("Pass"); + Mockito.when(propertySupplier.getUsername()).thenReturn("User"); + Mockito.when(propertySupplier.getRequestId()).thenReturn("1"); + Mockito.when(propertySupplier.getRandomUUID()).thenReturn("2"); + } + + private Map<String,String> getHeaders(){ + return ImmutableMap.<String, String>builder().put("Authorization", "Basic VXNlcjpQYXNz"). + put("X-FromAppId", "VidAaiController").put("Accept", "application/json").put("X-ECOMP-RequestID", "1"). + put("X-TransactionId", "2").put("Content-Type", "application/json").build(); + } + +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java index f000dc801..ce957ab67 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java @@ -21,21 +21,11 @@ package org.onap.vid.aai.util; -import org.junit.Before; -import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.vid.aai.exceptions.HttpClientBuilderException; +import org.mockito.junit.MockitoJUnitRunner; import javax.net.ssl.SSLContext; -import java.util.Optional; - -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class HttpsAuthClientTest { diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java index cd2b8ff28..7fad9019c 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.vid.aai.exceptions.InvalidPropertyException; import org.testng.Assert; diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java index 1282a6f78..e1c5e923b 100644 --- a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java @@ -15,8 +15,8 @@ import org.onap.sdc.toscaparser.api.NodeTemplate; import org.onap.vid.asdc.AsdcCatalogException; import org.onap.vid.asdc.AsdcClient; import org.onap.vid.asdc.local.LocalAsdcClient; -import org.onap.vid.model.*; import org.onap.vid.controllers.ToscaParserMockHelper; +import org.onap.vid.model.*; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -196,6 +196,28 @@ public class ToscaParserImpl2Test { JsonAssert.assertJsonEquals(expectedConfigurations, actualConfigurations); } + @Test + public void modelWithAnnotatedInputWithTwoProperties_vfModuleGetsTheInput() throws Exception { + final ToscaParserMockHelper mockHelper = new ToscaParserMockHelper("90fe6842-aa76-4b68-8329-5c86ff564407", "empty.json"); + final ServiceModel serviceModel = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())); + + assertJsonStringEqualsIgnoreNulls("{ vfModules: { 201712488_adiodvpe10..201712488AdiodVpe1..ADIOD_vRE_BV..module-1: { inputs: { 201712488_adiodvpe10_availability_zone_0: { } } } } }", om.writeValueAsString(serviceModel)); + } + + @Test + public void modelWithNfNamingWithToValues_ecompGeneratedNamingIsExtracted() throws Exception { + final ToscaParserMockHelper mockHelper = new ToscaParserMockHelper("90fe6842-aa76-4b68-8329-5c86ff564407", "empty.json"); + final ServiceModel serviceModel = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())); + + assertJsonStringEqualsIgnoreNulls("" + + "{ vnfs: " + + " { \"201712-488_ADIOD-vPE-1 0\": " + + " { properties: { " + + " ecomp_generated_naming: \"true\", " + + " nf_naming: \"{naming_policy=SDNC_Policy.Config_MS_1806SRIOV_VPE_ADIoDJson, ecomp_generated_naming=true}\" " + + "} } } }", om.writeValueAsString(serviceModel)); + } + private void setPprobeServiceProxy(Map<String, PortMirroringConfig> expectedConfigurations){ //Port Mirroring Configuration By Policy 0 doesn't contains pProbe. // But due to sdc design if pProbe not exists parser expects to get it from other source. diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java index c1d6ab78a..642569c73 100644 --- a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientTest.java @@ -25,7 +25,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.vid.asdc.AsdcCatalogException; import org.onap.vid.asdc.beans.Service; import org.onap.vid.client.SyncRestClient; @@ -37,9 +37,7 @@ import java.util.UUID; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyMapOf; -import static org.mockito.Matchers.matches; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) @@ -82,7 +80,7 @@ public class SdcRestClientTest { @Test public void shouldReturnServiceForGivenUUID() throws AsdcCatalogException { String url = String.format(METADATA_URL_REGEX, randomId); - when(mockedSyncRestClient.get(matches(url), anyMapOf(String.class, String.class), anyMapOf(String.class, String.class), any())).thenReturn(httpResponse); + when(mockedSyncRestClient.get(matches(url), anyMap(), anyMap(), any())).thenReturn(httpResponse); when(httpResponse.getBody()).thenReturn(sampleService); Service service = restClient.getService(randomId); @@ -94,7 +92,7 @@ public class SdcRestClientTest { @Test(expected = AsdcCatalogException.class) public void shouldRaiseAsdcExceptionWhenClientFails() throws AsdcCatalogException { String url = String.format(METADATA_URL_REGEX, randomId); - when(mockedSyncRestClient.get(matches(url), anyMapOf(String.class, String.class), anyMapOf(String.class, String.class), any())).thenThrow(new RuntimeException()); + when(mockedSyncRestClient.get(matches(url), anyMap(), anyMap(), any())).thenThrow(new RuntimeException()); restClient.getService(randomId); } @@ -119,7 +117,7 @@ public class SdcRestClientTest { @Test(expected = AsdcCatalogException.class) public void shouldRaiseAsdcExceptionWhenDownloadFails() throws AsdcCatalogException { String url = String.format(MODEL_URL_REGEX, randomId); - when(mockedSyncRestClient.getStream(matches(url), anyMapOf(String.class, String.class), anyMapOf(String.class, String.class))).thenThrow(new RuntimeException()); + when(mockedSyncRestClient.getStream(matches(url), anyMap(), anyMap())).thenThrow(new RuntimeException()); restClient.getServiceToscaModel(randomId); diff --git a/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java b/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java index 56ac28d2e..c1ac6a219 100644 --- a/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java +++ b/vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java @@ -21,13 +21,19 @@ package org.onap.vid.config; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import org.hibernate.SessionFactory; import org.mockito.Mockito; import org.onap.portalsdk.core.service.DataAccessService; -import org.onap.vid.aai.AaiClientInterface; +import org.onap.vid.aai.AaiOverTLSClient; +import org.onap.vid.aai.AaiOverTLSClientInterface; +import org.onap.vid.aai.AaiOverTLSPropertySupplier; import org.onap.vid.aai.util.HttpsAuthClient; import org.onap.vid.aai.util.SSLContextProvider; import org.onap.vid.aai.util.SystemPropertyHelper; +import org.onap.vid.client.SyncRestClient; import org.onap.vid.job.JobAdapter; import org.onap.vid.job.JobsBrokerService; import org.onap.vid.job.command.InProgressStatusCommand; @@ -84,12 +90,40 @@ public class JobCommandsConfigWithMockedMso { } @Bean + public AaiOverTLSClientInterface AaiOverTLSClient(){ + io.joshworks.restclient.http.mapper.ObjectMapper objectMapper = new io.joshworks.restclient.http.mapper.ObjectMapper() { + + ObjectMapper om = new ObjectMapper(); + + @Override + public <T> T readValue(String s, Class<T> aClass) { + try { + return om.readValue(s, aClass); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public String writeValue(Object o) { + try { + return om.writeValueAsString(o); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + }; + + return new AaiOverTLSClient(new SyncRestClient(objectMapper), new AaiOverTLSPropertySupplier()); + } + + @Bean public AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(DataAccessService dataAccessService, JobAdapter jobAdapter, JobsBrokerService jobsBrokerService, SessionFactory sessionFactory, - AaiClientInterface aaiClient) { - return new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiClient); + AaiOverTLSClientInterface aaiOverTLSClientInterface) { + return new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiOverTLSClientInterface); } @Bean diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/ClientCredentialsFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/ClientCredentialsFilterTest.java index 61f18f54a..113bf2bf9 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/ClientCredentialsFilterTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/ClientCredentialsFilterTest.java @@ -13,7 +13,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; /** @@ -71,7 +71,7 @@ public class ClientCredentialsFilterTest { FilterChain chain = Mockito.mock(FilterChain.class); - Mockito.when(filter.verifyClientCredentials(any(String.class),any(String.class))).thenReturn(clientVerified); + Mockito.when(filter.verifyClientCredentials(any(),any())).thenReturn(clientVerified); Mockito.doNothing().when(response).sendError(401); Mockito.doCallRealMethod().when(filter).doFilter(request,response,chain); diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/PromiseEcompRequestIdFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/PromiseEcompRequestIdFilterTest.java index 3bcb2d005..4f42171b5 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/PromiseEcompRequestIdFilterTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/PromiseEcompRequestIdFilterTest.java @@ -19,11 +19,12 @@ import java.io.IOException; import java.util.*; import java.util.function.Function; +import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.argThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.argThat; import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID; @Test @@ -130,8 +131,8 @@ public class PromiseEcompRequestIdFilterTest { private HttpServletRequest createMockedHttpServletRequest(Map<String, String> requestHeaders) { HttpServletRequest servletRequest = Mockito.mock(HttpServletRequest.class); requestHeaders.forEach((k, v) -> { - Mockito.when(servletRequest.getHeader(argThat(equalToIgnoringCase(k)))).thenReturn(v); - Mockito.when(servletRequest.getHeaders(argThat(equalToIgnoringCase(k)))).then(returnEnumerationAnswer(v)); + Mockito.when(servletRequest.getHeader(argThat(s -> equalsIgnoreCase(s, k)))).thenReturn(v); + Mockito.when(servletRequest.getHeaders(argThat(s -> equalsIgnoreCase(s, k)))).then(returnEnumerationAnswer(v)); }); Mockito.when(servletRequest.getHeaderNames()).then(returnEnumerationAnswer(requestHeaders.keySet())); return servletRequest; diff --git a/vid-app-common/src/test/java/org/onap/vid/controllers/ChangeManagementControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controllers/ChangeManagementControllerTest.java index 317bd978c..58406a662 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controllers/ChangeManagementControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controllers/ChangeManagementControllerTest.java @@ -1,23 +1,19 @@ package org.onap.vid.controllers; -import java.util.Collection; - -import javax.servlet.http.HttpServletRequest; - -import org.codehaus.jackson.map.ObjectMapper; import org.json.simple.JSONArray; import org.junit.Test; import org.onap.vid.changeManagement.ChangeManagementRequest; import org.onap.vid.changeManagement.GetVnfWorkflowRelationRequest; import org.onap.vid.changeManagement.VnfWorkflowRelationRequest; import org.onap.vid.mso.MsoResponseWrapperInterface; -import org.onap.vid.services.ChangeManagementService; import org.onap.vid.services.ChangeManagementServiceImpl; -import org.onap.vid.services.WorkflowService; import org.onap.vid.services.WorkflowServiceImpl; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import java.util.Collection; + public class ChangeManagementControllerTest { private ChangeManagementController createTestSubject() { diff --git a/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java index 6055bc390..4894f35ea 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java @@ -3,65 +3,99 @@ package org.onap.vid.controllers; import org.apache.log4j.BasicConfigurator; import org.junit.Before; import org.junit.Test; -import org.onap.vid.controllers.HealthCheckController.HealthStatus; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.vid.dao.FnAppDoaImpl; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import java.sql.SQLException; + +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.BDDMockito.given; +import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; +import static org.springframework.http.HttpStatus.OK; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - +@RunWith(MockitoJUnitRunner.class) public class HealthCheckControllerTest { - private HealthCheckController testSubject; - private MockMvc mockMvc; + private static final String ERROR_MESSAGE = "error message"; + private HealthCheckController testSubject; + private MockMvc mockMvc; + + @Mock + private FnAppDoaImpl fnAppDoa; - @Before - public void setUp() { - testSubject = new HealthCheckController(); - BasicConfigurator.configure(); - mockMvc = MockMvcBuilders.standaloneSetup(testSubject).build(); - } + @Before + public void setUp() { + testSubject = new HealthCheckController(fnAppDoa); + BasicConfigurator.configure(); + mockMvc = MockMvcBuilders.standaloneSetup(testSubject).build(); + } - @Test - public void testGetProfileCount() throws Exception { - String driver = ""; - String URL = ""; - String username = ""; - String password = ""; - int result; + @Test + public void getHealthCheckStatusForIDNS_shouldReturnSuccess_whenNoExceptionIsThrown() throws Exception { + databaseConnectionEstablished(); + mockMvc.perform(get("/healthCheck") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.statusCode").value(OK.value())) + .andExpect(jsonPath("$.detailedMsg").value("health check succeeded")); + } - // default test - result = testSubject.getProfileCount(driver, URL, username, password); - } + @Test + public void getHealthCheckStatusForIDNS_shouldReturnErrorCode_whenExceptionIsThrown() throws Exception { + databaseNotAccessible(); + mockMvc.perform(get("/healthCheck") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.statusCode").value(INTERNAL_SERVER_ERROR.value())) + .andExpect(jsonPath("$.detailedMsg").value("health check failed: " + ERROR_MESSAGE)); + } - @Test - public void testGethealthCheckStatusforIDNS() throws Exception { - HealthStatus result; + @Test + public void getHealthCheck_shouldReturnSuccess_whenNoExceptionIsThrown() throws Exception { + databaseConnectionEstablished(); + mockMvc.perform(get("/rest/healthCheck/{User-Agent}/{X-ECOMP-RequestID}", "userAgent", "requestId") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.statusCode").value(OK.value())) + .andExpect(jsonPath("$.detailedMsg").value("health check succeeded")) + .andExpect(jsonPath("$.date").isString()); + } - // default test - result = testSubject.gethealthCheckStatusforIDNS(); - } + @Test + public void getHealthCheck_shouldReturnErrorCode_whenExceptionIsThrown() throws Exception { + databaseNotAccessible(); + mockMvc.perform(get("/rest/healthCheck/{User-Agent}/{X-ECOMP-RequestID}", "userAgent", "requestId") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.statusCode").value(INTERNAL_SERVER_ERROR.value())) + .andExpect(jsonPath("$.detailedMsg").value("health check failed: " + ERROR_MESSAGE)); + } - @Test - public void testGetHealthCheck() throws Exception { - String UserAgent = ""; - String ECOMPRequestID = ""; - HealthStatus result; + @Test + public void getCommitInfo_shouldReturnCommitData_whenCorrectPropertiesFileExists() throws Exception { + mockMvc.perform(get("/commitInfo") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.commitId").value("123")) + .andExpect(jsonPath("$.commitMessageShort").value("Test short commit message")) + .andExpect(jsonPath("$.commitTime").value("1999-09-12T13:48:55+0200")); + } - // default test - result = testSubject.getHealthCheck(UserAgent, ECOMPRequestID); - } + private void databaseConnectionEstablished() throws SQLException { + given(fnAppDoa.getProfileCount(anyString(), anyString(), anyString())) + .willReturn(0); + } - @Test - public void testCommitInfoEndpoint() throws Exception { - mockMvc.perform(get("/commitInfo") - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.commitId").value("123987")) - .andExpect(jsonPath("$.commitMessageShort").value("Test short commit message")) - .andExpect(jsonPath("$.commitTime").value("1999-09-12T13:48:55+0200")); - } + private void databaseNotAccessible() throws SQLException { + given(fnAppDoa.getProfileCount(anyString(), anyString(), anyString())) + .willThrow(new SQLException(ERROR_MESSAGE)); + } }
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/controllers/MaintenanceControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controllers/MaintenanceControllerTest.java index 7bdd6b863..3a9d88f07 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controllers/MaintenanceControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controllers/MaintenanceControllerTest.java @@ -22,22 +22,8 @@ package org.onap.vid.controllers; * ============LICENSE_END========================================================= */ -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.then; -import static org.mockito.BDDMockito.willThrow; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.times; -import static org.onap.vid.model.CategoryParameter.Family.PARAMETER_STANDARDIZATION; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import java.util.Collections; -import java.util.function.BiFunction; -import javax.ws.rs.ForbiddenException; import org.apache.log4j.BasicConfigurator; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Before; @@ -45,7 +31,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentMatcher; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.vid.category.AddCategoryOptionResponse; import org.onap.vid.category.AddCategoryOptionsRequest; import org.onap.vid.category.CategoryParameterOptionRep; @@ -61,6 +47,19 @@ import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilde import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import javax.ws.rs.ForbiddenException; +import java.util.Collections; +import java.util.function.BiFunction; + +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.times; +import static org.onap.vid.model.CategoryParameter.Family.PARAMETER_STANDARDIZATION; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @RunWith(MockitoJUnitRunner.class) public class MaintenanceControllerTest { diff --git a/vid-app-common/src/test/java/org/onap/vid/controllers/PromiseEcompRequestIdFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/controllers/PromiseEcompRequestIdFilterTest.java index 77dba37e9..f17403955 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controllers/PromiseEcompRequestIdFilterTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controllers/PromiseEcompRequestIdFilterTest.java @@ -19,11 +19,12 @@ import java.io.IOException; import java.util.*; import java.util.function.Function; +import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.argThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.argThat; import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID; @Test @@ -130,8 +131,8 @@ public class PromiseEcompRequestIdFilterTest { private HttpServletRequest createMockedHttpServletRequest(Map<String, String> requestHeaders) { HttpServletRequest servletRequest = Mockito.mock(HttpServletRequest.class); requestHeaders.forEach((k, v) -> { - Mockito.when(servletRequest.getHeader(argThat(equalToIgnoringCase(k)))).thenReturn(v); - Mockito.when(servletRequest.getHeaders(argThat(equalToIgnoringCase(k)))).then(returnEnumerationAnswer(v)); + Mockito.when(servletRequest.getHeader(argThat(s -> equalsIgnoreCase(s, k)))).thenReturn(v); + Mockito.when(servletRequest.getHeaders(argThat(s -> equalsIgnoreCase(s, k)))).then(returnEnumerationAnswer(v)); }); Mockito.when(servletRequest.getHeaderNames()).then(returnEnumerationAnswer(requestHeaders.keySet())); return servletRequest; diff --git a/vid-app-common/src/test/java/org/onap/vid/controllers/VidControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controllers/VidControllerTest.java index 4e2d994e6..198680afc 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controllers/VidControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controllers/VidControllerTest.java @@ -1,189 +1,204 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Modifications Copyright 2018 Nokia + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.vid.controllers; -//import com.fasterxml.jackson.databind.ObjectMapper; -//import net.javacrumbs.jsonunit.JsonAssert; -//import org.apache.commons.io.IOUtils; -//import org.onap.vid.asdc.AsdcCatalogException; -//import org.onap.vid.asdc.AsdcClient; -//import org.onap.vid.asdc.parser.ToscaParserImpl2; -//import org.onap.vid.model.*; -//import org.onap.portalsdk.core.util.SystemProperties; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.mock.web.MockServletContext; -//import org.springframework.test.context.ContextConfiguration; -//import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -//import org.springframework.test.context.web.WebAppConfiguration; -//import org.testng.Assert; -//import org.testng.annotations.Test; -// -//import static org.onap.vid.testUtils.TestUtils.assertJsonStringEqualsIgnoreNulls; -// -//import java.io.IOException; -//import java.io.InputStream; -//import java.nio.file.Path; -//import java.util.Map; -//import java.util.UUID; -// -////import org.junit.Assert; -////import org.junit.Ignore; -////import org.junit.Test; -////import org.junit.runner.RunWith; -////import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -// -//@ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class}) -////@RunWith(SpringJUnit4ClassRunner.class) -//@WebAppConfiguration -// -//public class VidControllerTest extends AbstractTestNGSpringContextTests { -// -// @Autowired -// MockServletContext context; -// @Autowired -// private AsdcClient asdcClient; -// private ToscaParserImpl2 p2 = new ToscaParserImpl2(); -// private ObjectMapper om = new ObjectMapper(); -// -// -// @Test -// public void assertEqualsBetweenServices() throws Exception { -// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { -// Service expectedService = mockHelper.getNewServiceModel().getService(); -// Service actualService = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getService(); -// assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedService), om.writeValueAsString(actualService)); -// } -// } -// -//// @Test -//// public void assertEqualBetweenObjects() throws Exception { -//// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { -//// final Path csarPath = getCsarPath(mockHelper.getUuid()); -//// System.out.println("Comparing for csar " + csarPath); -//// ServiceModel actualServiceModel = p2.makeServiceModel(csarPath, getServiceByUuid(mockHelper.getUuid())); -//// assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(mockHelper.getNewServiceModel()), om.writeValueAsString(actualServiceModel)); -//// } -//// } -// -//// @Test -//// public void assertEqualsBetweenNetworkNodes() throws Exception { -//// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { -//// Map<String, Network> expectedNetworksMap = mockHelper.getNewServiceModel().getNetworks(); -//// Map<String, Network> actualNetworksMap = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getNetworks(); -//// for (Map.Entry<String, Network> entry : expectedNetworksMap.entrySet()) { -//// Network expectedNetwork = entry.getValue(); -//// Network actualNetwork = actualNetworksMap.get(entry.getKey()); -//// Assert.assertEquals(expectedNetwork.getModelCustomizationName(), actualNetwork.getModelCustomizationName()); -//// verifyBaseNodeProperties(expectedNetwork, actualNetwork); -//// compareProperties(expectedNetwork.getProperties(), actualNetwork.getProperties()); -//// } -//// } -//// } -// -// //Because we are not supporting the old flow, the JSON are different by definition. -// @Test -// public void assertEqualsBetweenVnfsOfTosca() throws Exception { -// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { -// Map<String, VNF> expectedVnfsMap = mockHelper.getNewServiceModel().getVnfs(); -// Map<String, VNF> actualVnfsMap = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVnfs(); -// for (Map.Entry<String, VNF> entry : expectedVnfsMap.entrySet()) { -// VNF expectedVnf = entry.getValue(); -// VNF actualVnf = actualVnfsMap.get(entry.getKey()); -// //need to uncomment these after 1806 merge -// //verifyBaseNodeProperties(expectedVnf, actualVnf); -// Assert.assertEquals(expectedVnf.getModelCustomizationName(), actualVnf.getModelCustomizationName()); -// //compareProperties(expectedVnf.getProperties(), actualVnf.getProperties()); -// //assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedVnf), om.writeValueAsString(actualVnf)); -// } -// } -// } -// -// @Test -// public void assertEqualsBetweenVolumeGroups() throws Exception { -// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { -// Map<String, VolumeGroup> actualVolumeGroups = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVolumeGroups(); -// Map<String, VolumeGroup> expectedVolumeGroups = mockHelper.getNewServiceModel().getVolumeGroups(); -// JsonAssert.assertJsonEquals(actualVolumeGroups, expectedVolumeGroups); -// } -// } -// -// @Test -// public void assertEqualsBetweenVfModules() throws Exception { -// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { -// Map<String, VfModule> actualVfModules = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVfModules(); -// Map<String, VfModule> expectedVfModules = mockHelper.getNewServiceModel().getVfModules(); -// //need to uncomment after 1906 merge -// //JsonAssert.assertJsonEquals(actualVfModules, expectedVfModules); -// } -// } -// -// /*@Test -// public void assertEqualsBetweenPolicyConfigurationNodes() throws Exception { -// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { -// Map<String, PortMirroringConfig> actualConfigurations = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getConfigurations(); -// Map<String, PortMirroringConfig> expectedConfigurations = mockHelper.getNewServiceModel().getConfigurations(); -// JsonAssert.assertJsonEquals(actualConfigurations, expectedConfigurations); -// } -// }*/ -// -// @Test -// public void assertEqualsBetweenServiceProxyNodes() throws Exception { -// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { -// Map<String, ServiceProxy> actualServiceProxies = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getServiceProxies(); -// Map<String, ServiceProxy> expectedServiceProxies = mockHelper.getNewServiceModel().getServiceProxies(); -// JsonAssert.assertJsonEquals(actualServiceProxies, expectedServiceProxies); -// } -// } -// -// private void verifyBaseNodeProperties(Node expectedNode, Node actualNode) { -// Assert.assertEquals(expectedNode.getName(), actualNode.getName()); -// Assert.assertEquals(expectedNode.getCustomizationUuid(), actualNode.getCustomizationUuid()); -// Assert.assertEquals(expectedNode.getDescription(), actualNode.getDescription()); -// Assert.assertEquals(expectedNode.getInvariantUuid(), actualNode.getInvariantUuid()); -// Assert.assertEquals(expectedNode.getUuid(), actualNode.getUuid()); -// Assert.assertEquals(expectedNode.getVersion(), actualNode.getVersion()); -// } -// -// private void compareProperties(Map<String, String> expectedProperties, Map<String, String> actualProperties) { -// for (Map.Entry<String, String> property : expectedProperties.entrySet()) { -// String expectedValue = property.getValue(); -// String key = property.getKey(); -// String actualValue = actualProperties.get(key); -// Assert.assertEquals(expectedValue, actualValue); -// } -// } -// -// private ToscaParserMockHelper[] getExpectedServiceModel() throws IOException { -// ToscaParserMockHelper[] mockHelpers = { -// new ToscaParserMockHelper(Constants.vlUuid, Constants.vlFilePath), -// new ToscaParserMockHelper(Constants.vfUuid, Constants.vfFilePath), -// new ToscaParserMockHelper(Constants.configurationUuid, Constants.configurationFilePath), -// }; -// for (ToscaParserMockHelper mockHelper : mockHelpers) { -// InputStream jsonFile = VidControllerTest.class.getClassLoader().getResourceAsStream(mockHelper.getFilePath()); -// String expectedJsonAsString = IOUtils.toString(jsonFile); -// NewServiceModel newServiceModel1 = om.readValue(expectedJsonAsString, NewServiceModel.class); -// mockHelper.setNewServiceModel(newServiceModel1); -// } -// return mockHelpers; -// } -// -// private Path getCsarPath(String uuid) throws AsdcCatalogException { -// return asdcClient.getServiceToscaModel(UUID.fromString(uuid)); -// } -// -// private org.onap.vid.asdc.beans.Service getServiceByUuid(String uuid) throws AsdcCatalogException { -// return asdcClient.getService(UUID.fromString(uuid)); -// } -// -// public class Constants { -// public static final String configurationUuid = "ee6d61be-4841-4f98-8f23-5de9da846ca7"; -// public static final String configurationFilePath = "policy-configuration-csar.JSON"; -// static final String vfUuid = "48a52540-8772-4368-9cdb-1f124ea5c931"; -// static final String vlUuid = "cb49608f-5a24-4789-b0f7-2595473cb997"; -// // public static final String PNFUuid = "68101369-6f08-4e99-9a28-fa6327d344f3"; -// static final String vfFilePath = "vf-csar.JSON"; -// static final String vlFilePath = "vl-csar.JSON"; -//// public static final String PNFFilePath = "/Users/Oren/Git/Att/vid_internal/vid-app-common/src/main/resources/pnf.csar"; -// -// } -// -//}
\ No newline at end of file + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import org.apache.log4j.BasicConfigurator; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.vid.asdc.AsdcCatalogException; +import org.onap.vid.asdc.beans.SecureServices; +import org.onap.vid.asdc.beans.Service; +import org.onap.vid.asdc.beans.ServiceBuilder; +import org.onap.vid.model.*; +import org.onap.vid.model.PombaInstance.PombaRequest; +import org.onap.vid.model.PombaInstance.ServiceInstance; +import org.onap.vid.roles.RoleProvider; +import org.onap.vid.services.AaiService; +import org.onap.vid.services.PombaService; +import org.onap.vid.services.VidService; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; + +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.IntStream; + +import static java.util.stream.Collectors.toMap; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.not; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.times; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(MockitoJUnitRunner.class) +public class VidControllerTest { + + public static final String REST_MODELS_SERVICES = "/rest/models/services"; + public static final String REST_MODELS_SERVICES_UUID = "/rest/models/services/{uuid}"; + public static final String REST_MODELS_RESET = "/rest/models/reset"; + public static final String REST_MODELS_SERVICES_VERIFY_SERVICE = "/rest/models/services/verifyService"; + @Mock + private VidService vidService; + @Mock + private AaiService aaiService; + @Mock + private RoleProvider roleProvider; + @Mock + private PombaService pombaService; + + private VidController vidController; + private MockMvc mockMvc; + private ObjectMapper objectMapper; + + private String uuid1; + private String uuid2; + private String uuid3; + + @Before + public void setUp() { + vidController = new VidController(vidService, aaiService, roleProvider, pombaService); + BasicConfigurator.configure(); + mockMvc = MockMvcBuilders.standaloneSetup(vidController).build(); + objectMapper = new ObjectMapper(); + + uuid1 = UUID.randomUUID().toString(); + uuid2 = UUID.randomUUID().toString(); + uuid3 = UUID.randomUUID().toString(); + } + + @Test + public void getServices_shouldReturnService_whenServiceExists() throws Exception { + List<Service> services = ImmutableList.of(createService(uuid1, 1), createService(uuid2, 2), createService(uuid3, 3)); + + given(aaiService.getServicesByDistributionStatus()).willReturn(services); + + SecureServices secureServices = new SecureServices(); + secureServices.setServices(services); + secureServices.setReadOnly(false); + + mockMvc.perform(get(REST_MODELS_SERVICES) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(objectMapper.writeValueAsString(secureServices))); + } + + @Test + public void getService_shouldReturnService_whenNoExceptionIsThrown() throws Exception { + ServiceModel model = expectedServiceModel(uuid1); + + given(vidService.getService(uuid1)).willReturn(model); + + mockMvc.perform(get(REST_MODELS_SERVICES_UUID, uuid1) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(objectMapper.writeValueAsString(model))); + } + + @Test + public void getService_shouldThrow_whenAsdcCatalogExceptionIsThrown() throws Exception { + String testUuid = UUID.randomUUID().toString(); + + given(vidService.getService(testUuid)).willThrow(new AsdcCatalogException("error msg")); + + mockMvc.perform(get(REST_MODELS_SERVICES_UUID, testUuid) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isServiceUnavailable()); + } + + @Test + public void invalidateServiceModelCache_shouldReturnAccepted() throws Exception { + mockMvc.perform(post(REST_MODELS_RESET) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isAccepted()); + + then(vidService).should(times(1)).invalidateServiceCache(); + } + + @Test + public void verifyServiceInstance_shouldReturnOk() throws Exception { + PombaRequest pombaRequest = new PombaRequest(); + pombaRequest.serviceInstanceList = ImmutableList.of(new ServiceInstance()); + + mockMvc.perform(post(REST_MODELS_SERVICES_VERIFY_SERVICE) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(pombaRequest))) + .andExpect(status().isOk()); + + ArgumentCaptor<PombaRequest> argumentCaptor = ArgumentCaptor.forClass(PombaRequest.class); + then(pombaService).should(times(1)).verify(argumentCaptor.capture()); + + assertThat(pombaRequest).isEqualToComparingFieldByFieldRecursively(argumentCaptor.getValue()); + } + + private ServiceModel expectedServiceModel(String uuid) { + final ServiceModel serviceModel = getModelsByUuid().get(uuid); + Assert.assertThat(serviceModel, is(not(nullValue()))); + return serviceModel; + } + + private Service createService(String uuid, int i) { + return new ServiceBuilder().setUuid(uuid).setInvariantUUID("invariantUUID" + i) + .setCategory("category" + i).setVersion("version" + i).setName("name" + i) + .setDistributionStatus("distStatus" + i).setToscaModelURL("toscaModelUrl" + i).build(); + } + + private ServiceModel createServiceModel(int i) { + ServiceModel model = new ServiceModel(); + + model.setCollectionResource(ImmutableMap.of("resKey" + i, new CR())); + model.setNetworks(ImmutableMap.of("network" + i, new Network())); + model.setPnfs(ImmutableMap.of("pnf" + i, new Node())); + model.setServiceProxies(ImmutableMap.of("servProxy" + i, new ServiceProxy())); + model.setVfModules(ImmutableMap.of("vfmod" + i, new VfModule())); + model.setVnfs(ImmutableMap.of("vnf" + i, new VNF())); + model.setVolumeGroups(ImmutableMap.of("volgroup" + i, new VolumeGroup())); + model.setService(new org.onap.vid.model.Service()); + return model; + } + + private Map<String, ServiceModel> getModelsByUuid() { + ServiceModel serviceModel1 = createServiceModel(1); + ServiceModel serviceModel2 = createServiceModel(2); + ServiceModel serviceModel3 = createServiceModel(3); + + List<ServiceModel> pseudoServiceModels = ImmutableList.of(serviceModel1, serviceModel2, serviceModel3); + List<String> uuids = ImmutableList.of(uuid1, uuid2, uuid3); + return IntStream.range(0, pseudoServiceModels.size()).boxed() + .collect(toMap(i -> uuids.get(i), i -> pseudoServiceModels.get(i))); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/dao/FnAppDoaImplTest.java b/vid-app-common/src/test/java/org/onap/vid/dao/FnAppDoaImplTest.java index e7a7e3a37..6d60aa18a 100644 --- a/vid-app-common/src/test/java/org/onap/vid/dao/FnAppDoaImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/dao/FnAppDoaImplTest.java @@ -1,97 +1,69 @@ package org.onap.vid.dao; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; -import org.junit.Assert; -import org.junit.Test; +import static org.assertj.core.api.Java6Assertions.assertThat; +import static org.assertj.core.api.Java6Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.BDDMockito.given; +@RunWith(MockitoJUnitRunner.class) public class FnAppDoaImplTest { - private FnAppDoaImpl createTestSubject() { - return new FnAppDoaImpl(); - } + private FnAppDoaImpl fnAppDoa; - @Test - public void testGetConnection() throws Exception { - String driver2 = ""; - String url = ""; - String username = ""; - String password = ""; - Connection result; - - // test 1 - url = null; - username = null; - password = null; - result = FnAppDoaImpl.getConnection(driver2, url, username); - Assert.assertEquals(null, result); - - // test 2 - url = ""; - username = null; - password = null; - result = FnAppDoaImpl.getConnection(driver2, url, username); - Assert.assertEquals(null, result); - - // test 3 - username = null; - url = null; - password = null; - result = FnAppDoaImpl.getConnection(driver2, url, username); - Assert.assertEquals(null, result); - - // test 4 - username = ""; - url = null; - password = null; - result = FnAppDoaImpl.getConnection(driver2, url, username); - Assert.assertEquals(null, result); - - // test 5 - password = null; - url = null; - username = null; - result = FnAppDoaImpl.getConnection(driver2, url, username); - Assert.assertEquals(null, result); - - // test 6 - password = ""; - url = null; - username = null; - result = FnAppDoaImpl.getConnection(driver2, url, username); - Assert.assertEquals(null, result); + @Mock + private ConnectionFactory connectionFactory; + + @Mock + private Connection connection; + + @Mock + private PreparedStatement preparedStatement; + + @Mock + private ResultSet resultSet; + + private static final String ERROR_MESSAGE = "error message"; + private static final String QUERY = "select count(*) from fn_app"; + + @Before + public void setUp() throws SQLException { + given(resultSet.next()).willReturn(true); + given(resultSet.getInt(1)).willReturn(5); + given(preparedStatement.executeQuery()).willReturn(resultSet); + given(connectionFactory.getConnection(anyString(), anyString(), anyString())).willReturn(connection); + fnAppDoa = new FnAppDoaImpl(connectionFactory); } - @Test - public void testCleanup() throws Exception { - ResultSet rs = null; - PreparedStatement st = null; + private void okCaseSetUp() throws SQLException { - // test 1 - rs = null; - FnAppDoaImpl.cleanup(rs, st, null); + given(connection.prepareStatement(QUERY)).willReturn(preparedStatement); + } - // test 2 - st = null; - FnAppDoaImpl.cleanup(rs, st, null); + private void nokCaseSetup() throws SQLException { + given(connection.prepareStatement(QUERY)).willThrow(new SQLException(ERROR_MESSAGE)); + } - // test 3 - FnAppDoaImpl.cleanup(rs, st, null); + @Test + public void getProfileCount_shouldReturnNumber_whenNoExceptionIsThrown() throws SQLException { + okCaseSetUp(); + assertThat(fnAppDoa.getProfileCount("anyUrl", "anyUsername", "anyPassword")).isEqualTo(5); } @Test - public void testGetProfileCount() throws Exception { - FnAppDoaImpl testSubject; - String driver = ""; - String URL = ""; - String username = ""; - String password = ""; - int result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProfileCount(driver, URL, username, password); + public void getProfileCount_shouldRethrowSQLException() throws SQLException { + nokCaseSetup(); + assertThatThrownBy(() -> fnAppDoa.getProfileCount("anyUrl", "anyUsername", "anyPassword")) + .isInstanceOf(SQLException.class).hasMessage(ERROR_MESSAGE); } }
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/JobWorkerTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/JobWorkerTest.java index b7e8e35a9..e58b6ba03 100644 --- a/vid-app-common/src/test/java/org/onap/vid/job/impl/JobWorkerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/JobWorkerTest.java @@ -19,7 +19,7 @@ import java.util.UUID; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java index 461673224..718e22fb4 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java @@ -20,25 +20,8 @@ */ package org.onap.vid.mso; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.junit.Assert.assertEquals; -import static org.mockito.BDDMockito.given; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.onap.vid.mso.MsoBusinessLogicImpl.validateEndpointPath; - import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.stream.Collectors; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -56,6 +39,22 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.togglz.core.manager.FeatureManager; +import java.io.IOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.onap.vid.mso.MsoBusinessLogicImpl.validateEndpointPath; + @ContextConfiguration(classes = {SystemProperties.class}) @RunWith(SpringJUnit4ClassRunner.class) public class MsoBusinessLogicImplTest { @@ -287,7 +286,7 @@ public class MsoBusinessLogicImplTest { return new String(Files.readAllBytes(path)); } - private static class MsoRequestWrapperMatcher extends + private static class MsoRequestWrapperMatcher implements ArgumentMatcher<org.onap.vid.changeManagement.RequestDetailsWrapper> { private final org.onap.vid.changeManagement.RequestDetailsWrapper expectedRequest; @@ -297,9 +296,8 @@ public class MsoBusinessLogicImplTest { } @Override - public boolean matches(Object argument) { - org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = (org.onap.vid.changeManagement.RequestDetailsWrapper) argument; - return expectedRequest.requestDetails.equals(requestDetailsWrapper.requestDetails); + public boolean matches(org.onap.vid.changeManagement.RequestDetailsWrapper argument) { + return expectedRequest.requestDetails.equals(argument.requestDetails); } } } diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestIdTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestIdTest.java index 909975fb8..197bfe75d 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestIdTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestIdTest.java @@ -2,12 +2,7 @@ package org.onap.vid.mso.rest; import com.google.common.collect.ImmutableList; import org.apache.commons.lang3.reflect.FieldUtils; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.InjectMocks; -import org.mockito.Matchers; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; +import org.mockito.*; import org.onap.vid.aai.util.AAIRestInterface; import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.controller.filter.PromiseEcompRequestIdFilter; @@ -31,13 +26,9 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.allOf; -import static org.hamcrest.Matchers.equalToIgnoringCase; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasToString; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.Matchers.*; public class OutgoingRequestIdTest { @@ -130,7 +121,7 @@ public class OutgoingRequestIdTest { ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class); Mockito.verify(fakeBuilder) .header( - Matchers.argThat(equalToIgnoringCase(requestIdHeader)), + Matchers.argThat(s -> equalsIgnoreCase(s, requestIdHeader)), argumentCaptor.capture() ); requestId = argumentCaptor.getValue(); diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java index 6390f5800..0655aca9e 100644 --- a/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java @@ -30,7 +30,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.testUtils.StubServerUtil; import org.testng.annotations.AfterMethod; diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java index ae6c2ccca..efa12f2c0 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java @@ -1,8 +1,28 @@ -package org.onap.vid.services; +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ -import java.util.Collection; -import java.util.List; +package org.onap.vid.services; +import com.google.common.collect.ImmutableList; +import io.joshworks.restclient.http.HttpResponse; import org.junit.Assert; import org.junit.Test; import org.onap.vid.aai.AaiResponse; @@ -13,6 +33,8 @@ import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse; import org.onap.vid.model.SubscriberList; import org.onap.vid.roles.RoleValidator; +import java.util.List; + public class AaiServiceImplTest { private AaiServiceImpl createTestSubject() { @@ -55,7 +77,7 @@ public class AaiServiceImplTest { @Test public void testGetFullSubscriberList_1() throws Exception { AaiServiceImpl testSubject; - AaiResponse<SubscriberList> result; + HttpResponse<SubscriberList> result; // default test try { @@ -144,7 +166,7 @@ public class AaiServiceImplTest { @Test public void testGetVersionByInvariantId() throws Exception { AaiServiceImpl testSubject; - List<String> modelInvariantId = null; + List<String> modelInvariantId = ImmutableList.of("some invariant id"); // default test try { diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java index c3d01283d..5ead3fce4 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java @@ -1,8 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + package org.onap.vid.services; import com.google.common.collect.ImmutableMap; +import io.joshworks.restclient.http.HttpResponse; import jersey.repackaged.com.google.common.collect.ImmutableList; -import org.onap.vid.aai.AaiClientInterface; +import org.apache.http.HttpStatus; +import org.apache.http.HttpVersion; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.DefaultHttpResponseFactory; +import org.apache.http.message.BasicStatusLine; +import org.onap.vid.aai.AaiOverTLSClientInterface; import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.model.AaiNodeQueryResponse; import org.onap.vid.aai.model.ResourceType; @@ -13,15 +40,14 @@ import org.onap.vid.model.serviceInstantiation.VfModule; import org.onap.vid.model.serviceInstantiation.Vnf; import org.onap.vid.mso.RestObject; import org.onap.vid.mso.rest.AsyncRequestStatus; -import org.onap.vid.services.AsyncInstantiationBusinessLogic; -import org.onap.vid.services.AsyncInstantiationBusinessLogicTest; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.togglz.core.manager.FeatureManager; import javax.inject.Inject; +import java.io.UnsupportedEncodingException; import java.util.*; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests { @@ -48,7 +74,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests protected FeatureManager featureManager; @Inject - protected AaiClientInterface aaiClient; + protected AaiOverTLSClientInterface aaiClient; public ServiceInstantiation generateMockServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure) { ModelInfo modelInfo = createModelInfo(); @@ -174,12 +200,15 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests return restObject; } - protected void mockAaiClientAnyNameFree() { + protected void mockAaiClientAnyNameFree() throws UnsupportedEncodingException { when(aaiClient.searchNodeTypeByName(any(), any())).thenReturn(aaiNodeQueryResponseNameFree()); } - protected AaiResponse<AaiNodeQueryResponse> aaiNodeQueryResponseNameFree() { - return new AaiResponse<>(new AaiNodeQueryResponse(null),"", 200); + protected HttpResponse<AaiNodeQueryResponse> aaiNodeQueryResponseNameFree() throws UnsupportedEncodingException { + org.apache.http.HttpResponse response = new DefaultHttpResponseFactory().newHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null), null); + response.setEntity(new StringEntity("")); + + return HttpResponse.fallback(new AaiNodeQueryResponse(null)); } protected AaiResponse<AaiNodeQueryResponse> aaiNodeQueryBadResponse() { diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java index 3f13c9dff..9711fa858 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java @@ -1,72 +1,9 @@ package org.onap.vid.services; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import jersey.repackaged.com.google.common.collect.ImmutableList; -import net.javacrumbs.jsonunit.JsonAssert; -import org.apache.commons.io.IOUtils; -import org.hibernate.SessionFactory; -import org.json.JSONException; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.onap.vid.aai.exceptions.InvalidAAIResponseException; -import org.onap.vid.aai.model.ResourceType; -import org.onap.vid.changeManagement.RequestDetailsWrapper; -import org.onap.vid.exceptions.GenericUncheckedException; -import org.onap.vid.exceptions.MaxRetriesException; -import org.onap.vid.exceptions.OperationNotAllowedException; -import org.onap.vid.job.Job; -import org.onap.vid.job.Job.JobStatus; -import org.onap.vid.job.JobAdapter; -import org.onap.vid.job.JobsBrokerService; -import org.onap.vid.job.impl.JobDaoImpl; -import org.onap.vid.model.JobAuditStatus; -import org.onap.vid.model.JobAuditStatus.SourceStatus; -import org.onap.vid.model.NameCounter; -import org.onap.vid.model.ServiceInfo; -import org.onap.vid.model.serviceInstantiation.ServiceInstantiation; -import org.onap.vid.model.serviceInstantiation.Vnf; -import org.onap.vid.mso.model.ServiceInstantiationRequestDetails; -import org.onap.vid.mso.rest.AsyncRequestStatus; -import org.onap.vid.utils.DaoUtils; +import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.config.DataSourceConfig; import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig; -import org.onap.vid.mso.MsoOperationalEnvironmentTest; -import org.onap.vid.services.AsyncInstantiationBaseTest; -import org.onap.portalsdk.core.domain.FusionObject; -import org.onap.portalsdk.core.service.DataAccessService; -import org.onap.portalsdk.core.util.SystemProperties; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.testng.Assert; -import org.testng.annotations.*; - -import javax.inject.Inject; -import java.io.IOException; -import java.lang.reflect.Method; -import java.net.URL; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.*; -import java.util.Optional; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.*; -import static org.hamcrest.core.Every.everyItem; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; -import static org.onap.vid.job.Job.JobStatus.*; -import static org.testng.Assert.*; @ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, MockedAaiClientAndFeatureManagerConfig.class}) public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseTest { diff --git a/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java index 6ac7b5447..7a4263c7e 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java @@ -20,18 +20,6 @@ */ package org.onap.vid.services; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import javax.ws.rs.ForbiddenException; import org.mockito.InjectMocks; import org.mockito.Mock; import org.onap.portalsdk.core.service.DataAccessService; @@ -50,6 +38,16 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; +import javax.ws.rs.ForbiddenException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.*; +import static org.mockito.MockitoAnnotations.initMocks; + public class CategoryParameterServiceImplTest { private static final String CATEGORY_NAME = "SAMPLE_CATEGORY_NAME"; @@ -89,7 +87,7 @@ public class CategoryParameterServiceImplTest { Assert.assertTrue(result.getErrors().isEmpty());; verify(dataAccessService, times(1)) - .saveDomainObject(anyObject(), anyObject()); + .saveDomainObject(any(), any()); } @Test @@ -162,12 +160,12 @@ public class CategoryParameterServiceImplTest { categoryParameter.getOptions().add(categoryParameterOption); List<CategoryParameter> aList = createCategoryParametersList(categoryParameter); - doReturn(aList).when(dataAccessService).getList(anyObject(), anyString(), anyString(), anyObject()); + doReturn(aList).when(dataAccessService).getList(any(), anyString(), any(), any()); testSubject.deleteCategoryOption(CATEGORY_NAME, categoryParameterOption); verify(dataAccessService, times(1)) - .deleteDomainObject(anyObject(), anyObject()); + .deleteDomainObject(any(), any()); } @Test @@ -178,7 +176,7 @@ public class CategoryParameterServiceImplTest { categoryParameter.getOptions().add(categoryParameterOption); List<CategoryParameter> aList = createCategoryParametersList(categoryParameter); - doReturn(aList).when(dataAccessService).getList(anyObject(), anyString(), anyString(), anyObject()); + doReturn(aList).when(dataAccessService).getList(any(), anyString(), any(), any()); CategoryParametersResponse response = testSubject.getCategoryParameters(Family.PARAMETER_STANDARDIZATION); @@ -186,7 +184,7 @@ public class CategoryParameterServiceImplTest { Assert.assertTrue(response.getCategoryParameters().containsKey(CATEGORY_NAME)); verify(dataAccessService, times(1)) - .getList(anyObject(), anyString(), anyString(), anyObject()); + .getList(any(), anyString(), any(), any()); } @Test @@ -202,7 +200,7 @@ public class CategoryParameterServiceImplTest { AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRepExisting); verify(dataAccessService, times(1)) - .saveDomainObject(anyObject(), anyObject()); + .saveDomainObject(any(), any()); } @Test(expectedExceptions = { ForbiddenException.class }) diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java index 157f59c74..00d9e1735 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java @@ -1,12 +1,12 @@ package org.onap.vid.services; import org.mockito.*; +import org.onap.portalsdk.core.service.DataAccessService; import org.onap.vid.changeManagement.ChangeManagementRequest; import org.onap.vid.changeManagement.RequestDetails; import org.onap.vid.mso.MsoBusinessLogic; import org.onap.vid.mso.MsoResponseWrapperInterface; import org.onap.vid.scheduler.SchedulerRestInterfaceIfc; -import org.onap.portalsdk.core.service.DataAccessService; import org.springframework.http.ResponseEntity; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -54,47 +54,47 @@ public class ChangeManagementServiceImplTest { @Test public void doChangeManagement_requestTypeIsUpdate_MsoUpdateVnfIsCalled() throws Exception { - Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnf(Mockito.any(),Mockito.anyString(),Mockito.anyString()); + Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnf(Mockito.any(),Mockito.any(),Mockito.any()); RequestDetails requestDetails = callChangeManagement(ChangeManagementRequest.UPDATE); ArgumentCaptor<RequestDetails> argumentCaptor = ArgumentCaptor.forClass(RequestDetails.class); - verify(msoBusinessLogicMock).updateVnf(argumentCaptor.capture(),Mockito.anyString(),Mockito.anyString()); + verify(msoBusinessLogicMock).updateVnf(argumentCaptor.capture(),Mockito.any(),Mockito.any()); assertEquals(argumentCaptor.getValue().getVnfInstanceId(),requestDetails.getVnfInstanceId()); } @Test public void doChangeManagement_requestTypeIsReplace_MsoUpdateVnfIsCalled() throws Exception { - Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).replaceVnf(Mockito.any(),Mockito.anyString(),Mockito.anyString()); + Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).replaceVnf(Mockito.any(),Mockito.any(),Mockito.any()); RequestDetails requestDetails = callChangeManagement(ChangeManagementRequest.REPLACE); ArgumentCaptor<RequestDetails> argumentCaptor = ArgumentCaptor.forClass(RequestDetails.class); - verify(msoBusinessLogicMock).replaceVnf(argumentCaptor.capture(),Mockito.anyString(),Mockito.anyString()); + verify(msoBusinessLogicMock).replaceVnf(argumentCaptor.capture(),Mockito.any(),Mockito.any()); assertEquals(argumentCaptor.getValue().getVnfInstanceId(),requestDetails.getVnfInstanceId()); } @Test public void doChangeManagement_requestTypeIsInPlaceSoftwareUpdate_MsoUpdateVnfIsCalled() throws Exception { - Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnfSoftware(Mockito.any(),Mockito.anyString(),Mockito.anyString()); + Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnfSoftware(Mockito.any(),Mockito.any(),Mockito.any()); RequestDetails requestDetails = callChangeManagement(ChangeManagementRequest.VNF_IN_PLACE_SOFTWARE_UPDATE); ArgumentCaptor<RequestDetails> argumentCaptor = ArgumentCaptor.forClass(RequestDetails.class); - verify(msoBusinessLogicMock).updateVnfSoftware(argumentCaptor.capture(),Mockito.anyString(),Mockito.anyString()); + verify(msoBusinessLogicMock).updateVnfSoftware(argumentCaptor.capture(),Mockito.any(),Mockito.any()); assertEquals(argumentCaptor.getValue().getVnfInstanceId(),requestDetails.getVnfInstanceId()); } @Test public void doChangeManagement_requestTypeIsConfigUpdate_MsoUpdateVnfIsCalled() throws Exception { - Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnfConfig(Mockito.any(),Mockito.anyString(),Mockito.anyString()); + Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnfConfig(Mockito.any(),Mockito.any(),Mockito.any()); RequestDetails requestDetails = callChangeManagement(ChangeManagementRequest.CONFIG_UPDATE); ArgumentCaptor<RequestDetails> argumentCaptor = ArgumentCaptor.forClass(RequestDetails.class); - verify(msoBusinessLogicMock).updateVnfConfig(argumentCaptor.capture(),Mockito.anyString(),Mockito.anyString()); + verify(msoBusinessLogicMock).updateVnfConfig(argumentCaptor.capture(),Mockito.any(),Mockito.any()); assertEquals(argumentCaptor.getValue().getVnfInstanceId(),requestDetails.getVnfInstanceId()); } @@ -106,8 +106,8 @@ public class ChangeManagementServiceImplTest { updateRequest.setRequestType(requestType); RequestDetails requestDetails = new RequestDetails(); requestDetails.setVnfInstanceId("vnfFakeId"); - Mockito.doReturn("fakeId").when(changeManagementServiceSpied).extractServiceInstanceId(Mockito.anyObject(),Mockito.anyString()); - Mockito.doReturn(requestDetails).when(changeManagementServiceSpied).findRequestByVnfName(Matchers.anyList(),Mockito.anyString()); + Mockito.doReturn("fakeId").when(changeManagementServiceSpied).extractServiceInstanceId(Mockito.any(),Mockito.any()); + Mockito.doReturn(requestDetails).when(changeManagementServiceSpied).findRequestByVnfName(Matchers.any(),Mockito.any()); changeManagementServiceSpied.doChangeManagement(updateRequest,"anyVnfName"); diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java index 8aafda3f0..d849869b0 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java @@ -24,6 +24,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.joshworks.restclient.http.HttpResponse; import org.apache.commons.io.IOUtils; import org.mockito.ArgumentCaptor; +import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.changeManagement.ChangeManagementRequest; import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.client.SyncRestClient; @@ -37,8 +39,6 @@ import org.onap.vid.mso.rest.RequestDetails; import org.onap.vid.properties.AsdcClientConfiguration; import org.onap.vid.scheduler.SchedulerRestInterfaceIfc; import org.onap.vid.testUtils.RegExMatcher; -import org.onap.portalsdk.core.service.DataAccessService; -import org.onap.portalsdk.core.util.SystemProperties; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.springframework.context.annotation.Bean; @@ -54,8 +54,8 @@ import java.net.URL; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; @@ -74,7 +74,7 @@ public class ChangeManagementServiceUnitTest extends AbstractTestNGSpringContext void testInPlaceSoftwareUpdateRequest() throws Exception { - doReturn(new HttpResponse<>(anyObject(), RequestReferencesContainer.class, anyObject())).when(restClientUnderTest).post(anyString(), anyObject(), anyObject()); + doReturn(new HttpResponse<>(any(), RequestReferencesContainer.class, any())).when(restClientUnderTest).post(anyString(), any(), any()); URL requestJsonUrl = this.getClass().getResource("/services/change_management_software_update_request.json"); ChangeManagementRequest changeManagementRequest = objectMapper.readValue(requestJsonUrl, ChangeManagementRequest.class); diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java index 0460f5325..b4c7828bc 100644 --- a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java +++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java @@ -22,8 +22,8 @@ import java.util.Iterator; import java.util.List; import static fj.parser.Parser.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; /** diff --git a/vid-app-common/src/test/resources/empty.json b/vid-app-common/src/test/resources/empty.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/vid-app-common/src/test/resources/empty.json @@ -0,0 +1 @@ +{}
\ No newline at end of file diff --git a/vid-app-common/src/test/resources/git.properties b/vid-app-common/src/test/resources/git.properties index d504e3e88..6db5795a5 100644 --- a/vid-app-common/src/test/resources/git.properties +++ b/vid-app-common/src/test/resources/git.properties @@ -1,3 +1,3 @@ -git.commit.id=123987 +git.commit.id=123 git.commit.message.short=Test short commit message git.commit.time=1999-09-12T13\:48\:55+0200
\ No newline at end of file diff --git a/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java index f4d3796ae..173897095 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java @@ -115,7 +115,7 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest { new ArrayList<>(), false, true, true, true, "2017-488_ADIOD-vPE 0", - "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1", 0, 1, new ArrayList<>()); + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1", 0, 1, ImmutableList.of("Bandwidth", "Bandwidth units")); String serviceInstanceName = deployServiceInstance(serviceData, false); vidBasePage.screenshotDeployDialog(serviceInstanceName); diff --git a/vid-webpack-master/src/app/components/vnf-popup/vnf-popup.service.spec.ts b/vid-webpack-master/src/app/components/vnf-popup/vnf-popup.service.spec.ts deleted file mode 100644 index 02296f728..000000000 --- a/vid-webpack-master/src/app/components/vnf-popup/vnf-popup.service.spec.ts +++ /dev/null @@ -1,827 +0,0 @@ -import {VnfPopupService} from './vnf-popup-service'; -import {ServicePlanningService} from '../../services/service-planning.service'; -import {ServiceNodeTypes} from '../../shared/models/ServiceNodeTypes'; -import {NgRedux} from '@angular-redux/store'; -import {VNFModel} from '../../shared/models/vnfModel'; -import {VfModule} from '../../shared/models/vfModule'; -import {FormControl, FormGroup, Validators} from '@angular/forms'; -import {NumbersLettersUnderscoreValidator} from '../../shared/components/validators/numbersLettersUnderscore/numbersLettersUnderscore.validator'; -import {VnfInstanceDetailsService} from './vnf-instance-details/vnf-instance-details.service'; -import {ReflectiveInjector} from '@angular/core'; - -export class MockAppStore<T> { -} - -describe('Vnf popup service', () => { - let injector; - let service: VnfPopupService; - let fg: FormGroup; - let data = generateModelData(); - let servicePopupDataModel = generateServicePopupDataModel(); - let form: FormGroup = generateFormGroup(); - beforeEach(() => { - - let injector = ReflectiveInjector.resolveAndCreate([ - VnfPopupService, - ServicePlanningService, - VnfInstanceDetailsService, - {provide: FormGroup, useClass: MockAppStore}, - {provide: NgRedux, useClass: MockAppStore} - ]); - - service = injector.get(VnfPopupService); - fg = injector.get(FormGroup); - }); - - describe('#updateVnfDataFromModel', () => { - it('update vnf data from model should return new vnf', (done: DoneFn) => { - let vnf: VNFModel = service.getModelFromResponse(data, ServiceNodeTypes.VF, '2017-388_ADIOD-vPE 1'); - - expect(vnf).toEqual(jasmine.any(VNFModel)); - done(); - }); - - it('update wrong vnf data from model should be undefined', (done: DoneFn) => { - let vnf: VNFModel = service.getModelFromResponse(data, ServiceNodeTypes.VF, '2017-388_ADIOD-vPE 3'); - - expect(vnf).toBeUndefined(); - done(); - }); - - it('update vfModule data from model should return new vfModule', (done: DoneFn) => { - let vfModule: VfModule = service.getModelFromResponse(data, ServiceNodeTypes.VFmodule, '2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1'); - - expect(vfModule).toEqual(jasmine.any(VfModule)); - done(); - }); - - }); - - - describe('#onControlError', () => { - it('onControlError should return true if instanceName is not legal', (done: DoneFn) => { - form.controls['instanceName'].setValue('aaaa - aaa'); - - let result: boolean = service.onControlError(<any>servicePopupDataModel, form, false, false); - expect(result).toBeTruthy(); - done(); - }); - - it('onControlError should return false if instanceName is legal', (done: DoneFn) => { - - form.controls['instanceName'].setValue('aaaa'); - let result = service.onControlError(<any>servicePopupDataModel, form, false, false); - expect(result).toBeFalsy(); - done(); - }); - - it('onControlError should return true if instanceName is not unique', (done: DoneFn) => { - - form.controls['instanceName'].setValue('aaaa'); - let result = service.onControlError(<any>servicePopupDataModel, form, true, false); - expect(result).toBeTruthy(); - done(); - }); - - it('onControlError should return true if lcpRegions is empty', (done: DoneFn) => { - servicePopupDataModel.vnfPopupDataModel['lcpRegions'] = []; - let result = service.onControlError(<any>servicePopupDataModel, form, true, false); - expect(result).toBeTruthy(); - done(); - }); - - it('onControlError should return true if isNotUniqueVolumeGroupName is true', (done: DoneFn) => { - let result = service.onControlError(<any>servicePopupDataModel, form, true, true); - expect(result).toBeTruthy(); - done(); - }) - }); - - - function generateServicePopupDataModel() { - return { - 'vnfPopupDataModel': JSON.parse('{"tenants" : [1,2,3],"lcpRegions":[1,2,3],"lcpRegionsTenantsMap":{},"productFamilies":[1,2,3],"lineOfBusinesses":[{"id":"ECOMP","name":"ECOMP"},{"id":"zzz1","name":"zzz1"}],"platforms":[{"id":"platform","name":"platform"},{"id":"xxx1","name":"xxx1"}],"rollbackOnFailure":[{"id":"true","name":"Rollback"}]}') - } - } - - function generateFormGroup() { - return new FormGroup({ - productFamilyId: new FormControl(), - lcpCloudRegionId: new FormControl(Validators.required), - tenantId: new FormControl({value: null, disabled: false}, Validators.required), - legacyRegion: new FormControl(), - lineOfBusiness: new FormControl(), - platformName: new FormControl(Validators.required), - instanceName: new FormControl({value: null}, Validators.compose([Validators.required, NumbersLettersUnderscoreValidator.valid])) - }); - } - - function generateModelData() { - return JSON.parse(JSON.stringify( - { - 'service': { - 'uuid': '2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd', - 'invariantUuid': 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0', - 'name': 'action-data', - 'version': '1.0', - 'toscaModelURL': null, - 'category': '', - 'serviceType': '', - 'serviceRole': '', - 'description': '', - 'serviceEcompNaming': 'true', - 'instantiationType': 'ClientConfig', - 'inputs': { - '2017488_adiodvpe0_ASN': { - 'type': 'string', - 'description': 'AV/PE', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'AV_vPE' - }, - 'adiodvpe0_bandwidth': { - 'type': 'string', - 'description': 'Requested VPE bandwidth', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': '10' - }, - '2017488_adiodvpe0_vnf_instance_name': { - 'type': 'string', - 'description': 'The hostname assigned to the vpe.', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'mtnj309me6' - }, - '2017488_adiodvpe0_vnf_config_template_version': { - 'type': 'string', - 'description': 'VPE Software Version', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': '17.2' - }, - '2017488_adiodvpe0_AIC_CLLI': { - 'type': 'string', - 'description': 'AIC Site CLLI', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'ATLMY8GA' - }, - 'adiodvpe0_bandwidth_units': { - 'type': 'string', - 'description': 'Units of bandwidth', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'Gbps' - } - } - }, - 'vnfs': { - '2017-388_ADIOD-vPE 1': { - 'uuid': '0903e1c0-8e03-4936-b5c2-260653b96413', - 'invariantUuid': '00beb8f9-6d39-452f-816d-c709b9cbb87d', - 'description': 'Name ADIOD vPE Description The provider edge function for the ADIOD service supported by the Junipers VMX product Category Router Vendor Juniper Vendor Release Code 17.2 Owners Mary Fragale. Updated 9-25 to use v8.0 of the Juniper Valid 2 VLM', - 'name': '2017-388_ADIOD-vPE', - 'version': '1.0', - 'customizationUuid': '280dec31-f16d-488b-9668-4aae55d6648a', - 'inputs': { - 'vnf_config_template_version': { - 'type': 'string', - 'description': 'VPE Software Version', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': '17.2' - }, - 'bandwidth_units': { - 'type': 'string', - 'description': 'Units of bandwidth', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'Gbps' - }, - 'bandwidth': { - 'type': 'string', - 'description': 'Requested VPE bandwidth', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': '10' - }, - 'AIC_CLLI': { - 'type': 'string', - 'description': 'AIC Site CLLI', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'ATLMY8GA' - }, - 'ASN': { - 'type': 'string', - 'description': 'AV/PE', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'AV_vPE' - }, - 'vnf_instance_name': { - 'type': 'string', - 'description': 'The hostname assigned to the vpe.', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'mtnj309me6' - } - }, - 'commands': { - 'vnf_config_template_version': { - 'displayName': 'vnf_config_template_version', - 'command': 'get_input', - 'inputName': '2017488_adiodvpe0_vnf_config_template_version' - }, - 'bandwidth_units': { - 'displayName': 'bandwidth_units', - 'command': 'get_input', - 'inputName': 'adiodvpe0_bandwidth_units' - }, - 'bandwidth': {'displayName': 'bandwidth', 'command': 'get_input', 'inputName': 'adiodvpe0_bandwidth'}, - 'AIC_CLLI': {'displayName': 'AIC_CLLI', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_AIC_CLLI'}, - 'ASN': {'displayName': 'ASN', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_ASN'}, - 'vnf_instance_name': { - 'displayName': 'vnf_instance_name', - 'command': 'get_input', - 'inputName': '2017488_adiodvpe0_vnf_instance_name' - } - }, - 'properties': { - 'vmxvre_retype': 'RE-VMX', - 'vnf_config_template_version': 'get_input:2017488_adiodvpe0_vnf_config_template_version', - 'sriov44_net_id': '48d399b3-11ee-48a8-94d2-f0ea94d6be8d', - 'int_ctl_net_id': '2f323477-6936-4d01-ac53-d849430281d9', - 'vmxvpfe_sriov41_0_port_mac': '00:11:22:EF:AC:DF', - 'int_ctl_net_name': 'VMX-INTXI', - 'vmx_int_ctl_prefix': '128.0.0.0', - 'sriov43_net_id': 'da349ca1-6de9-4548-be88-2d88e99bfef5', - 'sriov42_net_id': '760669ba-013d-4d9b-b0e7-4151fe2e6279', - 'sriov41_net_id': '25ad52d5-c165-40f8-b3b0-ddfc2373280a', - 'nf_type': 'vPE', - 'vmxvpfe_int_ctl_ip_1': '128.0.0.16', - 'is_AVPN_service': 'false', - 'vmx_RSG_name': 'vREXI-affinity', - 'vmx_int_ctl_forwarding': 'l2', - 'vmxvre_oam_ip_0': '10.40.123.5', - 'vmxvpfe_sriov44_0_port_mac': '00:11:22:EF:AC:DF', - 'vmxvpfe_sriov41_0_port_vlanstrip': 'false', - 'vmxvpfe_sriov42_0_port_vlanfilter': '4001', - 'vmxvpfe_sriov44_0_port_unknownunicastallow': 'true', - 'vmxvre_image_name_0': 'VRE-ENGINE_17.2-S2.1.qcow2', - 'vmxvre_instance': '0', - 'vmxvpfe_sriov43_0_port_mac': '00:11:22:EF:AC:DF', - 'vmxvre_flavor_name': 'ns.c1r16d32.v5', - 'vmxvpfe_volume_size_0': '40.0', - 'vmxvpfe_sriov43_0_port_vlanfilter': '4001', - 'nf_naming': '{ecomp_generated_naming=true}', - 'nf_naming_code': 'Navneet', - 'vmxvre_name_0': 'vREXI', - 'vmxvpfe_sriov42_0_port_vlanstrip': 'false', - 'vmxvpfe_volume_name_0': 'vPFEXI_FBVolume', - 'vmx_RSG_id': 'bd89a33c-13c3-4a04-8fde-1a57eb123141', - 'vmxvpfe_image_name_0': 'VPE_ROUTING-ENGINE_17.2R1-S2.1.qcow2', - 'vmxvpfe_sriov43_0_port_unknownunicastallow': 'true', - 'vmxvpfe_sriov44_0_port_unknownmulticastallow': 'true', - 'vmxvre_console': 'vidconsole', - 'vmxvpfe_sriov44_0_port_vlanfilter': '4001', - 'vmxvpfe_sriov42_0_port_mac': '00:11:22:EF:AC:DF', - 'vmxvpfe_volume_id_0': '47cede15-da2f-4397-a101-aa683220aff3', - 'vmxvpfe_sriov42_0_port_unknownmulticastallow': 'true', - 'vmxvpfe_sriov44_0_port_vlanstrip': 'false', - 'vf_module_id': '123', - 'nf_function': 'JAI', - 'vmxvpfe_sriov43_0_port_unknownmulticastallow': 'true', - 'vmxvre_int_ctl_ip_0': '128.0.0.1', - 'AIC_CLLI': 'get_input:2017488_adiodvpe0_AIC_CLLI', - 'vnf_name': 'mtnj309me6vre', - 'vmxvpfe_sriov41_0_port_unknownunicastallow': 'true', - 'vmxvre_volume_type_1': 'HITACHI', - 'vmxvpfe_sriov44_0_port_broadcastallow': 'true', - 'vmxvre_volume_type_0': 'HITACHI', - 'vmxvpfe_volume_type_0': 'HITACHI', - 'vmxvpfe_sriov43_0_port_broadcastallow': 'true', - 'bandwidth_units': 'get_input:adiodvpe0_bandwidth_units', - 'vnf_id': '123', - 'vmxvre_oam_prefix': '24', - 'availability_zone_0': 'mtpocfo-kvm-az01', - 'ASN': 'get_input:2017488_adiodvpe0_ASN', - 'vmxvre_chassis_i2cid': '161', - 'vmxvpfe_name_0': 'vPFEXI', - 'bandwidth': 'get_input:adiodvpe0_bandwidth', - 'availability_zone_max_count': '1', - 'vmxvre_volume_size_0': '45.0', - 'vmxvre_volume_size_1': '50.0', - 'vmxvpfe_sriov42_0_port_broadcastallow': 'true', - 'vmxvre_oam_gateway': '10.40.123.1', - 'vmxvre_volume_name_1': 'vREXI_FAVolume', - 'vmxvre_ore_present': '0', - 'vmxvre_volume_name_0': 'vREXI_FBVolume', - 'vmxvre_type': '0', - 'vnf_instance_name': 'get_input:2017488_adiodvpe0_vnf_instance_name', - 'vmxvpfe_sriov41_0_port_unknownmulticastallow': 'true', - 'oam_net_id': 'b95eeb1d-d55d-4827-abb4-8ebb94941429', - 'vmx_int_ctl_len': '24', - 'vmxvpfe_sriov43_0_port_vlanstrip': 'false', - 'vmxvpfe_sriov41_0_port_broadcastallow': 'true', - 'vmxvre_volume_id_1': '6e86797e-03cd-4fdc-ba72-2957119c746d', - 'vmxvpfe_sriov41_0_port_vlanfilter': '4001', - 'nf_role': 'Testing', - 'vmxvre_volume_id_0': 'f4eacb79-f687-4e9d-b760-21847c8bb15a', - 'vmxvpfe_sriov42_0_port_unknownunicastallow': 'true', - 'vmxvpfe_flavor_name': 'ns.c20r16d25.v5' - }, - 'type': 'VF', - 'modelCustomizationName': '2017-388_ADIOD-vPE 1', - 'vfModules': {}, - 'volumeGroups': {} - }, - '2017-388_ADIOD-vPE 0': { - 'uuid': 'afacccf6-397d-45d6-b5ae-94c39734b168', - 'invariantUuid': '72e465fe-71b1-4e7b-b5ed-9496118ff7a8', - 'description': 'Name ADIOD vPE Description The provider edge function for the ADIOD service supported by the Junipers VMX product Category Router Vendor Juniper Vendor Release Code 17.2 Owners Mary Fragale. Updated 9-25 to use v8.0 of the Juniper Valid 2 VLM', - 'name': '2017-388_ADIOD-vPE', - 'version': '4.0', - 'customizationUuid': 'b3c76f73-eeb5-4fb6-9d31-72a889f1811c', - 'inputs': { - 'vnf_config_template_version': { - 'type': 'string', - 'description': 'VPE Software Version', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': '17.2' - }, - 'bandwidth_units': { - 'type': 'string', - 'description': 'Units of bandwidth', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'Gbps' - }, - 'bandwidth': { - 'type': 'string', - 'description': 'Requested VPE bandwidth', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': '10' - }, - 'AIC_CLLI': { - 'type': 'string', - 'description': 'AIC Site CLLI', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'ATLMY8GA' - }, - 'ASN': { - 'type': 'string', - 'description': 'AV/PE', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'AV_vPE' - }, - 'vnf_instance_name': { - 'type': 'string', - 'description': 'The hostname assigned to the vpe.', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'mtnj309me6' - } - }, - 'commands': { - 'vnf_config_template_version': { - 'displayName': 'vnf_config_template_version', - 'command': 'get_input', - 'inputName': '2017488_adiodvpe0_vnf_config_template_version' - }, - 'bandwidth_units': { - 'displayName': 'bandwidth_units', - 'command': 'get_input', - 'inputName': 'adiodvpe0_bandwidth_units' - }, - 'bandwidth': {'displayName': 'bandwidth', 'command': 'get_input', 'inputName': 'adiodvpe0_bandwidth'}, - 'AIC_CLLI': {'displayName': 'AIC_CLLI', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_AIC_CLLI'}, - 'ASN': {'displayName': 'ASN', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_ASN'}, - 'vnf_instance_name': { - 'displayName': 'vnf_instance_name', - 'command': 'get_input', - 'inputName': '2017488_adiodvpe0_vnf_instance_name' - } - }, - 'properties': { - 'vmxvre_retype': 'RE-VMX', - 'vnf_config_template_version': 'get_input:2017488_adiodvpe0_vnf_config_template_version', - 'sriov44_net_id': '48d399b3-11ee-48a8-94d2-f0ea94d6be8d', - 'int_ctl_net_id': '2f323477-6936-4d01-ac53-d849430281d9', - 'vmxvpfe_sriov41_0_port_mac': '00:11:22:EF:AC:DF', - 'int_ctl_net_name': 'VMX-INTXI', - 'vmx_int_ctl_prefix': '128.0.0.0', - 'sriov43_net_id': 'da349ca1-6de9-4548-be88-2d88e99bfef5', - 'sriov42_net_id': '760669ba-013d-4d9b-b0e7-4151fe2e6279', - 'sriov41_net_id': '25ad52d5-c165-40f8-b3b0-ddfc2373280a', - 'nf_type': 'vPE', - 'vmxvpfe_int_ctl_ip_1': '128.0.0.16', - 'is_AVPN_service': 'false', - 'vmx_RSG_name': 'vREXI-affinity', - 'vmx_int_ctl_forwarding': 'l2', - 'vmxvre_oam_ip_0': '10.40.123.5', - 'vmxvpfe_sriov44_0_port_mac': '00:11:22:EF:AC:DF', - 'vmxvpfe_sriov41_0_port_vlanstrip': 'false', - 'vmxvpfe_sriov42_0_port_vlanfilter': '4001', - 'vmxvpfe_sriov44_0_port_unknownunicastallow': 'true', - 'vmxvre_image_name_0': 'VRE-ENGINE_17.2-S2.1.qcow2', - 'vmxvre_instance': '0', - 'vmxvpfe_sriov43_0_port_mac': '00:11:22:EF:AC:DF', - 'vmxvre_flavor_name': 'ns.c1r16d32.v5', - 'vmxvpfe_volume_size_0': '40.0', - 'vmxvpfe_sriov43_0_port_vlanfilter': '4001', - 'nf_naming': '{ecomp_generated_naming=true}', - 'nf_naming_code': 'Navneet', - 'vmxvre_name_0': 'vREXI', - 'vmxvpfe_sriov42_0_port_vlanstrip': 'false', - 'vmxvpfe_volume_name_0': 'vPFEXI_FBVolume', - 'vmx_RSG_id': 'bd89a33c-13c3-4a04-8fde-1a57eb123141', - 'vmxvpfe_image_name_0': 'VPE_ROUTING-ENGINE_17.2R1-S2.1.qcow2', - 'vmxvpfe_sriov43_0_port_unknownunicastallow': 'true', - 'vmxvpfe_sriov44_0_port_unknownmulticastallow': 'true', - 'vmxvre_console': 'vidconsole', - 'vmxvpfe_sriov44_0_port_vlanfilter': '4001', - 'vmxvpfe_sriov42_0_port_mac': '00:11:22:EF:AC:DF', - 'vmxvpfe_volume_id_0': '47cede15-da2f-4397-a101-aa683220aff3', - 'vmxvpfe_sriov42_0_port_unknownmulticastallow': 'true', - 'vmxvpfe_sriov44_0_port_vlanstrip': 'false', - 'vf_module_id': '123', - 'nf_function': 'JAI', - 'vmxvpfe_sriov43_0_port_unknownmulticastallow': 'true', - 'vmxvre_int_ctl_ip_0': '128.0.0.1', - 'AIC_CLLI': 'get_input:2017488_adiodvpe0_AIC_CLLI', - 'vnf_name': 'mtnj309me6vre', - 'vmxvpfe_sriov41_0_port_unknownunicastallow': 'true', - 'vmxvre_volume_type_1': 'HITACHI', - 'vmxvpfe_sriov44_0_port_broadcastallow': 'true', - 'vmxvre_volume_type_0': 'HITACHI', - 'vmxvpfe_volume_type_0': 'HITACHI', - 'vmxvpfe_sriov43_0_port_broadcastallow': 'true', - 'bandwidth_units': 'get_input:adiodvpe0_bandwidth_units', - 'vnf_id': '123', - 'vmxvre_oam_prefix': '24', - 'availability_zone_0': 'mtpocfo-kvm-az01', - 'ASN': 'get_input:2017488_adiodvpe0_ASN', - 'vmxvre_chassis_i2cid': '161', - 'vmxvpfe_name_0': 'vPFEXI', - 'bandwidth': 'get_input:adiodvpe0_bandwidth', - 'availability_zone_max_count': '1', - 'vmxvre_volume_size_0': '45.0', - 'vmxvre_volume_size_1': '50.0', - 'vmxvpfe_sriov42_0_port_broadcastallow': 'true', - 'vmxvre_oam_gateway': '10.40.123.1', - 'vmxvre_volume_name_1': 'vREXI_FAVolume', - 'vmxvre_ore_present': '0', - 'vmxvre_volume_name_0': 'vREXI_FBVolume', - 'vmxvre_type': '0', - 'vnf_instance_name': 'get_input:2017488_adiodvpe0_vnf_instance_name', - 'vmxvpfe_sriov41_0_port_unknownmulticastallow': 'true', - 'oam_net_id': 'b95eeb1d-d55d-4827-abb4-8ebb94941429', - 'vmx_int_ctl_len': '24', - 'vmxvpfe_sriov43_0_port_vlanstrip': 'false', - 'vmxvpfe_sriov41_0_port_broadcastallow': 'true', - 'vmxvre_volume_id_1': '6e86797e-03cd-4fdc-ba72-2957119c746d', - 'vmxvpfe_sriov41_0_port_vlanfilter': '4001', - 'nf_role': 'Testing', - 'vmxvre_volume_id_0': 'f4eacb79-f687-4e9d-b760-21847c8bb15a', - 'vmxvpfe_sriov42_0_port_unknownunicastallow': 'true', - 'vmxvpfe_flavor_name': 'ns.c20r16d25.v5' - }, - 'type': 'VF', - 'modelCustomizationName': '2017-388_ADIOD-vPE 0', - 'vfModules': {}, - 'volumeGroups': {} - }, - '2017488_ADIODvPE 0': { - 'uuid': '69e09f68-8b63-4cc9-b9ff-860960b5db09', - 'invariantUuid': '72e465fe-71b1-4e7b-b5ed-9496118ff7a8', - 'description': 'Name ADIOD vPE Description The provider edge function for the ADIOD service supported by the Junipers VMX product Category Router Vendor Juniper Vendor Release Code 17.2 Owners Mary Fragale. Updated 9-25 to use v8.0 of the Juniper Valid 2 VLM', - 'name': '2017488_ADIODvPE', - 'version': '5.0', - 'customizationUuid': '1da7b585-5e61-4993-b95e-8e6606c81e45', - 'inputs': { - 'vnf_config_template_version': { - 'type': 'string', - 'description': 'VPE Software Version', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': '17.2' - }, - 'bandwidth_units': { - 'type': 'string', - 'description': 'Units of bandwidth', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'Gbps' - }, - 'bandwidth': { - 'type': 'string', - 'description': 'Requested VPE bandwidth', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': '10' - }, - 'AIC_CLLI': { - 'type': 'string', - 'description': 'AIC Site CLLI', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'ATLMY8GA' - }, - 'ASN': { - 'type': 'string', - 'description': 'AV/PE', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'AV_vPE' - }, - 'vnf_instance_name': { - 'type': 'string', - 'description': 'The hostname assigned to the vpe.', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'mtnj309me6' - } - }, - 'commands': { - 'vnf_config_template_version': { - 'displayName': 'vnf_config_template_version', - 'command': 'get_input', - 'inputName': '2017488_adiodvpe0_vnf_config_template_version' - }, - 'bandwidth_units': { - 'displayName': 'bandwidth_units', - 'command': 'get_input', - 'inputName': 'adiodvpe0_bandwidth_units' - }, - 'bandwidth': {'displayName': 'bandwidth', 'command': 'get_input', 'inputName': 'adiodvpe0_bandwidth'}, - 'AIC_CLLI': {'displayName': 'AIC_CLLI', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_AIC_CLLI'}, - 'ASN': {'displayName': 'ASN', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_ASN'}, - 'vnf_instance_name': { - 'displayName': 'vnf_instance_name', - 'command': 'get_input', - 'inputName': '2017488_adiodvpe0_vnf_instance_name' - } - }, - 'properties': { - 'vmxvre_retype': 'RE-VMX', - 'vnf_config_template_version': 'get_input:2017488_adiodvpe0_vnf_config_template_version', - 'sriov44_net_id': '48d399b3-11ee-48a8-94d2-f0ea94d6be8d', - 'int_ctl_net_id': '2f323477-6936-4d01-ac53-d849430281d9', - 'vmxvpfe_sriov41_0_port_mac': '00:11:22:EF:AC:DF', - 'int_ctl_net_name': 'VMX-INTXI', - 'vmx_int_ctl_prefix': '128.0.0.0', - 'sriov43_net_id': 'da349ca1-6de9-4548-be88-2d88e99bfef5', - 'sriov42_net_id': '760669ba-013d-4d9b-b0e7-4151fe2e6279', - 'sriov41_net_id': '25ad52d5-c165-40f8-b3b0-ddfc2373280a', - 'nf_type': 'vPE', - 'vmxvpfe_int_ctl_ip_1': '128.0.0.16', - 'is_AVPN_service': 'false', - 'vmx_RSG_name': 'vREXI-affinity', - 'vmx_int_ctl_forwarding': 'l2', - 'vmxvre_oam_ip_0': '10.40.123.5', - 'vmxvpfe_sriov44_0_port_mac': '00:11:22:EF:AC:DF', - 'vmxvpfe_sriov41_0_port_vlanstrip': 'false', - 'vmxvpfe_sriov42_0_port_vlanfilter': '4001', - 'vmxvpfe_sriov44_0_port_unknownunicastallow': 'true', - 'vmxvre_image_name_0': 'VRE-ENGINE_17.2-S2.1.qcow2', - 'vmxvre_instance': '0', - 'vmxvpfe_sriov43_0_port_mac': '00:11:22:EF:AC:DF', - 'vmxvre_flavor_name': 'ns.c1r16d32.v5', - 'vmxvpfe_volume_size_0': '40.0', - 'vmxvpfe_sriov43_0_port_vlanfilter': '4001', - 'nf_naming': '{ecomp_generated_naming=true}', - 'nf_naming_code': 'Navneet', - 'vmxvre_name_0': 'vREXI', - 'vmxvpfe_sriov42_0_port_vlanstrip': 'false', - 'vmxvpfe_volume_name_0': 'vPFEXI_FBVolume', - 'vmx_RSG_id': 'bd89a33c-13c3-4a04-8fde-1a57eb123141', - 'vmxvpfe_image_name_0': 'VPE_ROUTING-ENGINE_17.2R1-S2.1.qcow2', - 'vmxvpfe_sriov43_0_port_unknownunicastallow': 'true', - 'vmxvpfe_sriov44_0_port_unknownmulticastallow': 'true', - 'vmxvre_console': 'vidconsole', - 'vmxvpfe_sriov44_0_port_vlanfilter': '4001', - 'vmxvpfe_sriov42_0_port_mac': '00:11:22:EF:AC:DF', - 'vmxvpfe_volume_id_0': '47cede15-da2f-4397-a101-aa683220aff3', - 'vmxvpfe_sriov42_0_port_unknownmulticastallow': 'true', - 'vmxvpfe_sriov44_0_port_vlanstrip': 'false', - 'vf_module_id': '123', - 'nf_function': 'JAI', - 'vmxvpfe_sriov43_0_port_unknownmulticastallow': 'true', - 'vmxvre_int_ctl_ip_0': '128.0.0.1', - 'AIC_CLLI': 'get_input:2017488_adiodvpe0_AIC_CLLI', - 'vnf_name': 'mtnj309me6vre', - 'vmxvpfe_sriov41_0_port_unknownunicastallow': 'true', - 'vmxvre_volume_type_1': 'HITACHI', - 'vmxvpfe_sriov44_0_port_broadcastallow': 'true', - 'vmxvre_volume_type_0': 'HITACHI', - 'vmxvpfe_volume_type_0': 'HITACHI', - 'vmxvpfe_sriov43_0_port_broadcastallow': 'true', - 'bandwidth_units': 'get_input:adiodvpe0_bandwidth_units', - 'vnf_id': '123', - 'vmxvre_oam_prefix': '24', - 'availability_zone_0': 'mtpocfo-kvm-az01', - 'ASN': 'get_input:2017488_adiodvpe0_ASN', - 'vmxvre_chassis_i2cid': '161', - 'vmxvpfe_name_0': 'vPFEXI', - 'bandwidth': 'get_input:adiodvpe0_bandwidth', - 'availability_zone_max_count': '1', - 'vmxvre_volume_size_0': '45.0', - 'vmxvre_volume_size_1': '50.0', - 'vmxvpfe_sriov42_0_port_broadcastallow': 'true', - 'vmxvre_oam_gateway': '10.40.123.1', - 'vmxvre_volume_name_1': 'vREXI_FAVolume', - 'vmxvre_ore_present': '0', - 'vmxvre_volume_name_0': 'vREXI_FBVolume', - 'vmxvre_type': '0', - 'vnf_instance_name': 'get_input:2017488_adiodvpe0_vnf_instance_name', - 'vmxvpfe_sriov41_0_port_unknownmulticastallow': 'true', - 'oam_net_id': 'b95eeb1d-d55d-4827-abb4-8ebb94941429', - 'vmx_int_ctl_len': '24', - 'vmxvpfe_sriov43_0_port_vlanstrip': 'false', - 'vmxvpfe_sriov41_0_port_broadcastallow': 'true', - 'vmxvre_volume_id_1': '6e86797e-03cd-4fdc-ba72-2957119c746d', - 'vmxvpfe_sriov41_0_port_vlanfilter': '4001', - 'nf_role': 'Testing', - 'vmxvre_volume_id_0': 'f4eacb79-f687-4e9d-b760-21847c8bb15a', - 'vmxvpfe_sriov42_0_port_unknownunicastallow': 'true', - 'vmxvpfe_flavor_name': 'ns.c20r16d25.v5' - }, - 'type': 'VF', - 'modelCustomizationName': '2017488_ADIODvPE 0', - 'vfModules': { - '2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1': { - 'uuid': '25284168-24bb-4698-8cb4-3f509146eca5', - 'invariantUuid': '7253ff5c-97f0-4b8b-937c-77aeb4d79aa1', - 'customizationUuid': 'f7e7c365-60cf-49a9-9ebf-a1aa11b9d401', - 'description': null, - 'name': '2017488AdiodVpe..ADIOD_vRE_BV..module-1', - 'version': '6', - 'modelCustomizationName': '2017488AdiodVpe..ADIOD_vRE_BV..module-1', - 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0}, - 'commands': {}, - 'volumeGroupAllowed': true, - 'inputs': { - '2017488_adiodvpe0_vnf_config_template_version': { - 'type': 'string', - 'description': 'VPE Software Version', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': '17.2' - }, - '2017488_adiodvpe0_AIC_CLLI': { - 'type': 'string', - 'description': 'AIC Site CLLI', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'ATLMY8GA' - } - } - }, - '2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0': { - 'uuid': 'f8360508-3f17-4414-a2ed-6bc71161e8db', - 'invariantUuid': 'b34833bb-6aa9-4ad6-a831-70b06367a091', - 'customizationUuid': 'a55961b2-2065-4ab0-a5b7-2fcee1c227e3', - 'description': null, - 'name': '2017488AdiodVpe..ADIOD_base_vPE_BV..module-0', - 'version': '5', - 'modelCustomizationName': '2017488AdiodVpe..ADIOD_base_vPE_BV..module-0', - 'properties': {'minCountInstances': 1, 'maxCountInstances': 1, 'initialCount': 1}, - 'commands': {}, - 'volumeGroupAllowed': false, - 'inputs': { - '2017488_adiodvpe0_ASN': { - 'type': 'string', - 'description': 'AV/PE', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': 'AV_vPE' - }, - 'adiodvpe0_bandwidth': { - 'type': 'string', - 'description': 'Requested VPE bandwidth', - 'entry_schema': null, - 'constraints': [], - 'required': true, - 'default': '10' - } - } - }, - '2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2': { - 'uuid': '0a0dd9d4-31d3-4c3a-ae89-a02f383e6a9a', - 'invariantUuid': 'eff8cc59-53a1-4101-aed7-8cf24ecf8339', - 'customizationUuid': '3cd946bb-50e0-40d8-96d3-c9023520b557', - 'description': null, - 'name': '2017488AdiodVpe..ADIOD_vPFE_BV..module-2', - 'version': '6', - 'modelCustomizationName': '2017488AdiodVpe..ADIOD_vPFE_BV..module-2', - 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0}, - 'commands': {}, - 'volumeGroupAllowed': true, - 'inputs': {} - } - }, - 'volumeGroups': { - '2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1': { - 'uuid': '25284168-24bb-4698-8cb4-3f509146eca5', - 'invariantUuid': '7253ff5c-97f0-4b8b-937c-77aeb4d79aa1', - 'customizationUuid': 'f7e7c365-60cf-49a9-9ebf-a1aa11b9d401', - 'description': null, - 'name': '2017488AdiodVpe..ADIOD_vRE_BV..module-1', - 'version': '6', - 'modelCustomizationName': '2017488AdiodVpe..ADIOD_vRE_BV..module-1', - 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0} - }, - '2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2': { - 'uuid': '0a0dd9d4-31d3-4c3a-ae89-a02f383e6a9a', - 'invariantUuid': 'eff8cc59-53a1-4101-aed7-8cf24ecf8339', - 'customizationUuid': '3cd946bb-50e0-40d8-96d3-c9023520b557', - 'description': null, - 'name': '2017488AdiodVpe..ADIOD_vPFE_BV..module-2', - 'version': '6', - 'modelCustomizationName': '2017488AdiodVpe..ADIOD_vPFE_BV..module-2', - 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0} - } - } - } - }, - 'vfModules': { - '2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1': { - 'uuid': '25284168-24bb-4698-8cb4-3f509146eca5', - 'invariantUuid': '7253ff5c-97f0-4b8b-937c-77aeb4d79aa1', - 'customizationUuid': 'f7e7c365-60cf-49a9-9ebf-a1aa11b9d401', - 'description': null, - 'name': '2017488AdiodVpe..ADIOD_vRE_BV..module-1', - 'version': '6', - 'modelCustomizationName': '2017488AdiodVpe..ADIOD_vRE_BV..module-1', - 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0}, - 'commands': {}, - 'volumeGroupAllowed': true - }, - '2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0': { - 'uuid': 'f8360508-3f17-4414-a2ed-6bc71161e8db', - 'invariantUuid': 'b34833bb-6aa9-4ad6-a831-70b06367a091', - 'customizationUuid': 'a55961b2-2065-4ab0-a5b7-2fcee1c227e3', - 'description': null, - 'name': '2017488AdiodVpe..ADIOD_base_vPE_BV..module-0', - 'version': '5', - 'modelCustomizationName': '2017488AdiodVpe..ADIOD_base_vPE_BV..module-0', - 'properties': {'minCountInstances': 1, 'maxCountInstances': 1, 'initialCount': 1}, - 'commands': {}, - 'volumeGroupAllowed': false - }, - '2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2': { - 'uuid': '0a0dd9d4-31d3-4c3a-ae89-a02f383e6a9a', - 'invariantUuid': 'eff8cc59-53a1-4101-aed7-8cf24ecf8339', - 'customizationUuid': '3cd946bb-50e0-40d8-96d3-c9023520b557', - 'description': null, - 'name': '2017488AdiodVpe..ADIOD_vPFE_BV..module-2', - 'version': '6', - 'modelCustomizationName': '2017488AdiodVpe..ADIOD_vPFE_BV..module-2', - 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0}, - 'commands': {}, - 'volumeGroupAllowed': true - } - }, - 'networks': {}, - 'collectionResource': {}, - 'configurations': {}, - 'serviceProxies': {}, - 'pnfs': {} - } - )) - } - -}); |