Skip to content

Commit

Permalink
write sql from workflow instead of oids cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ollyg committed Dec 26, 2024
1 parent 3d23519 commit 2fcb79f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/update_products.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Download Products JSON
name: Update Products
on:
workflow_dispatch:
inputs:
Expand All @@ -19,19 +19,21 @@ jobs:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.

- name: getjsonfiles
- name: Download and Build Products Table
run: |
cd products
echo 'DELETE FROM "product";' > ./product.sql.new
echo 'COPY "product" ("oid", "mib", "leaf", "description") FROM STDIN;' >> ./product.sql.new
curl --silent --location "https://mibbrowser.online/mibdb_search.php?all=1" | \
grep JUNIPER-CHASSIS-DEFINES | \
grep -o 'mib=[^"]\+' | \
sed -e 's/mib=//' | \
grep -hi -E '(product|oid|JUNIPER-CHASSIS-DEFINES)' | \
while read mib; do \
curl --silent --location "https://mibbrowser.online/mibs_json/$mib.json" | \
./pysmi-json-to-oid-cache.py >> ./products_oids.new; \
./pysmi-json-to-products-table.py >> ./product.sql.new; \
done
mv ./products_oids.new ./products_oids
mv ./product.sql.new ./product.sql
- name: Commit files
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json

'''
Makes netdisco-mibs oids cache from a pysmi JSON representation of a MIB.
Makes netdisco products lookup table from a pysmi JSON representation of a MIB.
Standard input to standard output.
'''
Expand All @@ -20,4 +20,5 @@
description = value.get('description', '')

# .1.3.6.1.6.3.10.3.1.1,SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance,,,,,,The description...
print(f".{value['oid']},{module}::{leaf},,,,,,{description}")
print(f'.{value['oid']}\t{module}\t{leaf}\t{description}')
# print(f".{value['oid']},{module}::{leaf},,,,,,{description}")

0 comments on commit 2fcb79f

Please sign in to comment.