From ce16741b481dbaae3a3447f84efb2b4ce5dffc82 Mon Sep 17 00:00:00 2001 From: Denes Nemeth Date: Wed, 30 May 2018 22:07:40 +0200 Subject: [PATCH] Fix template generator for R2 Change-Id: Ib686f1d29b659b64cb30f702c62ffd0ca4cd3f8b Signed-off-by: Denes Nemeth Issue-ID: VFC-728 --- nokiav2/docs/.gitignore | 2 + nokiav2/docs/sampleVnfs/simple/cbam.package.zip | Bin 0 -> 6902 bytes .../simple/{simple.csar => simple.v1.csar} | Bin .../docs/sampleVnfs/simple_cmcc/cbam.package.zip | Bin 0 -> 6902 bytes .../simple_cmcc/{simple.csar => simple.v1.csar} | Bin nokiav2/docs/sampleVnfs/simple_cmcc/simple.v2.csar | Bin 0 -> 7773 bytes .../vnfm/svnfm/nokia/NokiaSvnfmApplication.java | 8 +- .../direct/notification/GenericVnfManager.java | 3 +- .../OnapAbstractVnfdBuilder.java | 74 ++++++ ...geBuilder.java => OnapR1VnfPackageBuilder.java} | 15 +- .../packagetransformer/OnapR2VnfdBuilder.java | 276 +++++++++++++++++++++ .../nokia/packagetransformer/OnapVnfdBuilder.java | 60 ++--- .../SupportedOnapPackageVersions.java | 25 ++ .../vnfm/svnfm/nokia/restapi/ConverterApi.java | 19 +- .../vnfm/svnfm/nokia/vnfm/CatalogManager.java | 10 +- .../driver/vnfm/svnfm/nokia/vnfm/Constants.java | 2 +- .../vnfm/svnfm/nokia/vnfm/LifecycleManager.java | 35 +-- .../LifecycleChangeNotificationManager.java | 6 +- .../driver/src/main/resources/self.swagger.json | 8 +- nokiav2/driver/src/main/resources/upload.html | 7 +- .../svnfm/nokia/TestNokiaSvnfmApplication.java | 4 +- .../core/TestSelfRegistrationManagerForSo.java | 2 - .../core/TestSelfRegistrationManagerForVfc.java | 2 - .../direct/TestAAIExternalSystemInfoProvider.java | 2 +- .../vfc/TestVfcExternalSystemInfoProvider.java | 2 +- .../nokia/onap/vfc/TestVfcNotificationSender.java | 3 +- .../packagetransformer/TestOnapR2VnfdBuilder.java | 76 ++++++ .../TestOnapVnfPackageBuilder.java | 4 +- .../vnfm/svnfm/nokia/restapi/TestConverterApi.java | 10 + .../vnfm/svnfm/nokia/util/TestSystemFunctions.java | 6 +- .../driver/vnfm/svnfm/nokia/vnfm/TestBase.java | 18 +- .../svnfm/nokia/vnfm/TestCatalogManagerForSo.java | 4 +- .../svnfm/nokia/vnfm/TestCatalogManagerForVfc.java | 5 +- .../svnfm/nokia/vnfm/TestCbamCatalogManager.java | 7 +- .../nokia/vnfm/TestCbamRestApiProviderForSo.java | 4 +- .../nokia/vnfm/TestCbamRestApiProviderForVfc.java | 5 +- .../nokia/vnfm/TestCbamTokenProviderForSo.java | 4 +- .../nokia/vnfm/TestCbamTokenProviderForVfc.java | 4 +- .../vnfm/svnfm/nokia/vnfm/TestConstants.java | 2 +- .../vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java | 3 +- .../svnfm/nokia/vnfm/TestJobManagerForVfc.java | 2 +- .../svnfm/nokia/vnfm/TestLifecycleManager.java | 39 ++- .../nokia/vnfm/TestLifecycleManagerForSo.java | 5 +- .../nokia/vnfm/TestLifecycleManagerForVfc.java | 7 +- .../TestLifecycleChangeNotificationManager.java | 1 - ...stLifecycleChangeNotificationManagerForVfc.java | 1 - .../packageconverter/empty.vnfd.cbam.yaml | 8 +- .../packageconverter/empty.vnfd.onap.v2.yaml | 21 ++ .../packageconverter/nodes.vnfd.cbam.yaml | 25 +- .../packageconverter/nodes.vnfd.onap.v2.yaml | 133 ++++++++++ 50 files changed, 782 insertions(+), 177 deletions(-) create mode 100644 nokiav2/docs/sampleVnfs/simple/cbam.package.zip rename nokiav2/docs/sampleVnfs/simple/{simple.csar => simple.v1.csar} (100%) create mode 100644 nokiav2/docs/sampleVnfs/simple_cmcc/cbam.package.zip rename nokiav2/docs/sampleVnfs/simple_cmcc/{simple.csar => simple.v1.csar} (100%) create mode 100644 nokiav2/docs/sampleVnfs/simple_cmcc/simple.v2.csar create mode 100644 nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java rename nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/{OnapVnfPackageBuilder.java => OnapR1VnfPackageBuilder.java} (83%) create mode 100644 nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java create mode 100644 nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java create mode 100644 nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapR2VnfdBuilder.java create mode 100644 nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.v2.yaml create mode 100644 nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.v2.yaml diff --git a/nokiav2/docs/.gitignore b/nokiav2/docs/.gitignore index bd19fff5..b74d7233 100644 --- a/nokiav2/docs/.gitignore +++ b/nokiav2/docs/.gitignore @@ -2,3 +2,5 @@ _build .DS_Store internal.rst ims +tmp +cscf diff --git a/nokiav2/docs/sampleVnfs/simple/cbam.package.zip b/nokiav2/docs/sampleVnfs/simple/cbam.package.zip new file mode 100644 index 0000000000000000000000000000000000000000..1e0eaaf818c20ddce954cb733593212947e85dab GIT binary patch literal 6902 zcmb7I1z1#D*B+!{=xz{@9vbOJy1PTbAqR;e1OX`(fuUhgq!B@p2I-Uz=}x6f@}kH; zT<>?~D&PJ8|ID*y&Uv2M?_T??wby$0tEGyJf(5v|jD#Xp|GfF@3lBgI(9_hFli^ag z^R%|L_O#~K*TV!LE2e==F3rma8-RpzgaiPf5F>_YA%HG_G5!RKf5|%Qgm?--7{%{E zf8v5%5V-#aiM@{pg^nDlb19E__4F!_;;3@5_xBEz>F|v3FSz4EfwH8$EAAi_bxvjV zA+OivI(t0>{c0=jeH?7BN4%8PdwP2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0bX%!bez^8 zGNBjYJCx=D;Mj$Mod$yRSRCVq7UJULd`iT8ow(TX3cxv(IO{YKhC!MTtJvnFP0Jxs zp!CYPxV~Fl;Qc`YC#x8P&n6^#l?3)mCHK)5WBpMPjLFxytgD>DdmY&(&yo` z__r<4Bsk5i)V_}QqY}HPxmwjgd9ww2N5uv9BJ5+$sP$1>3C}~O>5@+^-N_7*ov|F+ zE*Gm^ljc6dXZr_k!a-T2FDey{$yC4Ar%4=d&uIf3<$a6RfzxzD%v+e#?-=6Ml}_5} zt!!=AH{YsxK5{I{65Z)6GvH=663254yrHFvbb}W8dR-O|K>im!!Ur_TT;BdBR-^t9 ztA9zqAE5tDs{R3rC~AP9VCCOIuL{@y27kTJsQ>U89Wl#a$}$4#T2=XS`9D4Vr>=a} z(>wox`iIK=e?$GJta26g1wz06)4{({FGZIB9rbsS;3sNMFf#_={~;M5X1hi%xSANh zbLAhiU5Z3aGS6@T*D_}W?zOD>=Ntc>H~(BkQ1HaHxK~&-VuEWJ^i{`yCs9`&=fns6 zMX3--*V3txBaWr p{N7@&PD6*-2)|Bqwc#M}uW2?~s;G!81^|GFj~s%hydb@N`X4B23nTyl literal 0 HcmV?d00001 diff --git a/nokiav2/docs/sampleVnfs/simple/simple.csar b/nokiav2/docs/sampleVnfs/simple/simple.v1.csar similarity index 100% rename from nokiav2/docs/sampleVnfs/simple/simple.csar rename to nokiav2/docs/sampleVnfs/simple/simple.v1.csar diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/cbam.package.zip b/nokiav2/docs/sampleVnfs/simple_cmcc/cbam.package.zip new file mode 100644 index 0000000000000000000000000000000000000000..46a85d7ad05f7a3d31625d19ebf4ce7b9e740763 GIT binary patch literal 6902 zcmb7I1z1#D*B+$1y9K0&Mx|4_yFKL*XcuKX3l}!Uxa*bTxEjrMcB? zJ*;f3Jgj*1bTI+Q3h6-OOY`)`1|XpvAOQdO*bTorDPe)vF{Ht&eQf*T$LM}~}V*$t?y#-*e- zd#87xUv=57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ILVQBJcd4k4BR2S=|i-|I6qVbWAZU7>n^8sKF@kRpwb~>wc!kH zX$Y~5L={JSQ}9rR(KD?XZJn3z%v^`yF}lHC5to>-X7-Bxw@KdQcYRG-h9q!HcY=Bq z&bY7P&Z?hUDB=Fwroy2#wUoR*OwXi!(ognjD;LQx6yjRFY1v`$If+M8Z)TN{z6_rv zylsIb!)RwEceTBql-fq-X;$ONnJzFmC@gRkV;^cnuZ`M>d+ak$mws;PNnwoYisRIB zzF6s=H1i%l+1+!!6PQi*qEf+#T;;SrUHtItoEE@A&Zl?{XPSP9WfODy9bd7Cl00AB3oT$`aCR#V)zaLH#Aj{ZqOlLugl^CDE^{H1b`;#%iG_?YSbTM z^)Ko71N6U1)jvQHMGX)br1U%JRpI*I;IH=?^&dW?BWC$aSw=uzt14eE|EH(_)RnJ# zdhb6_|4^C#Z>ay2Rj#7GK+fOmGc@zUuhzBC=~+f zS~~U9)!zx#RaYJULi%s?3W0wOwYs`ZesA_y@qq{(=#u0HO)p-1r?FS000i+Ba7fEFUT&R{s&7d3*rC( literal 0 HcmV?d00001 diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.v1.csar similarity index 100% rename from nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar rename to nokiav2/docs/sampleVnfs/simple_cmcc/simple.v1.csar diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/simple.v2.csar b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.v2.csar new file mode 100644 index 0000000000000000000000000000000000000000..dbb6cdadb8ce6f27340e1d5676598aca851127ac GIT binary patch literal 7773 zcmb7}RZtzwmbQW5ZozG%!8YzraCdii-MG8EyL)i=;O_1af)m{J&o}c|&CIDY7t>wq zVpVm&wYpY6ebKLi^cP4>FfdqHuw{=P8B9K{NFH1;uu~#1Fj_D$Fd-+9rJ12I$eBUJ z)WOEy!`9Re#2~LCA*#e+Y-DH)bTBlwHZ(T{dRjW9XhN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1E-;F`TN{YP9n(B z(@e<7AxTcrkAhpxR>@3G?LmP3|AN3^!5Y1LWJVPYucyGlz!o6Ez;M6_z+??A?UYTO zTrG`FRZMLiYz#rBKo3J(8&wrJurGiLWbJ>##T@|*9P<9}wtws;un?6oyA4Lv?pNBU zFJB7_q2LMen*>qDhJ+YIg%p0x;s$HCm#d;YKg2F8v}EBh(oK5ZZreCH)nn)c3P-`^ z#B_zBo)j2b29n~{2E6WK&R>#5AF|b=g#GSXxM01497Ki7{9rCUwe5xp{aW~#JsryR} zhvsh5)L67^-X3kYcRdMO>%dib1-G*=7tO0`a?oluu6>>i=`8kr6Gtj)`@n-0+ofiA zy0DUxS2+K4M zcgv@TX71TLSDx<*-Rxdu6l)}?hy?U8HMRAk?pit|_??uzefs3OWA>3avQrBH6h$Zd zfGCOogTe88iID=NV^8+8HX0mpRfV&A1J8C&>P28p?tu7z-d9_OK%tz!EuQ=vSbyW+ zT@PC`S-C#=Ktar|*RR`OG|y1aWhY7d*%mwai8^aFKyIeGAs_r9<)MZ^mdWS>fA}vq z-}D$aU=X(}B%$jp!bjX3gRON5?K}`jX`?<@e|+_rjU4HB!Sll!N6v#}c~<0kr5?MH zcBR?XTbyb~->EChbs*P}7o0siOf7j0Ef?LMupvLtuja?>6Y)Q~kH`e=tS=Rrp`o{x8+wzo`GOr2ivB^yMFp{vDAx|Dp1i zG%){wuXz8y0sqM-)PM5%FKqs6k^kDz|0TM886KiU5S D4hxL` literal 0 HcmV?d00001 diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java index f1c2a6f0..91240103 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java @@ -82,6 +82,10 @@ public class NokiaSvnfmApplication { this.selfRegistrationManagerForSo = selfRegistrationManagerForSo; } + private static boolean isDirect(ConfigurableApplicationContext applicationContext) { + return newHashSet(applicationContext.getEnvironment().getActiveProfiles()).contains("direct"); + } + @Override public void onApplicationEvent(ApplicationReadyEvent contextRefreshedEvent) { Callable singleRegistration = () -> { @@ -116,10 +120,6 @@ public class NokiaSvnfmApplication { }); } - private static boolean isDirect(ConfigurableApplicationContext applicationContext) { - return newHashSet(applicationContext.getEnvironment().getActiveProfiles()).contains("direct"); - } - } /** diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java index 164d3a23..48c008ac 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java @@ -100,8 +100,7 @@ public class GenericVnfManager extends AbstractManager { } if (nsId.isPresent()) { addSingletonRelation(vnf.getRelationshipList(), linkToNs(nsId.get())); - } - else{ + } else { logger.warn("Not linking VNF with {} identifier to any NS", vnfId); } aaiRestApiProvider.getNetworkApi().createOrUpdateNetworkGenericVnfsGenericVnf(vnf.getVnfId(), vnf).blockingFirst(); diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java new file mode 100644 index 00000000..f7f247a0 --- /dev/null +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java @@ -0,0 +1,74 @@ +/* + * Copyright 2016-2017, Nokia Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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; +import com.google.gson.JsonObject; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import java.util.regex.Pattern; +import org.slf4j.Logger; +import org.yaml.snakeyaml.Yaml; + +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; +import static org.slf4j.LoggerFactory.getLogger; + +/** + * Transforms a CBAM package into an ONAP package + */ +public class OnapAbstractVnfdBuilder { + public static final String DESCRIPTION = "description"; + public static final String PROPERTIES = "properties"; + public static final String REQUIREMENTS = "requirements"; + private static Logger logger = getLogger(OnapAbstractVnfdBuilder.class); + + @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"); + } + + protected static String getRequirement(JsonArray requirements, String key) { + for (int i = 0; i < requirements.size(); i++) { + JsonElement requirement = requirements.get(i); + Map.Entry next = requirement.getAsJsonObject().entrySet().iterator().next(); + String s = next.getKey(); + if (key.equals(s)) { + return next.getValue().getAsString(); + } + } + return null; + } + + private JsonElement get(String name, Set> nodes) { + for (Map.Entry node : nodes) { + if (name.equals(node.getKey())) { + return node.getValue(); + } + } + throw new NoSuchElementException("The VNFD does not have a node called " + name + " but required by an other node"); + } +} diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfPackageBuilder.java similarity index 83% rename from nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java rename to nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfPackageBuilder.java index 2a058777..6542a032 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfPackageBuilder.java @@ -33,7 +33,7 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager.getV * Transforms a CBAM package into an ONAP package */ -public class OnapVnfPackageBuilder { +public class OnapR1VnfPackageBuilder { /** * Entry point for the command line package transformer @@ -41,20 +41,23 @@ public class OnapVnfPackageBuilder { * @param args not used (required due to signature) */ public static void main(String[] args) throws Exception { - byte[] covert = new OnapVnfPackageBuilder().covert(systemFunctions().in()); + byte[] covert = new OnapR1VnfPackageBuilder().covert(systemFunctions().in(), SupportedOnapPackageVersions.V1); systemFunctions().out().write(covert); } /** - * @param zip the original CBAM package + * @param zip the original CBAM package + * @param version * @return the converted ONAP package */ - public byte[] covert(InputStream zip) throws IOException { + public byte[] covert(InputStream zip, SupportedOnapPackageVersions version) throws IOException { byte[] cbamVnfPackage = ByteStreams.toByteArray(zip); String vnfdLocation = getVnfdLocation(new ByteArrayInputStream(cbamVnfPackage)); ByteArrayOutputStream vnfdContent = getFileInZip(new ByteArrayInputStream(cbamVnfPackage), vnfdLocation); byte[] cbamVnfdContent = vnfdContent.toByteArray(); - String onapVnfd = new OnapVnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8)); + String onapVnfd = SupportedOnapPackageVersions.V2 == version ? + new OnapR2VnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8)) : + new OnapVnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8)); byte[] modifiedCbamPackage = new CbamVnfPackageBuilder().toModifiedCbamVnfPackage(cbamVnfPackage, vnfdLocation, new CbamVnfdBuilder().build(new String(cbamVnfdContent))); return buildNewOnapPackage(modifiedCbamPackage, onapVnfd); } @@ -78,6 +81,4 @@ public class OnapVnfPackageBuilder { out.close(); return result.toByteArray(); } - - } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java new file mode 100644 index 00000000..099f641c --- /dev/null +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java @@ -0,0 +1,276 @@ +/* + * Copyright 2016-2017, Nokia Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import java.util.HashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager; +import org.slf4j.Logger; +import org.yaml.snakeyaml.Yaml; + +import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfdBuilder.getRequirement; +import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfdBuilder.indent; +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; +import static org.slf4j.LoggerFactory.getLogger; + +/** + * Transforms a CBAM package into an ONAP package + */ +public class OnapR2VnfdBuilder { + public static final String DESCRIPTION = "description"; + public static final String PROPERTIES = "properties"; + public static final String REQUIREMENTS = "requirements"; + private static Logger logger = getLogger(OnapR2VnfdBuilder.class); + + private static String trimUnit(String data) { + //FIXME the unit should not be trimmed VF-C bug + return data; + //data.trim().replaceAll("[^0-9]", ""); + } + + /** + * @param cbamVnfd the CBAM VNFD + * @return the converted ONAP VNFD + */ + public String toOnapVnfd(String cbamVnfd) { + JsonObject root = new Gson().toJsonTree(new Yaml().load(cbamVnfd)).getAsJsonObject(); + JsonObject topologyTemplate = child(root, "topology_template"); + JsonObject substitution_mappings = child(topologyTemplate, "substitution_mappings"); + Map virtualLinks = new HashMap<>(); + if (topologyTemplate.has("node_templates")) { + Set> nodeTemplates = child(topologyTemplate, "node_templates").entrySet(); + + StringBuilder body = new StringBuilder(); + for (Map.Entry node : nodeTemplates) { + String type = childElement(node.getValue().getAsJsonObject(), "type").getAsString(); + if ("tosca.nodes.nfv.VDU".equals(type)) { + body.append(buildVdu(node.getKey(), substitution_mappings, node.getValue().getAsJsonObject(), nodeTemplates)); + } else if ("tosca.nodes.nfv.VirtualStorage".equals(type)) { + body.append(buildVolume(node.getKey(), node.getValue().getAsJsonObject())); + } else if ("tosca.nodes.nfv.VL".equals(type)) { + virtualLinks.put(node.getKey(), node.getValue()); + body.append(buildVl(node.getValue().getAsJsonObject().get(PROPERTIES).getAsJsonObject(), node.getKey())); + } else if ("tosca.nodes.nfv.ICP".equals(type)) { + body.append(buildIcp(node.getKey(), node.getValue().getAsJsonObject())); + } else if ("tosca.nodes.nfv.ECP".equals(type)) { + body.append(buildEcp(node.getKey(), node.getValue(), nodeTemplates)); + } else { + logger.warn("The {} type is not converted", type); + } + } + return buildHeader(topologyTemplate, virtualLinks) + body.toString(); + } + return buildHeader(topologyTemplate, virtualLinks); + } + + private String buildHeader(JsonObject toplogyTemplate, Map virtualLinks) { + JsonObject substitution_mappings = child(toplogyTemplate, "substitution_mappings"); + String vnfContent = buildVnf(substitution_mappings, virtualLinks); + return "tosca_definitions_version: tosca_simple_profile_yaml_1_1\n" + + "\n" + + "topology_template:\n" + + " inputs:\n" + + " etsi_config:\n" + + " type: string\n" + + " description: The ETSI configuration\n" + + " node_templates:\n" + vnfContent; + } + + private JsonElement get(String name, Set> nodes) { + for (Map.Entry node : nodes) { + if (name.equals(node.getKey())) { + return node.getValue(); + } + } + throw new NoSuchElementException("The VNFD does not have a node called " + name + " but required by an other node"); + } + + private String buildVdu(String name, JsonObject vnf, JsonObject vdu, Set> nodes) { + String memorySize = ""; + String cpuCount = ""; + StringBuilder body = new StringBuilder(); + JsonArray vduRequirements = childElement(vdu.getAsJsonObject(), REQUIREMENTS).getAsJsonArray(); + for (int i = 0; i < vduRequirements.size(); i++) { + JsonObject requirement = vduRequirements.get(i).getAsJsonObject(); + Map.Entry next = requirement.entrySet().iterator().next(); + String s = next.getKey(); + if ("virtual_compute".equals(s)) { + JsonObject virtualCompute = get(next.getValue().getAsString(), nodes).getAsJsonObject(); + cpuCount = childElement(child(child(virtualCompute, PROPERTIES), "virtual_cpu"), "num_virtual_cpu").getAsString(); + memorySize = trimUnit(childElement(child(child(virtualCompute, PROPERTIES), "virtual_memory"), "virtual_mem_size").getAsString()); + } else if ("virtual_storage".equals(s)) { + String item = indent( + "- virtual_storage:\n" + + " capability: tosca.capabilities.nfv.VirtualStorage\n" + + " node: " + next.getValue().getAsString() + "\n", 4); + body.append(item); + } + next.getValue(); + } + JsonObject flavourProperties = child(child(child(vnf, "capabilities"), "deployment_flavour"), "properties"); + JsonObject vduSizes = child(child(flavourProperties, "vdu_profile"), name); + String header = indent(name + ":\n" + + " type: tosca.nodes.nfv.Vdu.Compute\n" + + " properties:\n" + + " name: " + name + "\n" + + " description: " + childElement(child(vdu, PROPERTIES), "description").getAsString() + "\n" + + " configurable_properties:\n" + + " vdu_profile:\n" + + " min_number_of_instances: " + childElement(vduSizes, "min_number_of_instances").getAsString() + "\n" + + " max_number_of_instances: " + childElement(vduSizes, "max_number_of_instances").getAsString() + "\n" + + " capabilities:\n" + + " virtual_compute:\n" + + indent( + "properties:\n" + + " virtual_memory:\n" + + " virtual_mem_size: " + trimUnit(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> nodes) { + if (ecp.getAsJsonObject().has(REQUIREMENTS)) { + String icpName = getRequirement(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "internal_connection_point"); + if (icpName != null) { + return buildEcpInternal(name, icpName, nodes); + } else { + logger.warn("The {} ecp does not have an internal connection point", name); + } + } else { + logger.warn("The {} ecp does not have an requirements section", name); + } + return ""; + } + + private String buildVnf(JsonObject vnf, Map virtualLinks) { + JsonObject vnfProperties = child(vnf, PROPERTIES); + JsonObject flavourProperties = child(child(child(vnf, "capabilities"), "deployment_flavour"), "properties"); + StringBuilder vlContent = new StringBuilder(); + for (Map.Entry virtualLink : virtualLinks.entrySet()) { + vlContent.append(indent("- virtual_link:\n" + + " capability: tosca.capabilities.nfv.VirtualLinkable\n" + + " node: " + virtualLink.getKey() + "\n", 4)); + } + return indent("VNF:\n" + + " type: tosca.nodes.nfv.VNF\n" + + " " + PROPERTIES + ":\n" + + " descriptor_id: " + childElement(vnfProperties, "descriptor_id").getAsString() + "\n" + + " descriptor_version: " + childElement(vnfProperties, "descriptor_version").getAsString() + "\n" + + " provider: " + childElement(vnfProperties, "provider").getAsString() + "\n" + + " product_name: " + childElement(vnfProperties, "product_name").getAsString() + "\n" + + " software_version: " + childElement(vnfProperties, "software_version").getAsString() + "\n" + + " product_info_name: " + childElement(vnfProperties, "product_info_name").getAsString() + "\n" + + (vnfProperties.has("product_info_description") ? + " product_info_description: " + childElement(vnfProperties, "product_info_description").getAsString() + "\n" : "") + + " vnfm_info: [ " + SelfRegistrationManager.SERVICE_NAME + " ]\n" + + " flavour_id: " + childElement(flavourProperties, "flavour_id").getAsString() + "\n" + + " flavour_description: " + childElement(flavourProperties, "description").getAsString() + "\n", 2) + + " " + REQUIREMENTS + ":\n" + + vlContent.toString(); + } + + private String buildEcpInternal(String ecpName, String icpName, Set> nodes) { + JsonObject icpNode = get(icpName, nodes).getAsJsonObject(); + if (icpNode.has(REQUIREMENTS)) { + String vdu = getRequirement(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "virtual_binding"); + //internal connection point is bound to VDU + if (vdu != null) { + return buildVduCpd(ecpName, vdu, child(icpNode, PROPERTIES)); + } else { + logger.warn("The {} internal connection point of the {} ecp does not have a VDU", icpName, ecpName); + } + } else { + logger.warn("The {} internal connection point of the {} ecp does not have a requirements section", icpName, ecpName); + } + return ""; + } + + private String buildIcp(String name, JsonObject icp) { + if (icp.has(REQUIREMENTS)) { + JsonArray requirements = icp.get(REQUIREMENTS).getAsJsonArray(); + String vdu = getRequirement(requirements, "virtual_binding"); + String vl = getRequirement(requirements, "virtual_link"); + if (vdu == null) { + logger.warn("The {} internal connection point does not have a VDU", name); + } else if (vl == null) { + logger.warn("The {} internal connection point does not have a VL", name); + } else { + JsonObject properties = child(icp, PROPERTIES); + return indent(name + ":\n" + + " type: tosca.nodes.nfv.VduCp\n" + + " " + PROPERTIES + ":\n" + + " layer_protocol: [ " + childElement(properties, "layer_protocol").getAsString() + " ]\n" + + (properties.has(DESCRIPTION) ? + " description: " + childElement(properties, DESCRIPTION).getAsString() + "\n" : "") + + " protocol_data: []\n" + + " trunk_mode: false\n" + + " requirements:\n" + + " - virtual_binding: " + vdu + "\n" + + " - virtual_link: " + vl + "\n", 2); + } + } else { + logger.warn("The {} internal connection point does not have a requirements section", name); + } + return ""; + } + + private String buildVduCpd(String name, String vdu, JsonObject properties) { + return indent(name + ":\n" + + " type: tosca.nodes.nfv.VduCp\n" + + " " + PROPERTIES + ":\n" + + " layer_protocol: [ " + childElement(properties, "layer_protocol").getAsString() + " ]\n" + + " protocol_data: [ ]\n" + + " trunk_mode: false\n" + + (properties.has(DESCRIPTION) ? + " description: " + childElement(properties, DESCRIPTION).getAsString() + "\n" : "") + + " requirements:\n" + + " - virtual_binding: " + vdu + "\n", 2); + } + + private String buildVolume(String nodeName, JsonObject volume) { + return indent(nodeName + ":\n" + + " type: tosca.nodes.nfv.Vdu.VirtualStorage\n" + + " properties:\n" + + " type_of_storage: volume\n" + + " size_of_storage: " + trimUnit(childElement(child(volume, PROPERTIES), "size_of_storage").getAsString()) + "\n", 2); + } + + private String buildVl(JsonObject vlProperties, String name) { + return indent(name + ":\n" + + " type: tosca.nodes.nfv.VnfVirtualLink\n" + + " properties:\n" + + " connectivity_type:\n" + + " layer_protocol: [ " + childElement(child(vlProperties, "connectivity_type"), "layer_protocol").getAsString() + " ]\n" + + " flow_pattern: " + childElement(child(vlProperties, "connectivity_type"), "flow_pattern").getAsString() + "\n" + + " vl_profile:\n" + + " max_bit_rate_requirements:\n" + + " root: " + Integer.MAX_VALUE + "\n" + //FIXME GAP IN CBAM TEMPLATE + " leaf: " + Integer.MAX_VALUE + "\n" + //FIXME GAP IN CBAM TEMPLATE + " min_bit_rate_requirements:\n" + + " root: 0\n" + //FIXME GAP IN CBAM TEMPLATE + " leaf: 0\n", 2); //FIXME GAP IN CBAM TEMPLATE + } +} 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 406f0033..b5dd9616 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 @@ -56,6 +56,18 @@ public class OnapVnfdBuilder { return data.trim().replaceAll("[^0-9]", ""); } + public static String getRequirement(JsonArray requirements, String key) { + for (int i = 0; i < requirements.size(); i++) { + JsonElement requirement = requirements.get(i); + Map.Entry next = requirement.getAsJsonObject().entrySet().iterator().next(); + String s = next.getKey(); + if (key.equals(s)) { + return next.getValue().getAsString(); + } + } + return null; + } + /** * @param cbamVnfd the CBAM VNFD * @return the converted ONAP VNFD @@ -104,8 +116,8 @@ public class OnapVnfdBuilder { "topology_template:\n" + " inputs:\n" + " etsi_config:\n" + - " type: string\n"+ - " description: The ETSI configuration\n"+ + " type: string\n" + + " description: The ETSI configuration\n" + " node_templates:\n"; } @@ -157,7 +169,7 @@ public class OnapVnfdBuilder { private String buildEcp(String name, JsonElement ecp, Set> nodes) { if (ecp.getAsJsonObject().has(REQUIREMENTS)) { - String icpName = getIcpName(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray()); + String icpName = getRequirement(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "internal_connection_point"); if (icpName != null) { return buildEcpInternal(name, icpName, nodes); } else { @@ -172,7 +184,7 @@ public class OnapVnfdBuilder { private String buildEcpInternal(String ecpName, String icpName, Set> nodes) { JsonObject icpNode = get(icpName, nodes).getAsJsonObject(); if (icpNode.has(REQUIREMENTS)) { - String vdu = getVduOfIcp(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray()); + String vdu = getRequirement(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "virtual_binding"); //internal connection point is bound to VDU if (vdu != null) { return buildVduCpd(ecpName, vdu, child(icpNode, PROPERTIES)); @@ -185,47 +197,11 @@ public class OnapVnfdBuilder { return ""; } - private String getVduOfIcp(JsonArray icpRequirements) { - String vdu = null; - for (int i = 0; i < icpRequirements.size(); i++) { - JsonElement requirement = icpRequirements.get(i); - Map.Entry next = requirement.getAsJsonObject().entrySet().iterator().next(); - String s = next.getKey(); - if ("virtual_binding".equals(s)) { - vdu = next.getValue().getAsString(); - } - } - return vdu; - } - - private String getIcpName(JsonArray requirements) { - String icpName = null; - for (int i = 0; i < requirements.size(); i++) { - JsonElement requirement = requirements.get(i); - Map.Entry next = requirement.getAsJsonObject().entrySet().iterator().next(); - String s = next.getKey(); - if ("internal_connection_point".equals(s)) { - icpName = next.getValue().getAsString(); - } - } - return icpName; - } - private String buildIcp(String name, JsonObject icp) { if (icp.has(REQUIREMENTS)) { JsonArray requirements = icp.get(REQUIREMENTS).getAsJsonArray(); - String vdu = null; - String vl = null; - for (int i = 0; i < requirements.size(); i++) { - JsonElement requirement = requirements.get(i); - Map.Entry next = requirement.getAsJsonObject().entrySet().iterator().next(); - String s = next.getKey(); - if ("virtual_binding".equals(s)) { - vdu = next.getValue().getAsString(); - } else if ("virtual_link".equals(s)) { - vl = next.getValue().getAsString(); - } - } + String vdu = getRequirement(requirements, "virtual_binding"); + String vl = getRequirement(requirements, "virtual_link"); if (vdu == null) { logger.warn("The {} internal connection point does not have a VDU", name); } else if (vl == null) { diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java new file mode 100644 index 00000000..545b2d9e --- /dev/null +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java @@ -0,0 +1,25 @@ +/* + * Copyright 2016-2017, Nokia Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer; + +/** + * The supported ONAP package versions + */ +public enum SupportedOnapPackageVersions { + V1, + V2 +} \ No newline at end of file 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 5ecd884c..95438caa 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,13 +15,15 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi; +import com.google.common.base.Charsets; import com.google.common.io.ByteStreams; import java.io.ByteArrayInputStream; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.Part; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfPackageBuilder; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapR1VnfPackageBuilder; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.SupportedOnapPackageVersions; import org.slf4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -45,7 +47,7 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST; @RequestMapping(value = BASE_URL) public class ConverterApi { private static Logger logger = getLogger(ConverterApi.class); - private OnapVnfPackageBuilder vnfPackageConverter = new OnapVnfPackageBuilder(); + private OnapR1VnfPackageBuilder vnfPackageConverter = new OnapR1VnfPackageBuilder(); /** * Return the converted ONAP package @@ -57,16 +59,23 @@ public class ConverterApi { @ResponseBody public void convert(HttpServletResponse httpResponse, HttpServletRequest request) throws IOException { logger.info("REST: convert package"); + SupportedOnapPackageVersions version; + try { + request.getPart("version"); + version = SupportedOnapPackageVersions.valueOf(new String(ByteStreams.toByteArray(request.getPart("version").getInputStream()), Charsets.UTF_8)); + } catch (Exception e) { + throw buildFatalFailure(logger, "Unable to determine the desired ONAP package version", e); + } byte[] content; try { - Part part = request.getPart("fileToUpload"); - content = ByteStreams.toByteArray(part.getInputStream()); + Part uploadedFile = request.getPart("fileToUpload"); + content = ByteStreams.toByteArray(uploadedFile.getInputStream()); } catch (Exception e) { throw buildFatalFailure(logger, "Unable to extract package from REST parameters", e); } byte[] convertedPackage; try { - convertedPackage = vnfPackageConverter.covert(new ByteArrayInputStream(content)); + convertedPackage = vnfPackageConverter.covert(new ByteArrayInputStream(content), version); } catch (Exception e) { throw buildFatalFailure(logger, "Unable to convert VNF package", e); } 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 0993c6ee..ad02437d 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 @@ -52,7 +52,7 @@ public class CatalogManager { * The location of the CBAM package within the ONAP package */ public static final String CBAM_PACKAGE_NAME_IN_ZIP = "Artifacts/Deployment/OTHER/cbam.package.zip"; - public static final String ETSI_CONFIG_NAME_IN_ZIP = "Artifacts/Deployment/OTHER/" + ETSI_CONFIG +".json"; + public static final String ETSI_CONFIG_NAME_IN_ZIP = "Artifacts/Deployment/OTHER/" + ETSI_CONFIG + ".json"; private static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta"; private static final String TOSCA_VNFD_KEY = "Entry-Definitions"; @@ -112,7 +112,7 @@ public class CatalogManager { public CatalogAdapterVnfpackage preparePackageInCbam(String vnfmId, String csarId) { String cbamVnfdId = packageProvider.getCbamVnfdId(csarId); DefaultApi cbamCatalogApi = cbamRestApiProvider.getCbamCatalogApi(vnfmId); - if (!isPackageReplicated(cbamVnfdId, cbamCatalogApi)) { + if (!isPackageReplicated(cbamVnfdId, cbamCatalogApi)) { try { ByteArrayOutputStream cbamPackage = getFileInZip(new ByteArrayInputStream(packageProvider.getPackage(csarId)), CBAM_PACKAGE_NAME_IN_ZIP); return cbamCatalogApi.create(create(parse(APPLICATION_OCTET_STREAM.toString()), cbamPackage.toByteArray())).blockingFirst(); @@ -133,15 +133,15 @@ public class CatalogManager { /** * Download the ETSI configuration of the VNF + * * @param csarId the CSAR identifier of the package in ONAP catalog * @return the content of the ETSI configuration */ - public String getEtsiConfiguration(String csarId){ + public String getEtsiConfiguration(String csarId) { try { ByteArrayOutputStream etsiConfig = getFileInZip(new ByteArrayInputStream(packageProvider.getPackage(csarId)), ETSI_CONFIG_NAME_IN_ZIP); return new String(etsiConfig.toByteArray(), Charsets.UTF_8); - } - catch (Exception e){ + } catch (Exception e) { throw buildFatalFailure(logger, "Unable to download the ETSI configuration file"); } } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java index 1b6b4eb2..5342b4fd 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java @@ -27,7 +27,7 @@ public class Constants { public static final String BASE_URL = "/api" + BASE_SUFFIX; public static final String LCN_URL = "/lcn"; - private Constants(){ + private Constants() { //use in static way } } 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 e36ede4e..f64ce1e0 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 @@ -18,8 +18,6 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm; import com.google.common.base.Joiner; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -30,8 +28,6 @@ import com.nokia.cbam.lcm.v32.model.ScaleDirection; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.servlet.http.HttpServletResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.IGrantManager; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VimInfoProvider; @@ -45,6 +41,7 @@ import org.yaml.snakeyaml.Yaml; import static java.lang.Integer.parseInt; import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.stream.Collectors.toList; import static com.google.common.base.Splitter.on; import static com.google.common.collect.Iterables.find; @@ -302,17 +299,15 @@ public class LifecycleManager { private AdditionalParameters convertInstantiationAdditionalParams(String csarId, Object additionalParams) { JsonObject root = new Gson().toJsonTree(additionalParams).getAsJsonObject(); - if(root.has(PROPERTIES)){ + if (root.has(PROPERTIES)) { JsonObject properties = new JsonParser().parse(root.get(PROPERTIES).getAsString()).getAsJsonObject(); - if(properties.has(ETSI_CONFIG)){ + if (properties.has(ETSI_CONFIG)) { JsonElement etsiConfig = properties.get(ETSI_CONFIG); return new Gson().fromJson(etsiConfig.getAsString(), AdditionalParameters.class); + } else { + logger.info("The instantiation input for VNF with {} CSAR id does not have an " + ETSI_CONFIG + " section", csarId); } - else{ - logger.info("The instantiation input for VNF with {} CSAR id does not have an " + ETSI_CONFIG +" section", csarId); - } - } - else{ + } else { logger.info("The instantiation input for VNF with {} CSAR id does not have a properties section", csarId); } JsonObject inputs = child(root, "inputs"); @@ -333,14 +328,11 @@ public class LifecycleManager { private Set> getAcceptableOperationParameters(String vnfdContent, String operationName) { JsonObject root = new Gson().toJsonTree(new Yaml().load(vnfdContent)).getAsJsonObject(); JsonObject interfaces = child(child(child(root, "topology_template"), "substitution_mappings"), "interfaces"); - for (Map.Entry categoryOfOperation : interfaces.entrySet()) { - for (Map.Entry operation : categoryOfOperation.getValue().getAsJsonObject().entrySet()) { - if(operation.getKey().equals(operationName)){ - JsonObject additionalParameters = child(child(operation.getValue().getAsJsonObject(), "inputs"), "additional_parameters"); - return additionalParameters.entrySet(); - } + List>> operations = interfaces.entrySet().stream().map(m -> m.getValue().getAsJsonObject().entrySet().stream().collect(toList())).collect(toList()); + for (Map.Entry operation : operations.stream().flatMap(List::stream).collect(toList())) { + if (operation.getKey().equals(operationName)) { + return child(child(operation.getValue().getAsJsonObject(), "inputs"), "additional_parameters").entrySet(); } - logger.debug("The {} operation was not found in {} interface", operationName, categoryOfOperation.getKey()); } throw buildFatalFailure(logger, "Unable to find operation named " + operationName); } @@ -384,14 +376,13 @@ public class LifecycleManager { } } - private void addSpecifiedExtensions(String vnfmId, String vnfId, AdditionalParameters additionalParameters){ - if(!additionalParameters.getExtensions().isEmpty()){ + private void addSpecifiedExtensions(String vnfmId, String vnfId, AdditionalParameters additionalParameters) { + if (!additionalParameters.getExtensions().isEmpty()) { ModifyVnfInfoRequest request = new ModifyVnfInfoRequest(); request.setExtensions(new ArrayList<>()); request.getExtensions().addAll(additionalParameters.getExtensions()); executeModifyVnfInfo(vnfmId, vnfId, request); - } - else{ + } else { logger.info("No extensions specified for VNF with {} identifier", vnfId); } } 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 c4cd4342..8d5ad490 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 @@ -218,11 +218,9 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif } else { return handleFailure(operationExecution); } - } - catch(OperationMustBeAborted handledFailuire){ + } catch (OperationMustBeAborted handledFailuire) { throw handledFailuire; - } - catch (Exception e) { + } catch (Exception e) { logger.warn("Unable to build affected connection points", e); return toleratedFailure(); } diff --git a/nokiav2/driver/src/main/resources/self.swagger.json b/nokiav2/driver/src/main/resources/self.swagger.json index 37da1b30..2645cd0e 100644 --- a/nokiav2/driver/src/main/resources/self.swagger.json +++ b/nokiav2/driver/src/main/resources/self.swagger.json @@ -1046,8 +1046,14 @@ { "description": "The CBAM VNF package", "in": "formData", - "name": "upfile", + "name": "fileToUpload", "type": "file" + }, + { + "description": "ONAP version of the package", + "in": "formData", + "name": "version", + "type": "string" } ], "summary": "Converts the Nokia CBAM package to ONAP package", diff --git a/nokiav2/driver/src/main/resources/upload.html b/nokiav2/driver/src/main/resources/upload.html index a5c686f4..ace9d2e4 100644 --- a/nokiav2/driver/src/main/resources/upload.html +++ b/nokiav2/driver/src/main/resources/upload.html @@ -4,9 +4,12 @@
Select CBAM package to upload: - + ONAP package version: +
- \ No newline at end of file diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java index 8964c80b..e727602f 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java @@ -167,7 +167,7 @@ public class TestNokiaSvnfmApplication extends TestBase { doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { - if(calls.size() == 0){ + if (calls.size() == 0) { calls.add(true); throw e2; } @@ -209,7 +209,7 @@ public class TestNokiaSvnfmApplication extends TestBase { doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { - if(calls.size() == 0){ + if (calls.size() == 0) { calls.add(true); throw e2; } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForSo.java index 4fd5a022..1ee48c8f 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForSo.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForSo.java @@ -20,10 +20,8 @@ import org.mockito.Mockito; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcNotificationSender; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc; import static junit.framework.TestCase.assertNotNull; -import static org.junit.Assert.*; public class TestSelfRegistrationManagerForSo extends TestBase { @Test diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForVfc.java index aee54a97..4e98d2c0 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForVfc.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForVfc.java @@ -17,9 +17,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core; import org.junit.Test; import org.mockito.Mockito; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcNotificationSender; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase; import static junit.framework.TestCase.assertNotNull; diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIExternalSystemInfoProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIExternalSystemInfoProvider.java index fd5f112e..3d1e3c82 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIExternalSystemInfoProvider.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIExternalSystemInfoProvider.java @@ -202,7 +202,7 @@ public class TestAAIExternalSystemInfoProvider extends TestBase { * the list of VNFMs is retrieved from AAI */ @Test - public void testQueryAAIExternaSystemProvider() throws Exception{ + public void testQueryAAIExternaSystemProvider() throws Exception { EsrVnfmList e = new EsrVnfmList(); EsrVnfm esrVnfmItem = new EsrVnfm(); esrVnfmItem.setVnfmId(VNFM_ID); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java index 60256049..3e585d1d 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java @@ -102,7 +102,7 @@ public class TestVfcExternalSystemInfoProvider extends TestBase { * The VNFM identifier is loaded from property files */ @Test - public void testGetVnfms(){ + public void testGetVnfms() { setFieldWithPropertyAnnotation(vfcExternalSystemInfoProvider, "${vnfmId}", "myVnfmId"); assertEquals(Sets.newHashSet("myVnfmId"), vfcExternalSystemInfoProvider.getVnfms()); } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java index ed6375fa..0eba92dd 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java @@ -41,7 +41,8 @@ import org.threeten.bp.OffsetDateTime; import static java.util.Optional.empty; import static java.util.Optional.of; -import static junit.framework.TestCase.*; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.fail; import static org.mockito.Mockito.*; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION; import static org.springframework.test.util.ReflectionTestUtils.setField; diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapR2VnfdBuilder.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapR2VnfdBuilder.java new file mode 100644 index 00000000..6916d382 --- /dev/null +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapR2VnfdBuilder.java @@ -0,0 +1,76 @@ +/* + * Copyright 2016-2017, Nokia Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer; + +import java.util.NoSuchElementException; +import org.junit.Before; +import org.junit.Test; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase; + +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.fail; +import static org.springframework.test.util.ReflectionTestUtils.setField; + + +public class TestOnapR2VnfdBuilder extends TestBase { + private OnapR2VnfdBuilder packageTransformer = new OnapR2VnfdBuilder(); + + + @Before + public void init() { + setField(OnapVnfdBuilder.class, "logger", logger); + } + + + /** + * Test empty VNFD conversion + */ + @Test + public void testEmpty() { + assertEquals(new String(TestUtil.loadFile("unittests/packageconverter/empty.vnfd.onap.v2.yaml")), packageTransformer.toOnapVnfd(new String(TestUtil.loadFile("unittests/packageconverter/empty.vnfd.cbam.yaml")))); + } + + /** + * Test all Tosca nodes conversions for successful scenario + */ + @Test + public void testNodes() { + assertEquals(new String(TestUtil.loadFile("unittests/packageconverter/nodes.vnfd.onap.v2.yaml")), packageTransformer.toOnapVnfd(new String(TestUtil.loadFile("unittests/packageconverter/nodes.vnfd.cbam.yaml")))); + /* verify(logger).warn("The {} ecp does not have an internal connection point", "myEcpWithoutIcp"); + verify(logger).warn("The {} ecp does not have an requirements section", "ecpWithIcpWithOutRequirements"); + verify(logger).warn("The {} internal connection point of the {} ecp does not have a VDU", "icpWithoutVdu", "myEcpWithoutIcpWithoutVdu"); + verify(logger).warn("The {} internal connection point of the {} ecp does not have a requirements section", "icpWithOutRequiements", "myEcpWithoutIcpWithoutIcpReq"); + verify(logger).warn("The {} internal connection point does not have a VDU", "icpWithOutVdu"); + verify(logger).warn("The {} internal connection point does not have a requirements section", "icpWithOutRequiements"); + verify(logger).warn("The {} internal connection point does not have a VL", "icpWithOutVl"); + verify(logger).warn("The {} type is not converted", "tosca.nodes.nfv.Unknown")*/ + } + + /** + * if a node refers to a non existing node it results in a failure + */ + @Test + public void testInconsitentVnfd() { + try { + packageTransformer.toOnapVnfd(new String(TestUtil.loadFile("unittests/packageconverter/nodes.vnfd.inconsistent.cbam.yaml"))); + fail(); + } catch (NoSuchElementException e) { + assertEquals("The VNFD does not have a node called myComputeMissing but required by an other node", e.getMessage()); + } + } + +} diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java index 1abb432f..55949ab0 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java @@ -49,7 +49,7 @@ public class TestOnapVnfPackageBuilder extends TestBase { String expectedOnapVnfd = new OnapVnfdBuilder().toOnapVnfd(cbamVnfd); //when - OnapVnfPackageBuilder.main(null); + OnapR1VnfPackageBuilder.main(null); //verify assertFileInZip(bos.toByteArray(), "TOSCA-Metadata/TOSCA.meta", TestUtil.loadFile("TOSCA.meta")); assertFileInZip(bos.toByteArray(), "MainServiceTemplate.yaml", expectedOnapVnfd.getBytes()); @@ -65,7 +65,7 @@ public class TestOnapVnfPackageBuilder extends TestBase { */ @Test public void testPreventMove() { - assertEquals("b3JnLm9uYXAudmZjLm5mdm8uZHJpdmVyLnZuZm0uc3ZuZm0ubm9raWEucGFja2FnZXRyYW5zZm9ybWVyLk9uYXBWbmZQYWNrYWdlQnVpbGRlcg==", Base64.getEncoder().encodeToString(OnapVnfPackageBuilder.class.getCanonicalName().getBytes())); + assertEquals("b3JnLm9uYXAudmZjLm5mdm8uZHJpdmVyLnZuZm0uc3ZuZm0ubm9raWEucGFja2FnZXRyYW5zZm9ybWVyLk9uYXBSMVZuZlBhY2thZ2VCdWlsZGVy", Base64.getEncoder().encodeToString(OnapR1VnfPackageBuilder.class.getCanonicalName().getBytes())); } 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 8a79a33a..48d2cab0 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 @@ -73,6 +73,9 @@ public class TestConverterApi extends TestBase { Part part = Mockito.mock(Part.class); when(part.getInputStream()).thenReturn(new ByteArrayInputStream(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip"))); when(httpRequest.getPart("fileToUpload")).thenReturn(part); + Part part2 = Mockito.mock(Part.class); + when(httpRequest.getPart("version")).thenReturn(part2); + when(part2.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes())); //when converterApi.convert(httpResponse, httpRequest); //verify @@ -117,6 +120,9 @@ public class TestConverterApi extends TestBase { public void testUnableToExtractPackageToBeConverted() throws Exception { IOException expectedException = new IOException(); when(httpRequest.getPart("fileToUpload")).thenThrow(expectedException); + Part part = Mockito.mock(Part.class); + when(httpRequest.getPart("version")).thenReturn(part); + when(part.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes())); try { converterApi.convert(httpResponse, httpRequest); fail(); @@ -135,6 +141,10 @@ public class TestConverterApi extends TestBase { Part part = Mockito.mock(Part.class); when(part.getInputStream()).thenReturn(new ByteArrayInputStream(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip"))); when(httpRequest.getPart("fileToUpload")).thenReturn(part); + + Part part2 = Mockito.mock(Part.class); + when(httpRequest.getPart("version")).thenReturn(part2); + when(part2.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes())); try { converterApi.convert(httpResponse, httpRequest); fail(); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java index 1b34d28b..749b249d 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java @@ -64,16 +64,16 @@ public class TestSystemFunctions { Inter inter = new Inter(); inter.start(); //wait for thread to enter waiting - while(!entered.get() && inter.getState() != Thread.State.TIMED_WAITING && (System.currentTimeMillis() < start + 60*1000) ){ + while (!entered.get() && inter.getState() != Thread.State.TIMED_WAITING && (System.currentTimeMillis() < start + 60 * 1000)) { Thread.sleep(10); } - if(!(System.currentTimeMillis() < start + 60*1000)){ + if (!(System.currentTimeMillis() < start + 60 * 1000)) { throw new RuntimeException("Thread did not enter waiting state"); } //when inter.interrupt(); //verify - while (exceptions.size() != 1 && (System.currentTimeMillis() < start + 60*1000)) { + while (exceptions.size() != 1 && (System.currentTimeMillis() < start + 60 * 1000)) { Thread.sleep(10); } assertEquals(1, exceptions.size()); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java index cee26fd1..67efe84a 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java @@ -67,9 +67,7 @@ import org.springframework.test.util.ReflectionTestUtils; import retrofit2.Call; import retrofit2.Response; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.*; import static org.mockito.Mockito.when; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager.getFileInZip; @@ -250,6 +248,13 @@ public class TestBase { throw new NoSuchElementException("The " + obj.getClass() + " does not have a filed with " + key + " annotation"); } + protected void assertBean(Class clazz) { + assertEquals(1, clazz.getDeclaredConstructors().length); + Autowired annotation = clazz.getDeclaredConstructors()[0].getAnnotation(Autowired.class); + assertNotNull(annotation); + assertNotNull(clazz.getAnnotation(Component.class)); + } + public static class VoidObservable { boolean called = false; ObservableFromCallable s = new ObservableFromCallable(new Callable() { @@ -268,11 +273,4 @@ public class TestBase { return s; } } - - protected void assertBean(Class clazz){ - assertEquals(1, clazz.getDeclaredConstructors().length); - Autowired annotation = clazz.getDeclaredConstructors()[0].getAnnotation(Autowired.class); - assertNotNull(annotation); - assertNotNull(clazz.getAnnotation(Component.class)); - } } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java index 8d2094b1..9eed2d8e 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java @@ -21,12 +21,12 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.SdcPackageProvider; import static junit.framework.TestCase.assertNotNull; -public class TestCatalogManagerForSo extends TestBase{ +public class TestCatalogManagerForSo extends TestBase { /** * Test bean */ @Test - public void testPojo(){ + public void testPojo() { SdcPackageProvider sdcPackageProvider = Mockito.mock(SdcPackageProvider.class); CatalogManagerForSo catalogManagerForSo = new CatalogManagerForSo(cbamRestApiProviderForSo, sdcPackageProvider); assertNotNull(catalogManagerForSo); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java index 1a21bd51..a4068d40 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java @@ -17,17 +17,16 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm; import org.junit.Test; import org.mockito.Mockito; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.SdcPackageProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcPackageProvider; import static junit.framework.TestCase.assertNotNull; -public class TestCatalogManagerForVfc extends TestBase{ +public class TestCatalogManagerForVfc extends TestBase { /** * Test bean */ @Test - public void testPojo(){ + public void testPojo() { VfcPackageProvider vfcPackageProvider = Mockito.mock(VfcPackageProvider.class); CatalogManagerForVfc catalogManagerForVfc = new CatalogManagerForVfc(cbamRestApiProviderForVfc, vfcPackageProvider); assertNotNull(catalogManagerForVfc); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java index 28e4709a..f1e1a10c 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java @@ -255,7 +255,7 @@ public class TestCbamCatalogManager extends TestBase { * ETSI configuration extraction from the package */ @Test - public void testEtsiConfigurationDownload() throws Exception{ + public void testEtsiConfigurationDownload() throws Exception { //given byte[] onapPackageContent = TestUtil.loadFile("unittests/TestCbamCatalogManager.sample.csar"); when(packageProvider.getPackage(CSAR_ID)).thenReturn(onapPackageContent); @@ -269,7 +269,7 @@ public class TestCbamCatalogManager extends TestBase { * ETSI configuration extraction from the package */ @Test - public void testEtsiConfigurationMissing() throws Exception{ + public void testEtsiConfigurationMissing() throws Exception { //given byte[] onapPackageContent = TestUtil.loadFile("unittests/missing.vnfd.zip"); when(packageProvider.getPackage(CSAR_ID)).thenReturn(onapPackageContent); @@ -277,8 +277,7 @@ public class TestCbamCatalogManager extends TestBase { try { cbamCatalogManager.getEtsiConfiguration(CSAR_ID); fail(); - } - catch (Exception e){ + } catch (Exception e) { assertEquals("Unable to download the ETSI configuration file", e.getMessage()); verify(logger).error("Unable to download the ETSI configuration file"); } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java index dcc6e424..24f4602d 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java @@ -22,9 +22,9 @@ import org.mockito.Mockito; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider; -public class TestCbamRestApiProviderForSo extends TestBase{ +public class TestCbamRestApiProviderForSo extends TestBase { @Test - public void testBean(){ + public void testBean() { CbamTokenProviderForSo cbamTokenProvider = Mockito.mock(CbamTokenProviderForSo.class); AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = Mockito.mock(AAIExternalSystemInfoProvider.class); CbamSecurityProvider cbamSecurityProvider = Mockito.mock(CbamSecurityProvider.class); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForVfc.java index d762bd72..9bca475a 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForVfc.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForVfc.java @@ -19,13 +19,12 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm; import junit.framework.TestCase; import org.junit.Test; import org.mockito.Mockito; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider; -public class TestCbamRestApiProviderForVfc extends TestBase{ +public class TestCbamRestApiProviderForVfc extends TestBase { @Test - public void testBean(){ + public void testBean() { CbamTokenProviderForVfc cbamTokenProvider = Mockito.mock(CbamTokenProviderForVfc.class); VfcExternalSystemInfoProvider c = Mockito.mock(VfcExternalSystemInfoProvider.class); CbamSecurityProvider cbamSecurityProvider = Mockito.mock(CbamSecurityProvider.class); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java index 1135df98..526f2bfa 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java @@ -18,14 +18,12 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm; import junit.framework.TestCase; import org.junit.Test; -import org.mockito.Mock; import org.mockito.Mockito; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider; public class TestCbamTokenProviderForSo extends TestBase { @Test - public void testBean(){ + public void testBean() { AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = Mockito.mock(AAIExternalSystemInfoProvider.class); CbamTokenProviderForSo cbamTokenProviderForSo = new CbamTokenProviderForSo(aaiExternalSystemInfoProvider); TestCase.assertNotNull(cbamTokenProviderForSo); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java index edd54d03..696d3449 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java @@ -19,13 +19,11 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm; import junit.framework.TestCase; import org.junit.Test; import org.mockito.Mockito; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider; public class TestCbamTokenProviderForVfc extends TestBase { @Test - public void testBean(){ + public void testBean() { VfcExternalSystemInfoProvider vfcExternalSystemInfoProvider = Mockito.mock(VfcExternalSystemInfoProvider.class); CbamTokenProviderForVfc cbamTokenProviderForVfc = new CbamTokenProviderForVfc(vfcExternalSystemInfoProvider); TestCase.assertNotNull(cbamTokenProviderForVfc); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java index 58afb9bd..6244203b 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java @@ -21,7 +21,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil; public class TestConstants { @Test - public void useInStaticWay(){ + public void useInStaticWay() { TestUtil.coveragePrivateConstructorForClassesWithStaticMethodsOnly(Constants.class); } } \ No newline at end of file diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java index d25859fa..c442071f 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java @@ -15,7 +15,6 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm; -import junit.framework.TestCase; import org.junit.Test; import static junit.framework.TestCase.assertNotNull; @@ -26,7 +25,7 @@ public class TestJobManagerForSo extends TestBase { * Test bean */ @Test - public void testPojo(){ + public void testPojo() { JobManagerForSo jobManagerForSo = new JobManagerForSo(cbamRestApiProviderForSo, selfRegistrationManagerForSo); assertNotNull(jobManagerForSo); assertBean(JobManagerForVfc.class); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java index 1a073b58..856d7a1c 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java @@ -25,7 +25,7 @@ public class TestJobManagerForVfc extends TestBase { * Test bean */ @Test - public void testPojo(){ + public void testPojo() { JobManagerForVfc jobManagerForVfc = new JobManagerForVfc(cbamRestApiProviderForVfc, selfRegistrationManagerForVfc); assertNotNull(jobManagerForVfc); assertBean(JobManagerForVfc.class); 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 02be5a8d..ea379e67 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 @@ -908,7 +908,7 @@ public class TestLifecycleManager extends TestBase { fail(); } catch (RuntimeException e) { assertEquals(expectedException, e.getCause().getCause()); - verify(logger).error("Unable to set the externalVnfmId,onapCsarId properties on the VNF with " + VNF_ID +" identifier", expectedException); + verify(logger).error("Unable to set the externalVnfmId,onapCsarId properties on the VNF with " + VNF_ID + " identifier", expectedException); } } @@ -1198,7 +1198,7 @@ public class TestLifecycleManager extends TestBase { notificationIsProcessedBeforeDeletingTheVnf.verify(notificationManager).waitForTerminationToBeProcessed("terminationId"); notificationIsProcessedBeforeDeletingTheVnf.verify(vnfApi).vnfsVnfInstanceIdDelete(VNF_ID, NOKIA_LCM_API_VERSION); } - + /** * test explicit forceful termination */ @@ -1683,23 +1683,6 @@ public class TestLifecycleManager extends TestBase { } } - public static class X{ - public Map getInputs() { - return inputs; - } - - public void setInputs(Map inputs) { - this.inputs = inputs; - } - - @SerializedName("inputs") - public Map inputs = new HashMap(); - - public String vimId; - - public String properties; - } - private VnfInstantiateRequest prepareInstantiationRequest(VimInfo.VimInfoTypeEnum cloudType, boolean addExtension) { VnfInstantiateRequest instantiationRequest = new VnfInstantiateRequest(); instantiationRequest.setVnfPackageId(ONAP_CSAR_ID); @@ -1775,7 +1758,7 @@ public class TestLifecycleManager extends TestBase { image.setVnfdSoftwareImageId("imageId"); additionalParam.getSoftwareImages().add(image); additionalParam.setAdditionalParams(new JsonParser().parse("{ \"a\" : \"b\" }")); - if(addExtensions) { + if (addExtensions) { VnfProperty p1 = new VnfProperty(); p1.setName("n1"); p1.setValue(Lists.newArrayList("a", "b")); @@ -1844,7 +1827,6 @@ public class TestLifecycleManager extends TestBase { assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck()); } - /** * additional params of instantiation may be passed as directly attached artifact */ @@ -1929,4 +1911,19 @@ public class TestLifecycleManager extends TestBase { assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck()); verify(logger).info("The instantiation input for VNF with {} CSAR id does not have an " + LifecycleManager.ETSI_CONFIG + " section", ONAP_CSAR_ID); } + + public static class X { + @SerializedName("inputs") + public Map inputs = new HashMap(); + public String vimId; + public String properties; + + public Map getInputs() { + return inputs; + } + + public void setInputs(Map inputs) { + this.inputs = inputs; + } + } } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java index ae51dc85..42ce042c 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java @@ -15,7 +15,6 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm; -import junit.framework.TestCase; import org.junit.Test; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.GrantlessGrantManager; @@ -24,13 +23,13 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChan import static junit.framework.TestCase.assertNotNull; import static org.mockito.Mockito.mock; -public class TestLifecycleManagerForSo extends TestBase{ +public class TestLifecycleManagerForSo extends TestBase { /** * Test bean */ @Test - public void testBean(){ + public void testBean() { CatalogManagerForSo catalogManager = mock(CatalogManagerForSo.class); GrantlessGrantManager grantManager = mock(GrantlessGrantManager.class); AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = mock(AAIExternalSystemInfoProvider.class); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java index 326476ef..730cfc7b 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java @@ -16,22 +16,19 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm; import org.junit.Test; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.GrantlessGrantManager; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcGrantManager; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForSo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc; import static junit.framework.TestCase.assertNotNull; import static org.mockito.Mockito.mock; -public class TestLifecycleManagerForVfc extends TestBase{ +public class TestLifecycleManagerForVfc extends TestBase { /** * Test bean */ @Test - public void testBean(){ + public void testBean() { CatalogManagerForVfc catalogManager = mock(CatalogManagerForVfc.class); VfcGrantManager vfcGrantManager = mock(VfcGrantManager.class); VfcExternalSystemInfoProvider vfcExternalSystemInfoProvider = mock(VfcExternalSystemInfoProvider.class); 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 d0657852..bfb30abd 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 @@ -23,7 +23,6 @@ import java.util.NoSuchElementException; import java.util.Optional; import java.util.concurrent.*; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManagerForVfc.java index 35a8fcee..7a282115 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManagerForVfc.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManagerForVfc.java @@ -17,7 +17,6 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification; import org.junit.Test; import org.mockito.Mockito; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.AAINotificationProcessor; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcNotificationSender; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase; diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.cbam.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.cbam.yaml index 45bfb73f..e80e9141 100644 --- a/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.cbam.yaml +++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.cbam.yaml @@ -4,8 +4,14 @@ topology_template: substitution_mappings: node_type: tosca.nodes.nfv.VNF properties: + descriptor_id: myId descriptor_version: '1.0' provider: myProvider product_name: 'myName' software_version: '2.0' - product_info_name: product_info_name \ No newline at end of file + product_info_name: product_info_name + capabilities: + deployment_flavour: + properties: + flavour_id: myFlavorId + description: myFlavorDescription \ No newline at end of file diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.v2.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.v2.yaml new file mode 100644 index 00000000..7d48b7ad --- /dev/null +++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.v2.yaml @@ -0,0 +1,21 @@ +tosca_definitions_version: tosca_simple_profile_yaml_1_1 + +topology_template: + inputs: + etsi_config: + type: string + description: The ETSI configuration + node_templates: + VNF: + type: tosca.nodes.nfv.VNF + properties: + descriptor_id: myId + descriptor_version: 1.0 + provider: myProvider + product_name: myName + software_version: 2.0 + product_info_name: product_info_name + vnfm_info: [ NokiaSVNFM ] + flavour_id: myFlavorId + flavour_description: myFlavorDescription + requirements: diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml index 985ab276..3870605f 100644 --- a/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml +++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml @@ -4,11 +4,22 @@ topology_template: substitution_mappings: node_type: tosca.nodes.nfv.VNF properties: + descriptor_id: Nokia~Maria DB~1.0~1.0 descriptor_version: '1.0' provider: myProvider product_name: 'myName' software_version: '2.0' product_info_name: product_info_name + product_info_description: Relational database, non-scalable + capabilities: + deployment_flavour: + properties: + flavour_id: scalableRouted + description: flavorDescription + vdu_profile: + vduNode: + min_number_of_instances: 3 + max_number_of_instances: 11 node_templates: vduNode: type: tosca.nodes.nfv.VDU @@ -35,19 +46,29 @@ topology_template: type: tosca.nodes.nfv.VirtualStorage properties: id: myStorage1 - size_of_storage: 1G + size_of_storage: 1 GB myStorage2: type: tosca.nodes.nfv.VirtualStorage properties: id: myStorage2 - size_of_storage: 2G + size_of_storage: 2 GB myNetwork1: type: tosca.nodes.nfv.VL + properties: + connectivity_type: + layer_protocol: ipv4 + flow_pattern: mesh + description: myDescription myNetwork2: type: tosca.nodes.nfv.VL + properties: + connectivity_type: + layer_protocol: ipv4 + flow_pattern: mesh + description: myDescription icpWithOutEcp: type: tosca.nodes.nfv.ICP diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.v2.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.v2.yaml new file mode 100644 index 00000000..fe0ccf4c --- /dev/null +++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.v2.yaml @@ -0,0 +1,133 @@ +tosca_definitions_version: tosca_simple_profile_yaml_1_1 + +topology_template: + inputs: + etsi_config: + type: string + description: The ETSI configuration + node_templates: + VNF: + type: tosca.nodes.nfv.VNF + properties: + descriptor_id: Nokia~Maria DB~1.0~1.0 + descriptor_version: 1.0 + provider: myProvider + product_name: myName + software_version: 2.0 + product_info_name: product_info_name + product_info_description: Relational database, non-scalable + vnfm_info: [ NokiaSVNFM ] + flavour_id: scalableRouted + flavour_description: flavorDescription + requirements: + - virtual_link: + capability: tosca.capabilities.nfv.VirtualLinkable + node: myNetwork2 + - virtual_link: + capability: tosca.capabilities.nfv.VirtualLinkable + node: myNetwork1 + vduNode: + type: tosca.nodes.nfv.Vdu.Compute + properties: + name: vduNode + description: myVduDesc + configurable_properties: + vdu_profile: + min_number_of_instances: 3 + max_number_of_instances: 11 + capabilities: + virtual_compute: + properties: + virtual_memory: + virtual_mem_size: 8192 MB + virtual_cpu: + num_virtual_cpu: 4 + requirements: + - virtual_storage: + capability: tosca.capabilities.nfv.VirtualStorage + node: myStorage1 + - virtual_storage: + capability: tosca.capabilities.nfv.VirtualStorage + node: myStorage2 + myStorage1: + type: tosca.nodes.nfv.Vdu.VirtualStorage + properties: + type_of_storage: volume + size_of_storage: 1 GB + myStorage2: + type: tosca.nodes.nfv.Vdu.VirtualStorage + properties: + type_of_storage: volume + size_of_storage: 2 GB + myNetwork1: + type: tosca.nodes.nfv.VnfVirtualLink + properties: + connectivity_type: + layer_protocol: [ ipv4 ] + flow_pattern: mesh + vl_profile: + max_bit_rate_requirements: + root: 2147483647 + leaf: 2147483647 + min_bit_rate_requirements: + root: 0 + leaf: 0 + myNetwork2: + type: tosca.nodes.nfv.VnfVirtualLink + properties: + connectivity_type: + layer_protocol: [ ipv4 ] + flow_pattern: mesh + vl_profile: + max_bit_rate_requirements: + root: 2147483647 + leaf: 2147483647 + min_bit_rate_requirements: + root: 0 + leaf: 0 + icpWithOutEcp: + type: tosca.nodes.nfv.VduCp + properties: + layer_protocol: [ ipv4 ] + description: myDescription + protocol_data: [] + trunk_mode: false + requirements: + - virtual_binding: vduNode + - virtual_link: myNetwork1 + icpWithEcp: + type: tosca.nodes.nfv.VduCp + properties: + layer_protocol: [ ipv4 ] + description: myDescription + protocol_data: [] + trunk_mode: false + requirements: + - virtual_binding: vduNode + - virtual_link: myNetwork1 + icpWithOutDescription: + type: tosca.nodes.nfv.VduCp + properties: + layer_protocol: [ ipv4 ] + protocol_data: [] + trunk_mode: false + requirements: + - virtual_binding: vduNode + - virtual_link: myNetwork1 + myEcp: + type: tosca.nodes.nfv.VduCp + properties: + layer_protocol: [ ipv4 ] + protocol_data: [ ] + trunk_mode: false + description: myDescription + requirements: + - virtual_binding: vduNode + myEcpWithDescription: + type: tosca.nodes.nfv.VduCp + properties: + layer_protocol: [ ipv4 ] + protocol_data: [ ] + trunk_mode: false + requirements: + - virtual_binding: vduNode -- 2.16.6