From 0205edd07828499839850893105131cd566b21e7 Mon Sep 17 00:00:00 2001 From: AndrewLamb Date: Mon, 7 Sep 2020 11:54:21 +0100 Subject: Add support for Create Vnf Request with Package Id Issue-ID: SO-3218 Change-Id: If5ca57ce94c0a735c5abf0a77db0e7d725763121 Signed-off-by: AndrewLamb --- .../lcm/lifecycle/LifecycleManager.java | 21 ++++++++++++++++----- .../src/main/resources/etsisol003adapter.yaml | 5 ++++- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'adapters/etsi-sol003-adapter') diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java index 472b5176d5..a2af1a4580 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/lifecycle/LifecycleManager.java @@ -48,6 +48,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.google.common.base.Optional; +import static org.apache.commons.lang3.StringUtils.isNotBlank; /** * Manages lifecycle operations towards the VNFMs. @@ -152,15 +153,16 @@ public class LifecycleManager { } } - private InlineResponse201 sendCreateRequestToVnfm(final CreateVnfRequest aaiRequest, final GenericVnf genericVnf, - final String vnfIdInAai, final EsrVnfm vnfm) { - logger.debug("Sending a create request to SVNFM " + aaiRequest); + private InlineResponse201 sendCreateRequestToVnfm(final CreateVnfRequest createVnfRequest, + final GenericVnf genericVnf, final String vnfIdInAai, final EsrVnfm vnfm) { + logger.debug("Sending a create request to SVNFM {}", createVnfRequest); final org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.model.CreateVnfRequest vnfmRequest = new org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.model.CreateVnfRequest(); - final String vnfdId = packageProvider.getVnfdId(genericVnf.getModelVersionId()); + final String pkgId = getPackageId(createVnfRequest, genericVnf); + final String vnfdId = packageProvider.getVnfdId(pkgId); vnfmRequest.setVnfdId(vnfdId); - vnfmRequest.setVnfInstanceName(aaiRequest.getName().replaceAll(" ", "_")); + vnfmRequest.setVnfInstanceName(createVnfRequest.getName().replaceAll(" ", "_")); vnfmRequest.setVnfInstanceDescription(vnfIdInAai); final Optional optionalResponse = vnfmServiceProvider.createVnf(vnfm, vnfmRequest); @@ -174,6 +176,15 @@ public class LifecycleManager { } } + private String getPackageId(final CreateVnfRequest createVnfRequest, final GenericVnf genericVnf) { + if (isNotBlank(createVnfRequest.getPkgId())) { + logger.info("Found createVnfRequest pkgId: {}", createVnfRequest.getPkgId()); + return createVnfRequest.getPkgId(); + } + logger.info("Found genericVnf modelVersionId: {}", genericVnf.getModelVersionId()); + return genericVnf.getModelVersionId(); + } + private void createNotificationSubscription(final EsrVnfm vnfm, final String vnfId) { try { final LccnSubscriptionRequest subscriptionRequest = vnfmHelper.createNotificationSubscriptionRequest(vnfId); diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/etsisol003adapter.yaml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/etsisol003adapter.yaml index 9d0a5283af..578708ded8 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/etsisol003adapter.yaml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/etsisol003adapter.yaml @@ -168,6 +168,9 @@ definitions: description: The name to be applied to the VNF. tenant: $ref: '#/definitions/Tenant' + pkgId: + type: string + description: An identifier for the vnf package. additionalParams: type: object description: >- @@ -519,4 +522,4 @@ definitions: description: > Type of the resource in the scope of the VIM or the resource provider. - type: string \ No newline at end of file + type: string -- cgit 1.2.3-korg