Skip to content
Snippets Groups Projects
Commit 03a6134f authored by yadavmr's avatar yadavmr
Browse files

Bug 515 fixed


Change-Id: I152ba68153d5ba4792949586d12f6d367b66a4d5
Signed-off-by: default avataryadavmr <my00514913@techmahindra.com>
parent c0fcbb08
No related branches found
No related tags found
No related merge requests found
......@@ -790,6 +790,13 @@ if [ $CREATE == false ]; then
fi
cd $BASE_DIR
# Mrityunjay Yadav: Validate descriptor
python /usr/share/osm-devops/descriptor-packages/tools/validate_descriptor.py $DEST_DIR/$PKG/$descriptor
if [ $? -ne 0 ]; then
rc=$?
echo "ERROR: validating descriptor for $PKG ($rc)" >&2
exit $rc
fi
if [ $DRY_RUN == false ]; then
if [ $VERBOSE == true ]; then
tar zcvf "$DEST_DIR/$PKG.tar.gz" "${PKG}" ${RM}
......
......@@ -22,6 +22,7 @@ import json
import yaml
import sys
import getopt
import os
"""
Tests the format of OSM VNFD and NSD descriptors
......@@ -46,6 +47,7 @@ def usage():
print(" -i|--input FILE: (same as param FILE) descriptor file to be upgraded")
return
def remove_prefix(desc, prefix):
"""
Recursively removes prefix from keys
......@@ -68,7 +70,33 @@ def remove_prefix(desc, prefix):
if isinstance(desc, (list, tuple, dict)):
remove_prefix(i, prefix)
if __name__=="__main__":
# Mrityunjay Yadav: Function to verify charm included in VNF Package
def validate_charm(charm, desc_file):
"""
Verify charm included in VNF Package and raised error if invalid
:param charm: vnf-configuration/vdu-configuration
:param desc_file: descriptor file
:return: None
"""
check_list = ['layer.yaml', 'metadata.yaml', 'actions.yaml', 'actions', 'hooks']
charm_name = charm['juju']['charm']
charm_dir = os.path.join(os.path.abspath(os.path.dirname(desc_file)), 'charms', charm_name)
config_primitive = charm.get('config-primitive', [])
initial_config_primitive = charm.get('initial-config-primitive', [])
if charm.get('metrics'):
check_list.append('metrics.yaml')
if os.path.exists(charm_dir):
if not all(item in os.listdir(charm_dir) for item in check_list):
raise KeyError("Invalid charm {}".format(charm_name))
else:
raise KeyError("Provided charm:{} does not exist in descriptor.".format(charm_name))
if __name__ == "__main__":
error_position = []
format_output_yaml = True
input_file_name = None
......@@ -133,10 +161,17 @@ if __name__=="__main__":
if interface.get("virtual-interface", {}).get("type") == "OM-MGMT":
raise KeyError(
"Wrong 'Virtual-interface type': Deprecated 'OM-MGMT' value. Please, use 'PARAVIRT' instead")
# Mrityunjay yadav: Verify charm if included in vdu
if vdu.get("vdu-configuration", False):
validate_charm(vdu["vdu-configuration"], input_file_name)
if vnfd.get("mgmt-interface"):
mgmt_iface = True
if vnfd["mgmt-interface"].get("vdu-id"):
raise KeyError("'mgmt-iface': Deprecated 'vdu-id' field. Please, use 'cp' field instead")
# Mrityunjay yadav: Verify charm if included in vnf
if vnfd.get("vnf-configuration", False):
validate_charm(vnfd["vnf-configuration"], input_file_name)
if not mgmt_iface:
raise KeyError("'mgmt-iface' is a mandatory field and it is not defined")
myvnfd = vnfd_catalog.vnfd()
......
......@@ -19,8 +19,9 @@ RUN add-apt-repository -y "deb ${REPOSITORY_BASE}/${RELEASE} ${REPOSITORY} devop
ARG OSMCLIENT_VERSION
ARG DEVOPS_VERSION
ARG IM_VERSION
RUN apt-get update && apt-get -y install osm-devops${DEVOPS_VERSION} python-osmclient${OSMCLIENT_VERSION}
RUN apt-get update && apt-get -y install osm-devops${DEVOPS_VERSION} python-osmclient${OSMCLIENT_VERSION} python-osm-im${IM_VERSION}
ENV OSM_SOL005=True
ENV OSM_HOSTNAME=nbi:9999
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment