diff options
Diffstat (limited to 'csarvalidation/src/main/java/org')
10 files changed, 674 insertions, 36 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 9d80605..7574ab5 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java @@ -905,6 +905,15 @@ public class CSARArchive implements AutoCloseable { } } + + public String getProductName() { + if (this.toscaMeta.getMode().equals(Mode.WITH_TOSCA_META_DIR)) { + return this.manifest.getMetadata().getProductName(); + } else { + return this.definition.getMetadata().getTemplateAuthor(); + } + } + public String getVendorName() { if (this.toscaMeta.getMode().equals(Mode.WITH_TOSCA_META_DIR)) { return this.toscaMeta.getCompanyName(); @@ -915,7 +924,7 @@ public class CSARArchive implements AutoCloseable { public String getVersion() { if (this.toscaMeta.getMode().equals(Mode.WITH_TOSCA_META_DIR)) { - return this.toscaMeta.getCsarVersion(); + return this.manifest.getMetadata().getPackageVersion(); } else { return this.definition.getMetadata().getTemplateVersion(); } @@ -937,7 +946,7 @@ public class CSARArchive implements AutoCloseable { int lineNo =0; List<String>lines = FileUtils.readLines(this.manifestMfFile); - //first hit the metadata section + //first hit the metadata: section for (String line: lines) { lineNo ++; line = line.trim(); @@ -955,13 +964,13 @@ public class CSARArchive implements AutoCloseable { if (lineNo < lines.size()) { for (int i = lineNo; i< lines.size(); i++) { String line = lines.get(i).trim(); - i ++; - if (line.startsWith("#")) { + if (line.startsWith("#") || line.isEmpty()) { continue; } String[] tokens = line.split(":"); + if (tokens.length < 2) continue; String key = tokens[0]; String value = tokens[1]; 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 6a8e3bd..006d78d 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java @@ -195,6 +195,7 @@ public class VTPValidateCSAR extends OnapCommand { //Fill up the basic details CSARValidation validation = new CSARValidation(); + validation.getVnf().setName(csar.getProductName()); validation.getVnf().setVendor(csar.getVendorName()); validation.getVnf().setVersion(csar.getVersion()); validation.getVnf().setType("TOSCA"); @@ -206,16 +207,14 @@ public class VTPValidateCSAR extends OnapCommand { CSARValidation.Result resultSOL004 = new CSARValidation.Result(); resultSOL004.setVnfreqName("SOL004"); resultSOL004.setDescription(csar.getSOL004Version()); - resultSOL004.setErrors(csar.getErrors()); - resultSOL004.setPassed(true); - for (CSARError error: resultSOL004.getErrors()) { + for (CSARError error: csar.getErrors()) { if (!ignoreCodes.contains(error.getCode())) { - resultSOL004.setPassed(false); + resultSOL004.getErrors().add(error); overallPass = false; - break; } } + resultSOL004.setPassed(resultSOL004.getErrors().size() == 0); validation.getResults().add(resultSOL004); @@ -232,22 +231,19 @@ public class VTPValidateCSAR extends OnapCommand { result.setDescription(cmd.getDescription()); cmd.execute(); - result.setErrors( (List<CSARError>)cmd.getResult().getOutput()); - result.setPassed(true); - - for (CSARError error: result.getErrors()) { - if (!ignoreCodes.contains(error.getCode())) { - result.setPassed(false); - overallPass = false; - break; + for (CSARError error: (List<CSARError>) cmd.getResult().getOutput()) { + if (!ignoreCodes.contains(error.getCode()) && !ignoreCodes.contains(vnfreq + "-"+ error.getCode())) { + result.getErrors().add(error); } } + result.setPassed(result.getErrors().size() == 0); validation.getResults().add(result); } catch (Exception e) { result.setPassed(false); overallPass = false; result.getErrors().add(new CSARArchive.CSARErrorUnknown(e.getMessage())); + validation.getResults().add(result); } } 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/sol001/VTPValidateCSARR02454.java index 14998f5..7d0489e 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR02454.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol001/VTPValidateCSARR02454.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.onap.cvc.csar.cc.sol004; +package org.onap.cvc.csar.cc.sol001; import java.io.FileInputStream; import java.util.Map; 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 index cbacc35..407d872 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright 2017 Huawei Technologies Co., Ltd. +x * 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. @@ -28,13 +28,20 @@ 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) { + public static class CSARErrorEntryMissingVDUCompute extends CSARErrorEntryMissing { + public CSARErrorEntryMissingVDUCompute(String defYaml, String entry) { super(entry, defYaml); this.setCode("0x1000"); } } + public static class CSARErrorEntryMissingVDUVirtualStorage extends CSARErrorEntryMissing { + public CSARErrorEntryMissingVDUVirtualStorage(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1001"); + } + } + @Override protected void validateCSAR(CSARArchive csar) throws Exception { try(FileInputStream ipStream = new FileInputStream(csar.getDefinitionYamlFile())) { @@ -42,23 +49,34 @@ public class VTPValidateCSARR09467 extends VTPValidateCSARBase { yaml = (Map<String, ?>) yaml.get("topology_template"); Map<String, ?> nodeTmpls = (Map<String,?>) yaml.get("node_templates"); - boolean vlExist = false; + boolean computeExist = false; + boolean storageExist = 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; + computeExist = true; + + } + + if (type.equalsIgnoreCase("tosca.nodes.nfv.VDU.VirtualStorage")) { + storageExist = true; + } } } - if (!vlExist) - this.errors.add(new CSARErrorEntryMissingFlavor( + if (!computeExist) + this.errors.add(new CSARErrorEntryMissingVDUCompute( csar.getDefinitionYamlFile().getName(), - "Flavor")); + "VDU Compute")); + + if (!storageExist) + this.errors.add(new CSARErrorEntryMissingVDUVirtualStorage( + csar.getDefinitionYamlFile().getName(), + "VirtualStorage")); } } 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 index fac261a..c5f6319 100644 --- 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 @@ -19,13 +19,66 @@ 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; +import org.yaml.snakeyaml.Yaml; + +import java.io.FileInputStream; +import java.util.Map; @OnapCommandSchema(schema = "vtp-validate-csar-r32155.yaml") public class VTPValidateCSARR32155 extends VTPValidateCSARBase { + public static class CSARErrorEntryMissingVirtualLink extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingVirtualLink(String entry, String file) { + super(entry, file); + 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, ?> yamlTmpls = (Map<String, ?>) yaml.get("node_templates"); + + boolean vlExist[] = new boolean[2]; + + for (Object node0 : yamlTmpls.values()) { + + Map<String, ?> node = (Map<String, ?>) node0; + + if (node.containsKey("type")) { + String type = (String) node.get("type"); + + if (type.equalsIgnoreCase("tosca.nodes.nfv.VnfVirtualLinkDesc")) { + + vlExist[0] = true; + } + + if (type.equalsIgnoreCase("tosca.capabilities.nfv.VirtualLinkable")) { + + vlExist[1] = true; + } + } + } + + if (!vlExist[0]) { + this.errors.add( + new CSARErrorEntryMissingVirtualLink( + "Virtual", + csar.getDefinitionYamlFile().getName())); + } + + if (!vlExist[1]) { + this.errors.add( + new CSARErrorEntryMissingVirtualLink( + "Virtual", + csar.getDefinitionYamlFile().getName())); + } + } + } @Override 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 index 6c7b3a6..f25afd7 100644 --- 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 @@ -28,8 +28,23 @@ 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) { + public static class CSARErrorEntryMissingDefinitionYamlVnfVirtualLink extends CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamlVnfVirtualLink(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + + public static class CSARErrorEntryMissingDefinitionYamlVduCp extends CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamlVduCp(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamlVnfExtCp extends CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamlVnfExtCp(String defYaml, String entry) { super(entry, defYaml); this.setCode("0x1000"); } @@ -42,23 +57,44 @@ public class VTPValidateCSARR35851 extends VTPValidateCSARBase { yaml = (Map<String, ?>) yaml.get("topology_template"); Map<String, ?> nodeTmpls = (Map<String,?>) yaml.get("node_templates"); - boolean vlExist = false; + boolean vlExist[] = new boolean[3]; 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; + vlExist[0] = true; + + } + + if (type.equalsIgnoreCase("tosca.nodes.nfv.VduCp")) { + vlExist[1] = true; + + } + + if (type.equalsIgnoreCase("tosca.nodes.nfv.VnfExtCp")) { + vlExist[2] = true; + } } } - if (!vlExist) - this.errors.add(new CSARErrorEntryMissingDefinitionYamlTopology( + if (!vlExist[0]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamlVnfVirtualLink( csar.getDefinitionYamlFile().getName(), - "Topology VL")); + "nodes VnfVirtualLink")); + + + if (!vlExist[1]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamlVduCp( + csar.getDefinitionYamlFile().getName(), + "nodes VduCp")); + + if (!vlExist[2]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamlVnfExtCp( + csar.getDefinitionYamlFile().getName(), + "nodes VnfExtCp")); } } 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 index 02f7b0d..eaf9ad9 100644 --- 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 @@ -19,13 +19,435 @@ 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; +import org.yaml.snakeyaml.Yaml; + +import java.io.FileInputStream; +import java.util.Map; @OnapCommandSchema(schema = "vtp-validate-csar-r54356.yaml") public class VTPValidateCSARR54356 extends VTPValidateCSARBase { + public static class CSARErrorEntryMissingDefinitionYamldatatypesL3AddressData extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesL3AddressData(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesAddressData extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesAddressData(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVirtualNetworkInterfaceRequirements extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVirtualNetworkInterfaceRequirements(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesConnectivityType extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesConnectivityType(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesRequestedAdditionalCapability extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesRequestedAdditionalCapability(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVirtualMemory extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVirtualMemory(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVirtualCpu extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVirtualCpu(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVirtualCpuPinning extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVirtualCpuPinning(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfcConfigurableProperties extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVnfcConfigurableProperties(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVduProfile extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVduProfile(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVlProfile extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVlProfile(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesInstantiationLevel extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesInstantiationLevel(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVduLevel extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVduLevel(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesScaleInfo extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesScaleInfo(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesinjectFile extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesinjectFile(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesScalingAspect extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesScalingAspect(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesLinkBitRateRequirements extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesLinkBitRateRequirements(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesQos extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesQos(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesCpProtocolData extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesCpProtocolData(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfConfigurableProperties extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVnfConfigurableProperties(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfAdditionalConfigurableProperties extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVnfAdditionalConfigurableProperties(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributes extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributes(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributesExtensions extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributesExtensions(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributesMetadata extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributesMetadata(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[] = new boolean[30]; + + 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.datatypes.nfv.L3AddressData")) { + vlExist[0] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.AddressData")) { + vlExist[1] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VirtualNetworkInterfaceRequirements")) { + vlExist[2] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.ConnectivityType")) { + vlExist[3] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.RequestedAdditionalCapability")) { + vlExist[4] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VirtualMemory")) { + vlExist[5] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VirtualCpu")) { + vlExist[6] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VirtualCpuPinning")) { + vlExist[7] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfcConfigurableProperties")) { + vlExist[8] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VduProfile")) { + vlExist[9] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VlProfile")) { + vlExist[10] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.InstantiationLevel")) { + vlExist[11] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VduLevel")) { + vlExist[12] = true; + + } + if (type.equalsIgnoreCase("tosca.datatypes.nfv.ScaleInfo")) { + vlExist[13] = true; + + } + if (type.equalsIgnoreCase("tosca.datatypes.nfv.injectFile")) { + vlExist[14] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.ScalingAspect")) { + vlExist[15] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.LinkBitRateRequirements")) { + vlExist[16] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.Qos")) { + vlExist[17] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.CpProtocolData")) { + vlExist[18] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfConfigurableProperties")) { + vlExist[19] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfAdditionalConfigurableProperties")) { + vlExist[20] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfInfoModifiableAttributes")) { + vlExist[21] = true; + + } + + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfInfoModifiableAttributesExtensions")) { + vlExist[22] = true; + + } + if (type.equalsIgnoreCase("tosca.datatypes.nfv.VnfInfoModifiableAttributesMetadata")) { + vlExist[23] = true; + + } + + } + } + + if (!vlExist[0]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesL3AddressData( + csar.getDefinitionYamlFile().getName(), + "datatypes L3AddressData")); + + + if (!vlExist[1]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesAddressData( + csar.getDefinitionYamlFile().getName(), + "datatypes AddressData")); + + if (!vlExist[2]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVirtualNetworkInterfaceRequirements( + csar.getDefinitionYamlFile().getName(), + "datatypes VirtualNetworkInterfaceRequirements")); + + if (!vlExist[3]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesConnectivityType( + csar.getDefinitionYamlFile().getName(), + "datatypes ConnectivityType")); + + if (!vlExist[4]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesRequestedAdditionalCapability( + csar.getDefinitionYamlFile().getName(), + "datatypes RequestedAdditionalCapability")); + + if (!vlExist[5]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVirtualMemory( + csar.getDefinitionYamlFile().getName(), + "datatypes VirtualMemory")); + + if (!vlExist[6]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVirtualCpu( + csar.getDefinitionYamlFile().getName(), + "datatypes VirtualCpu")); + + if (!vlExist[7]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVirtualCpuPinning( + csar.getDefinitionYamlFile().getName(), + "datatypes VirtualCpuPinning")); + + if (!vlExist[8]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVnfcConfigurableProperties( + csar.getDefinitionYamlFile().getName(), + "datatypes VnfcConfigurableProperties")); + + if (!vlExist[9]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVduProfile( + csar.getDefinitionYamlFile().getName(), + "datatypes VduProfile")); + + if (!vlExist[10]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVlProfile( + csar.getDefinitionYamlFile().getName(), + "datatypes VlProfile")); + + if (!vlExist[11]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesInstantiationLevel( + csar.getDefinitionYamlFile().getName(), + "datatypes InstantiationLevel")); + + if (!vlExist[12]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVduLevel( + csar.getDefinitionYamlFile().getName(), + "datatypes VduLevel")); + + if (!vlExist[13]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesScaleInfo( + csar.getDefinitionYamlFile().getName(), + "datatypes ScaleInfo")); + + if (!vlExist[14]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesinjectFile( + csar.getDefinitionYamlFile().getName(), + "datatypes injectFile")); + + if (!vlExist[15]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesScalingAspect( + csar.getDefinitionYamlFile().getName(), + "datatypes ScalingAspect")); + + if (!vlExist[16]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesLinkBitRateRequirements( + csar.getDefinitionYamlFile().getName(), + "datatypes LinkBitRateRequirements")); + + if (!vlExist[17]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesQos( + csar.getDefinitionYamlFile().getName(), + "datatypes Qos")); + + if (!vlExist[18]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesCpProtocolData( + csar.getDefinitionYamlFile().getName(), + "datatypes CpProtocolData")); + + if (!vlExist[19]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVnfConfigurableProperties( + csar.getDefinitionYamlFile().getName(), + "datatypes VnfConfigurableProperties")); + + if (!vlExist[20]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVnfAdditionalConfigurableProperties( + csar.getDefinitionYamlFile().getName(), + "datatypes VnfAdditionalConfigurableProperties")); + + if (!vlExist[21]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributes( + csar.getDefinitionYamlFile().getName(), + "datatypes VnfInfoModifiableAttributes")); + + if (!vlExist[22]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributesExtensions( + csar.getDefinitionYamlFile().getName(), + "datatypes VnfInfoModifiableAttributesExtensions")); + if (!vlExist[23]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamldatatypesVnfInfoModifiableAttributesMetadata( + csar.getDefinitionYamlFile().getName(), + "datatypes VnfInfoModifiableAttributesMetadata")); + } } @Override 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 index a45ba5e..c6075bc 100644 --- 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 @@ -19,12 +19,64 @@ 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; +import org.yaml.snakeyaml.Yaml; + +import java.io.FileInputStream; +import java.util.Map; @OnapCommandSchema(schema = "vtp-validate-csar-r67895.yaml") public class VTPValidateCSARR67895 extends VTPValidateCSARBase { + + public static class CSARErrorEntryMissingDefinitionYamlcapabilitiesVirtualBindable extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamlcapabilitiesVirtualBindable(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamlcapabilitiesVirtualLinkable extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamlcapabilitiesVirtualLinkable(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[] = new boolean[2]; + + 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.capabilities.nfv.VirtualBindable")) { + vlExist[0] = true; + + } + + if (type.equalsIgnoreCase("tosca.capabilities.nfv.VirtualLinkable")) { + vlExist[1] = true; + + } + } + } + + if (!vlExist[0]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamlcapabilitiesVirtualBindable( + csar.getDefinitionYamlFile().getName(), + "capabilities VirtualBindable")); + + if (!vlExist[1]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamlcapabilitiesVirtualLinkable( + csar.getDefinitionYamlFile().getName(), + "capabilities VirtualLinkable")); + } } @Override 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 index fd9b2d6..c7daafe 100644 --- 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 @@ -19,13 +19,65 @@ 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; +import org.yaml.snakeyaml.Yaml; + +import java.io.FileInputStream; +import java.util.Map; @OnapCommandSchema(schema = "vtp-validate-csar-r95321.yaml") public class VTPValidateCSARR95321 extends VTPValidateCSARBase { + public static class CSARErrorEntryMissingDefinitionYamlRelationshipsVirtualBindsTo extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamlRelationshipsVirtualBindsTo(String defYaml, String entry) { + super(entry, defYaml); + this.setCode("0x1000"); + } + } + + public static class CSARErrorEntryMissingDefinitionYamlRelationshipsVirtualLinksTo extends CSARArchive.CSARErrorEntryMissing { + public CSARErrorEntryMissingDefinitionYamlRelationshipsVirtualLinksTo(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[] = new boolean[2]; + + 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.relationships.nfv.VirtualBindsTo")) { + vlExist[0] = true; + + } + + if (type.equalsIgnoreCase("tosca.relationships.nfv.VirtualLinksTo")) { + vlExist[1] = true; + + } + } + } + + if (!vlExist[0]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamlRelationshipsVirtualBindsTo( + csar.getDefinitionYamlFile().getName(), + "Relationships VirtualBindsTo")); + + if (!vlExist[1]) + this.errors.add(new CSARErrorEntryMissingDefinitionYamlRelationshipsVirtualLinksTo( + csar.getDefinitionYamlFile().getName(), + "RelationshipsRelationships VirtualLinksTo")); + } } @Override 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 index 8fc216b..a34196e 100644 --- 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 @@ -21,7 +21,7 @@ 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") +@OnapCommandSchema(schema = "vtp-validate-csar-r01123.yaml") public class VTPValidateCSARR01123 extends VTPValidateCSARBase { public static class CSARErrorEntryVNFProviderDetailsNotFound extends CSARErrorEntryMissing { |