Set of files and scripts for Embedded Lab 1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

45 lines
1.1 KiB

  1. #
  2. # Installation information:
  3. # ln -s ~lab/.local ~root
  4. # ~/.local/bin/virtaulenv venv
  5. # . ./venv/bin/activate
  6. # export TMPDIR=/var/tmp
  7. # pip install git+https://www.funkthat.com/gitea/jmg/vlanmang.git
  8. #
  9. # Configuration information:
  10. # . ./venv/bin/activate
  11. # python -m vlanmang
  12. #
  13. import vlanmang
  14. from pysnmp.hlapi import usmDESPrivProtocol
  15. protomapping = dict(DES=usmDESPrivProtocol)
  16. def parse_snmpconf(fname):
  17. snmpconf = {}
  18. with open(fname) as fp:
  19. snmpconf = dict((l.strip().split() for l in fp if l.strip()))
  20. return snmpconf
  21. def make_vlanswitch(fname, switch_info, *args):
  22. snmpconf = parse_snmpconf(fname)
  23. authdata = dict(username=snmpconf['defSecurityName'], authKey=snmpconf['defAuthPassphrase'],
  24. privKey=snmpconf['defPrivPassphrase'], privProtocol=protomapping[snmpconf['defPrivType']])
  25. switch = vlanmang.SwitchConfig(snmpconf['transport'], authdata, switch_info, *args)
  26. return switch
  27. switch = {
  28. 1: {
  29. 'u': [ 1, 24 ],
  30. }
  31. }
  32. for i in range(2, 24):
  33. switch[i + 100] = dict(t=[ 1 ], u=[ i ])
  34. switch = make_vlanswitch('/root/.snmp/hosts/poe.conf', switch, list(range(25, 36)))