diff options
author | Denes Nemeth <denes.nemeth@nokia.com> | 2018-03-03 11:44:14 +0100 |
---|---|---|
committer | Denes Nemeth <denes.nemeth@nokia.com> | 2018-03-03 11:44:14 +0100 |
commit | c13b3688cd0bc63954c78819fe4bad148c8ac2a3 (patch) | |
tree | 11bf76b9c11bc0bfaff2bfdf9cd28e96c12c6a20 /nokiav2/driver/src/main/java/org | |
parent | 4d24e40338421555cad5cd5f9691894a1eb15843 (diff) |
Fix CP handling
Change-Id: I8105b4a8e9bb56b52a1cd6af4991cf1eb023f953
Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com>
Issue-ID: VFC-728
Diffstat (limited to 'nokiav2/driver/src/main/java/org')
3 files changed, 42 insertions, 40 deletions
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/INotificationSender.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/INotificationSender.java index 92099cc3..241e5de6 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/INotificationSender.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/INotificationSender.java @@ -33,4 +33,5 @@ public interface INotificationSender { * @param vimId the identifier of the VIM in ONAP */ void processNotification(VnfLifecycleChangeNotification receivedNotification, OperationExecution operationExecution, ReportedAffectedConnectionPoints affectedConnectionPoints, String vimId); + } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java index 26439b5c..98b9a22f 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java @@ -15,6 +15,7 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc; +import com.google.common.base.Optional; import com.google.gson.Gson; import com.nokia.cbam.lcm.v32.model.OperationExecution; import com.nokia.cbam.lcm.v32.model.ScaleVnfRequest; @@ -33,6 +34,8 @@ import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; +import static com.google.common.base.Optional.of; +import static com.google.common.collect.Iterables.tryFind; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.ILifecycleChangeNotificationManager.SEPARATOR; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager.extractOnapJobId; @@ -84,7 +87,7 @@ public class VfcNotificationSender implements INotificationSender { } } - private AffectedCp buildAffectedCp(String vimId, String vnfId, ReportedAffectedCp affectedCp) { + private AffectedCp buildAffectedCp(String vimId, String vnfId, VnfCpNotificationType changeType, ReportedAffectedCp affectedCp) { AffectedCp onapAffectedCp = new AffectedCp(); AffectedCpPortResource port = new AffectedCpPortResource(); port.setInstId(affectedCp.getServerProviderId()); @@ -98,21 +101,11 @@ public class VfcNotificationSender implements INotificationSender { onapAffectedCp.setCpdid(affectedCp.getCpId()); onapAffectedCp.setCpinstanceid(vnfId + SEPARATOR + affectedCp.getCpId()); onapAffectedCp.setVirtualLinkInstanceId(affectedCp.getNetworkProviderId()); - onapAffectedCp.setChangeType(transform(affectedCp.getChangeType())); + onapAffectedCp.setChangeType(changeType); //owner id & type can be left empty it will default to VNF id on VF-C return onapAffectedCp; } - private VnfCpNotificationType transform(com.nokia.cbam.lcm.v32.model.ChangeType changeType) { - switch (changeType) { - case ADDED: - return VnfCpNotificationType.ADDED; - case REMOVED: - return VnfCpNotificationType.REMOVED; - default: //can only be MODIFIED - return VnfCpNotificationType.CHANGED; - } - } private void addAffectedVnfcs(String vimId, String vnfId, VNFLCMNotification notificationToSend, VnfLifecycleChangeNotification request) { if (request.getAffectedVnfcs() != null) { @@ -147,24 +140,49 @@ public class VfcNotificationSender implements INotificationSender { } } + private Optional<VnfCpNotificationType> getChangeType(ReportedAffectedConnectionPoints affectedCps, ReportedAffectedCp affectedCp) { + Optional<ReportedAffectedCp> cpBeforeOperation = tryFind(affectedCps.getPre(), pre -> affectedCp.getCpId().equals(pre.getCpId())); + Optional<ReportedAffectedCp> cpAfterOperation = tryFind(affectedCps.getPost(), post -> affectedCp.getCpId().equals(post.getCpId())); + if(cpBeforeOperation.isPresent() && cpAfterOperation.isPresent()){ + return cpAfterOperation.get().equals(cpBeforeOperation.get()) ? Optional.absent() : of(VnfCpNotificationType.CHANGED); + } + else{ + //the affected CP must be present in the pre or post + return of((cpAfterOperation.isPresent() ? VnfCpNotificationType.ADDED : VnfCpNotificationType.REMOVED)); + } + } + private void addAffectedCps(String vimId, VNFLCMNotification notificationToSend, ReportedAffectedConnectionPoints affectedCps) { if (affectedCps != null) { notificationToSend.setAffectedCp(new ArrayList<>()); - for (ReportedAffectedCp affectedCp : affectedCps.getPost()) { - if (affectedCp.getCpdId() != null) { - AffectedCp onapAffectedCp = buildAffectedCp(vimId, notificationToSend.getVnfInstanceId(), affectedCp); - onapAffectedCp.setCpdid(affectedCp.getCpdId()); - notificationToSend.getAffectedCp().add(onapAffectedCp); + for (ReportedAffectedCp pre : affectedCps.getPre()) { + Optional<VnfCpNotificationType> changeType = getChangeType(affectedCps, pre); + if(of(VnfCpNotificationType.REMOVED).equals(changeType)){ + addModifiedCp(vimId, notificationToSend, pre, changeType); } - if (affectedCp.getEcpdId() != null) { - AffectedCp onapAffectedCp = buildAffectedCp(vimId, notificationToSend.getVnfInstanceId(), affectedCp); - onapAffectedCp.setCpdid(affectedCp.getEcpdId()); - notificationToSend.getAffectedCp().add(onapAffectedCp); + } + for (ReportedAffectedCp post : affectedCps.getPost()) { + Optional<VnfCpNotificationType> changeType = getChangeType(affectedCps, post); + if(of(VnfCpNotificationType.ADDED).equals(changeType) || of(VnfCpNotificationType.CHANGED).equals(changeType)){ + addModifiedCp(vimId, notificationToSend, post, changeType); } } } } + private void addModifiedCp(String vimId, VNFLCMNotification notificationToSend, ReportedAffectedCp post, Optional<VnfCpNotificationType> changeType) { + if (post.getCpdId() != null) { + AffectedCp onapAffectedCp = buildAffectedCp(vimId, notificationToSend.getVnfInstanceId(), changeType.get(), post); + onapAffectedCp.setCpdid(post.getCpdId()); + notificationToSend.getAffectedCp().add(onapAffectedCp); + } + if (post.getEcpdId() != null) { + AffectedCp onapAffectedCp = buildAffectedCp(vimId, notificationToSend.getVnfInstanceId(), changeType.get(), post); + onapAffectedCp.setCpdid(post.getEcpdId()); + notificationToSend.getAffectedCp().add(onapAffectedCp); + } + } + private org.onap.vnfmdriver.model.OperationType getOperation(String vnfmId, String vnfId, OperationExecution operationExecution, com.nokia.cbam.lcm.v32.model.OperationType type, List<com.nokia.cbam.lcm.v32.model.AffectedVnfc> affectedVnfcs) { switch (type) { case TERMINATE: diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ReportedAffectedCp.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ReportedAffectedCp.java index ab9d6314..6d265c60 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ReportedAffectedCp.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ReportedAffectedCp.java @@ -33,7 +33,6 @@ public class ReportedAffectedCp { private String serverProviderId; private String name; private String networkProviderId; - private ChangeType changeType; /** * @return the provider id of the port @@ -175,20 +174,6 @@ public class ReportedAffectedCp { this.networkProviderId = networkProviderId; } - /** - * @return the state of the port in the current operation - */ - public ChangeType getChangeType() { - return changeType; - } - - /** - * @param changeType the state of the port in the current operation - */ - public void setChangeType(ChangeType changeType) { - this.changeType = changeType; - } - @Override public String toString() { return "ReportedAffectedCp{" + @@ -202,7 +187,6 @@ public class ReportedAffectedCp { ", serverProviderId='" + serverProviderId + '\'' + ", name='" + name + '\'' + ", networkProviderId='" + networkProviderId + '\'' + - ", changeType=" + changeType + '}'; } @@ -220,12 +204,11 @@ public class ReportedAffectedCp { Objects.equals(macAddress, that.macAddress) && Objects.equals(serverProviderId, that.serverProviderId) && Objects.equals(name, that.name) && - Objects.equals(networkProviderId, that.networkProviderId) && - changeType == that.changeType; + Objects.equals(networkProviderId, that.networkProviderId); } @Override public int hashCode() { - return Objects.hash(providerId, cpdId, ecpdId, cpId, tenantId, ipAddress, macAddress, serverProviderId, name, networkProviderId, changeType); + return Objects.hash(providerId, cpdId, ecpdId, cpId, tenantId, ipAddress, macAddress, serverProviderId, name, networkProviderId); } }
\ No newline at end of file |