summaryrefslogtreecommitdiffstats
path: root/nokiav2
diff options
context:
space:
mode:
Diffstat (limited to 'nokiav2')
-rwxr-xr-xnokiav2/deployment/src/main/resources/build_image.sh2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/INotificationSender.java2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VimInfoProvider.java1
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VnfmInfoProvider.java1
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java6
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java9
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java13
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcExternalSystemInfoProvider.java6
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java46
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java8
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java16
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcRestApiProvider.java4
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java81
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java24
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java4
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java12
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/StoreLoader.java10
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java (renamed from nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParams.java)13
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java10
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProvider.java11
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/DriverProperties.java2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/ILifecycleChangeNotificationManager.java12
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java70
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java234
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java29
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ProcessedNotification.java2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ReportedAffectedConnectionPoints.java2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ReportedAffectedCp.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java48
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java51
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java9
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java33
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestCbamUtils.java22
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestAdditionalParams.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java11
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java40
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java2
-rw-r--r--nokiav2/pom.xml5
39 files changed, 549 insertions, 308 deletions
diff --git a/nokiav2/deployment/src/main/resources/build_image.sh b/nokiav2/deployment/src/main/resources/build_image.sh
index 878e3672..24706f86 100755
--- a/nokiav2/deployment/src/main/resources/build_image.sh
+++ b/nokiav2/deployment/src/main/resources/build_image.sh
@@ -68,5 +68,7 @@ build_image
if [ "a$2" != "apushImage" ]; then
echo "Skipping image pushing"
echo "If you would like to push the docker image by maven execute mvn package -Dexec.args=\"buildDocker pushImage\""
+else
+ echo "Pushing image"
push_image
fi
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 241e5de6..c601f5ac 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
@@ -23,6 +23,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffec
* Responsible for processing the preprocessed notification from CBAM and making the changes
* based on the notification in various ONAP sub systems.
*/
+@FunctionalInterface
public interface INotificationSender {
/**
* Execute changes in the ONAP subsystem based on the received notification
@@ -33,5 +34,4 @@ 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/api/VimInfoProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VimInfoProvider.java
index 111f44b3..ec783a4c 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VimInfoProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VimInfoProvider.java
@@ -20,6 +20,7 @@ import org.onap.vnfmdriver.model.VimInfo;
/**
* Responsible for providing information from the VIM to be used for the VNF
*/
+@FunctionalInterface
public interface VimInfoProvider {
/**
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VnfmInfoProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VnfmInfoProvider.java
index 3fe9e3f7..c659b91d 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VnfmInfoProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/api/VnfmInfoProvider.java
@@ -20,6 +20,7 @@ import org.onap.vnfmdriver.model.VnfmInfo;
/**
* Responsible for providing information from the VNFM itself
*/
+@FunctionalInterface
public interface VnfmInfoProvider {
/**
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java
index f13e2bbe..13b070a7 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java
@@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit;
import static com.google.common.cache.CacheBuilder.newBuilder;
import static java.lang.Long.valueOf;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -63,7 +63,7 @@ public abstract class GenericExternalSystemInfoProvider extends IpMappingProvide
vnfmInfoCache = newBuilder().expireAfterWrite(environment.getProperty(VNFM_INFO_CACHE_EVICTION_IN_MS, Long.class, valueOf(DEFAULT_CACHE_EVICTION_TIMEOUT_IN_MS)), TimeUnit.MILLISECONDS).concurrencyLevel(1).build(new CacheLoader<String, VnfmInfo>() {
@Override
public VnfmInfo load(String vnfmId) throws Exception {
- logger.info("Quering VNFM info from source with " + vnfmId + " identifier");
+ logger.info("Querying VNFM info from source with " + vnfmId + " identifier");
return queryVnfmInfoFromSource(vnfmId);
}
});
@@ -77,7 +77,7 @@ public abstract class GenericExternalSystemInfoProvider extends IpMappingProvide
try {
return vnfmInfoCache.get(vnfmId);
} catch (Exception e) {
- throw fatalFailure(logger, "Unable to query VNFM info for " + vnfmId, e);
+ throw buildFatalFailure(logger, "Unable to query VNFM info for " + vnfmId, e);
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java
index 195e776e..ec98e966 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java
@@ -26,7 +26,7 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import static java.lang.Integer.valueOf;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -60,7 +60,8 @@ public class MsbApiProvider extends IpMappingProvider {
public String getMicroServiceUrl(String name, String version) {
MicroServiceFullInfo microServiceFullInfo = getMicroServiceInfo(name, version);
String ipAnPort = getNodeIpAnPort(microServiceFullInfo);
- //FIXME the enable_ssl field should be used, but it is not available in SDK depends on MSB-151 jira issue
+ //FIXME the enable_ssl field should be used, but it is not available in SDK
+ //depends on https://jira.onap.org/browse/MSB-151
String protocol = (ipAnPort.endsWith(":8443") || ipAnPort.endsWith(":443")) ? "https://" : "http://";
//the field name in A&AI is misleading the URL is relative path postfixed to http(s)://ip:port
return protocol + ipAnPort + microServiceFullInfo.getUrl();
@@ -70,7 +71,7 @@ public class MsbApiProvider extends IpMappingProvider {
try {
return getMsbClient().queryMicroServiceInfo(name, version);
} catch (RouteException e) {
- throw fatalFailure(logger, "Unable to get micro service URL for " + name + " with version " + version, e);
+ throw buildFatalFailure(logger, "Unable to get micro service URL for " + name + " with version " + version, e);
}
}
@@ -80,7 +81,7 @@ public class MsbApiProvider extends IpMappingProvider {
return mapPrivateIpToPublicIp(nodeInfo.getIp()) + ":" + nodeInfo.getPort();
}
}
- throw fatalFailure(logger, "The " + microServiceFullInfo.getServiceName() + " service with " + microServiceFullInfo.getVersion() + " does not have any valid nodes" + microServiceFullInfo.getNodes());
+ throw buildFatalFailure(logger, "The " + microServiceFullInfo.getServiceName() + " service with " + microServiceFullInfo.getVersion() + " does not have any valid nodes" + microServiceFullInfo.getNodes());
}
private boolean isADokcerInternalAddress(NodeInfo nodeInfo) {
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
index 3c918f5e..3fda6192 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
@@ -35,7 +35,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import static com.nokia.cbam.lcn.v32.model.SubscriptionAuthentication.TypeEnum.NONE;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCN_API_VERSION;
import static org.slf4j.LoggerFactory.getLogger;
@@ -96,8 +96,9 @@ public class SelfRegistrationManager {
try {
msbApiProvider.getMsbClient().queryMicroServiceInfo(SERVICE_NAME, DRIVER_VERSION);
//the micro service still exists
- fatalFailure(logger, "Unable to deRegister Nokia VNFM driver", e);
+ throw buildFatalFailure(logger, "Unable to deRegister Nokia VNFM driver", e);
} catch (RouteException e1) {
+ logger.info("Unable to query " + SERVICE_NAME + " from MSB (so the service was successfully deleted)", e1);
// the micro service was deleted (even though 500 HTTP code was reported)
}
}
@@ -126,7 +127,7 @@ public class SelfRegistrationManager {
}
}
} catch (ApiException e) {
- fatalFailure(logger, "Unable to delete CBAM LCN subscription", e);
+ throw buildFatalFailure(logger, "Unable to delete CBAM LCN subscription", e);
}
}
@@ -139,7 +140,7 @@ public class SelfRegistrationManager {
microServiceInfo.setVisualRange(INTERNAL_SERVICE);
microServiceInfo.setServiceName(SERVICE_NAME);
microServiceInfo.setVersion(DRIVER_VERSION);
- //FIXME set enable_ssl to false after the field has been added to MSB SDK
+ //FIXME set enable_ssl to false after the field has been added to MSB SDK https://jira.onap.org/browse/MSB-151
//currently defaults to false, which is good
Node node = new Node();
microServiceInfo.setNodes(new HashSet<>());
@@ -150,7 +151,7 @@ public class SelfRegistrationManager {
try {
return msbApiProvider.getMsbClient().registerMicroServiceInfo(microServiceInfo);
} catch (RouteException e) {
- throw fatalFailure(logger, "Unable to register Nokia VNFM driver", e);
+ throw buildFatalFailure(logger, "Unable to register Nokia VNFM driver", e);
}
}
@@ -178,7 +179,7 @@ public class SelfRegistrationManager {
request.setAuthentication(subscriptionAuthentication);
lcnApi.subscriptionsPost(request, NOKIA_LCN_API_VERSION);
} catch (ApiException e) {
- fatalFailure(logger, "Unable to subscribe to CBAM LCN", e);
+ throw buildFatalFailure(logger, "Unable to subscribe to CBAM LCN", e);
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcExternalSystemInfoProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcExternalSystemInfoProvider.java
index 1959e480..416367d7 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcExternalSystemInfoProvider.java
@@ -26,7 +26,7 @@ import org.springframework.context.annotation.Conditional;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -49,7 +49,7 @@ public class VfcExternalSystemInfoProvider extends GenericExternalSystemInfoProv
try {
return vfcRestApiProvider.getNsLcmApi().queryVnfmInfo(vnfmId);
} catch (ApiException e) {
- throw fatalFailure(logger, "Unable to query VNFM from VF-C with " + vnfmId + " identifier", e);
+ throw buildFatalFailure(logger, "Unable to query VNFM from VF-C with " + vnfmId + " identifier", e);
}
}
@@ -58,7 +58,7 @@ public class VfcExternalSystemInfoProvider extends GenericExternalSystemInfoProv
try {
return vfcRestApiProvider.getNsLcmApi().queryVIMInfo(vimId);
} catch (org.onap.vnfmdriver.ApiException e) {
- throw fatalFailure(logger, "Unable to query VIM from VF-C with " + vimId + " identifier", e);
+ throw buildFatalFailure(logger, "Unable to query VIM from VF-C with " + vimId + " identifier", e);
}
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java
index a268a73a..f283672e 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java
@@ -39,7 +39,7 @@ import org.yaml.snakeyaml.Yaml;
import java.util.*;
import static com.nokia.cbam.lcm.v32.model.InstantiationState.INSTANTIATED;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION;
import static org.onap.vnfmdriver.model.OperationType.TERMINAL;
import static org.slf4j.LoggerFactory.getLogger;
@@ -92,7 +92,7 @@ public class VfcGrantManager implements IGrantManager {
grantRequest.setVnfInstanceId(vnfId);
requestGrant(grantRequest);
} catch (ApiException e) {
- fatalFailure(logger, "Unable to query VNF " + vnfId, e);
+ throw buildFatalFailure(logger, "Unable to query VNF " + vnfId, e);
}
}
@@ -102,23 +102,27 @@ public class VfcGrantManager implements IGrantManager {
GrantVNFRequest grantRequest;
try {
grantRequest = buildGrantRequest(vnfmId, vimId, onapVnfdId, jobId, TERMINAL);
- if (vnf.getInstantiatedVnfInfo().getVnfcResourceInfo() != null) {
- for (VnfcResourceInfo vnfc : vnf.getInstantiatedVnfInfo().getVnfcResourceInfo()) {
- ResourceChange resourceChange = new ResourceChange();
- grantRequest.getRemoveResource().add(resourceChange);
- resourceChange.setVdu(vnfc.getVduId());
- resourceChange.setType(ChangeType.VDU);
- resourceChange.setResourceDefinitionId(UUID.randomUUID().toString());
- }
- }
grantRequest.setVnfInstanceId(vnfId);
+ addVnfsToGrant(vnf, grantRequest);
} catch (Exception e) {
- throw fatalFailure(logger, "Unable to prepare grant request for termination", e);
+ throw buildFatalFailure(logger, "Unable to prepare grant request for termination", e);
}
requestGrant(grantRequest);
}
}
+ private void addVnfsToGrant(VnfInfo vnf, GrantVNFRequest grantRequest) {
+ if (vnf.getInstantiatedVnfInfo().getVnfcResourceInfo() != null) {
+ for (VnfcResourceInfo vnfc : vnf.getInstantiatedVnfInfo().getVnfcResourceInfo()) {
+ ResourceChange resourceChange = new ResourceChange();
+ grantRequest.getRemoveResource().add(resourceChange);
+ resourceChange.setVdu(vnfc.getVduId());
+ resourceChange.setType(ChangeType.VDU);
+ resourceChange.setResourceDefinitionId(UUID.randomUUID().toString());
+ }
+ }
+ }
+
@Override
public GrantVNFResponseVim requestGrantForInstantiate(String vnfmId, String vnfId, String vimId, String onapVnfdId, String instantiationLevelId, String cbamVnfdContent, String jobId) {
GrantVNFRequest grantRequest;
@@ -128,14 +132,19 @@ public class VfcGrantManager implements IGrantManager {
grantRequest.setAddResource(new ArrayList<>());
grantRequest.getAddResource().addAll(calculateResourceChangeDuringInstantiate(cbamVnfdContent, instantiationLevelId));
} catch (Exception e) {
- throw fatalFailure(logger, "Unable to prepare grant request for instantiation", e);
+ throw buildFatalFailure(logger, "Unable to prepare grant request for instantiation", e);
}
return requestGrant(grantRequest);
}
private GrantVNFRequest buildGrantRequest(String vnfmId, String vimId, String onapCsarId, String jobId, OperationType operationType) {
- //FIXME the vimId should not be required for grant request see VFC-603 issue
GrantVNFRequest grantVNFRequest = new GrantVNFRequest();
+ //FIXME
+ //Currently the grant request sent to VF-C must contain the VIM identifier in the
+ //grant response (normally in ETSI VIM identifier is received in the grant response
+ //from ETSI orchestrator the vimId parameter should be removed from this POJO
+ //to be able to fix this https://jira.onap.org/browse/VFC-603 must be solved
+ //the vimId should be removed from the AdditionalGrantParams structure
grantVNFRequest.setAdditionalParam(new AdditionalGrantParams(vnfmId, vimId));
grantVNFRequest.setVnfDescriptorId(onapCsarId);
grantVNFRequest.setJobId(jobId);
@@ -149,7 +158,7 @@ public class VfcGrantManager implements IGrantManager {
try {
return vfcRestApiProvider.getNsLcmApi().grantvnf(grantRequest).getVim();
} catch (org.onap.vnfmdriver.ApiException e) {
- throw fatalFailure(logger, "Unable to request grant", e);
+ throw buildFatalFailure(logger, "Unable to request grant", e);
}
}
@@ -177,7 +186,7 @@ public class VfcGrantManager implements IGrantManager {
Set<ResourceChange> resourceChanges = new HashSet<>();
JsonArray policies = CbamUtils.child(root, "topology_template").getAsJsonObject().get("policies").getAsJsonArray();
for (JsonElement policy : policies) {
- if (policy.getAsJsonObject().entrySet().iterator().next().getKey().equals("heat_mapping")) {
+ if ("heat_mapping".equals(policy.getAsJsonObject().entrySet().iterator().next().getKey())) {
JsonObject aspects = policy.getAsJsonObject().entrySet().iterator().next().getValue().getAsJsonObject().get("properties").getAsJsonObject().get("aspects").getAsJsonObject();
JsonObject aspect = aspects.get(aspectId).getAsJsonObject();
if (aspect.has("vdus")) {
@@ -227,11 +236,6 @@ public class VfcGrantManager implements IGrantManager {
* @return the identifier of the VIM for which the grant is requested
*/
public String getVimId() {
- //FIXME
- //Currently the grant request sent to VF-C must contain the VIM identifier in the
- //grant response (normally in ETSI VIM identifier is received in the grant response
- //from ETSI orchestrator the vimId parameter should be removed from this POJO
- //to be able to fix this https://jira.onap.org/browse/VFC-603 must be solved
return 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 f7667c57..32c3f909 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
@@ -35,8 +35,9 @@ import java.util.ArrayList;
import static com.google.common.base.Optional.of;
import static com.google.common.collect.Iterables.tryFind;
+import static com.nokia.cbam.lcm.v32.model.ScaleDirection.IN;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager.extractOnapJobId;
import static org.slf4j.LoggerFactory.getLogger;
@@ -84,7 +85,7 @@ public class VfcNotificationSender implements INotificationSender {
}
vfcRestApiProvider.getNsLcmApi().vNFLCMNotification(driverProperties.getVnfmId(), notification.getVnfInstanceId(), notification);
} catch (Exception e) {
- fatalFailure(logger, "Unable to send LCN to VF-C", e);
+ throw buildFatalFailure(logger, "Unable to send LCN to VF-C", e);
}
}
@@ -190,8 +191,7 @@ public class VfcNotificationSender implements INotificationSender {
case INSTANTIATE:
return org.onap.vnfmdriver.model.OperationType.INSTANTIATE;
case SCALE:
- ScaleVnfRequest originalRequest = new Gson().fromJson(new Gson().toJson(operationExecution.getOperationParams()), ScaleVnfRequest.class);
- if (originalRequest.getType() == com.nokia.cbam.lcm.v32.model.ScaleDirection.IN) {
+ if (IN == new Gson().fromJson(new Gson().toJson(operationExecution.getOperationParams()), ScaleVnfRequest.class).getType()) {
return OperationType.SCALEIN;
} else {
return OperationType.SCALEOUT;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java
index bc201f51..71880d0b 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java
@@ -37,7 +37,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
@@ -66,7 +66,7 @@ public class VfcPackageProvider implements IPackageProvider {
JsonElement vnfdModel = new JsonParser().parse(vnfPackageDetails.getPackageInfo().getVnfdModel());
return vnfdModel.getAsJsonObject().get("metadata").getAsJsonObject().get("resourceVendorModelNumber").getAsString();
} catch (Exception e) {
- throw fatalFailure(logger, "Unable to query VNF package with " + csarId, e);
+ throw buildFatalFailure(logger, "Unable to query VNF package with " + csarId, e);
}
}
@@ -76,18 +76,16 @@ public class VfcPackageProvider implements IPackageProvider {
try {
VnfpackageApi onapCatalogApi = restApiProvider.getOnapCatalogApi();
VnfPkgDetailInfo vnfPackageDetails = onapCatalogApi.queryVnfPackage(csarId);
- downloadUrl = vnfPackageDetails.getPackageInfo().getDownloadUrl();
- String host = new URL(downloadUrl).getHost();
- if (!ipMappingProvider.mapPrivateIpToPublicIp(host).equals(host)) {
- downloadUrl = downloadUrl.replaceFirst("://" + host, "://" + ipMappingProvider.mapPrivateIpToPublicIp(host));
- }
+ String urlFromVfc = vnfPackageDetails.getPackageInfo().getDownloadUrl();
+ String host = new URL(urlFromVfc).getHost();
+ downloadUrl = urlFromVfc.replaceFirst("://" + host, "://" + ipMappingProvider.mapPrivateIpToPublicIp(host));
} catch (Exception e) {
- throw fatalFailure(logger, "Unable to query VNF package with " + csarId, e);
+ throw buildFatalFailure(logger, "Unable to query VNF package with " + csarId, e);
}
try {
return downloadCbamVnfPackage(downloadUrl);
} catch (Exception e) {
- throw fatalFailure(logger, "Unable to download package from " + downloadUrl, e);
+ throw buildFatalFailure(logger, "Unable to download package from " + downloadUrl, e);
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcRestApiProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcRestApiProvider.java
index fd4e6932..baa61f75 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcRestApiProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcRestApiProvider.java
@@ -68,7 +68,9 @@ public class VfcRestApiProvider {
*/
private String fixIncorrectUrl() {
String urlInMsb = msbApiProvider.getMicroServiceUrl(NSLCM_API_SERVICE_NAME, NSLCM_API_VERION);
- //FIXME in VF-C swagger API definitions
+ //FIXME VF-C exposes multiple APIs in the single swagger definition, since the base path of different
+ //API is different the some API calls are incorrectly prefixed
+ //VF-C team refuses to fix this in Amsterdam https://jira.onap.org/browse/VFC-597?filter=-2
return urlInMsb.replaceFirst("/nslcm/v1", "");
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
index 01256aa0..03c27a83 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
@@ -16,6 +16,7 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer;
+import com.google.common.annotations.VisibleForTesting;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@@ -26,6 +27,7 @@ import org.yaml.snakeyaml.Yaml;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.regex.Pattern;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.child;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.childElement;
@@ -39,6 +41,16 @@ public class OnapVnfdBuilder {
public static final String PROPERTIES = "properties";
public static final String REQUIREMENTS = "requirements";
+ @VisibleForTesting
+ static String indent(String content, int prefixSize) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < prefixSize; i++) {
+ sb.append(" ");
+ }
+ Pattern pattern = Pattern.compile("^(.*)$", Pattern.MULTILINE);
+ return pattern.matcher(content).replaceAll(sb.toString() + "$1");
+ }
+
/**
* @param cbamVnfd the CBAM VNFD
* @return the converted ONAP VNFD
@@ -118,42 +130,45 @@ public class OnapVnfdBuilder {
memorySize = childElement(child(child(virtualCompute, PROPERTIES), "virtual_memory"), "virtual_mem_size").getAsString();
} else if ("virtual_storage".equals(s)) {
- String item =
- " - virtual_storage:\n" +
- " capability: tosca.capabilities.nfv.VirtualStorage\n" +
- " node: " + next.getValue().getAsString() + "\n";
+ String item = indent(
+ "- virtual_storage:\n" +
+ " capability: tosca.capabilities.nfv.VirtualStorage\n" +
+ " node: " + next.getValue().getAsString() + "\n", 4);
body.append(item);
}
next.getValue();
}
- String header = " " + name + ":\n" +
- " type: tosca.nodes.nfv.VDU.Compute\n" +
- " capabilities:\n" +
- " virtual_compute:\n" +
- " properties:\n" +
- " virtual_memory:\n" +
- " virtual_mem_size: " + memorySize + "\n" +
- " virtual_cpu:\n" +
- " num_virtual_cpu: " + cpuCount + "\n" +
- " " + REQUIREMENTS + ":\n";
+ String header = indent(name + ":\n" +
+ " type: tosca.nodes.nfv.VDU.Compute\n" +
+ " capabilities:\n" +
+ " virtual_compute:\n" +
+ indent(
+ "properties:\n" +
+ " virtual_memory:\n" +
+ " virtual_mem_size: " + memorySize + "\n" +
+ " virtual_cpu:\n" +
+ " num_virtual_cpu: " + cpuCount + "\n", 3) +
+ " " + REQUIREMENTS + ":\n", 2);
return header + body.toString();
}
private String buildEcp(String name, JsonElement ecp, Set<Map.Entry<String, JsonElement>> nodes) {
if (ecp.getAsJsonObject().has(REQUIREMENTS)) {
- JsonArray requirements = ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray();
- String icpName = getIcpName(requirements);
+ String icpName = getIcpName(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray());
if (icpName != null) {
- JsonObject icpNode = get(icpName, nodes).getAsJsonObject();
- if (icpNode.has(REQUIREMENTS)) {
- requirements = icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray();
- String vdu = getVdu(requirements);
- if (vdu != null) {
- JsonObject properties = child(icpNode, PROPERTIES);
- return buildVduCpd(name, vdu, properties);
- }
- }
+ return buildIcp(name, icpName, nodes);
+ }
+ }
+ return "";
+ }
+
+ private String buildIcp(String name, String icpName, Set<Map.Entry<String, JsonElement>> nodes) {
+ JsonObject icpNode = get(icpName, nodes).getAsJsonObject();
+ if (icpNode.has(REQUIREMENTS)) {
+ String vdu = getVdu(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray());
+ if (vdu != null) {
+ return buildVduCpd(name, vdu, child(icpNode, PROPERTIES));
}
}
return "";
@@ -188,15 +203,15 @@ public class OnapVnfdBuilder {
}
private String buildVduCpd(String name, String vdu, JsonObject properties) {
- return " " + name + ":\n" +
- " type: tosca.nodes.nfv.VduCpd\n" +
- " " + PROPERTIES + ":\n" +
- " layer_protocol: " + childElement(properties, "layer_protocol").getAsString() + "\n" +
- " role: leaf\n" +
+ return indent(name + ":\n" +
+ " type: tosca.nodes.nfv.VduCpd\n" +
+ " " + PROPERTIES + ":\n" +
+ " layer_protocol: " + childElement(properties, "layer_protocol").getAsString() + "\n" +
+ " role: leaf\n" +
(properties.has(DESCRIPTION) ?
- " description: " + childElement(properties, DESCRIPTION).getAsString() + "\n" : "") +
- " requirements:\n" +
- " - virtual_binding: " + vdu + "\n";
+ " description: " + childElement(properties, DESCRIPTION).getAsString() + "\n" : "") +
+ " requirements:\n" +
+ " - virtual_binding: " + vdu + "\n", 2);
}
private String buildIcp(String name, JsonObject icp) {
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
index 6af13c58..8eb2007b 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
@@ -15,6 +15,7 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
+import com.google.common.io.ByteStreams;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfPackageBuilder;
import org.slf4j.Logger;
import org.springframework.stereotype.Controller;
@@ -24,9 +25,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import static org.apache.http.entity.ContentType.APPLICATION_OCTET_STREAM;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.BASE_URL;
import static org.slf4j.LoggerFactory.getLogger;
@@ -53,15 +56,26 @@ public class ConverterApi {
*/
@RequestMapping(value = "/convert", method = POST)
@ResponseBody
- public void convert(HttpServletResponse httpResponse, HttpServletRequest request) throws Exception {
+ public void convert(HttpServletResponse httpResponse, HttpServletRequest request) throws IOException {
logger.info("REST: convert package");
- Part part = request.getParts().iterator().next();
- byte[] bytes = vnfPackageConverter.covert(part.getInputStream());
+ byte[] content;
+ try {
+ Part part = request.getParts().iterator().next();
+ content = ByteStreams.toByteArray(part.getInputStream());
+ } catch (Exception e) {
+ throw buildFatalFailure(logger, "Unable to extract package from REST parameters", e);
+ }
+ byte[] convertedPackage;
+ try {
+ convertedPackage = vnfPackageConverter.covert(new ByteArrayInputStream(content));
+ } catch (IOException e) {
+ throw buildFatalFailure(logger, "Unable to convert VNF package", e);
+ }
httpResponse.addHeader(CONTENT_TYPE, APPLICATION_OCTET_STREAM.getMimeType());
httpResponse.setStatus(OK.value());
- httpResponse.addHeader(CONTENT_LENGTH, Integer.toString(bytes.length));
+ httpResponse.addHeader(CONTENT_LENGTH, Integer.toString(convertedPackage.length));
httpResponse.addHeader(CONTENT_DISPOSITION, "attachment; filename=\"" + "core.csar" + "\"");
- httpResponse.getOutputStream().write(bytes);
+ httpResponse.getOutputStream().write(convertedPackage);
httpResponse.getOutputStream().flush();
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java
index fa7cec4c..74ac6ea2 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java
@@ -64,7 +64,9 @@ public class LcmApi {
@ResponseBody
public VnfInstantiateResponse instantiateVnf(@RequestBody VnfInstantiateRequest request, @PathVariable("vnfmId") String vnfmId, HttpServletResponse httpResponse) {
logger.info("REST: Instantiate VNF");
- VnfInstantiateResponse response = lifecycleManager.instantiate(vnfmId, request, httpResponse);
+ //FIXME
+
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(vnfmId, request, httpResponse);
httpResponse.setStatus(SC_CREATED);
return response;
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java
index 3bd715e4..b4e59151 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java
@@ -57,28 +57,28 @@ public class CbamUtils {
}
/**
- * Logs and throws a runtime exception
+ * Logs and returns a runtime exception
*
* @param logger the logger
* @param msg the error message
* @param e the exception to be wrapped
* @return never reached (runtime exception is thrown)
*/
- public static RuntimeException fatalFailure(Logger logger, String msg, Exception e) {
+ public static RuntimeException buildFatalFailure(Logger logger, String msg, Exception e) {
logger.error(msg, e);
- throw new OperationMustBeAborted(e, msg);
+ return new OperationMustBeAborted(e, msg);
}
/**
- * Logs and throws a runtime exception
+ * Logs and returns a runtime exception
*
* @param logger the logger
* @param msg the error message
* @return never reached (runtime exception is thrown)
*/
- public static RuntimeException fatalFailure(Logger logger, String msg) {
+ public static RuntimeException buildFatalFailure(Logger logger, String msg) {
logger.error(msg);
- throw new OperationMustBeAborted(msg);
+ return new OperationMustBeAborted(msg);
}
private static class OperationMustBeAborted extends RuntimeException {
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/StoreLoader.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/StoreLoader.java
index 71ddd4e2..643d0286 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/StoreLoader.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/StoreLoader.java
@@ -23,11 +23,9 @@ import java.io.InputStream;
import java.security.KeyFactory;
import java.security.KeyStore;
import java.security.KeyStore.TrustedCertificateEntry;
-import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
-import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Collection;
import java.util.HashSet;
@@ -36,7 +34,7 @@ import java.util.Set;
import static java.util.Optional.empty;
import static java.util.Optional.of;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -138,7 +136,7 @@ public final class StoreLoader {
certificates.addAll(c);
}
} catch (Exception e) {
- throw fatalFailure(logger, "Unable to load certificates", e);
+ throw buildFatalFailure(logger, "Unable to load certificates", e);
}
if (!certificates.isEmpty()) {
@@ -157,8 +155,8 @@ public final class StoreLoader {
return of(keyFactory.generatePrivate(keySpec));
}
return empty();
- } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
- throw fatalFailure(logger, "Unable to load key", e);
+ } catch (Exception e) {
+ throw buildFatalFailure(logger, "Unable to load key", e);
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParams.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java
index 879a9567..70cf11ca 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParams.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java
@@ -23,7 +23,7 @@ import java.util.*;
/**
* Represents the additional parameters to be sent during instantiation from VF-C to the driver
*/
-public class AdditionalParams {
+public class AdditionalParameters {
private VimInfoTypeEnum vimType;
private String domain;
private String instantiationLevel;
@@ -35,7 +35,7 @@ public class AdditionalParams {
private List<ExtVirtualLinkData> extVirtualLinks = new ArrayList<>();
private Object additionalParams;
- AdditionalParams() {
+ AdditionalParameters() {
//only used through reflection (gson)
}
@@ -75,7 +75,7 @@ public class AdditionalParams {
}
/**
- * @param domain
+ * @param domain the domain of the OpenStack (required for v3 API)
*/
public void setDomain(String domain) {
this.domain = domain;
@@ -174,10 +174,12 @@ public class AdditionalParams {
}
@Override
+ //generated code. This is the recommended way to formulate equals
+ @SuppressWarnings({"squid:S00122", "squid:S1067"})
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- AdditionalParams that = (AdditionalParams) o;
+ AdditionalParameters that = (AdditionalParameters) o;
return vimType == that.vimType &&
Objects.equals(domain, that.domain) &&
Objects.equals(instantiationLevel, that.instantiationLevel) &&
@@ -192,12 +194,13 @@ public class AdditionalParams {
@Override
public int hashCode() {
+
return Objects.hash(vimType, domain, instantiationLevel, computeResourceFlavours, zones, softwareImages, extManagedVirtualLinks, externalConnectionPointAddresses, extVirtualLinks, additionalParams);
}
@Override
public String toString() {
- return "AdditionalParams{" +
+ return "AdditionalParameters{" +
"vimType=" + vimType +
", domain='" + domain + '\'' +
", instantiationLevel='" + instantiationLevel + '\'' +
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java
index 3396d765..6a35d8e2 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java
@@ -37,7 +37,7 @@ import static com.google.common.base.Splitter.on;
import static com.google.common.collect.Iterables.filter;
import static java.nio.file.Files.createTempFile;
import static java.nio.file.Files.write;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.slf4j.LoggerFactory.getLogger;
@@ -126,7 +126,7 @@ public class CatalogManager {
if (isPackageReplicated(cbamVnfdId, cbamCatalogApi)) {
return queryPackageFromCBAM(cbamVnfdId, cbamCatalogApi);
} else {
- throw fatalFailure(logger, "Unable to create VNF with " + csarId + " CSAR identifier in package in CBAM", e);
+ throw buildFatalFailure(logger, "Unable to create VNF with " + csarId + " CSAR identifier in package in CBAM", e);
}
}
}
@@ -146,7 +146,7 @@ public class CatalogManager {
String vnfdPath = getVnfdLocation(new FileInputStream(content));
return new String(getFileInZip(new FileInputStream(content), vnfdPath).toByteArray());
} catch (Exception e) {
- throw fatalFailure(logger, "Unable to get package with (" + vnfdId + ")", e);
+ throw buildFatalFailure(logger, "Unable to get package with (" + vnfdId + ")", e);
}
}
@@ -154,7 +154,7 @@ public class CatalogManager {
try {
return isPackageReplicatedToCbam(cbamVnfdId, cbamCatalogApi);
} catch (Exception e) {
- throw fatalFailure(logger, "Unable to determine if the VNF package has been replicated in CBAM", e);
+ throw buildFatalFailure(logger, "Unable to determine if the VNF package has been replicated in CBAM", e);
}
}
@@ -162,7 +162,7 @@ public class CatalogManager {
try {
return cbamCatalogApi.getById(cbamVnfdId);
} catch (ApiException e) {
- throw fatalFailure(logger, "Unable to query VNF package with " + cbamVnfdId + " from CBAM", e);
+ throw buildFatalFailure(logger, "Unable to query VNF package with " + cbamVnfdId + " from CBAM", e);
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProvider.java
index e32ee6b0..a8c7ca04 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamTokenProvider.java
@@ -42,7 +42,7 @@ import java.security.cert.X509Certificate;
import java.util.Set;
import static java.util.UUID.randomUUID;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE;
@@ -51,6 +51,9 @@ import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VAL
* Responsible for providing a token to access CBAM APIs
*/
@Component
+//even if the value for grant type an user password is the same they do not mean the same thing
+//the duplication of this is intentional
+@SuppressWarnings("squid:S1192")
public class CbamTokenProvider {
public static final int MAX_RETRY_COUNT = 5;
public static final String GRANT_TYPE = "password";
@@ -126,14 +129,14 @@ public class CbamTokenProvider {
token = new CurrentToken(tokenResponse, getTokenRefreshTime(tokenResponse));
return;
} else {
- fatalFailure(logger, "Bad response from CBAM KeyStone");
+ throw buildFatalFailure(logger, "Bad response from CBAM KeyStone");
}
} catch (Exception e) {
lastException = e;
logger.warn("Unable to get token to access CBAM API (" + (i + 1) + "/" + MAX_RETRY_COUNT + ")", e);
}
}
- throw fatalFailure(logger, "Unable to get token to access CBAM API (giving up retries)", lastException);
+ throw buildFatalFailure(logger, "Unable to get token to access CBAM API (giving up retries)", lastException);
}
@VisibleForTesting
@@ -168,7 +171,7 @@ public class CbamTokenProvider {
sslContext.init(null, trustManagers, new SecureRandom());
return sslContext.getSocketFactory();
} catch (GeneralSecurityException e) {
- throw fatalFailure(logger, "Unable to create SSL socket factory", e);
+ throw buildFatalFailure(logger, "Unable to create SSL socket factory", e);
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/DriverProperties.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/DriverProperties.java
index 3f50bcc3..d510ba25 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/DriverProperties.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/DriverProperties.java
@@ -90,6 +90,8 @@ public class DriverProperties {
}
@Override
+ //generated code. This is the recommended way to formulate equals
+ @SuppressWarnings({"squid:S00122", "squid:S1067"})
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/ILifecycleChangeNotificationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/ILifecycleChangeNotificationManager.java
index 723bfb46..d31633dd 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/ILifecycleChangeNotificationManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/ILifecycleChangeNotificationManager.java
@@ -15,8 +15,6 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
-import com.google.common.collect.Ordering;
-import com.nokia.cbam.lcm.v32.model.OperationExecution;
import com.nokia.cbam.lcm.v32.model.VnfLifecycleChangeNotification;
/**
@@ -25,16 +23,6 @@ import com.nokia.cbam.lcm.v32.model.VnfLifecycleChangeNotification;
public interface ILifecycleChangeNotificationManager {
/**
- * Order the operations by start time (latest first)
- */
- Ordering<OperationExecution> NEWEST_OPERATIONS_FIRST = new Ordering<OperationExecution>() {
- @Override
- public int compare(OperationExecution left, OperationExecution right) {
- return right.getStartTime().toLocalDate().compareTo(left.getStartTime().toLocalDate());
- }
- };
-
- /**
* Transform a CBAM LCN into ONAP LCN
*
* @param receivedNotification the CBAM LCN
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java
index 5a21225b..2aba46b3 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java
@@ -26,7 +26,6 @@ import com.nokia.cbam.lcm.v32.model.OperationExecution;
import com.nokia.cbam.lcm.v32.model.VnfInfo;
import org.apache.http.HttpStatus;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManager;
import org.onap.vnfmdriver.model.JobDetailInfo;
import org.onap.vnfmdriver.model.JobDetailInfoResponseDescriptor;
import org.onap.vnfmdriver.model.JobResponseInfo;
@@ -39,14 +38,16 @@ import javax.servlet.http.HttpServletResponse;
import java.util.*;
import static com.google.common.base.Splitter.on;
+import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.tryFind;
import static com.google.common.collect.Lists.newArrayList;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManager.NEWEST_OPERATIONS_FIRST;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.util.StringUtils.isEmpty;
@@ -107,11 +108,11 @@ public class JobManager {
synchronized (this) {
if (preparingForShutDown) {
response.setStatus(HttpStatus.SC_SERVICE_UNAVAILABLE);
- fatalFailure(logger, "The service is preparing to shut down");
+ throw buildFatalFailure(logger, "The service is preparing to shut down");
}
if (!selfRegistrationManager.isReady()) {
response.setStatus(HttpStatus.SC_SERVICE_UNAVAILABLE);
- fatalFailure(logger, "The service is not yet ready");
+ throw buildFatalFailure(logger, "The service is not yet ready");
}
}
ongoingJobs.add(jobId);
@@ -190,6 +191,7 @@ public class JobManager {
OperationExecution operation = findOperationByJobId(vnfmId, vnf, jobId);
return getJobDetailInfo(vnfmId, jobId, vnfId, operation);
} catch (NoSuchElementException e) {
+ logger.warn("No operation could be identified for job with {} identifier", jobId, e);
if (ongoingJobs.contains(jobId)) {
return reportOngoing(jobId);
} else {
@@ -204,27 +206,31 @@ public class JobManager {
return reportOngoing(jobId);
case FINISHED:
case OTHER:
- //termination includes VNF deletion in ONAP terminology
- if (operation.getOperationType() == com.nokia.cbam.lcm.v32.model.OperationType.TERMINATE) {
- if (ongoingJobs.contains(jobId)) {
- return reportOngoing(jobId);
- } else {
- //the VNF must be queried again since it could have been deleted since the VNF has been terminated
- if (getVnf(vnfmId, vnfId).isPresent()) {
- return reportFailed(jobId, "unable to delete VNF");
- } else {
- return reportFinished(jobId);
- }
- }
- } else {
- return reportFinished(jobId);
- }
+ return getJobForTerminalOperationState(vnfmId, jobId, vnfId, operation);
case FAILED:
default: //all cases handled
return reportFailed(jobId, operation.getError().getTitle() + ": " + operation.getError().getDetail());
}
}
+ private JobDetailInfo getJobForTerminalOperationState(String vnfmId, String jobId, String vnfId, OperationExecution operation) {
+ //termination includes VNF deletion in ONAP terminology
+ if (operation.getOperationType() == com.nokia.cbam.lcm.v32.model.OperationType.TERMINATE) {
+ if (ongoingJobs.contains(jobId)) {
+ return reportOngoing(jobId);
+ } else {
+ //the VNF must be queried again since it could have been deleted since the VNF has been terminated
+ if (getVnf(vnfmId, vnfId).isPresent()) {
+ return reportFailed(jobId, "unable to delete VNF");
+ } else {
+ return reportFinished(jobId);
+ }
+ }
+ } else {
+ return reportFinished(jobId);
+ }
+ }
+
private JobDetailInfo buildJob(String jobId, JobResponseInfo... history) {
JobDetailInfo job = new JobDetailInfo();
job.setJobId(jobId);
@@ -273,20 +279,24 @@ public class JobManager {
//the operations are sorted so that the newest operations are queried first
//performance optimization that usually the core system is interested in the operations executed last
if (vnf.getOperationExecutions() != null) {
- for (OperationExecution operationExecution : LifecycleChangeNotificationManager.NEWEST_OPERATIONS_FIRST.sortedCopy(vnf.getOperationExecutions())) {
- try {
- Object operationParams = cbamOperationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet(operationExecution.getId(), NOKIA_LCM_API_VERSION);
- if (extractOnapJobId(operationParams).equals(jobId)) {
- return operationExecution;
- }
- } catch (ApiException e) {
- fatalFailure(logger, "Unable to retrieve operation parameters", e);
- }
- }
+ List<OperationExecution> sortedOperation = NEWEST_OPERATIONS_FIRST.sortedCopy(vnf.getOperationExecutions());
+ return find(sortedOperation, operation -> isCurrentOperationTriggeredByJob(jobId, cbamOperationExecutionApi, operation));
}
throw new NoSuchElementException();
}
+ private boolean isCurrentOperationTriggeredByJob(String jobId, OperationExecutionsApi cbamOperationExecutionApi, OperationExecution operationExecution) {
+ try {
+ Object operationParams = cbamOperationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet(operationExecution.getId(), NOKIA_LCM_API_VERSION);
+ if (extractOnapJobId(operationParams).equals(jobId)) {
+ return true;
+ }
+ } catch (ApiException e) {
+ throw buildFatalFailure(logger, "Unable to retrieve operation parameters", e);
+ }
+ return false;
+ }
+
private Optional<VnfInfo> getVnf(String vnfmId, String vnfId) {
try {
//test if the VNF exists (required to be able to distingush between failed request )
@@ -303,7 +313,7 @@ public class JobManager {
return of(cbamLcmApi.vnfsVnfInstanceIdGet(vnfId, NOKIA_LCM_API_VERSION));
}
} catch (ApiException e) {
- throw fatalFailure(logger, "Unable to retrieve VNF", e);
+ throw buildFatalFailure(logger, "Unable to retrieve VNF", e);
}
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
index e0ee8f83..cbf5341d 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
@@ -43,6 +43,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.google.common.base.Splitter.on;
+import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet;
@@ -55,7 +56,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.*;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.ILifecycleChangeNotificationManager.NEWEST_OPERATIONS_FIRST;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManager.NEWEST_OPERATIONS_FIRST;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.util.StringUtils.isEmpty;
@@ -93,10 +94,18 @@ public class LifecycleManager {
this.catalogManager = catalogManager;
}
+ /**
+ * @param vimId the VIM identifier
+ * @return the name of the region
+ */
public static String getRegionName(String vimId) {
return newArrayList(on(SEPARATOR).split(vimId)).get(1);
}
+ /**
+ * @param vimId the VIM identifier
+ * @return the owner of the cloud
+ */
public static String getCloudOwner(String vimId) {
return newArrayList(on(SEPARATOR).split(vimId)).get(0);
}
@@ -106,6 +115,73 @@ public class LifecycleManager {
}
/**
+ * Create the VNF. It consists of the following steps
+ * <ul>
+ * <li>upload the VNF package to CBAM package (if not already there)</li>
+ * <li>create the VNF on CBAM</li>
+ * <li>modify attributes of the VNF (add onapCsarId field)</li>
+ * </ul>
+ * The rollback of the failed operation is not implemented
+ * <ul>
+ * <li>delete the VNF if error occurs before instantiation</li>
+ * <li>terminate & delete VNF if error occurs after instantiation</li>
+ * </ul>
+ *
+ * @param vnfmId the identifier of the VNFM
+ * @param csarId the identifier of the VNF package
+ * @param vnfName the name of the VNF
+ * @param description the description of the VNF
+ * @param addtionalParams additional parameters for the VNF instantiation request
+ * @return the VNF creation result
+ */
+ public VnfCreationResult create(String vnfmId, String csarId, String vnfName, String description, AdditionalParameters addtionalParams) {
+ logOperationInput("not yet specified", "create", addtionalParams);
+ validateVimType(addtionalParams.getVimType());
+ try {
+ CatalogAdapterVnfpackage cbamPackage = catalogManager.preparePackageInCbam(vnfmId, csarId);
+ CreateVnfRequest vnfCreateRequest = new CreateVnfRequest();
+ vnfCreateRequest.setVnfdId(cbamPackage.getVnfdId());
+ vnfCreateRequest.setName(vnfName);
+ vnfCreateRequest.setDescription(description);
+ com.nokia.cbam.lcm.v32.model.VnfInfo vnfInfo = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsPost(vnfCreateRequest, NOKIA_LCM_API_VERSION);
+ addVnfdIdToVnfModifyableAttributeExtensions(vnfmId, vnfInfo.getId(), csarId);
+ return new VnfCreationResult(vnfInfo, cbamPackage.getVnfdId());
+ } catch (Exception e) {
+ throw buildFatalFailure(logger, "Unable to create the VNF", e);
+ }
+ }
+
+ private void logOperationInput(String vnfId, String operationName, Object payload){
+ if(logger.isInfoEnabled()){
+ logger.info("Starting {} operation on VNF with {} identifier with {} parameter", operationName, vnfId, new Gson().toJson(payload));
+ }
+ }
+
+ /**
+ * Instantiate the VNF
+ *
+ * @param vnfmId the identifier of the VNFM
+ * @param request the VNF instantiation request
+ * @param httpResponse the HTTP response that corresponds to the VNF instantiation request
+ * @param additionalParameters additional parameters
+ * @param vnfId thr identifier of the VNF
+ * @param vnfdId the identifier of the VNF package in CBAM
+ * @return the instantiation response
+ */
+ public VnfInstantiateResponse instantiate(String vnfmId, VnfInstantiateRequest request, HttpServletResponse httpResponse, AdditionalParameters additionalParameters, String vnfId, String vnfdId) {
+ logOperationInput(vnfId, "instantiate", request);
+ validateVimType(additionalParameters.getVimType());
+ VnfInstantiateResponse response = new VnfInstantiateResponse();
+ response.setVnfInstanceId(vnfId);
+ String vimId = getVimId(request.getAdditionalParam());
+ JobInfo spawnJob = scheduleExecution(vnfId, httpResponse, "instantiate", jobInfo ->
+ instantiateVnf(vnfmId, request, additionalParameters, vnfdId, vnfId, vimId, jobInfo)
+ );
+ response.setJobId(spawnJob.getJobId());
+ return response;
+ }
+
+ /**
* Instantiate (VF-C terminology) the VNF. It consists of the following steps
* <ul>
* <li>upload the VNF package to CBAM package (if not already there)</li>
@@ -128,81 +204,59 @@ public class LifecycleManager {
* @param httpResponse the HTTP response
* @return the instantiation response
*/
- public VnfInstantiateResponse instantiate(String vnfmId, VnfInstantiateRequest request, HttpServletResponse httpResponse) {
- if (logger.isDebugEnabled()) {
- logger.debug("Additional parameters for instantiation: {}", new Gson().toJson(request.getAdditionalParam()));
- }
- AdditionalParams additionalParams = convertInstantiationAdditionalParams(request.getVnfPackageId(), request.getAdditionalParam());
- validateVimType(additionalParams);
- CatalogAdapterVnfpackage cbamPackage = catalogManager.preparePackageInCbam(vnfmId, request.getVnfPackageId());
- try {
- CreateVnfRequest vnfCreateRequest = new CreateVnfRequest();
- vnfCreateRequest.setVnfdId(cbamPackage.getId());
- vnfCreateRequest.setName(request.getVnfInstanceName());
- vnfCreateRequest.setDescription(request.getVnfInstanceDescription());
- com.nokia.cbam.lcm.v32.model.VnfInfo vnfInfo = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsPost(vnfCreateRequest, NOKIA_LCM_API_VERSION);
- VnfInstantiateResponse response = new VnfInstantiateResponse();
- response.setVnfInstanceId(vnfInfo.getId());
- String vimId = getVimId(request.getAdditionalParam());
- addVnfdIdToVnfModifyableAttributeExtensions(vnfmId, vnfInfo.getId(), request.getVnfPackageId());
- JobInfo spawnJob = scheduleExecution(vnfInfo.getId(), httpResponse, "instantiate", jobInfo ->
- instantiateVnf(vnfmId, request, additionalParams, cbamPackage, vnfInfo, vimId, jobInfo)
- );
- response.setJobId(spawnJob.getJobId());
- return response;
- } catch (Exception e) {
- throw fatalFailure(logger, "Unable to create the VNF", e);
- }
+ public VnfInstantiateResponse createAndInstantiate(String vnfmId, VnfInstantiateRequest request, HttpServletResponse httpResponse) {
+ AdditionalParameters additionalParameters = convertInstantiationAdditionalParams(request.getVnfPackageId(), request.getAdditionalParam());
+ VnfCreationResult creationResult = create(vnfmId, request.getVnfDescriptorId(), request.getVnfInstanceName(), request.getVnfInstanceDescription(), additionalParameters);
+ return instantiate(vnfmId, request, httpResponse, additionalParameters, creationResult.vnfInfo.getId(), creationResult.vnfdId);
}
- private void instantiateVnf(String vnfmId, VnfInstantiateRequest request, AdditionalParams additionalParams, CatalogAdapterVnfpackage cbamPackage, com.nokia.cbam.lcm.v32.model.VnfInfo vnfInfo, String vimId, JobInfo jobInfo) throws ApiException {
- String vnfdContent = catalogManager.getCbamVnfdContent(vnfmId, cbamPackage.getId());
- GrantVNFResponseVim vim = grantManager.requestGrantForInstantiate(vnfmId, vnfInfo.getId(), vimId, request.getVnfPackageId(), additionalParams.getInstantiationLevel(), vnfdContent, jobInfo.getJobId());
+ private void instantiateVnf(String vnfmId, VnfInstantiateRequest request, AdditionalParameters additionalParameters, String vnfdId, String vnfId, String vimId, JobInfo jobInfo) throws ApiException {
+ String vnfdContent = catalogManager.getCbamVnfdContent(vnfmId, vnfdId);
+ GrantVNFResponseVim vim = grantManager.requestGrantForInstantiate(vnfmId, vnfId, vimId, request.getVnfPackageId(), additionalParameters.getInstantiationLevel(), vnfdContent, jobInfo.getJobId());
if (vim.getVimId() == null) {
- fatalFailure(logger, "VF-C did not send VIM identifier in grant response");
+ throw buildFatalFailure(logger, "VF-C did not send VIM identifier in grant response");
}
VimInfo vimInfo = vimInfoProvider.getVimInfo(vim.getVimId());
InstantiateVnfRequest instantiationRequest = new InstantiateVnfRequest();
- addExernalLinksToRequest(request.getExtVirtualLink(), additionalParams, instantiationRequest, vimId);
- if (additionalParams.getVimType() == OPENSTACK_V2_INFO) {
- instantiationRequest.getVims().add(buildOpenStackV2INFO(vimId, vim, vimInfo));
-
- } else if (additionalParams.getVimType() == OPENSTACK_V3_INFO) {
- instantiationRequest.getVims().add(buildOpenStackV3INFO(vimId, additionalParams, vim, vimInfo));
-
- } else if (additionalParams.getVimType() == VMWARE_VCLOUD_INFO) {
- instantiationRequest.getVims().add(buildVcloudInfo(vimId, vimInfo));
-
- }
+ addExternalLinksToRequest(request.getExtVirtualLink(), additionalParameters, instantiationRequest, vimId);
+ instantiationRequest.getVims().add(addVim(additionalParameters, vimId, vim, vimInfo, instantiationRequest));
instantiationRequest.setFlavourId(getFlavorId(vnfdContent));
- instantiationRequest.setComputeResourceFlavours(additionalParams.getComputeResourceFlavours());
+ instantiationRequest.setComputeResourceFlavours(additionalParameters.getComputeResourceFlavours());
instantiationRequest.setGrantlessMode(true);
- instantiationRequest.setInstantiationLevelId(additionalParams.getInstantiationLevel());
- instantiationRequest.setSoftwareImages(additionalParams.getSoftwareImages());
- instantiationRequest.setZones(additionalParams.getZones());
- instantiationRequest.setExtManagedVirtualLinks(additionalParams.getExtManagedVirtualLinks());
- for (ExtVirtualLinkData extVirtualLinkData : additionalParams.getExtVirtualLinks()) {
+ instantiationRequest.setInstantiationLevelId(additionalParameters.getInstantiationLevel());
+ instantiationRequest.setSoftwareImages(additionalParameters.getSoftwareImages());
+ instantiationRequest.setZones(additionalParameters.getZones());
+ instantiationRequest.setExtManagedVirtualLinks(additionalParameters.getExtManagedVirtualLinks());
+ for (ExtVirtualLinkData extVirtualLinkData : additionalParameters.getExtVirtualLinks()) {
instantiationRequest.addExtVirtualLinksItem(extVirtualLinkData);
}
JsonObject root = new Gson().toJsonTree(jobInfo).getAsJsonObject();
- if (additionalParams.getAdditionalParams() != null && !isEmpty(additionalParams.getAdditionalParams().toString())) {
- for (Map.Entry<String, JsonElement> item : new Gson().toJsonTree(additionalParams.getAdditionalParams()).getAsJsonObject().entrySet()) {
+ if (additionalParameters.getAdditionalParams() != null && !isNullOrEmpty(additionalParameters.getAdditionalParams().toString())) {
+ for (Map.Entry<String, JsonElement> item : new Gson().toJsonTree(additionalParameters.getAdditionalParams()).getAsJsonObject().entrySet()) {
root.add(item.getKey(), item.getValue());
}
}
instantiationRequest.setAdditionalParams(root);
- OperationExecution operationExecution = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdInstantiatePost(vnfInfo.getId(), instantiationRequest, NOKIA_LCM_API_VERSION);
- waitForOperationToFinish(vnfmId, vnfInfo.getId(), operationExecution.getId());
- }
-
- private void validateVimType(AdditionalParams additionalParams) {
- switch (additionalParams.getVimType()) {
- case OPENSTACK_V2_INFO:
- case OPENSTACK_V3_INFO:
- case VMWARE_VCLOUD_INFO:
- break;
- default:
- throw fatalFailure(logger, "Only " + OPENSTACK_V2_INFO + ", " + OPENSTACK_V3_INFO + " and " + VMWARE_VCLOUD_INFO + " is the supported VIM types");
+ OperationExecution operationExecution = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdInstantiatePost(vnfId, instantiationRequest, NOKIA_LCM_API_VERSION);
+ waitForOperationToFinish(vnfmId, vnfId, operationExecution.getId());
+ }
+
+ private com.nokia.cbam.lcm.v32.model.VimInfo addVim(AdditionalParameters additionalParameters, String vimId, GrantVNFResponseVim vim, VimInfo vimInfo, InstantiateVnfRequest instantiationRequest) {
+ if (additionalParameters.getVimType() == OPENSTACK_V2_INFO) {
+ return buildOpenStackV2INFO(vimId, vim, vimInfo);
+
+ } else if (additionalParameters.getVimType() == OPENSTACK_V3_INFO) {
+ return buildOpenStackV3INFO(vimId, additionalParameters, vim, vimInfo);
+
+ } else {
+ //OTHER VIM TYPE is not possible
+ return buildVcloudInfo(vimId, vimInfo);
+ }
+ }
+
+ private void validateVimType(com.nokia.cbam.lcm.v32.model.VimInfo.VimInfoTypeEnum vimType) {
+ if(com.nokia.cbam.lcm.v32.model.VimInfo.VimInfoTypeEnum.OTHER_VIM_INFO.equals(vimType)){
+ throw buildFatalFailure(logger, "Only " + OPENSTACK_V2_INFO + ", " + OPENSTACK_V3_INFO + " and " + VMWARE_VCLOUD_INFO + " is the supported VIM types");
}
}
@@ -210,13 +264,13 @@ public class LifecycleManager {
return childElement(new Gson().toJsonTree(additionalParams).getAsJsonObject(), "vimId").getAsString();
}
- private AdditionalParams convertInstantiationAdditionalParams(String csarId, Object additionalParams) {
+ private AdditionalParameters convertInstantiationAdditionalParams(String csarId, Object additionalParams) {
JsonObject vnfParameters = child(child(new Gson().toJsonTree(additionalParams).getAsJsonObject(), "inputs"), "vnfs");
if (!vnfParameters.has(csarId)) {
- throw fatalFailure(logger, "The additional parameter section does not contain setting for VNF with " + csarId + " CSAR id");
+ throw buildFatalFailure(logger, "The additional parameter section does not contain setting for VNF with " + csarId + " CSAR id");
}
JsonElement additionalParamsForVnf = vnfParameters.get(csarId);
- return new Gson().fromJson(additionalParamsForVnf, AdditionalParams.class);
+ return new Gson().fromJson(additionalParamsForVnf, AdditionalParameters.class);
}
private String getFlavorId(String vnfdContent) {
@@ -233,7 +287,7 @@ public class LifecycleManager {
return additionalParameters.keySet();
}
- private void addExernalLinksToRequest(List<ExtVirtualLinkInfo> extVirtualLinks, AdditionalParams additionalParams, InstantiateVnfRequest instantiationRequest, String vimId) {
+ private void addExternalLinksToRequest(List<ExtVirtualLinkInfo> extVirtualLinks, AdditionalParameters additionalParameters, InstantiateVnfRequest instantiationRequest, String vimId) {
for (ExtVirtualLinkInfo extVirtualLink : extVirtualLinks) {
ExtVirtualLinkData cbamExternalVirtualLink = new ExtVirtualLinkData();
cbamExternalVirtualLink.setVimId(vimId);
@@ -242,7 +296,7 @@ public class LifecycleManager {
cbamExternalVirtualLink.setExtVirtualLinkId(extVirtualLink.getVlInstanceId());
cbamExternalVirtualLink.getExtCps().add(ecp);
ecp.setCpdId(extVirtualLink.getCpdId());
- List<NetworkAddress> addresses = additionalParams.getExternalConnectionPointAddresses().get(extVirtualLink.getCpdId());
+ List<NetworkAddress> addresses = additionalParameters.getExternalConnectionPointAddresses().get(extVirtualLink.getCpdId());
ecp.setAddresses(addresses);
instantiationRequest.addExtVirtualLinksItem(cbamExternalVirtualLink);
}
@@ -264,17 +318,17 @@ public class LifecycleManager {
OperationExecution operationExecution = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdPatch(vnfId, request, NOKIA_LCM_API_VERSION);
waitForOperationToFinish(vnfmId, vnfId, operationExecution.getId());
} catch (ApiException e) {
- fatalFailure(logger, "Unable to set the " + ONAP_CSAR_ID + " property on the VNF", e);
+ throw buildFatalFailure(logger, "Unable to set the " + ONAP_CSAR_ID + " property on the VNF", e);
}
}
- private OPENSTACKV3INFO buildOpenStackV3INFO(String vimId, AdditionalParams additionalParams, GrantVNFResponseVim vim, org.onap.vnfmdriver.model.VimInfo vimInfo) {
+ private OPENSTACKV3INFO buildOpenStackV3INFO(String vimId, AdditionalParameters additionalParameters, GrantVNFResponseVim vim, org.onap.vnfmdriver.model.VimInfo vimInfo) {
OPENSTACKV3INFO openstackv3INFO = new OPENSTACKV3INFO();
openstackv3INFO.setVimInfoType(OPENSTACK_V3_INFO);
OpenStackAccessInfoV3 accessInfov3 = new OpenStackAccessInfoV3();
openstackv3INFO.accessInfo(accessInfov3);
accessInfov3.setPassword(vimInfo.getPassword());
- accessInfov3.setDomain(additionalParams.getDomain());
+ accessInfov3.setDomain(additionalParameters.getDomain());
accessInfov3.setProject(vim.getAccessInfo().getTenant());
accessInfov3.setRegion(getRegionName(vimId));
accessInfov3.setUsername(vimInfo.getUserName());
@@ -370,6 +424,7 @@ public class LifecycleManager {
* @return the job for polling the progress of the termination
*/
public JobInfo terminateVnf(String vnfmId, String vnfId, VnfTerminateRequest request, HttpServletResponse httpResponse) {
+ logOperationInput(vnfId, "termination", request);
return scheduleExecution(vnfId, httpResponse, "terminate", jobInfo -> {
TerminateVnfRequest cbamRequest = new TerminateVnfRequest();
cbamRequest.setAdditionalParams(jobInfo);
@@ -386,10 +441,8 @@ public class LifecycleManager {
com.nokia.cbam.lcm.v32.model.VnfInfo vnf = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdGet(vnfId, NOKIA_LCM_API_VERSION);
if (vnf.getInstantiationState() == INSTANTIATED) {
terminateVnf(vnfmId, vnfId, jobInfo, cbamRequest, vnf);
-
} else {
cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdDelete(vnfId, NOKIA_LCM_API_VERSION);
-
}
});
}
@@ -442,7 +495,7 @@ public class LifecycleManager {
vnfInfo.setVnfType("Kuku");
return vnfInfo;
} catch (ApiException e) {
- throw fatalFailure(logger, "Unable to query VNF (" + vnfId + ")", e);
+ throw buildFatalFailure(logger, "Unable to query VNF (" + vnfId + ")", e);
}
}
@@ -464,9 +517,7 @@ public class LifecycleManager {
* @return the job for tracking the scale
*/
public JobInfo scaleVnf(String vnfmId, String vnfId, VnfScaleRequest request, HttpServletResponse httpResponse) {
- if (logger.isInfoEnabled()) {
- logger.info("Scale VNF with {} identifier REST: {}", vnfId, new Gson().toJson(request));
- }
+ logOperationInput(vnfId, "scale", request);
return scheduleExecution(vnfId, httpResponse, "scale", jobInfo -> {
ScaleVnfRequest cbamRequest = new ScaleVnfRequest();
cbamRequest.setAspectId(request.getAspectId());
@@ -477,15 +528,7 @@ public class LifecycleManager {
com.nokia.cbam.lcm.v32.model.VnfInfo cbamVnfInfo = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdGet(vnfId, NOKIA_LCM_API_VERSION);
String vnfdContent = catalogManager.getCbamVnfdContent(vnfmId, cbamVnfInfo.getVnfdId());
Set<String> acceptableOperationParameters = getAcceptableOperationParameters(vnfdContent, "Basic", "scale");
- if (request.getAdditionalParam() != null) {
- for (Map.Entry<String, JsonElement> item : new Gson().toJsonTree(request.getAdditionalParam()).getAsJsonObject().entrySet()) {
- if (acceptableOperationParameters.contains(item.getKey())) {
- root.add(item.getKey(), item.getValue());
- }
- }
- } else {
- logger.warn("No additional parameters were passed for scaling");
- }
+ buildAdditionalParameters(request, root, acceptableOperationParameters);
cbamRequest.setAdditionalParams(root);
grantManager.requestGrantForScale(vnfmId, vnfId, getVimIdFromInstantiationRequest(vnfmId, vnf), getVnfdIdFromModifyableAttributes(vnf), request, jobInfo.getJobId());
OperationExecution operationExecution = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdScalePost(vnfId, cbamRequest, NOKIA_LCM_API_VERSION);
@@ -493,6 +536,18 @@ public class LifecycleManager {
});
}
+ private void buildAdditionalParameters(VnfScaleRequest request, JsonObject root, Set<String> acceptableOperationParameters) {
+ if (request.getAdditionalParam() != null) {
+ for (Map.Entry<String, JsonElement> item : new Gson().toJsonTree(request.getAdditionalParam()).getAsJsonObject().entrySet()) {
+ if (acceptableOperationParameters.contains(item.getKey())) {
+ root.add(item.getKey(), item.getValue());
+ }
+ }
+ } else {
+ logger.warn("No additional parameters were passed for scaling");
+ }
+ }
+
/**
* Heal the VNF
*
@@ -503,6 +558,7 @@ public class LifecycleManager {
* @return the job for tracking the heal
*/
public JobInfo healVnf(String vnfmId, String vnfId, VnfHealRequest request, HttpServletResponse httpResponse) {
+ logOperationInput(vnfId, "heal", request);
return scheduleExecution(vnfId, httpResponse, "heal", job -> {
HealVnfRequest cbamHealRequest = new HealVnfRequest();
Map<String, String> additionalParams = new HashMap<>();
@@ -564,4 +620,14 @@ public class LifecycleManager {
private interface AsynchronousExecution {
void execute(JobInfo job) throws ApiException;
}
+
+ private static class VnfCreationResult {
+ private com.nokia.cbam.lcm.v32.model.VnfInfo vnfInfo;
+ private String vnfdId;
+
+ VnfCreationResult(com.nokia.cbam.lcm.v32.model.VnfInfo vnfInfo, String vnfdId) {
+ this.vnfInfo = vnfInfo;
+ this.vnfdId = vnfdId;
+ }
+ }
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
index 30195c9e..9ee8cbda 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
@@ -17,6 +17,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
@@ -43,8 +44,8 @@ import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.tryFind;
import static com.google.common.collect.Sets.newConcurrentHashSet;
import static com.nokia.cbam.lcm.v32.model.OperationType.INSTANTIATE;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.childElement;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCN_API_VERSION;
import static org.slf4j.LoggerFactory.getLogger;
@@ -68,6 +69,15 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
public static final String PROBLEM = "All operations must return the { \"operationResult\" : { \"cbam_pre\" : [<fillMeOut>], \"cbam_post\" : [<fillMeOut>] } } structure";
/**
+ * Order the operations by start time (latest first)
+ */
+ public static final Ordering<OperationExecution> NEWEST_OPERATIONS_FIRST = new Ordering<OperationExecution>() {
+ @Override
+ public int compare(OperationExecution left, OperationExecution right) {
+ return right.getStartTime().toLocalDate().compareTo(left.getStartTime().toLocalDate());
+ }
+ };
+ /**
* < Separates the VNF id and the resource id within a VNF
*/
private static final Set<OperationStatus> terminalStatus = Sets.newHashSet(OperationStatus.FINISHED, OperationStatus.FAILED);
@@ -107,24 +117,25 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
try {
List<VnfInfo> vnfs = cbamLcmApi.vnfsGet(NOKIA_LCM_API_VERSION);
com.google.common.base.Optional<VnfInfo> currentVnf = tryFind(vnfs, vnf -> vnf.getId().equals(recievedNotification.getVnfInstanceId()));
+ String vnfHeader = "The VNF with " + recievedNotification.getVnfInstanceId() + " identifier";
if (!currentVnf.isPresent()) {
- logger.warn("The VNF with " + recievedNotification.getVnfInstanceId() + " disappeared before being able to process the LCN");
+ logger.warn(vnfHeader + " disappeared before being able to process the LCN");
//swallow LCN
return;
} else {
VnfInfo vnf = cbamLcmApi.vnfsVnfInstanceIdGet(recievedNotification.getVnfInstanceId(), NOKIA_LCN_API_VERSION);
com.google.common.base.Optional<VnfProperty> externalVnfmId = tryFind(vnf.getExtensions(), prop -> prop.getName().equals(LifecycleManager.EXTERNAL_VNFM_ID));
if (!externalVnfmId.isPresent()) {
- logger.warn("The VNF with " + vnf.getId() + " identifier is not a managed VNF");
+ logger.warn(vnfHeader + " is not a managed VNF");
return;
}
if (!externalVnfmId.get().getValue().equals(driverProperties.getVnfmId())) {
- logger.warn("The VNF with " + vnf.getId() + " identifier is not a managed by the VNFM with id " + externalVnfmId.get().getValue());
+ logger.warn(vnfHeader + " is not a managed by the VNFM with id " + externalVnfmId.get().getValue());
return;
}
}
} catch (Exception e) {
- fatalFailure(logger, "Unable to list VNFs / query VNF", e);
+ throw buildFatalFailure(logger, "Unable to list VNFs / query VNF", e);
}
OperationExecutionsApi cbamOperationExecutionApi = restApiProvider.getCbamOperationExecutionApi(driverProperties.getVnfmId());
try {
@@ -137,7 +148,7 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
processedNotifications.add(new ProcessedNotification(recievedNotification.getLifecycleOperationOccurrenceId(), recievedNotification.getStatus()));
}
} catch (ApiException e) {
- fatalFailure(logger, "Unable to retrieve the current VNF " + recievedNotification.getVnfInstanceId(), e);
+ throw buildFatalFailure(logger, "Unable to retrieve the current VNF " + recievedNotification.getVnfInstanceId(), e);
}
}
@@ -146,7 +157,7 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
Object operationParams = cbamOperationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet(closestInstantiationToOperation.getId(), NOKIA_LCM_API_VERSION);
return getVimId(operationParams);
} catch (Exception e) {
- throw fatalFailure(logger, "Unable to detect last instantiation operation", e);
+ throw buildFatalFailure(logger, "Unable to detect last instantiation operation", e);
}
}
@@ -205,9 +216,9 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
case STARTED: //can not happen (the changed resources are only executed for terminal state
case FINISHED:
if (e != null) {
- fatalFailure(logger, PROBLEM, e);
+ throw buildFatalFailure(logger, PROBLEM, e);
}
- fatalFailure(logger, PROBLEM);
+ throw buildFatalFailure(logger, PROBLEM);
}
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ProcessedNotification.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ProcessedNotification.java
index 044e1ca2..8f91604e 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ProcessedNotification.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ProcessedNotification.java
@@ -62,6 +62,8 @@ class ProcessedNotification {
}
@Override
+ //generated code. This is the recommended way to formulate equals
+ @SuppressWarnings({"squid:S00122", "squid:S1067"})
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ReportedAffectedConnectionPoints.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ReportedAffectedConnectionPoints.java
index 9bf629e3..7bd79435 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ReportedAffectedConnectionPoints.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/ReportedAffectedConnectionPoints.java
@@ -59,6 +59,8 @@ public class ReportedAffectedConnectionPoints {
}
@Override
+ //generated code. This is the recommended way to formulate equals
+ @SuppressWarnings({"squid:S00122", "squid:S1067"})
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
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 5a4c174d..c9d87bfa 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
@@ -189,6 +189,8 @@ public class ReportedAffectedCp {
}
@Override
+ //generated code. This is the recommended way to formulate equals
+ @SuppressWarnings({"squid:S00122", "squid:S1067"})
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java
index ea1afe5f..17cf8258 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java
@@ -27,6 +27,7 @@ import org.springframework.test.util.ReflectionTestUtils;
import static java.lang.Long.valueOf;
import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.fail;
import static org.mockito.Mockito.*;
public class TestGenericExternalSystemInfoProvider extends TestBase {
@@ -52,12 +53,12 @@ public class TestGenericExternalSystemInfoProvider extends TestBase {
//when
VnfmInfo vnfmInfo = genericExternalSystemInfoProvider.getVnfmInfo(VNFM_ID);
//verify
- verify(logger).info("Quering VNFM info from source with " + VNFM_ID + " identifier");
+ verify(logger).info("Querying VNFM info from source with " + VNFM_ID + " identifier");
assertEquals(expectedVnfmInfo, vnfmInfo);
//when
VnfmInfo vnfmInfo2 = genericExternalSystemInfoProvider.getVnfmInfo(VNFM_ID);
//verify source system not called again
- verify(logger).info("Quering VNFM info from source with " + VNFM_ID + " identifier");
+ verify(logger).info("Querying VNFM info from source with " + VNFM_ID + " identifier");
verify(genericExternalSystemInfoProvider, Mockito.times(1)).queryVnfmInfoFromSource(VNFM_ID);
}
@@ -65,24 +66,24 @@ public class TestGenericExternalSystemInfoProvider extends TestBase {
* the VNFM info is retrieved without the cache eviction period
*/
@Test
+ //sleeping is required to make time pass (for cache to notice the change)
+ //cache is configured with 1 ms cache eviction without sleep it is not
+ //deterministic that at least 1 ms time will pass between calls
+ @SuppressWarnings("squid:S2925")
public void testQueryVnfmInfoOutside() throws Exception {
VnfmInfo expectedVnfmInfo = Mockito.mock(VnfmInfo.class);
when(genericExternalSystemInfoProvider.queryVnfmInfoFromSource(VNFM_ID)).thenReturn(expectedVnfmInfo);
when(environment.getProperty(GenericExternalSystemInfoProvider.VNFM_INFO_CACHE_EVICTION_IN_MS, Long.class, valueOf(GenericExternalSystemInfoProvider.DEFAULT_CACHE_EVICTION_TIMEOUT_IN_MS))).thenReturn(Long.valueOf(1));
genericExternalSystemInfoProvider.afterPropertiesSet();
-
//when
VnfmInfo vnfmInfo = genericExternalSystemInfoProvider.getVnfmInfo(VNFM_ID);
//verify
assertEquals(expectedVnfmInfo, vnfmInfo);
//when
- //sleeping is required to make time pass (for cache to notice the change)
- //cache is configured with 1 ms cache eviction without sleep it is not
- //deterministic that at least 1 ms time will pass between calls
- Thread.sleep(10); //NO SONAR
+ Thread.sleep(10);
VnfmInfo vnfmInfo2 = genericExternalSystemInfoProvider.getVnfmInfo(VNFM_ID);
//verify source system called again
- verify(logger, times(2)).info("Quering VNFM info from source with " + VNFM_ID + " identifier");
+ verify(logger, times(2)).info("Querying VNFM info from source with " + VNFM_ID + " identifier");
verify(genericExternalSystemInfoProvider, Mockito.times(2)).queryVnfmInfoFromSource(VNFM_ID);
}
@@ -103,4 +104,35 @@ public class TestGenericExternalSystemInfoProvider extends TestBase {
}
}
+
+ /**
+ * Unable to query VNFM results is propagated
+ */
+ @Test
+ public void testUnableToQueryVnfmInfoProvider() throws Exception{
+ class TestClass extends GenericExternalSystemInfoProvider {
+
+ TestClass(Environment environment) {
+ super(environment);
+ }
+
+ @Override
+ public VnfmInfo queryVnfmInfoFromSource(String vnfmId) {
+ throw new RuntimeException();
+ }
+
+ @Override
+ public VimInfo getVimInfo(String vimId) {
+ return null;
+ }
+ }
+ try {
+ new TestClass(null).getVnfmInfo(VNFM_ID);
+ fail();
+ }
+ catch (Exception e){
+ assertEquals("Unable to query VNFM info for myVnfmId", e.getMessage());
+ verify(logger).error(eq("Unable to query VNFM info for myVnfmId"), any(RuntimeException.class));
+ }
+ }
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java
index e6d8ebb4..aefe63a2 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java
@@ -119,6 +119,57 @@ public class TestMsbApiProvider extends TestBase {
assertEquals("http://1.2.3.4:234/lead/nslcm/v1", msbApiProvider.getMicroServiceUrl("serviceName", "v1"));
}
+
+ /**
+ * use HTTPS for known ports (443) should be removed if https://jira.onap.org/browse/MSB-151 is solved
+ */
+ @Test
+ public void testMsb151IssueHack() throws Exception {
+ NodeInfo nonDocker = new NodeInfo();
+ nonDocker.setIp("173.1.2.3");
+ nonDocker.setPort("443");
+ microServiceInfo.setServiceName("serviceName");
+ microServiceInfo.setVersion("v1");
+ microServiceInfo.setUrl("/lead/nslcm/v1");
+ when(environment.getProperty(IpMappingProvider.IP_MAP, String.class, "")).thenReturn("173.1.2.3->1.2.3.4");
+ nodes.add(nonDocker);
+ msbApiProvider = new MsbApiProvider(environment) {
+ @Override
+ public MSBServiceClient getMsbClient() {
+ return msbClient;
+ }
+ };
+ when(msbClient.queryMicroServiceInfo("serviceName", "v1")).thenReturn(microServiceInfo);
+ msbApiProvider.afterPropertiesSet();
+ //when
+ assertEquals("https://1.2.3.4:443/lead/nslcm/v1", msbApiProvider.getMicroServiceUrl("serviceName", "v1"));
+ }
+
+ /**
+ * use HTTPS for known ports (443) should be removed if https://jira.onap.org/browse/MSB-151 is solved
+ */
+ @Test
+ public void testMsb151IssueHack2() throws Exception {
+ NodeInfo nonDocker = new NodeInfo();
+ nonDocker.setIp("173.1.2.3");
+ nonDocker.setPort("8443");
+ microServiceInfo.setServiceName("serviceName");
+ microServiceInfo.setVersion("v1");
+ microServiceInfo.setUrl("/lead/nslcm/v1");
+ when(environment.getProperty(IpMappingProvider.IP_MAP, String.class, "")).thenReturn("173.1.2.3->1.2.3.4");
+ nodes.add(nonDocker);
+ msbApiProvider = new MsbApiProvider(environment) {
+ @Override
+ public MSBServiceClient getMsbClient() {
+ return msbClient;
+ }
+ };
+ when(msbClient.queryMicroServiceInfo("serviceName", "v1")).thenReturn(microServiceInfo);
+ msbApiProvider.afterPropertiesSet();
+ //when
+ assertEquals("https://1.2.3.4:8443/lead/nslcm/v1", msbApiProvider.getMicroServiceUrl("serviceName", "v1"));
+ }
+
/**
* if unable to get micro service info the error is propagated
*/
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java
index 1edf5eca..fd93dce2 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java
@@ -28,6 +28,15 @@ import static junit.framework.TestCase.fail;
public class TestOnapVnfdBuilder extends TestBase {
private OnapVnfdBuilder packageTransformer = new OnapVnfdBuilder();
+ @Test
+ public void indent() {
+ assertEquals(" x", packageTransformer.indent("x", 2));
+ assertEquals(" x\n", packageTransformer.indent("x\n", 2));
+ assertEquals(" x\n y", packageTransformer.indent("x\ny", 2));
+ assertEquals(" x\n y\n", packageTransformer.indent("x\ny\n", 2));
+ assertEquals(" \n", packageTransformer.indent("\n", 2));
+ }
+
/**
* Test empty VNFD conversion
*/
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
index 9ac38914..95bdc5f4 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
@@ -37,9 +37,13 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Part;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertTrue;
+import static junit.framework.TestCase.fail;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager.getFileInZip;
@@ -48,7 +52,6 @@ import static org.springframework.test.util.ReflectionTestUtils.setField;
public class TestConverterApi extends TestBase {
-
@InjectMocks
private ConverterApi converterApi;
@Mock
@@ -60,9 +63,10 @@ public class TestConverterApi extends TestBase {
}
/**
+ * test VNF package conversion success scenario
*/
@Test
- public void test() throws Exception {
+ public void testConversion() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream actualOut = new PrintStream(bos, true);
when(systemFunctions.out()).thenReturn(actualOut);
@@ -97,8 +101,11 @@ public class TestConverterApi extends TestBase {
assertItenticalZips(expectedModifiedCbamPackage, actualModifiedCbamVnfPackage.toByteArray());
}
+ /**
+ * the HTML based converted page works
+ */
@Test
- public void testDownloaderPage() throws Exception {
+ public void testConverterPage() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream actualOut = new PrintStream(bos, true);
when(httpResponse.getOutputStream()).thenReturn(new DelegatingServletOutputStream(actualOut));
@@ -106,9 +113,25 @@ public class TestConverterApi extends TestBase {
//when
converterApi.getUploadPageForConvertingVnfd(httpResponse);
//verify
- TestCase.assertTrue(Arrays.equals(TestUtil.loadFile("upload.html"), bos.toByteArray()));
+ assertTrue(Arrays.equals(TestUtil.loadFile("upload.html"), bos.toByteArray()));
verify(httpResponse).addHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(bos.toByteArray().length));
-
}
+ /**
+ * error is propagated if unable to extract package from HTTP request
+ */
+ @Test
+ public void testUnableToExtractPackageToBeConverted() throws Exception{
+ IOException expectedException = new IOException();
+ when(httpRequest.getParts()).thenThrow(expectedException);
+ try {
+ converterApi.convert(httpResponse, httpRequest);
+ fail();
+ }
+ catch (Exception e){
+ verify(logger).error("Unable to extract package from REST parameters", expectedException);
+ assertEquals("Unable to extract package from REST parameters", e.getMessage());
+ assertEquals(expectedException, e.getCause());
+ }
+ }
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
index 1fdeb323..4d10fd52 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
@@ -56,7 +56,7 @@ public class TestLcmApi extends TestBase {
//when
lcmApi.instantiateVnf(req, VNFM_ID, httpResponse);
//verify
- verify(lifecycleManager).instantiate(VNFM_ID, req, httpResponse);
+ verify(lifecycleManager).createAndInstantiate(VNFM_ID, req, httpResponse);
verify(httpResponse).setStatus(SC_CREATED);
verify(logger).info("REST: Instantiate VNF");
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestCbamUtils.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestCbamUtils.java
index 7f544616..360e1d7c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestCbamUtils.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestCbamUtils.java
@@ -102,14 +102,10 @@ public class TestCbamUtils {
public void testFatalFailure() throws Exception {
Exception expectedException = new Exception();
Logger logger = Mockito.mock(Logger.class);
- try {
- CbamUtils.fatalFailure(logger, "msg", expectedException);
- fail();
- } catch (RuntimeException e) {
- assertEquals("msg", e.getMessage());
- assertEquals(expectedException, e.getCause());
- verify(logger).error("msg", expectedException);
- }
+ RuntimeException e = CbamUtils.buildFatalFailure(logger, "msg", expectedException);
+ assertEquals("msg", e.getMessage());
+ assertEquals(expectedException, e.getCause());
+ verify(logger).error("msg", expectedException);
}
/**
@@ -118,13 +114,9 @@ public class TestCbamUtils {
@Test
public void testFatalFailureWithNoException() throws Exception {
Logger logger = Mockito.mock(Logger.class);
- try {
- CbamUtils.fatalFailure(logger, "msg");
- fail();
- } catch (RuntimeException e) {
- assertEquals("msg", e.getMessage());
- verify(logger).error("msg");
- }
+ RuntimeException e = CbamUtils.buildFatalFailure(logger, "msg");
+ assertEquals("msg", e.getMessage());
+ verify(logger).error("msg");
}
@Test
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestAdditionalParams.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestAdditionalParams.java
index e0e90000..d1afeac4 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestAdditionalParams.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestAdditionalParams.java
@@ -56,6 +56,6 @@ public class TestAdditionalParams {
}
final AbstractFieldValueChanger valueChanger = new MapValueChanger().attachNext(DefaultFieldValueChanger.INSTANCE);
- assertPojoMethodsFor(AdditionalParams.class).using(valueChanger).areWellImplemented();
+ assertPojoMethodsFor(AdditionalParameters.class).using(valueChanger).areWellImplemented();
}
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
index aa3d63c4..4b59eeb3 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
@@ -518,17 +518,16 @@ public class TestJobManager extends TestBase {
* Ongoing job are out waited during the the preparation for shutdown
*/
@Test
+ //need to wait for an asynchronous execution to finish
+ //this is the most optimal way to do it
+ @SuppressWarnings("squid:S2925")
public void onGoingJobsAreOutwaitedDuringShutdown() throws Exception {
String firstJobId = jobManager.spawnJob(VNF_ID, httpResponse);
ExecutorService executorService = Executors.newCachedThreadPool();
ArgumentCaptor<Integer> sleeps = ArgumentCaptor.forClass(Integer.class);
doNothing().when(systemFunctions).sleep(sleeps.capture());
- Future<?> shutDown = executorService.submit(new Runnable() {
- @Override
- public void run() {
- jobManager.prepareForShutdown();
- }
- });
+ //when prepare job manager for shutdown
+ Future<?> shutDown = executorService.submit(() -> jobManager.prepareForShutdown());
while (sleeps.getAllValues().size() == 0) {
try {
Thread.sleep(1);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
index 2c28bfc1..3ff53643 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
@@ -80,7 +80,7 @@ public class TestLifecycleManager extends TestBase {
private VimInfoProvider vimInfoProvider;
private ArgumentCaptor<CreateVnfRequest> createRequest = ArgumentCaptor.forClass(CreateVnfRequest.class);
- private AdditionalParams additionalParam = new AdditionalParams();
+ private AdditionalParameters additionalParam = new AdditionalParameters();
private String INSTANTIATION_LEVEL = "level1";
private GrantVNFResponseVim grantResponse = new GrantVNFResponseVim();
private String cbamVnfdContent;
@@ -178,7 +178,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
//verify
assertEquals(VNF_ID, response.getVnfInstanceId());
@@ -251,6 +251,8 @@ public class TestLifecycleManager extends TestBase {
//the 3.2 API does not accept empty array
assertNull(actualVnfModifyRequest.getValue().getVnfConfigurableProperties());
verify(jobManager).spawnJob(VNF_ID, restResponse);
+ //verify(logger).info(eq("Additional parameters for instantiation: {}"), anyString());
+ //FIXME
}
/**
@@ -261,15 +263,17 @@ public class TestLifecycleManager extends TestBase {
//given
VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OTHER_VIM_INFO);
when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(vnfInfo);
+ when(logger.isDebugEnabled()).thenReturn(false);
//when
try {
- lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verify
fail();
} catch (Exception e) {
assertEquals("Only OPENSTACK_V2_INFO, OPENSTACK_V3_INFO and VMWARE_VCLOUD_INFO is the supported VIM types", e.getMessage());
}
verify(vnfApi, never()).vnfsPost(Mockito.any(), Mockito.any());
+ verify(logger, never()).debug(eq("Additional parameters for instantiation: {}"), anyString());
verify(logger).error("Only OPENSTACK_V2_INFO, OPENSTACK_V3_INFO and VMWARE_VCLOUD_INFO is the supported VIM types");
}
@@ -293,7 +297,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -322,7 +326,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -348,7 +352,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -387,7 +391,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -425,7 +429,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -460,7 +464,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -497,7 +501,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -533,7 +537,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -567,7 +571,7 @@ public class TestLifecycleManager extends TestBase {
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenThrow(expectedException);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verfiy
waitForJobToFinishInJobManager(finished);
assertEquals(VNF_ID, response.getVnfInstanceId());
@@ -595,7 +599,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(0, actualInstantiationRequest.getAllValues().size());
//verify
@@ -632,7 +636,7 @@ public class TestLifecycleManager extends TestBase {
}
});
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verfiy
waitForJobToFinishInJobManager(finished);
assertEquals(VNF_ID, response.getVnfInstanceId());
@@ -656,7 +660,7 @@ public class TestLifecycleManager extends TestBase {
when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenThrow(expectedException);
//when
try {
- lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verify
fail();
} catch (RuntimeException e) {
@@ -679,7 +683,7 @@ public class TestLifecycleManager extends TestBase {
//when
try {
- lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verify
fail();
} catch (RuntimeException e) {
@@ -704,7 +708,7 @@ public class TestLifecycleManager extends TestBase {
when(vimInfoProvider.getVimInfo(VIM_ID)).thenThrow(new RuntimeException());
//when
- lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verify
waitForJobToFinishInJobManager(finished);
verify(vnfApi, never()).vnfsVnfInstanceIdInstantiatePost(Mockito.any(), Mockito.any(), Mockito.any());
@@ -941,7 +945,7 @@ public class TestLifecycleManager extends TestBase {
instantiationRequest.setAdditionalParam(new JsonParser().parse(src));
//when
try {
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
fail();
} catch (Exception e) {
assertEquals("The additional parameter section does not contain setting for VNF with myOnapCsarId CSAR id", e.getMessage());
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
index e26eab1a..18567f4c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
@@ -262,7 +262,7 @@ public class TestLifecycleChangeNotificationManager extends TestBase {
lifecycleChangeNotificationManager.handleLcn(recievedLcn);
//verify
Mockito.verifyZeroInteractions(operationExecutionApi);
- verify(logger).warn("The VNF with " + VNF_ID + " disappeared before being able to process the LCN");
+ verify(logger).warn("The VNF with " + VNF_ID + " identifier disappeared before being able to process the LCN");
}
/**
diff --git a/nokiav2/pom.xml b/nokiav2/pom.xml
index 5ed0e65c..f1c9f52c 100644
--- a/nokiav2/pom.xml
+++ b/nokiav2/pom.xml
@@ -31,7 +31,10 @@
<version>1.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>vfc-nfvo-driver-vnfm-svnfm-nokiav2</name>
- <modules>
+ <properties>
+ <jacoco.version>0.8.0</jacoco.version>
+ </properties>
+<modules>
<module>generatedapis</module>
<module>driver</module>
<module>driverwar</module>