Skip to content
Snippets Groups Projects
Commit b9932662 authored by Marko Mecina's avatar Marko Mecina
Browse files

add dummy MIB generator option to import_mib

parent 87825e7e
No related branches found
No related tags found
No related merge requests found
...@@ -96,24 +96,39 @@ def import_mib(): ...@@ -96,24 +96,39 @@ def import_mib():
s.commit() s.commit()
s.close() s.close()
print('...DONE!')
if __name__ == '__main__': if __name__ == '__main__':
do_import = True
if '-c' in sys.argv: if '-c' in sys.argv:
MIBDIR = '/home/user/space/mib' # directory containing the SCOS2000 *.dat files MIBDIR = '/home/user/space/mib' # directory containing the SCOS2000 *.dat files
DBNAME = 'mib_schema_test' # SQL schema name to be created DBNAME = 'mib_schema_test' # SQL schema name to be created
DBURL = 'mysql://user:password@127.0.0.1' # credentials of MySQL account DBURL = 'mysql://user:password@127.0.0.1' # credentials of MySQL account
elif len(sys.argv) > 1:
elif '--dummy' in sys.argv:
sys.argv.remove('--dummy')
DBNAME, dbuser = sys.argv[-2:]
dbpw = getpass.getpass()
DBURL = 'mysql://{}:{}@127.0.0.1'.format(dbuser, dbpw)
do_import = False
elif len(sys.argv) > 3:
MIBDIR, DBNAME, dbuser = sys.argv[1:4] MIBDIR, DBNAME, dbuser = sys.argv[1:4]
dbpw = getpass.getpass() dbpw = getpass.getpass()
DBURL = 'mysql://{}:{}@127.0.0.1'.format(dbuser, dbpw) DBURL = 'mysql://{}:{}@127.0.0.1'.format(dbuser, dbpw)
else: else:
print('USAGE: ./import_mib.py <MIBDIR> <DBSCHEMA> <DBUSERNAME> [-c]\n' print('USAGE: ./import_mib.py <MIBDIR> <DBSCHEMA> <DBUSERNAME> [-c]\n'
'Options:\n\t-c\tUse configuration in script, any command line arguments will be ignored') 'Options:\n\t-c\tUse configuration in script, any command line arguments will be ignored.\n'
'\t--dummy\tCreate empty MIB structure only. Omit <MIBDIR> argument.')
sys.exit() sys.exit()
generate_wbsql() generate_wbsql()
create_schema() create_schema()
import_mib()
if do_import:
import_mib()
print('...DONE!')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment