diff options
17 files changed, 98 insertions, 62 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java index d348235..730b27d 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java @@ -24,6 +24,8 @@ import java.util.Properties; import org.onap.cli.fw.cmd.OnapCommand; import org.onap.cli.fw.error.OnapCommandException; import org.onap.cli.fw.error.OnapCommandExecutionFailed; +import org.onap.cli.fw.error.OnapCommandInvalidParameterValue; +import org.onap.cli.fw.input.OnapCommandParameter; import org.onap.cli.fw.output.OnapCommandResultType; import org.onap.cli.fw.registrar.OnapCommandRegistrar; import org.onap.cli.fw.schema.OnapCommandSchema; @@ -39,6 +41,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; @OnapCommandSchema(schema = "vtp-validate-csar.yaml") public class VTPValidateCSAR extends OnapCommand { private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSAR.class); + public static final String PNF_ATTRIBUTE_NAME = "pnf"; public static class CSARValidation { public static class VNF { @@ -184,7 +187,7 @@ public class VTPValidateCSAR extends OnapCommand { protected void run() throws OnapCommandException { //Read the input arguments String path = (String) getParametersMap().get("csar").getValue(); - boolean isPnf = (boolean) getParametersMap().get("pnf").getValue(); + boolean isPnf = (boolean) getParametersMap().get(PNF_ATTRIBUTE_NAME).getValue(); boolean overallPass = true; try(CSARArchive csar = isPnf ? new PnfCSARArchive(): new CSARArchive()){ @@ -228,6 +231,7 @@ public class VTPValidateCSAR extends OnapCommand { String command = "csar-validate-" + vnfreq; OnapCommand cmd = OnapCommandRegistrar.getRegistrar().get(command, this.getInfo().getProduct()); cmd.getParametersMap().get("csar").setValue(path); + setPnfValueIfAvailable(isPnf, cmd); result.setDescription(cmd.getDescription()); cmd.execute(); @@ -266,6 +270,13 @@ public class VTPValidateCSAR extends OnapCommand { } } + private void setPnfValueIfAvailable(boolean isPnf, OnapCommand cmd) throws OnapCommandInvalidParameterValue { + final OnapCommandParameter pnf = cmd.getParametersMap().get(PNF_ATTRIBUTE_NAME); + if(pnf!=null) { + pnf.setValue(isPnf); + } + } + private List<String> getPropertiesList(String key) { String[] enabledReqs = prp.getProperty(key, "").split(","); List<String> list = new ArrayList<>(); diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java index bd771e0..eafdbde 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java @@ -19,9 +19,11 @@ package org.onap.cvc.csar.cc; import org.onap.cli.fw.cmd.OnapCommand; import org.onap.cli.fw.error.OnapCommandException; import org.onap.cli.fw.error.OnapCommandExecutionFailed; +import org.onap.cli.fw.input.OnapCommandParameter; import org.onap.cvc.csar.CSARArchive; import org.onap.cvc.csar.CSARArchive.CSARError; import org.onap.cvc.csar.FileArchive; +import org.onap.cvc.csar.PnfCSARArchive; import org.onap.cvc.csar.ZipFileContentValidator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,9 +46,10 @@ public abstract class VTPValidateCSARBase extends OnapCommand { protected void run() throws OnapCommandException { //Read the input arguments String path = (String) getParametersMap().get("csar").getValue(); + boolean isPnf = isPnf(); //execute - try (CSARArchive csar = this.createArchiveInstance()){ + try (CSARArchive csar = isPnf ? new PnfCSARArchive(): new CSARArchive()){ csar.init(path); @@ -77,7 +80,12 @@ public abstract class VTPValidateCSARBase extends OnapCommand { this.getResult().setOutput(this.errors); } - protected CSARArchive createArchiveInstance(){ - return new CSARArchive(); - } + private boolean isPnf() { + final OnapCommandParameter pnf = getParametersMap().get("pnf"); + return pnf != null && (boolean) pnf.getValue(); + } + + public List<CSARError> getErrors() { + return this.errors; + } } diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidatePnfCSARBase.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidatePnfCSARBase.java deleted file mode 100644 index 6c7d3a0..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidatePnfCSARBase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2019 Nokia - * <p> - * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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.cvc.csar.cc; - -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.PnfCSARArchive; - -import java.util.List; - -public abstract class VTPValidatePnfCSARBase extends VTPValidateCSARBase { - @Override - protected CSARArchive createArchiveInstance(){ - return new PnfCSARArchive(); - } - - public List<CSARArchive.CSARError> getErrors(){ - return this.errors; - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java index 1cdfe7a..3d767ff 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java @@ -22,7 +22,7 @@ import org.onap.cli.fw.schema.OnapCommandSchema; import org.onap.cvc.csar.CSARArchive; import org.onap.cvc.csar.PnfCSARError; import org.onap.cvc.csar.PnfCSARError.PnfCSARErrorEntryMissing; -import org.onap.cvc.csar.cc.VTPValidatePnfCSARBase; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; import java.io.File; import java.util.ArrayList; @@ -33,7 +33,7 @@ import java.util.Set; import java.util.stream.Collectors; @OnapCommandSchema(schema = "vtp-validate-csar-r146092.yaml") -public class VTPValidateCSARR146092 extends VTPValidatePnfCSARBase { +public class VTPValidateCSARR146092 extends VTPValidateCSARBase { private static final int UNKNOWN_LINE_NUMBER = -1; private static final String SOURCE_ELEMENT_TAG = "source"; diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java index b114880..a832b4d 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901.java @@ -21,12 +21,12 @@ package org.onap.cvc.csar.cc.sol004; import org.onap.cli.fw.schema.OnapCommandSchema; import org.onap.cvc.csar.CSARArchive; import org.onap.cvc.csar.PnfCSARError.PnfCSARErrorEntryMissing; -import org.onap.cvc.csar.cc.VTPValidatePnfCSARBase; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; import java.util.Objects; @OnapCommandSchema(schema = "vtp-validate-csar-r293901.yaml") -public class VTPValidateCSARR293901 extends VTPValidatePnfCSARBase { +public class VTPValidateCSARR293901 extends VTPValidateCSARBase { private static final int UNKNOWN_LINE_NUMBER = -1; diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019.java index 8f6118b..3dea564 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019.java @@ -21,12 +21,12 @@ package org.onap.cvc.csar.cc.sol004; import org.onap.cli.fw.schema.OnapCommandSchema; import org.onap.cvc.csar.CSARArchive; import org.onap.cvc.csar.PnfCSARError.PnfCSARErrorEntryMissing; -import org.onap.cvc.csar.cc.VTPValidatePnfCSARBase; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; import java.util.Objects; @OnapCommandSchema(schema = "vtp-validate-csar-r57019.yaml") -public class VTPValidateCSARR57019 extends VTPValidatePnfCSARBase { +public class VTPValidateCSARR57019 extends VTPValidateCSARBase { private static final int UNKNOWN_LINE_NUMBER = -1; diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java index ede1b6c..a5ff4ed 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965.java @@ -22,7 +22,7 @@ import org.onap.cli.fw.error.OnapCommandException; import org.onap.cli.fw.schema.OnapCommandSchema; import org.onap.cvc.csar.CSARArchive; import org.onap.cvc.csar.FileArchive; -import org.onap.cvc.csar.cc.VTPValidatePnfCSARBase; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; import org.onap.cvc.csar.rsa.RSACertificateValidator; import org.onap.cvc.csar.rsa.X509RsaCertification; import org.slf4j.Logger; @@ -34,7 +34,7 @@ import java.util.Base64; import java.util.Optional; @OnapCommandSchema(schema = "vtp-validate-csar-r787965.yaml") -public class VTPValidateCSARR787965 extends VTPValidatePnfCSARBase { +public class VTPValidateCSARR787965 extends VTPValidateCSARBase { private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR787965.class); diff --git a/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r15837.yaml b/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r15837.yaml index 586f4af..f02cdfc 100644 --- a/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r15837.yaml +++ b/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r15837.yaml @@ -32,7 +32,13 @@ parameters: short_option: b type: binary is_optional: false - + - name: pnf + description: CSAR file contains PNF + long_option: pnf + short_option: p + type: bool + is_optional: true + default_value: false results: direction: landscape attributes: diff --git a/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r17852.yaml b/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r17852.yaml index 6626765..0ce2dea 100644 --- a/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r17852.yaml +++ b/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r17852.yaml @@ -17,7 +17,7 @@ open_cli_schema_version: 1.0 name: csar-validate-r17852 description: | - The VNFD MAY include TOSCA/YAML definitions that are not part of NFV Profile. If provided, + The VNFD/PNFD MAY include TOSCA/YAML definitions that are not part of NFV Profile. If provided, these definitions MUST comply with TOSCA Simple Profile in YAML v.1.2. info: @@ -33,7 +33,13 @@ parameters: short_option: b type: binary is_optional: false - + - name: pnf + description: CSAR file contains PNF + long_option: pnf + short_option: p + type: bool + is_optional: true + default_value: false results: direction: landscape attributes: diff --git a/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r35854.yaml b/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r35854.yaml index 1a824da..3556c6d 100644 --- a/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r35854.yaml +++ b/csarvalidation/src/main/resources/open-cli-schema/sol001/vtp-validate-csar-r35854.yaml @@ -17,8 +17,8 @@ open_cli_schema_version: 1.0 name: csar-validate-r35854 description: | - The VNF Descriptor (VNFD) provided by VNF vendor MUST comply with TOSCA/YAML based Service template - for VNF descriptor specified in ETSI NFV-SOL001. + The VNF/PNF Descriptor (VNFD/PNFD) provided by VNF/PNF vendor MUST comply with TOSCA/YAML based Service template + for VNF/PNF descriptor specified in ETSI NFV-SOL001. info: product: onap-vtp @@ -33,7 +33,13 @@ parameters: short_option: b type: binary is_optional: false - + - name: pnf + description: CSAR file contains PNF + long_option: pnf + short_option: p + type: bool + is_optional: true + default_value: false results: direction: landscape attributes: diff --git a/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r146092.yaml b/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r146092.yaml index 5646c98..4f30e8f 100644 --- a/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r146092.yaml +++ b/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r146092.yaml @@ -36,6 +36,13 @@ parameters: short_option: b type: binary is_optional: false + - name: pnf + description: CSAR file contains PNF + long_option: pnf + short_option: p + type: bool + is_optional: true + default_value: true results: direction: landscape diff --git a/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r293901.yaml b/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r293901.yaml index 34f75e5..af42229 100644 --- a/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r293901.yaml +++ b/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r293901.yaml @@ -37,7 +37,13 @@ parameters: short_option: b type: binary is_optional: false - + - name: pnf + description: CSAR file contains PNF + long_option: pnf + short_option: p + type: bool + is_optional: true + default_value: true results: direction: landscape attributes: diff --git a/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r57019.yaml b/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r57019.yaml index 2e4380f..eb0f686 100644 --- a/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r57019.yaml +++ b/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r57019.yaml @@ -38,6 +38,13 @@ parameters: short_option: b type: binary is_optional: false + - name: pnf + description: CSAR file contains PNF + long_option: pnf + short_option: p + type: bool + is_optional: true + default_value: true results: direction: landscape diff --git a/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r787965.yaml b/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r787965.yaml index 04eb147..f12409a 100644 --- a/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r787965.yaml +++ b/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r787965.yaml @@ -32,7 +32,13 @@ parameters: short_option: b type: binary is_optional: false - + - name: pnf + description: CSAR file contains PNF + long_option: pnf + short_option: p + type: bool + is_optional: true + default_value: true results: direction: landscape attributes: diff --git a/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r87234.yaml b/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r87234.yaml index 01d45bf..e16ea0e 100644 --- a/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r87234.yaml +++ b/csarvalidation/src/main/resources/open-cli-schema/sol004/vtp-validate-csar-r87234.yaml @@ -17,7 +17,7 @@ open_cli_schema_version: 1.0 name: csar-validate-r87234 description: | - The VNF package provided by a VNF vendor MAY be either with TOSCA-Metadata directory (CSAR Option 1) + The VNF/PNF package provided by a VNF/PNF vendor MAY be either with TOSCA-Metadata directory (CSAR Option 1) or without TOSCA-Metadata directory (CSAR Option 2) as specified in ETSI GS NFV-SOL004. On-boarding entity (ONAP SDC) must support both options. @@ -34,6 +34,13 @@ parameters: short_option: b type: binary is_optional: false + - name: pnf + description: CSAR file contains PNF + long_option: pnf + short_option: p + type: bool + is_optional: true + default_value: false results: direction: landscape diff --git a/csarvalidation/src/main/resources/vnfreqs.properties b/csarvalidation/src/main/resources/vnfreqs.properties index 6f41351..935729a 100644 --- a/csarvalidation/src/main/resources/vnfreqs.properties +++ b/csarvalidation/src/main/resources/vnfreqs.properties @@ -1,5 +1,5 @@ vnfreqs.enabled=r02454,r04298,r07879,r09467,r13390,r23823,r26881,r27310,r35851,r40293,r43958,r66070,r77707,r77786,r87234,r10087,r21322,r26885,r40820,r35854,r65486,r17852,r46527,r15837,r54356,r67895,r95321,r32155,r01123,r51347,r787965 -pnfreqs.enabled=r293901,r146092,r57019,r787965 +pnfreqs.enabled=r87234,r35854,r15837,r17852,r293901,r146092,r57019,r787965 # ignored all chef and ansible related tests vnferrors.ignored=0x1005,0x1006,r07879-0x1000,r13390-0x1000,r27310-0x1000,r40293-0x1000,r77786-0x1000,r04298-0x1000,r07879-0x1000,r10087-0x1000,r13390-0x1000,r23823-0x1000,r26881-0x1000,r40820-0x1000,r35851-0x1000,r32155-0x1000,r54356-0x1000,r67895-0x1000,r95321-0x1000,r46527-0x1000,r02454-0x1000 pnferrors.ignored=
\ No newline at end of file diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java index 5e1c836..bed3a90 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java @@ -24,7 +24,7 @@ import org.onap.cli.fw.input.OnapCommandParameter; import org.onap.cli.fw.output.OnapCommandResult; import org.onap.cli.fw.output.OnapCommandResultAttribute; import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.cc.VTPValidatePnfCSARBase; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; import java.net.URISyntaxException; import java.util.List; @@ -38,11 +38,11 @@ public class IntegrationTestUtils { } public static String absoluteFilePath(String relativeFilePath) throws URISyntaxException { - return VTPValidatePnfCSARBase.class.getClassLoader().getResource(relativeFilePath) + return VTPValidateCSARBase.class.getClassLoader().getResource(relativeFilePath) .toURI().getPath(); } - static void configureTestCase(VTPValidatePnfCSARBase testCase, String fileName) throws OnapCommandException, URISyntaxException { + static void configureTestCase(VTPValidateCSARBase testCase, String fileName) throws OnapCommandException, URISyntaxException { configureCommandAttributes(testCase); testCase.initializeSchema("vtp-validate-csar-r146092.yaml"); @@ -50,7 +50,7 @@ public class IntegrationTestUtils { configurePathToCsar(testCase, fileName); } - private static void configureCommandAttributes(VTPValidatePnfCSARBase testCase) { + private static void configureCommandAttributes(VTPValidateCSARBase testCase) { OnapCommandResult onapCommandResult = new OnapCommandResult(); OnapCommandResultAttribute onapCommandResultAttributeCode = new OnapCommandResultAttribute(); onapCommandResultAttributeCode.setName("code"); @@ -65,7 +65,7 @@ public class IntegrationTestUtils { testCase.setResult(onapCommandResult); } - private static void configurePathToCsar(VTPValidatePnfCSARBase testCase, String fileName) throws URISyntaxException, OnapCommandInvalidParameterValue { + private static void configurePathToCsar(VTPValidateCSARBase testCase, String fileName) throws URISyntaxException, OnapCommandInvalidParameterValue { String pathToFile = absoluteFilePath(fileName); Set<OnapCommandParameter> parameters = testCase.getParameters(); OnapCommandParameter csar = parameters.stream().filter(op -> op.getName().equals("csar")).findFirst().get(); |