summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main/java/org/onap/cvc/csar/cc
diff options
context:
space:
mode:
Diffstat (limited to 'csarvalidation/src/main/java/org/onap/cvc/csar/cc')
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR02454.java119
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR04298.java81
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR07879.java81
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR09467.java114
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR13390.java81
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR23823.java81
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR26881.java81
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR27310.java82
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR35851.java120
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR40293.java81
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR43958.java81
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR66070.java85
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR77707.java83
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR77786.java81
14 files changed, 1251 insertions, 0 deletions
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
new file mode 100644
index 0000000..c77db76
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR02454.java
@@ -0,0 +1,119 @@
+/*
+ * 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
new file mode 100644
index 0000000..3c2ffd5
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR04298.java
@@ -0,0 +1,81 @@
+/*
+ * 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
new file mode 100644
index 0000000..8f975cc
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR07879.java
@@ -0,0 +1,81 @@
+/*
+ * 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
new file mode 100644
index 0000000..8ce3a23
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR09467.java
@@ -0,0 +1,114 @@
+/*
+ * 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
new file mode 100644
index 0000000..6c44ee6
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR13390.java
@@ -0,0 +1,81 @@
+/*
+ * 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
new file mode 100644
index 0000000..f8a0385
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR23823.java
@@ -0,0 +1,81 @@
+/*
+ * 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/VTPValidateCSARR26881.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR26881.java
new file mode 100644
index 0000000..e9efd38
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR26881.java
@@ -0,0 +1,81 @@
+/*
+ * 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-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 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");
+ }
+ }
+
+ @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());
+ }
+
+ csar.cleanup();
+ } catch (Exception e) {
+ LOG.error("R-26881: ", 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
new file mode 100644
index 0000000..7b2e25a
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR27310.java
@@ -0,0 +1,82 @@
+/*
+ * 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
new file mode 100644
index 0000000..068b372
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR35851.java
@@ -0,0 +1,120 @@
+/*
+ * 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
new file mode 100644
index 0000000..eaf0710
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR40293.java
@@ -0,0 +1,81 @@
+/*
+ * 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
new file mode 100644
index 0000000..10ae1c0
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR43958.java
@@ -0,0 +1,81 @@
+/*
+ * 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
new file mode 100644
index 0000000..8d51c94
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR66070.java
@@ -0,0 +1,85 @@
+/*
+ * 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
new file mode 100644
index 0000000..9549e67
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR77707.java
@@ -0,0 +1,83 @@
+/*
+ * 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
new file mode 100644
index 0000000..1fa5a1f
--- /dev/null
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR77786.java
@@ -0,0 +1,81 @@
+/*
+ * 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()));
+ }
+ }
+}