diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2019-03-15 16:23:12 +0800 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2019-03-15 16:23:12 +0800 |
commit | 54c4f708eee7e8f212865c41462ba31112fa264b (patch) | |
tree | 50e2d4c97f927d1e51e8c107b2a6684ab026ba85 /csarvalidation/src/main/java/org/onap | |
parent | 2b9836d721a4c16ddb0fab8bbf5cb5bbba44350a (diff) |
Add SOL001 test case place holder
Issue-ID: VNFSDK-352
Change-Id: I8fc71d456054dc66bede1cc9f53f83e4e519f534
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'csarvalidation/src/main/java/org/onap')
46 files changed, 1414 insertions, 1240 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java index c8f16e5..e94ff88 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java @@ -135,9 +135,9 @@ public class CSARArchive { this.code = code; } - private String code; + private String vnfreqNo; - private String subCode; + private String code; protected String message = ""; @@ -177,6 +177,14 @@ public class CSARArchive { this.lineNumber = lineNumber; } + public String getVnfreqNo() { + return this.vnfreqNo; + } + + public void setVnfreqNo(String no) { + this.vnfreqNo = no; + } + public String toString() { try { return new ObjectMapper().writeValueAsString(this); @@ -185,22 +193,6 @@ public class CSARArchive { return "{}"; } } - - public String getSubCode() { - return subCode; - } - - public void setSubCode(String subCode) { - this.subCode = subCode; - } - - public String getErrorCode() { - if (this.getSubCode() != null) { - return this.getSubCode(); - } - - return this.getCode(); - } } public static class CSARErrorInvalidEntry extends CSARError { @@ -217,6 +209,11 @@ public class CSARArchive { public static class CSARErrorInvalidEntryValue extends CSARError { public CSARErrorInvalidEntryValue(String entry, String file, int lineNo, String message, String validValues) { + this(entry, file, message, validValues); + this.lineNumber = lineNo; + } + + public CSARErrorInvalidEntryValue(String entry, String file, String message, String validValues) { super("0x1001"); this.message = "Invalid value. Entry [" + entry + "]"; if (validValues != null) { @@ -228,7 +225,6 @@ public class CSARArchive { } this.file = file; - this.lineNumber = lineNo; } } @@ -242,6 +238,12 @@ public class CSARArchive { this.file = file; this.lineNumber = lineNo; } + + public CSARErrorEntryMissing(String entry, String file) { + super("0x1002"); + this.message = "Missing. Entry [" + entry + "]"; + this.file = file; + } } @@ -317,7 +319,7 @@ public class CSARArchive { definitionYaml, -1, null); - this.setSubCode("0x001"); + this.setCode("0x001"); } } @@ -329,7 +331,7 @@ public class CSARArchive { null, Entry_Definition__tosca_definitions_version__simple_1_1); - this.setSubCode("0x0002"); + this.setCode("0x0002"); } } @@ -341,7 +343,7 @@ public class CSARArchive { -1, null); - this.setSubCode("0x0003"); + this.setCode("0x0003"); } } @@ -353,7 +355,7 @@ public class CSARArchive { -1, null); - this.setSubCode("0x0004"); + this.setCode("0x0004"); } } @@ -365,7 +367,7 @@ public class CSARArchive { -1, null); - this.setSubCode("0x0005"); + this.setCode("0x0005"); } } @@ -377,7 +379,7 @@ public class CSARArchive { definitionYaml + " does not exist", null); - this.setSubCode("0x0006"); + this.setCode("0x0006"); } } @@ -389,7 +391,7 @@ public class CSARArchive { manifest + " does not exist", null); - this.setSubCode("0x0007"); + this.setCode("0x0007"); } } @@ -401,7 +403,7 @@ public class CSARArchive { logs + " does not exist", null); - this.setSubCode("0x0008"); + this.setCode("0x0008"); } } @@ -413,7 +415,7 @@ public class CSARArchive { tests + " folder does not exist", null); - this.setSubCode("0x0009"); + this.setCode("0x0009"); } } @@ -425,7 +427,7 @@ public class CSARArchive { license + " does not exist", null); - this.setSubCode("0x000a"); + this.setCode("0x000a"); } } @@ -437,7 +439,7 @@ public class CSARArchive { certificate + " does not exist", null); - this.setSubCode("0x000b"); + this.setCode("0x000b"); } } @@ -448,7 +450,7 @@ public class CSARArchive { -1, null); - this.setSubCode("0x000c"); + this.setCode("0x000c"); } } @@ -459,7 +461,7 @@ public class CSARArchive { -1, null); - this.setSubCode("0x000d"); + this.setCode("0x000d"); } } @@ -470,7 +472,7 @@ public class CSARArchive { -1, null); - this.setSubCode("0x000e"); + this.setCode("0x000e"); } } @@ -481,7 +483,7 @@ public class CSARArchive { -1, null); - this.setSubCode("0x000f"); + this.setCode("0x000f"); } } @@ -492,7 +494,7 @@ public class CSARArchive { -1, null); - this.setSubCode("0x0010"); + this.setCode("0x0010"); } } @@ -504,7 +506,7 @@ public class CSARArchive { "Only one definition YAML should be provided at the root of the archive", fileNames); - this.setSubCode("0x0011"); + this.setCode("0x0011"); } } @@ -517,7 +519,7 @@ public class CSARArchive { "Only one manifest MF file should be provided at the root of the archive", fileNames); - this.setSubCode("0x0012"); + this.setCode("0x0012"); } } @@ -530,7 +532,7 @@ public class CSARArchive { definitionYaml + ".mf", //fix the name part manifest); - this.setSubCode("0x0013"); + this.setCode("0x0013"); } } @@ -542,7 +544,7 @@ public class CSARArchive { "Only one certificates file should be provided at the root of the archive", fileNames); - this.setSubCode("0x0014"); + this.setCode("0x0014"); } } @@ -555,7 +557,7 @@ public class CSARArchive { definitionYaml + ".cert", //fix the name part certificate); - this.setSubCode("0x0015"); + this.setCode("0x0015"); } } 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 c480332..6a8e3bd 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java @@ -210,7 +210,7 @@ public class VTPValidateCSAR extends OnapCommand { resultSOL004.setPassed(true); for (CSARError error: resultSOL004.getErrors()) { - if (!ignoreCodes.contains(error.getErrorCode())) { + if (!ignoreCodes.contains(error.getCode())) { resultSOL004.setPassed(false); overallPass = false; break; @@ -236,7 +236,7 @@ public class VTPValidateCSAR extends OnapCommand { result.setPassed(true); for (CSARError error: result.getErrors()) { - if (!ignoreCodes.contains(error.getErrorCode())) { + if (!ignoreCodes.contains(error.getCode())) { result.setPassed(false); overallPass = false; break; diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR26881.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java index e9efd38..d07884d 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR26881.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARBase.java @@ -22,60 +22,47 @@ import java.util.List; 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.schema.OnapCommandSchema; import org.onap.cvc.csar.CSARArchive; import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * R-26881: VNF artifacts - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r26881.yaml") -public class VTPValidateCSARR26881 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR26881.class); +public abstract class VTPValidateCSARBase extends OnapCommand { + protected static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARBase.class); - public static class CSARErrorEntryMissingArtifactsNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryMissingArtifactsNotFound() { - super( - "Artifacts", - CSARArchive.CSAR_Archive, - -1, - "The VNF provider MUST provide the binaries and images needed to instantiate the VNF (VNF and VNFC images)."); - this.setSubCode("r26881-0x1000"); - } - } + protected abstract void validateCSAR(CSARArchive csar) throws Exception; + + protected abstract String getVnfReqsNo(); + + protected List<CSARError> errors = new ArrayList<>(); @Override protected void run() throws OnapCommandException { //Read the input arguments String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); + //execute try { CSARArchive csar = new CSARArchive(); csar.init(path); csar.parse(); - if (!csar.getFileFromCsar("artifacts").exists()) { - errors.add(new CSARErrorEntryMissingArtifactsNotFound()); - } + this.validateCSAR(csar); csar.cleanup(); } catch (Exception e) { - LOG.error("R-26881: ", e); + LOG.error(this.getVnfReqsNo() + ": Failed to validate CSAR" , e); throw new OnapCommandExecutionFailed(e.getMessage()); } - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); + for (CSARError e: this.errors) { + e.setVnfreqNo(this.getVnfReqsNo()); + this.getResult().getRecordsMap().get("code").getValues().add(this.getVnfReqsNo() + "-" + e.getCode()); this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); } + + this.getResult().setOutput(this.errors); } } diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR02454.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR02454.java deleted file mode 100644 index c77db76..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR02454.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.Yaml; - -/** - * R-02454: The VNF MUST support the existence of multiple major/minor - * versions of the VNF software and/or sub-components and interfaces that - * support both forward and backward compatibility to be transparent to the - * Service Provider usage. - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r02454.yaml") -public class VTPValidateCSARR02454 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR02454.class); - - public static class CSARErrorEntryMissingSwImage extends CSARErrorEntryMissing { - public CSARErrorEntryMissingSwImage(String defYaml, String entry) { - super( - entry, - defYaml, - -1, - "The VNF MUST support the existence of multiple major/minor versions " - + "of the VNF software and/or sub-components and interfaces that support both " - + "forward and backward compatibility to be transparent to the Service Provider usage."); - this.setSubCode("r02454-0x1000"); - } - } - - private List<CSARError> validate(CSARArchive csar) throws FileNotFoundException, IOException { - List<CSARError> errors = new ArrayList<>(); - - try(FileInputStream ipStream = new FileInputStream(csar.getDefinitionYamlFile())) { - Map<String, ?> yaml = (Map<String, ?>) new Yaml().load(ipStream); - yaml = (Map<String, ?>) yaml.get("topology_template"); - Map<String, ?> nodeTmpls = (Map<String,?>) yaml.get("node_templates"); - - boolean vlExist = false; - - for (Object nodeO: nodeTmpls.values()) { - Map<String, ?> node = (Map<String, ?>) nodeO; - if (node.containsKey("type")) { - String type = (String)node.get("type"); - if (type.equalsIgnoreCase("tosca.artifacts.nfv.SwImage")) { - vlExist = true; - break; - } - } - } - - if (!vlExist) - errors.add(new CSARErrorEntryMissingSwImage( - csar.getDefinitionYamlFile().getName(), - "Software Image")); - } - - return errors; - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - errors = this.validate(csar); - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-02454: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR04298.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR04298.java deleted file mode 100644 index 3c2ffd5..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR04298.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.util.ArrayList; -import java.util.List; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * R-04298: VNF provider MUST provider their testing scripts to support testing. - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r04298.yaml") -public class VTPValidateCSARR04298 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR04298.class); - - public static class CSARErrorEntryMissingTestFolderNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryMissingTestFolderNotFound() { - super( - "Tests", - CSARArchive.CSAR_Archive, - -1, - "The VNF provider MUST provide their testing scripts to support testing."); - this.setSubCode("r04298-0x1000"); - } - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - if (csar.getTestsFolder() == null) { - errors.add(new CSARErrorEntryMissingTestFolderNotFound()); - } - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-04298: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR07879.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR07879.java deleted file mode 100644 index 8f975cc..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR07879.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.util.ArrayList; -import java.util.List; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * R-07879: playbooks directory - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r07879.yaml") -public class VTPValidateCSARR07879 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR07879.class); - - public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryMissingAnsiblePlaybookNotFound() { - super( - "playbooks", - CSARArchive.CSAR_Archive, - -1, - "The VNF Package MUST include all relevant playbooks to ONAP to be loaded on the Ansible Server."); - this.setSubCode("r07879-0x1000"); - } - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - if (!csar.getFileFromCsar("playbooks").exists()) { - errors.add(new CSARErrorEntryMissingAnsiblePlaybookNotFound()); - } - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-07879: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR09467.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR09467.java deleted file mode 100644 index 8ce3a23..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR09467.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.Yaml; - -/** - * R-09467: The VNF MUST utilize only NCSP standard compute flavors. [5] - compute, virtual storage - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r09467.yaml") -public class VTPValidateCSARR09467 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR09467.class); - - public static class CSARErrorEntryMissingFlavor extends CSARErrorEntryMissing { - public CSARErrorEntryMissingFlavor(String defYaml, String entry) { - super( - entry, - defYaml, - -1, - "The VNF MUST utilize only NCSP standard compute flavors. [5] - compute, virtual storage"); - this.setSubCode("r09467-0x1000"); - } - } - - private List<CSARError> validate(CSARArchive csar) throws FileNotFoundException, IOException { - List<CSARError> errors = new ArrayList<>(); - - try(FileInputStream ipStream = new FileInputStream(csar.getDefinitionYamlFile())) { - Map<String, ?> yaml = (Map<String, ?>) new Yaml().load(ipStream); - yaml = (Map<String, ?>) yaml.get("topology_template"); - Map<String, ?> nodeTmpls = (Map<String,?>) yaml.get("node_templates"); - - boolean vlExist = false; - - for (Object nodeO: nodeTmpls.values()) { - Map<String, ?> node = (Map<String, ?>) nodeO; - if (node.containsKey("type")) { - String type = (String)node.get("type"); - if (type.equalsIgnoreCase("tosca.nodes.nfv.VDU.Compute")) { - vlExist = true; - break; - } - } - } - - if (!vlExist) - errors.add(new CSARErrorEntryMissingFlavor( - csar.getDefinitionYamlFile().getName(), - "Flavor")); - } - - return errors; - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - errors = this.validate(csar); - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-09467: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR13390.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR13390.java deleted file mode 100644 index 6c44ee6..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR13390.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.util.ArrayList; -import java.util.List; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * R-r13390: cookbooks directory - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r13390.yaml") -public class VTPValidateCSARR13390 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR13390.class); - - public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryMissingAnsiblePlaybookNotFound() { - super( - "cookbooks", - CSARArchive.CSAR_Archive, - -1, - "The VNF provider MUST provide cookbooks to be loaded on the appropriate Chef Server."); - this.setSubCode("r13390-0x1000"); - } - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - if (!csar.getFileFromCsar("playbooks").exists()) { - errors.add(new CSARErrorEntryMissingAnsiblePlaybookNotFound()); - } - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-13390: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR23823.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR23823.java deleted file mode 100644 index f8a0385..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR23823.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.util.ArrayList; -import java.util.List; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * R-04298: VNF provider MUST provider their testing scripts to support testing. - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r23823.yaml") -public class VTPValidateCSARR23823 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR23823.class); - - public static class CSARErrorEntryMissingCertificatesNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryMissingCertificatesNotFound() { - super( - "Certificates", - CSARArchive.CSAR_Archive, - -1, - "The VNF Package MUST include appropriate credentials so that ONAP can interact with the Chef Server"); - this.setSubCode("r23823-0x1000"); - } - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - if (csar.getCertificatesFile() == null) { - errors.add(new CSARErrorEntryMissingCertificatesNotFound()); - } - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-23823: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR27310.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR27310.java deleted file mode 100644 index 7b2e25a..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR27310.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.util.ArrayList; -import java.util.List; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * R-27310: Manifest file - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r27310.yaml") -public class VTPValidateCSARR27310 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR27310.class); - - public static class CSARErrorEntryMissingChefArtifactsNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryMissingChefArtifactsNotFound() { - super( - "cookbooks", - CSARArchive.CSAR_Archive, - -1, - "The VNF Package MUST include all relevant Chef artifacts (roles/cookbooks/recipes) " - + "required to execute VNF actions requested by ONAP for loading on appropriate Chef Server."); - this.setSubCode("r27310-0x1000"); - } - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - if (!csar.getFileFromCsar("cookbooks").exists()) { - errors.add(new CSARErrorEntryMissingChefArtifactsNotFound()); - } - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-27310: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR35851.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR35851.java deleted file mode 100644 index 068b372..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR35851.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.Yaml; - -/** - * R-35851: The VNF Package MUST include VNF topology that describes - * basic network and application connectivity internal and external to the VNF - * including Link type, KPIs, Bandwidth, latency, jitter, QoS - * (if applicable) for each interface - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r35851.yaml") -public class VTPValidateCSARR35851 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR35851.class); - - public static class CSARErrorEntryMissingDefinitionYamlTopology extends CSARErrorEntryMissing { - public CSARErrorEntryMissingDefinitionYamlTopology(String defYaml, String entry) { - super( - entry, - defYaml, - -1, - "The VNF Package MUST include VNF topology that describes basic " - + "network and application connectivity internal and external to " - + "the VNF including Link type, KPIs, Bandwidth, latency, jitter, " - + "QoS (if applicable) for each interface"); - this.setSubCode("r35851-0x1000"); - } - } - - private List<CSARError> validate(CSARArchive csar) throws FileNotFoundException, IOException { - List<CSARError> errors = new ArrayList<>(); - - try(FileInputStream ipStream = new FileInputStream(csar.getDefinitionYamlFile())) { - Map<String, ?> yaml = (Map<String, ?>) new Yaml().load(ipStream); - yaml = (Map<String, ?>) yaml.get("topology_template"); - Map<String, ?> nodeTmpls = (Map<String,?>) yaml.get("node_templates"); - - boolean vlExist = false; - - for (Object nodeO: nodeTmpls.values()) { - Map<String, ?> node = (Map<String, ?>) nodeO; - if (node.containsKey("type")) { - String type = (String)node.get("type"); - if (type.equalsIgnoreCase("tosca.nodes.nfv.VnfVirtualLink")) { - vlExist = true; - break; - } - } - } - - if (!vlExist) - errors.add(new CSARErrorEntryMissingDefinitionYamlTopology( - csar.getDefinitionYamlFile().getName(), - "Topology VL")); - } - - return errors; - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - errors = this.validate(csar); - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-35851: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR40293.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR40293.java deleted file mode 100644 index eaf0710..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR40293.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.util.ArrayList; -import java.util.List; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * R-r40293: playbooks directory - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r40293.yaml") -public class VTPValidateCSARR40293 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR40293.class); - - public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryMissingAnsiblePlaybookNotFound() { - super( - "playbooks", - CSARArchive.CSAR_Archive, - -1, - "The VNF MUST make available (or load on VNF Ansible Server) playbooks that conform to the ONAP requirement."); - this.setSubCode("r40293-0x1000"); - } - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - if (!csar.getFileFromCsar("playbooks").exists()) { - errors.add(new CSARErrorEntryMissingAnsiblePlaybookNotFound()); - } - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-40293: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR43958.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR43958.java deleted file mode 100644 index 10ae1c0..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR43958.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.util.ArrayList; -import java.util.List; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * R-43958: Test reports - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r43958.yaml") -public class VTPValidateCSARR43958 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR43958.class); - - public static class CSARErrorEntryMissingTestReportNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryMissingTestReportNotFound() { - super( - "Tests/report.txt", - CSARArchive.CSAR_Archive, - -1, - "The VNF Package MUST include documentation describing the tests that were conducted by the VNF provider and the test results."); - this.setSubCode("r43958-0x1000"); - } - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - if (!csar.getFileFromCsar("Tests/report.txt").exists()) { - errors.add(new CSARErrorEntryMissingTestReportNotFound()); - } - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-43958: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR66070.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR66070.java deleted file mode 100644 index 8d51c94..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR66070.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.util.ArrayList; -import java.util.List; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * R-66070: VNF provider details - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r66070.yaml") -public class VTPValidateCSARR66070 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR66070.class); - - public static class CSARErrorEntryVNFProviderDetailsNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryVNFProviderDetailsNotFound() { - super( - "VNF Vendor details", - CSARArchive.TOSCA_Metadata + " or " + CSARArchive.TOSCA_Metadata__TOSCA_Meta__Entry_Definitions + " file", - -1, - "The VNF Package MUST include VNF Identification Data to uniquely identify the" - + " resource for a given VNF provider. The identification data must include: " - + "an identifier for the VNF, the name of the VNF as was given by the VNF provider, " - + "VNF description, VNF provider, and version."); - this.setSubCode("r66070-0x1000"); - } - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - if (csar.getVendorName() == null || - csar.getVersion() == null) { - errors.add(new CSARErrorEntryVNFProviderDetailsNotFound()); - } - //do the validation - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-66070: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR77707.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR77707.java deleted file mode 100644 index 9549e67..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR77707.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.util.ArrayList; -import java.util.List; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * R-77707: Manifest file - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r77707.yaml") -public class VTPValidateCSARR77707 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR77707.class); - - public static class CSARErrorEntryMissingDefinitionNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryMissingDefinitionNotFound() { - super( - "TOSCA definition or Tosca.Meata", - CSARArchive.CSAR_Archive, - -1, - "The VNF provider MUST include a Manifest File that contains a list " - + "of all the components in the VNF package."); - this.setSubCode("r77707-0x1000"); - } - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - if (csar.getToscaMeta().getEntryDefinitionYaml() == null || - csar.getDefinitionYamlFile() == null || !csar.getDefinitionYamlFile().exists()) { - errors.add(new CSARErrorEntryMissingDefinitionNotFound()); - } - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-77707: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR77786.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR77786.java deleted file mode 100644 index 1fa5a1f..0000000 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR77786.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * 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.cvc.csar.cc; - -import java.util.ArrayList; -import java.util.List; - -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.schema.OnapCommandSchema; -import org.onap.cvc.csar.CSARArchive; -import org.onap.cvc.csar.CSARArchive.CSARError; -import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * R-77786: cookbooks directory - */ -@OnapCommandSchema(schema = "vtp-validate-csar-r77786.yaml") -public class VTPValidateCSARR77786 extends OnapCommand { - private static final Logger LOG = LoggerFactory.getLogger(VTPValidateCSARR77786.class); - - public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing { - public CSARErrorEntryMissingAnsiblePlaybookNotFound() { - super( - "cookbooks", - CSARArchive.CSAR_Archive, - -1, - "The VNF Package MUST include all relevant cookbooks to be loaded on the ONAP Chef Server."); - this.setSubCode("r77786-0x1000"); - } - } - - @Override - protected void run() throws OnapCommandException { - //Read the input arguments - String path = (String) getParametersMap().get("csar").getValue(); - List<CSARError> errors = new ArrayList<>(); - //execute - try { - CSARArchive csar = new CSARArchive(); - csar.init(path); - csar.parse(); - - if (!csar.getFileFromCsar("playbooks").exists()) { - errors.add(new CSARErrorEntryMissingAnsiblePlaybookNotFound()); - } - - csar.cleanup(); - } catch (Exception e) { - LOG.error("R-77786: ", e); - throw new OnapCommandExecutionFailed(e.getMessage()); - } - - this.getResult().setOutput(errors); - - //set the result - for (CSARError e: errors) { - this.getResult().getRecordsMap().get("code").getValues().add(e.getCode()); - this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage()); - this.getResult().getRecordsMap().get("file").getValues().add(e.getFile()); - this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber())); - } - } -} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR09467.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR09467.java new file mode 100644 index 0000000..cbacc35 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR09467.java @@ -0,0 +1,69 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import java.io.FileInputStream; +import java.util.Map; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; +import org.yaml.snakeyaml.Yaml; + +@OnapCommandSchema(schema = "vtp-validate-csar-r09467.yaml") +public class VTPValidateCSARR09467 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingFlavor extends CSARErrorEntryMissing { + public CSARErrorEntryMissingFlavor(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + try(FileInputStream ipStream = new FileInputStream(csar.getDefinitionYamlFile())) { + Map<String, ?> yaml = (Map<String, ?>) new Yaml().load(ipStream); + yaml = (Map<String, ?>) yaml.get("topology_template"); + Map<String, ?> nodeTmpls = (Map<String,?>) yaml.get("node_templates"); + + boolean vlExist = false; + + for (Object nodeO: nodeTmpls.values()) { + Map<String, ?> node = (Map<String, ?>) nodeO; + if (node.containsKey("type")) { + String type = (String)node.get("type"); + if (type.equalsIgnoreCase("tosca.nodes.nfv.VDU.Compute")) { + vlExist = true; + break; + } + } + } + + if (!vlExist) + this.errors.add(new CSARErrorEntryMissingFlavor( + csar.getDefinitionYamlFile().getName(), + "Flavor")); + } + } + + @Override + protected String getVnfReqsNo() { + return "R09467"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR15837.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR15837.java new file mode 100644 index 0000000..e89bb85 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR15837.java @@ -0,0 +1,36 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r15837.yaml") +public class VTPValidateCSARR15837 extends VTPValidateCSARBase { + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + + } + + @Override + protected String getVnfReqsNo() { + return "R15837"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR17852.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR17852.java new file mode 100644 index 0000000..96181fd --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR17852.java @@ -0,0 +1,34 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r17852.yaml") +public class VTPValidateCSARR17852 extends VTPValidateCSARBase { + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + } + + @Override + protected String getVnfReqsNo() { + return "R17852"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR32155.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR32155.java new file mode 100644 index 0000000..fac261a --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR32155.java @@ -0,0 +1,36 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r32155.yaml") +public class VTPValidateCSARR32155 extends VTPValidateCSARBase { + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + + } + + @Override + protected String getVnfReqsNo() { + return "R32155"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35851.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35851.java new file mode 100644 index 0000000..6c7b3a6 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35851.java @@ -0,0 +1,70 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import java.io.FileInputStream; +import java.util.Map; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; +import org.yaml.snakeyaml.Yaml; + +@OnapCommandSchema(schema = "vtp-validate-csar-r35851.yaml") +public class VTPValidateCSARR35851 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingDefinitionYamlTopology extends CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamlTopology(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + try(FileInputStream ipStream = new FileInputStream(csar.getDefinitionYamlFile())) { + Map<String, ?> yaml = (Map<String, ?>) new Yaml().load(ipStream); + yaml = (Map<String, ?>) yaml.get("topology_template"); + Map<String, ?> nodeTmpls = (Map<String,?>) yaml.get("node_templates"); + + boolean vlExist = false; + + for (Object nodeO: nodeTmpls.values()) { + Map<String, ?> node = (Map<String, ?>) nodeO; + if (node.containsKey("type")) { + String type = (String)node.get("type"); + if (type.equalsIgnoreCase("tosca.nodes.nfv.VnfVirtualLink")) { + vlExist = true; + break; + } + } + } + + if (!vlExist) + this.errors.add(new CSARErrorEntryMissingDefinitionYamlTopology( + csar.getDefinitionYamlFile().getName(), + "Topology VL")); + } + + } + + @Override + protected String getVnfReqsNo() { + return "R35851"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35854.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35854.java new file mode 100644 index 0000000..1b442cb --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR35854.java @@ -0,0 +1,36 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r35854.yaml") +public class VTPValidateCSARR35854 extends VTPValidateCSARBase { + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + + } + + @Override + protected String getVnfReqsNo() { + return "R35854"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR46527.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR46527.java new file mode 100644 index 0000000..bc680a3 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR46527.java @@ -0,0 +1,35 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r46527.yaml") +public class VTPValidateCSARR46527 extends VTPValidateCSARBase { + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + } + + @Override + protected String getVnfReqsNo() { + return "R46527"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR54356.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR54356.java new file mode 100644 index 0000000..02f7b0d --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR54356.java @@ -0,0 +1,36 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r54356.yaml") +public class VTPValidateCSARR54356 extends VTPValidateCSARBase { + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + + } + + @Override + protected String getVnfReqsNo() { + return "R54356"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR65486.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR65486.java new file mode 100644 index 0000000..0f4f64d --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR65486.java @@ -0,0 +1,36 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r65486.yaml") +public class VTPValidateCSARR65486 extends VTPValidateCSARBase { + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + + } + + @Override + protected String getVnfReqsNo() { + return "R65486"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR67895.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR67895.java new file mode 100644 index 0000000..a45ba5e --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR67895.java @@ -0,0 +1,34 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r67895.yaml") +public class VTPValidateCSARR67895 extends VTPValidateCSARBase { + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + + } + + @Override + protected String getVnfReqsNo() { + return "R67895"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR95321.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR95321.java new file mode 100644 index 0000000..fd9b2d6 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR95321.java @@ -0,0 +1,36 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol001; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r95321.yaml") +public class VTPValidateCSARR95321 extends VTPValidateCSARBase { + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + + } + + @Override + protected String getVnfReqsNo() { + return "R95321"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java new file mode 100644 index 0000000..8fc216b --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java @@ -0,0 +1,49 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-01123.yaml") +public class VTPValidateCSARR01123 extends VTPValidateCSARBase { + + public static class CSARErrorEntryVNFProviderDetailsNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryVNFProviderDetailsNotFound() { + super("VNF Vendor details", + CSARArchive.TOSCA_Metadata + " or " + CSARArchive.TOSCA_Metadata__TOSCA_Meta__Entry_Definitions + " file"); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (csar.getVendorName() == null || + csar.getVersion() == null) { + errors.add(new CSARErrorEntryVNFProviderDetailsNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R01123"; + } + + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR02454.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR02454.java new file mode 100644 index 0000000..14998f5 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR02454.java @@ -0,0 +1,69 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import java.io.FileInputStream; +import java.util.Map; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; +import org.yaml.snakeyaml.Yaml; + +@OnapCommandSchema(schema = "vtp-validate-csar-r02454.yaml") +public class VTPValidateCSARR02454 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingSwImage extends CSARErrorEntryMissing { + public CSARErrorEntryMissingSwImage(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + @Override + protected String getVnfReqsNo() { + return "R02454"; + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + try(FileInputStream ipStream = new FileInputStream(csar.getDefinitionYamlFile())) { + Map<String, ?> yaml = (Map<String, ?>) new Yaml().load(ipStream); + yaml = (Map<String, ?>) yaml.get("topology_template"); + Map<String, ?> nodeTmpls = (Map<String,?>) yaml.get("node_templates"); + + boolean vlExist = false; + + for (Object nodeO: nodeTmpls.values()) { + Map<String, ?> node = (Map<String, ?>) nodeO; + if (node.containsKey("type")) { + String type = (String)node.get("type"); + if (type.equalsIgnoreCase("tosca.artifacts.nfv.SwImage")) { + vlExist = true; + break; + } + } + } + + if (!vlExist) + this.errors.add(new CSARErrorEntryMissingSwImage( + csar.getDefinitionYamlFile().getName(), + "Software Image")); + } + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR04298.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR04298.java new file mode 100644 index 0000000..6503c54 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR04298.java @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r04298.yaml") +public class VTPValidateCSARR04298 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingTestFolderNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingTestFolderNotFound() { + super("Tests", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + + if (csar.getTestsFolder() == null) { + this.errors.add(new CSARErrorEntryMissingTestFolderNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R04298"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR07879.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR07879.java new file mode 100644 index 0000000..ad46620 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR07879.java @@ -0,0 +1,45 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r07879.yaml") +public class VTPValidateCSARR07879 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingAnsiblePlaybookNotFound() { + super("playbooks", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (!csar.getFileFromCsar("playbooks").exists()) { + this.errors.add(new CSARErrorEntryMissingAnsiblePlaybookNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R07879"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087.java new file mode 100644 index 0000000..31298fa --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087.java @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARError; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissingToscaDefinitionMetadataTemplateName; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissingToscaDefinitionNotFound; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissingToscaMetaDefinition; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r10087.yaml") +public class VTPValidateCSARR10087 extends VTPValidateCSARBase { + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + + for (CSARError e : csar.getErrors()) { + if (e instanceof CSARErrorEntryMissingToscaMetaDefinition || + e instanceof CSARErrorEntryMissingToscaDefinitionNotFound || + e instanceof CSARErrorEntryMissingToscaDefinitionMetadataTemplateName) { + this.errors.add(e); + } + } + } + + @Override + protected String getVnfReqsNo() { + return "R10087"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR13390.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR13390.java new file mode 100644 index 0000000..17c3018 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR13390.java @@ -0,0 +1,45 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r13390.yaml") +public class VTPValidateCSARR13390 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingAnsiblePlaybookNotFound() { + super("cookbooks", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (!csar.getFileFromCsar("playbooks").exists()) { + this.errors.add(new CSARErrorEntryMissingAnsiblePlaybookNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R13390"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR21322.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR21322.java new file mode 100644 index 0000000..9c0a791 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR21322.java @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r21322.yaml") +public class VTPValidateCSARR21322 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingTestFolderNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingTestFolderNotFound() { + super("Tests", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (csar.getTestsFolder() == null) { + this.errors.add(new CSARErrorEntryMissingTestFolderNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R21322"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR23823.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR23823.java new file mode 100644 index 0000000..6919f28 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR23823.java @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r23823.yaml") +public class VTPValidateCSARR23823 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingCertificatesNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingCertificatesNotFound() { + super("Certificates", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (csar.getCertificatesFile() == null) { + errors.add(new CSARErrorEntryMissingCertificatesNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R23823"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26881.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26881.java new file mode 100644 index 0000000..e036ce6 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26881.java @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r26881.yaml") +public class VTPValidateCSARR26881 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingArtifactsNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingArtifactsNotFound() { + super("Artifacts", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (!csar.getFileFromCsar("artifacts").exists()) { + errors.add(new CSARErrorEntryMissingArtifactsNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R26881"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26885.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26885.java new file mode 100644 index 0000000..97f2d3c --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR26885.java @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r26885.yaml") +public class VTPValidateCSARR26885 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingArtifactImage extends CSARErrorEntryMissing { + public CSARErrorEntryMissingArtifactImage() { + super("Artifacts/VNF_Image.bin", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (!csar.getFileFromCsar("Artifacts/VNF_Image.bin").exists()) { + this.errors.add(new CSARErrorEntryMissingArtifactImage()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R26885"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR27310.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR27310.java new file mode 100644 index 0000000..4c2210a --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR27310.java @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r27310.yaml") +public class VTPValidateCSARR27310 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingChefArtifactsNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingChefArtifactsNotFound() { + super("cookbooks", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (!csar.getFileFromCsar("cookbooks").exists()) { + errors.add(new CSARErrorEntryMissingChefArtifactsNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R27310"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40293.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40293.java new file mode 100644 index 0000000..7173156 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40293.java @@ -0,0 +1,45 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r40293.yaml") +public class VTPValidateCSARR40293 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingAnsiblePlaybookNotFound() { + super("playbooks", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (!csar.getFileFromCsar("playbooks").exists()) { + errors.add(new CSARErrorEntryMissingAnsiblePlaybookNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R40293"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40820.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40820.java new file mode 100644 index 0000000..99f180b --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR40820.java @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r40820.yaml") +public class VTPValidateCSARR40820 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingLicenseTerm extends CSARErrorEntryMissing { + public CSARErrorEntryMissingLicenseTerm() { + super("Licenses/License_term.txt", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (!csar.getFileFromCsar("Licenses/License_term.txt").exists()) { + this.errors.add(new CSARErrorEntryMissingLicenseTerm()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R40820"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR43958.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR43958.java new file mode 100644 index 0000000..0d42628 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR43958.java @@ -0,0 +1,45 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r43958.yaml") +public class VTPValidateCSARR43958 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingTestReportNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingTestReportNotFound() { + super("Tests/report.txt", CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (!csar.getFileFromCsar("Tests/report.txt").exists()) { + this.errors.add(new CSARErrorEntryMissingTestReportNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R43958"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR51347.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR51347.java new file mode 100644 index 0000000..1a39e14 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR51347.java @@ -0,0 +1,43 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARError; +import org.onap.cvc.csar.CSARArchive.CSARErrorInvalidEntryValueToscaDefinitionVersion; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r51347.yaml") +public class VTPValidateCSARR51347 extends VTPValidateCSARBase { + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + for (CSARError e : csar.getErrors()) { + if (e instanceof CSARErrorInvalidEntryValueToscaDefinitionVersion) { + this.errors.add(e); + break; + } + } + } + + @Override + protected String getVnfReqsNo() { + return "R51347"; + } + +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR66070.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR66070.java new file mode 100644 index 0000000..1d5c3c5 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR66070.java @@ -0,0 +1,47 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r66070.yaml") +public class VTPValidateCSARR66070 extends VTPValidateCSARBase { + + public static class CSARErrorEntryVNFProviderDetailsNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryVNFProviderDetailsNotFound() { + super("VNF Vendor details", + CSARArchive.TOSCA_Metadata + " or " + CSARArchive.TOSCA_Metadata__TOSCA_Meta__Entry_Definitions + " file"); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (csar.getVendorName() == null || + csar.getVersion() == null) { + errors.add(new CSARErrorEntryVNFProviderDetailsNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R66070"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77707.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77707.java new file mode 100644 index 0000000..13ac502 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77707.java @@ -0,0 +1,47 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r77707.yaml") +public class VTPValidateCSARR77707 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingDefinitionNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionNotFound() { + super("TOSCA definition or Tosca.Meata", + CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (csar.getToscaMeta().getEntryDefinitionYaml() == null || + csar.getDefinitionYamlFile() == null || !csar.getDefinitionYamlFile().exists()) { + errors.add(new CSARErrorEntryMissingDefinitionNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R77707"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77786.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77786.java new file mode 100644 index 0000000..efb258b --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR77786.java @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorEntryMissing; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r77786.yaml") +public class VTPValidateCSARR77786 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingAnsiblePlaybookNotFound extends CSARErrorEntryMissing { + public CSARErrorEntryMissingAnsiblePlaybookNotFound() { + super("cookbooks", + CSARArchive.CSAR_Archive); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (!csar.getFileFromCsar("playbooks").exists()) { + errors.add(new CSARErrorEntryMissingAnsiblePlaybookNotFound()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R77786"; + } +} diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234.java new file mode 100644 index 0000000..6400012 --- /dev/null +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234.java @@ -0,0 +1,48 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.cvc.csar.cc.sol004; + +import org.onap.cli.fw.schema.OnapCommandSchema; +import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARErrorInvalidEntryValue; +import org.onap.cvc.csar.cc.VTPValidateCSARBase; + +@OnapCommandSchema(schema = "vtp-validate-csar-r87234.yaml") +public class VTPValidateCSARR87234 extends VTPValidateCSARBase { + + public static class CSARErrorInvalidEntryValueNonToscaMetaNotSupported extends CSARErrorInvalidEntryValue { + public CSARErrorInvalidEntryValueNonToscaMetaNotSupported() { + super("CSAR Mode", "CSAR Archive", + "Only " + CSARArchive.Mode.WITH_TOSCA_META_DIR.name() + " mode is supported", + CSARArchive.Mode.WITH_TOSCA_META_DIR.name()); + this.setCode("0x1000"); + } + } + + @Override + protected void validateCSAR(CSARArchive csar) throws Exception { + if (!csar.getToscaMeta().getMode().name().equalsIgnoreCase(CSARArchive.Mode.WITH_TOSCA_META_DIR.name())) { + this.errors.add(new CSARErrorInvalidEntryValueNonToscaMetaNotSupported()); + } + } + + @Override + protected String getVnfReqsNo() { + return "R87234"; + } + +} |