From 54a4057295ea8883dcf7b06aa390d6de2f69b20f Mon Sep 17 00:00:00 2001 From: Piotr Borelowski Date: Fri, 28 Feb 2020 13:59:45 +0100 Subject: Basic ETSI -> DMaaP translation added Ve-Vnfm (SOL002) Adapter project Issue-ID: SO-2574 Signed-off-by: Piotr Borelowski Change-Id: Ia838887fad65099d37c37fc6b71f0f2f092e4a10 --- .../onap/so/adapters/vevnfm/event/AaiEvent.java | 44 +++++++++ .../onap/so/adapters/vevnfm/event/DmaapEvent.java | 110 +++++++++++++++++++++ .../so/adapters/vevnfm/service/DmaapService.java | 30 +++++- .../src/main/resources/application.yaml | 4 + 4 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/AaiEvent.java create mode 100644 adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java (limited to 'adapters/mso-ve-vnfm-adapter') diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/AaiEvent.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/AaiEvent.java new file mode 100644 index 0000000000..ceabb8a020 --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/AaiEvent.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * SO + * ================================================================================ + * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.event; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class AaiEvent { + + private final boolean vserverIsClosedLoopDisabled; + private final String genericVnfVnfId; + + public AaiEvent(final boolean cld, final String id) { + this.vserverIsClosedLoopDisabled = cld; + this.genericVnfVnfId = id; + } + + @JsonProperty("vserver.is-closed-loop-disabled") + public boolean isVserverIsClosedLoopDisabled() { + return vserverIsClosedLoopDisabled; + } + + @JsonProperty("generic-vnf.vnf-id") + public String getGenericVnfVnfId() { + return genericVnfVnfId; + } +} diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java new file mode 100644 index 0000000000..dc0c5502dd --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * SO + * ================================================================================ + * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.event; + +import static java.time.temporal.ChronoField.INSTANT_SECONDS; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.Instant; +import java.util.UUID; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; + +public class DmaapEvent { + + public static final String MSERVICE = "microservice.stringmatcher"; + public static final String ONSET = "ONSET"; + public static final String VNF = "VNF"; + public static final String VNFID = "generic-vnf.vnf-id"; + public static final String ETSI = "ETSI"; + + private final String closedLoopControlName; + private final long closedLoopAlarmStart; + private final String closedLoopEventClient; + private final String closedLoopEventStatus; + private final String requestId; + private final String targetType; + private final String target; + private final AaiEvent aaiEvent; + private final String from; + private final String version; + private final VnfLcmOperationOccurrenceNotification etsiLcmEvent; + + public DmaapEvent(final String closedLoopControlName, final String version, + final VnfLcmOperationOccurrenceNotification etsiLcmEvent) { + this.closedLoopControlName = closedLoopControlName; + this.closedLoopAlarmStart = Instant.now().getLong(INSTANT_SECONDS); + this.closedLoopEventClient = MSERVICE; + this.closedLoopEventStatus = ONSET; + this.requestId = UUID.randomUUID().toString(); + this.targetType = VNF; + this.target = VNFID; + this.aaiEvent = new AaiEvent(false, etsiLcmEvent.getId()); + this.from = ETSI; + this.version = version; + this.etsiLcmEvent = etsiLcmEvent; + } + + public String getClosedLoopControlName() { + return closedLoopControlName; + } + + public long getClosedLoopAlarmStart() { + return closedLoopAlarmStart; + } + + public String getClosedLoopEventClient() { + return closedLoopEventClient; + } + + public String getClosedLoopEventStatus() { + return closedLoopEventStatus; + } + + @JsonProperty("requestID") + public String getRequestId() { + return requestId; + } + + @JsonProperty("target_type") + public String getTargetType() { + return targetType; + } + + public String getTarget() { + return target; + } + + @JsonProperty("AAI") + public AaiEvent getAaiEvent() { + return aaiEvent; + } + + public String getFrom() { + return from; + } + + public String getVersion() { + return version; + } + + public VnfLcmOperationOccurrenceNotification getEtsiLcmEvent() { + return etsiLcmEvent; + } +} diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java index 36a4c3300d..c685ae815a 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java @@ -1,5 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * SO + * ================================================================================ + * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.service; +import org.onap.so.adapters.vevnfm.event.DmaapEvent; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; @@ -21,12 +42,19 @@ public class DmaapService { @Value("${dmaap.topic}") private String topic; + @Value("${dmaap.closed-loop.control.name}") + private String closedLoopControlName; + + @Value("${dmaap.version}") + private String version; + @Autowired private HttpRestServiceProvider restProvider; public void send(final VnfLcmOperationOccurrenceNotification notification) { try { - final ResponseEntity response = restProvider.postHttpRequest(notification, getUrl(), String.class); + final DmaapEvent event = new DmaapEvent(closedLoopControlName, version, notification); + final ResponseEntity response = restProvider.postHttpRequest(event, getUrl(), String.class); final HttpStatus statusCode = response.getStatusCode(); final String body = response.getBody(); diff --git a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml index 72198b83c1..a2a33bfb5c 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml +++ b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml @@ -35,6 +35,10 @@ vnfm: dmaap: endpoint: http://message-router.onap:30227 topic: /events/unauthenticated.DCAE_CL_OUTPUT + closed-loop: + control: + name: ClosedLoopControlName + version: 1.0.2 spring: security: -- cgit 1.2.3-korg