Fix tools for diagnostics

This commit is contained in:
Vivek Kumar Dutta 2024-06-16 19:18:32 +05:30
parent 094ee2ecb7
commit d3eb113a02
6 changed files with 48 additions and 17 deletions

1
.gitignore vendored
View file

@ -12,3 +12,4 @@ out
/datamodel /datamodel
/build /build
/.repo /.repo
/utilities/bbf_configd

View file

@ -19,6 +19,9 @@ fi
[ ! -d "${BBFDM_PLUGIN_DIR}" ] && mkdir -p "${BBFDM_PLUGIN_DIR}" [ ! -d "${BBFDM_PLUGIN_DIR}" ] && mkdir -p "${BBFDM_PLUGIN_DIR}"
rm -f ${BBFDM_PLUGIN_DIR}/* rm -f ${BBFDM_PLUGIN_DIR}/*
[ ! -d "${BBFDM_MS_DIR}" ] && mkdir -p "${BBFDM_MS_DIR}"
rm -f ${BBFDM_MS_DIR}/*
if [ -z "${1}" ]; then if [ -z "${1}" ]; then
./tools/generate_dm.py tools/tools_input.json ./tools/generate_dm.py tools/tools_input.json
else else

View file

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
BBFDM_PLUGIN_DIR="/usr/share/bbfdm/plugins" BBFDM_PLUGIN_DIR="/usr/share/bbfdm/plugins"
BBFDM_MS_DIR="/usr/share/bbfdm/micro_services"
if [ -z "${CI_PROJECT_PATH}" ]; then if [ -z "${CI_PROJECT_PATH}" ]; then
CI_PROJECT_PATH=${PWD} CI_PROJECT_PATH=${PWD}

View file

@ -30,6 +30,7 @@ INSTALL(TARGETS bbfdm
INSTALL(DIRECTORY DESTINATION etc/bbfdm) INSTALL(DIRECTORY DESTINATION etc/bbfdm)
INSTALL(DIRECTORY DESTINATION etc/bbfdm/dmmap) INSTALL(DIRECTORY DESTINATION etc/bbfdm/dmmap)
INSTALL(DIRECTORY DESTINATION usr/share/bbfdm/plugins) INSTALL(DIRECTORY DESTINATION usr/share/bbfdm/plugins)
INSTALL(DIRECTORY DESTINATION usr/share/bbfdm/micro_services)
INSTALL(DIRECTORY DESTINATION usr/share/bbfdm) INSTALL(DIRECTORY DESTINATION usr/share/bbfdm)
INSTALL(DIRECTORY DESTINATION usr/libexec/rpcd) INSTALL(DIRECTORY DESTINATION usr/libexec/rpcd)

View file

@ -13,6 +13,9 @@ import glob
# Constants # Constants
BBF_ERROR_CODE = 0 BBF_ERROR_CODE = 0
CURRENT_PATH = os.getcwd() CURRENT_PATH = os.getcwd()
BBF_PLUGIN_DIR = "/usr/share/bbfdm/plugins/"
BBF_MS_DIR = "/usr/share/bbfdm/micro_services/"
DM_JSON_FILE = os.path.join(CURRENT_PATH, "libbbfdm", "dmtree", "json", "datamodel.json") DM_JSON_FILE = os.path.join(CURRENT_PATH, "libbbfdm", "dmtree", "json", "datamodel.json")
LIST_SUPPORTED_USP_DM = [] LIST_SUPPORTED_USP_DM = []
@ -145,11 +148,18 @@ def clear_list(input_list):
input_list.clear() input_list.clear()
def generate_shared_library(output_library, source_files, vendor_prefix, extra_dependencies): def generate_shared_library(dm_name, source_files, vendor_prefix, extra_dependencies, is_microservice=False):
# Return if source_files (list) is empty # Return if source_files (list) is empty
if len(source_files) == 0: if len(source_files) == 0:
return return
if is_microservice:
outdir=BBF_MS_DIR
else:
outdir=BBF_PLUGIN_DIR
output_library = outdir + dm_name
# Set vendor prefix # Set vendor prefix
if vendor_prefix is not None: if vendor_prefix is not None:
VENDOR_PREFIX = vendor_prefix VENDOR_PREFIX = vendor_prefix
@ -219,7 +229,7 @@ def build_and_install_bbfdm(vendor_prefix, vendor_list):
print('Compiling and installing bbfdmd done') print('Compiling and installing bbfdmd done')
def create_bbfdm_input_json_file(proto): def create_bbfdm_input_json_file(proto, dm_name=None):
data = { data = {
"daemon": { "daemon": {
}, },
@ -239,6 +249,10 @@ def create_bbfdm_input_json_file(proto):
} }
} }
if dm_name:
del data["cli"]["input"]["plugin_dir"]
data["cli"]["input"]["name"] = dm_name
file_path = '/tmp/bbfdm/input.json' file_path = '/tmp/bbfdm/input.json'
# Ensure the directory exists # Ensure the directory exists
@ -249,9 +263,7 @@ def create_bbfdm_input_json_file(proto):
json.dump(data, json_file, indent=4) json.dump(data, json_file, indent=4)
def fill_list_dm(proto, dm_list): def fill_list_dm(dm_list):
create_bbfdm_input_json_file(proto)
command = "bbfdmd -c schema Device." command = "bbfdmd -c schema Device."
try: try:
# Run the command # Run the command
@ -296,18 +308,24 @@ def remove_duplicate_elements(input_list):
def fill_list_supported_dm(): def fill_list_supported_dm():
for proto, DB in [("usp", LIST_SUPPORTED_USP_DM), ("cwmp", LIST_SUPPORTED_CWMP_DM)]:
create_bbfdm_input_json_file(proto)
fill_list_dm(DB)
DB.sort(key=lambda x: x['param'], reverse=False)
DB[:] = remove_duplicate_elements(DB)
fill_list_dm("usp", LIST_SUPPORTED_USP_DM) for file in os.listdir(BBF_MS_DIR):
LIST_SUPPORTED_USP_DM.sort(key=lambda x: x['param'], reverse=False) f = os.path.join(BBF_MS_DIR, file)
LIST_SUPPORTED_USP_DM[:] = remove_duplicate_elements(LIST_SUPPORTED_USP_DM)
fill_list_dm("cwmp", LIST_SUPPORTED_CWMP_DM)
LIST_SUPPORTED_CWMP_DM.sort(key=lambda x: x['param'], reverse=False)
LIST_SUPPORTED_CWMP_DM[:] = remove_duplicate_elements(LIST_SUPPORTED_CWMP_DM)
if os.path.isfile(f):
for proto, DB in [("usp", LIST_SUPPORTED_USP_DM), ("cwmp", LIST_SUPPORTED_CWMP_DM)]:
create_bbfdm_input_json_file(proto, f)
fill_list_dm(DB)
DB.sort(key=lambda x: x['param'], reverse=False)
DB[:] = remove_duplicate_elements(DB)
def clone_git_repository(repo, version=None): def clone_git_repository(repo, version=None):
repo_path='.repo/'+os.path.basename(repo) repo_path='.repo/'+os.path.basename(repo).replace('.git','')
if os.path.exists(repo_path): if os.path.exists(repo_path):
print(f' {repo} already exists at {repo_path} !') print(f' {repo} already exists at {repo_path} !')
return True return True
@ -344,18 +362,20 @@ def download_and_build_plugins(plugins, vendor_prefix):
repo = get_option_value(plugin, "repo") repo = get_option_value(plugin, "repo")
proto = get_option_value(plugin, "proto") proto = get_option_value(plugin, "proto")
dm_files = get_option_value(plugin, "dm_files") dm_files = get_option_value(plugin, "dm_files")
is_microservice = get_option_value(plugin, "is_microservice")
extra_dependencies = get_option_value(plugin, "extra_dependencies", []) extra_dependencies = get_option_value(plugin, "extra_dependencies", [])
repo_path = None repo_path = None
name=os.path.basename(repo).replace('.git','')
if repo is None or proto is None or dm_files is None or not isinstance(dm_files, list): if repo is None or proto is None or dm_files is None or not isinstance(dm_files, list):
print("Necessary input missing") print("Necessary input missing")
BBF_ERROR_CODE += 1 BBF_ERROR_CODE += 1
continue continue
print(f' - Processing plugin: {plugin}') print(f' - Processing plugin: MS({is_microservice}) {plugin}')
if proto == "git": if proto == "git":
repo_path = ".repo/"+os.path.basename(repo) repo_path = ".repo/"+name
version = get_option_value(plugin, "version") version = get_option_value(plugin, "version")
@ -394,7 +414,7 @@ def download_and_build_plugins(plugins, vendor_prefix):
BBF_ERROR_CODE += 1 BBF_ERROR_CODE += 1
if len(LIST_FILES) > 0: if len(LIST_FILES) > 0:
if not generate_shared_library(f"/usr/share/bbfdm/plugins/lib{plugin_index}.so", LIST_FILES, vendor_prefix, extra_dependencies): if not generate_shared_library(f"{name}{plugin_index}.so", LIST_FILES, vendor_prefix, extra_dependencies, is_microservice):
BBF_ERROR_CODE += 1 BBF_ERROR_CODE += 1
clear_list(LIST_FILES) clear_list(LIST_FILES)

View file

@ -223,6 +223,9 @@
"dm_files": [ "dm_files": [
"bbf_plugin/vendor_ethernet.c", "bbf_plugin/vendor_ethernet.c",
"bbf_plugin/dmlayer.c" "bbf_plugin/dmlayer.c"
],
"extra_dependencies": [
"-DTR181_VENDOR_EXTENSIONS_MACVLAN"
] ]
}, },
{ {
@ -255,6 +258,7 @@
"repo": "https://dev.iopsys.eu/bbf/tr143d.git", "repo": "https://dev.iopsys.eu/bbf/tr143d.git",
"proto": "git", "proto": "git",
"version": "devel", "version": "devel",
"is_microservice": true,
"dm_files": [ "dm_files": [
"src/diagnostics.c" "src/diagnostics.c"
] ]
@ -263,6 +267,7 @@
"repo": "https://dev.iopsys.eu/bbf/tr471d.git", "repo": "https://dev.iopsys.eu/bbf/tr471d.git",
"proto": "git", "proto": "git",
"version": "devel", "version": "devel",
"is_microservice": true,
"dm_files": [ "dm_files": [
"src/iplayercap.c" "src/iplayercap.c"
] ]