Refactor to use VPPApiJSONFiles
This commit is contained in:
16
vppapi.py
16
vppapi.py
@ -3,7 +3,7 @@ The functions in this file interact with the VPP API to retrieve certain
|
|||||||
interface metadata.
|
interface metadata.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from vpp_papi import VPPApiClient
|
from vpp_papi import VPPApiClient, VPPApiJSONFiles
|
||||||
import os
|
import os
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import logging
|
import logging
|
||||||
@ -30,19 +30,13 @@ class VPPApi:
|
|||||||
if self.connected:
|
if self.connected:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
vpp_json_dir = "/usr/share/vpp/api/"
|
vpp_json_dir = VPPApiJSONFiles.find_api_dir([])
|
||||||
|
vpp_jsonfiles = VPPApiJSONFiles.find_api_files(api_dir=vpp_json_dir)
|
||||||
# construct a list of all the json api files
|
if not vpp_jsonfiles:
|
||||||
jsonfiles = []
|
|
||||||
for root, dirnames, filenames in os.walk(vpp_json_dir):
|
|
||||||
for filename in fnmatch.filter(filenames, "*.api.json"):
|
|
||||||
jsonfiles.append(os.path.join(root, filename))
|
|
||||||
|
|
||||||
if not jsonfiles:
|
|
||||||
logger.error("no json api files found")
|
logger.error("no json api files found")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.vpp = VPPApiClient(apifiles=jsonfiles, server_address=self.address)
|
self.vpp = VPPApiClient(apifiles=vpp_jsonfiles, server_address=self.address)
|
||||||
try:
|
try:
|
||||||
logger.info("Connecting to VPP")
|
logger.info("Connecting to VPP")
|
||||||
self.vpp.connect(self.clientname)
|
self.vpp.connect(self.clientname)
|
||||||
|
Reference in New Issue
Block a user