botblox / botblox-manager-software Goto Github PK
View Code? Open in Web Editor NEWUniversal Command Line Interface for programming managed BotBlox offerings
License: MIT License
Universal Command Line Interface for programming managed BotBlox offerings
License: MIT License
Currently, we rely on the user knowing what inputs to put into the optional arguments in the command line. Whilst it is fairly straightforward, it is not idiot-proof. A better idea would be to implement something along the lines of https://github.com/CITGuru/PyInquirer to make an interactive user interface that limits the options the user can pick.
Test botblox -D /dev/ttyUSB0 vlan --group 1 --group 2 --group 3 --group 4 --group 5
to ensure that we get the expected result (which is that each register setting should be different with only the bitmask for the port being included in the port vlan member group.
Issue:
Acceptance:
Follow the format for VLAN
configuration and do something similar with port mirroring. Crucially the CLI should have a --reset
option for this functionality as well.
Other technical debts are handled in other tickets but try to do this ticket in a way that makes refactoring the code a lot easier when we come to pay off the technical debt.
Update the confluence wiki with information on how a user runs our application and documentation on what each function on the CLI does.
Includes pages for each functionality (i.e. page for VLAN, port mirroring, etc) and a list of acceptable values
Update the Readme with some of this information (not all of it else the readme becomes way too long).
In firmware, the number of "commands" that can be stored is set to 20:
Is it possible to raise this number if required? I see the internal EEPROM has 512 B, which would allow storing 128 commands (assuming "command" is the 4-byte register write thing). What would be the consequences? Would the startup/memory store/read times get longer?
Also, what is the expected lifetime of the EEPROM? How many writes should it survive?
This is a necessary part of the CI/CD flow to enable developers regardless of their setup to use our software
Issue:
mirror
commandAcceptance:
https://botblox.atlassian.net/wiki/spaces/HARDWARE/pages/34373710/BotBlox+Manager+configuration+documentation is talking about portmirror
command, but the latest master branch has mirror
command.
Also, the Example
column contents are weird. Now it contains:
<Base command> <Base positional argument {vlan}> --group 1 2 --group 3 4
Why not
botblox vlan --group 1 2 --group 3 4
?
Self-explanatory title description here - the idea is that it will help with modularising the application further and cleaning up the code base
Issue:
switch.py
is very specific to SMI protocol, which may not be sustainable going into the future as we are likely to add more devices that communicate with the switch chip.The tool currently requires Python 3.7 or even 3.8. The readme of this package states 3.6+ is required. And I really vouch for supporting 3.6 as that is the default version on Ubuntu 18.04 which still has 2 years of support ahead.
Also, the readme says the installation command is pip install botblox
. This command is almost never correct (except when used in a virtualenv, which is however described after this command). On some systems, pip
will denote the Python 2 pip. These systems know Python 3's pip as pip3
. To avoid any confusion, the safest way to always get Python3 pip is python3 -m pip
. Also, I would suggest to either prepend the command with sudo
, add the --user
or move the virtualenv specs directly to the installation section.
This is what I get running on Python 3.6:
$ python3.6 -m manager
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/peci1/.local/lib/python3.6/site-packages/manager/__main__.py", line 12, in <module>
main()
File "/home/peci1/.local/lib/python3.6/site-packages/manager/__main__.py", line 8, in main
cli()
File "/home/peci1/.local/lib/python3.6/site-packages/manager/cli.py", line 82, in cli
required=True,
File "/usr/lib/python3.6/argparse.py", line 1716, in add_subparsers
action = parsers_class(option_strings=[], **kwargs)
I've set up port-based VLAN using the following command:
python3.8 -m manager -D /dev/ttyACM0 vlan --group 1 2 --group 3 4 5
After this command, cables connected to ports 1 and 2 are not able to communicate. When I reset the vlan config, the communication is without problems. I also tried other ports, but it seems that setting any vlan config, all ports that are part of any vlan group are not able to communicate. Their LEDs blink, but no data pass through the switch.
I'll try to investigate this more in depth.
I'm not sure if it requires some changes in the firmware or not, but it would be great if the switch were not working in the half-initialized state when it is loading the configuration command-by-command. Some the intermediate states may be invalid and destructive for the rest of the network.
Maybe the 0.11 Power Down
register could be used to shut down all ports, then do the configuration changes, and then enable the ports again?
Currently, the dictionary which contains the register information for the memory registers that we write to on the IC chip is hardcoded in the vlan_config.py
as a dictionary. This makes it pretty much unable to be reused.
We want a way to be able to define all the configurations (preferably) in a single config file (.json file) so that it can be used and edited easily, without the need to hardcode into the .py
files
Issue:
Acceptance:
Follow similar procedure as in https://github.com/botblox/botblox-manager-firmware
Follow convention set by #21
I haven't found in docs whether all commands I issue via the botblox
tool are somehow "stacked" and all stored in the EEPROM, or if always just the last vlan
and last mirror
commands are stored and reloaded after boot.
Currently, we are hardcoding the information in that we sent to the firmware on the STM32.
To realise this project and take it to the next level, we need to implement CLI functionality as a high priority.
Start with VLAN as it is relatively straightforward conceptually to think about.
Tasks:
<python app.py vlan --groups 1,2,3 4,5>
when ran inside the docker container as it is running. vlan
is a required positional argument and --groups are the exact groups with space separators between groups and comma delimiters between different members of that group.Disclaimer: this may not lead to a desirable and readable outcome and in that case where it becomes a time-sink, I suggest that you don't sink too much time into it. It could become a 'hobgoblin of little minds' as Guido might say.
Issue:
casts
in tagvlan.py
are jarring as I really don't think tagvlan.py
needs to know the specifics of the implementation of the _switch.fields
attribute.Potential solutions:
TypedDict
mapping type for _switch.fields
? Pros: very explicitly and it keeps all the types in one place (complexity in only a single place is better). Cons: it does defeat the point of duck-typing, may as well code in C++, potentially un-pythonic.set_value
and get_value
methods which will check the type of the field and then use the correct method accordingly. Pros: achieves the issue and more pythonic than above. Cons: doesn't really expose the types of each field to the outside, just handles the setting and getting of a field value.# type: ignore
statements and wrap in try-catch
: Pros: Probably the most pythonic. Cons: It could lead to a lot of code with very minimal benefit to the reader.Use a class with class methods to create the port mirroring configuration
Fix pre commit shield not working as expected in readme.
Python module called manager
is quite a generic name. Could you please rename it to something that is less prone to name clashes with other packages?
There are some cool Github actions that we can use to improve the user-friendliness of this repo. Investigate the best actions and see if we can apply a couple to this repo without hurting functionality too much.
When unit tests are complete, we want a way to run them automatically.
Locally:
CircleCI:
The endgame for this project is to make it an installable python package.
Preferably, we want the user to install pip install botblox
and it will install the package to a virtual environment (or globally) and one can run commands without any use of Docker (which whilst it ensures portability between host OS, it adds overhead and is one more dependency that the user will have to install on their system).
Milestones:
pip install
and pip uninstall
to check that it can be installed and uninstalled.PyPi
botblox --device {device} vlan --group 1 5 --group 2 5 --group 3 5 --group 4 5
does not seem to work as intended for port 1?
Use a class with methods to create the VLAN configuration - will futureproof for reusability in the future
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.