# ============LICENSE_END=========================================================
-tag_version: nexus3.onap.org:10003/dcae-services/org.onap.dcaegen2.services.components.bbs-event-processor:1.0.0-SNAPSHOT
+tag_version: nexus3.onap.org:10003/onap/org.onap.dcaegen2.services.components.bbs-event-processor:1.0.0-SNAPSHOT
pnf_reregistration_url: http:message-router:3904/events/unauthenticated.PNF_UPDATE
cpe_authentication_url: http:message-router:3904/events/unauthenticated.CPE_AUTHENTICATION
close_loop_url: http:message-router:3904/events/unauthenticated.DCAE_CL_OUTPUT
imports:
- "http://www.getcloudify.org/spec/cloudify/3.4/types.yaml"
- - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R3/k8splugin/1.4.4/k8splugin_types.yaml
+ - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.11/k8splugin_types.yaml
inputs:
aai_enrichment_host:
application_cbs_polling_interval_sec:
type: integer
default: 300
+ application_logging_level:
+ type: string
+ default: "INFO"
dmaap_consumer_id:
type: string
dmaap_consumer_group:
application.reregistration.configKey: "pnf_reregistration"
application.cpeAuth.configKey: "cpe_authentication"
application.closeLoop.configKey: "close_loop"
+ application.loggingLevel: { get_input: application_logging_level }
host_port:
{ get_input: host_port }
container_port:
"policy_editable": true,
"sourced_at_deployment": true,
"description": "Config-key for Close Loop"
+ },
+ {
+ "name": "application.loggingLevel",
+ "value": "INFO",
+ "designer_editable": false,
+ "policy_editable": false,
+ "sourced_at_deployment": true,
+ "description": "Application Logging Level"
}
],
"auxilary": {
},
"artifacts": [
{
- "uri": "nexus3.onap.org:10003/dcae-services/org.onap.dcaegen2.services.components.bbs-event-processor:1.0.0-SNAPSHOT",
+ "uri": "nexus3.onap.org:10003/onap/org.onap.dcaegen2.services.components.bbs-event-processor:1.0.0-SNAPSHOT",
"type": "docker image"
}
]
<dependency.dir.name>libs</dependency.dir.name>
<dependency.dir.location>${project.build.directory}/${dependency.dir.name}</dependency.dir.location>
<docker.artifact.dir>/opt</docker.artifact.dir>
- <docker.image.name>dcae-services/${project.groupId}.${project.artifactId}</docker.image.name>
+ <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
</properties>
<goal>build</goal>
</goals>
</execution>
+ <execution>
+ <id>tag-and-push-image-latest</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>tag</goal>
+ </goals>
+ <configuration>
+ <image>${docker.image.name}:latest</image>
+ <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:latest</newName>
+ <pushImage>true</pushImage>
+ </configuration>
+ </execution>
<execution>
<id>tag-and-push-image-with-version</id>
<phase>deploy</phase>
import org.onap.bbs.event.processor.exceptions.ApplicationEnvironmentException;
import org.onap.bbs.event.processor.exceptions.ConfigurationParsingException;
import org.onap.bbs.event.processor.model.GeneratedAppConfigObject;
+import org.onap.bbs.event.processor.utilities.LoggingUtil;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapConsumerConfiguration;
genericProperties.getReRegistration().setClControlName(newConfiguration.reRegistrationClControlName());
genericProperties.getCpeAuthentication().setPolicyScope(newConfiguration.cpeAuthPolicyScope());
genericProperties.getCpeAuthentication().setClControlName(newConfiguration.cpeAuthClControlName());
+
+ LoggingUtil.changeLoggingLevel(newConfiguration.loggingLevel());
}
notifyObservers();
final String cpeAuthConfigKey = configObject.get("application.cpeAuth.configKey").getAsString();
final String closeLoopConfigKey = configObject.get("application.closeLoop.configKey").getAsString();
+ final String loggingLevel = configObject.get("application.loggingLevel").getAsString();
+
final JsonObject streamsPublishes = configObject.getAsJsonObject("streams_publishes");
final JsonObject streamsSubscribes = configObject.getAsJsonObject("streams_subscribes");
.reRegConfigKey(reRegConfigKey)
.cpeAuthConfigKey(cpeAuthConfigKey)
.closeLoopConfigKey(closeLoopConfigKey)
+ .loggingLevel(loggingLevel)
.streamSubscribesMap(parseStreamsObjects(streamsSubscribes))
.streamPublishesMap(parseStreamsObjects(streamsPublishes))
.build();
import org.onap.bbs.event.processor.pipelines.CpeAuthenticationPipeline;
import org.onap.bbs.event.processor.pipelines.ReRegistrationPipeline;
import org.onap.bbs.event.processor.pipelines.Scheduler;
+import org.onap.bbs.event.processor.utilities.LoggingUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
);
}
}
+
+ /**
+ * Change logging level for BBS code.
+ * @param level new logging level
+ * @return Proper HTTP response based on change logging level result
+ */
+ @PostMapping("logging/{level}")
+ public Mono<ResponseEntity<String>> changeLoggingLevel(@PathVariable String level) {
+ return Mono.defer(() -> {
+ if (LoggingUtil.changeLoggingLevel(level)) {
+ LOGGER.info("Changed logging level to {}", level);
+ return Mono.just(new ResponseEntity<>("Changed BBS event processor logging level\n",
+ HttpStatus.OK));
+ } else {
+ return Mono.just(new ResponseEntity<>("Unacceptable logging level\n",
+ HttpStatus.NOT_ACCEPTABLE));
+ }
+ }
+ );
+ }
}
@SerializedName(value = "application.closeLoop.configKey", alternate = "application.closeLoop.configKey")
String closeLoopConfigKey();
+ @SerializedName(value = "application.loggingLevel", alternate = "application.loggingLevel")
+ String loggingLevel();
+
@SerializedName(value = "streams_subscribes", alternate = "streams_subscribes")
Map<String, StreamsObject> streamSubscribesMap();
import static org.onap.bbs.event.processor.utilities.CpeAuthenticationEventFields.STATE_INTERFACE;
import static org.onap.bbs.event.processor.utilities.CpeAuthenticationEventFields.SW_VERSION;
+import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class CpeAuthenticationDmaapConsumerJsonParser {
private static final Logger LOGGER = LoggerFactory.getLogger(CpeAuthenticationDmaapConsumerJsonParser.class);
+ private static final Gson gson = new Gson();
private static final String CPE_AUTHENTICATION_DUMPING_TEMPLATE = "%n{"
+ "\"" + CORRELATION_ID + COMMON_FORMAT + ","
private Mono<CpeAuthenticationConsumerDmaapModel> transform(JsonObject dmaapResponseJsonObject) {
+ LOGGER.trace("Event from DMaaP to be parsed: \n{}", gson.toJson(dmaapResponseJsonObject));
+
if (!containsProperHeaders(dmaapResponseJsonObject)) {
LOGGER.warn("Incorrect CPE Authentication JSON event - missing headers");
return Mono.empty();
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * BBS-RELOCATION-CPE-AUTHENTICATION-HANDLER
+ * ================================================================================
+ * Copyright (C) 2019 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.bbs.event.processor.utilities;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.slf4j.LoggerFactory;
+
+public class LoggingUtil {
+
+ private static final String BBS_EP_APPLICATION_PACKAGE = "org.onap.bbs";
+ private static final Logger applicationLogger = (Logger) LoggerFactory.getLogger(BBS_EP_APPLICATION_PACKAGE);
+ private static final List<String> loggingLevels =
+ Arrays.asList("OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE");
+
+ // Non-instantiable class
+ private LoggingUtil() {
+ }
+
+ /**
+ * Change Application logging level.
+ * @param level logging level. Must be one of OFF, ERROR, WARN, INFO, DEBUG, TRACE
+ * @return Flag indicating if it changed the level or not
+ */
+ public static boolean changeLoggingLevel(String level) {
+ if (loggingLevels.contains(level)) {
+ applicationLogger.setLevel(Level.toLevel(level));
+ return true;
+ }
+ return false;
+ }
+}
import static org.onap.bbs.event.processor.utilities.ReRegistrationEventFields.REMOTE_ID;
import static org.onap.bbs.event.processor.utilities.ReRegistrationEventFields.SVLAN;
+import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class ReRegistrationDmaapConsumerJsonParser {
private static final Logger LOGGER = LoggerFactory.getLogger(ReRegistrationDmaapConsumerJsonParser.class);
+ private static final Gson gson = new Gson();
private static final String RE_REGISTRATION_DUMPING_TEMPLATE = "%n{"
+ "\"" + CORRELATION_ID + COMMON_FORMAT + ","
private Mono<ReRegistrationConsumerDmaapModel> transform(JsonObject dmaapResponseJsonObject) {
+ LOGGER.trace("Event from DMaaP to be parsed: \n{}", gson.toJson(dmaapResponseJsonObject));
+
if (!containsProperHeaders(dmaapResponseJsonObject)) {
LOGGER.warn("Incorrect JsonObject - missing headers");
return Mono.empty();
.reRegConfigKey("config_key_1")
.cpeAuthConfigKey("config_key_2")
.closeLoopConfigKey("config_key_3")
+ .loggingLevel("TRACE")
.streamSubscribesMap(subscribes)
.streamPublishesMap(Collections.singletonMap("config_key_3", streamsObject3))
.build();
+ "\"application.reregistration.configKey\": \"config_key_2\","
+ "\"application.cpeAuth.configKey\": \"config_key_1\","
+ "\"application.closeLoop.configKey\": \"config_key_3\","
+ + "\"application.loggingLevel\": \"TRACE\","
+ "\"streams_subscribes\": {"
+ "\"config_key_1\": {"
+ "\"type\": \"message_router\","
.reRegConfigKey("config_key_2")
.cpeAuthConfigKey("config_key_1")
.closeLoopConfigKey("config_key_3")
+ .loggingLevel("TRACE")
.streamSubscribesMap(subscribes)
.streamPublishesMap(Collections.singletonMap("config_key_3", streamsObject3))
.build();