If you find this useful, that's great.
I have made a major update to the notebook. It was initially using a very kludgey way of modifying the config XML. Just jamming new XML in Python text formatting. This is all now totally replaced by code that operates natively on XML using Python's xml.etree.ElementTree library. There are only two tiny cosmetic differences between the output of this script and the output of OPNsense's own config manupulators: Python adds an extra space in tags like this:
<sometag/>
So, they look like this:
<sometag />
This is not configurable that I can see in Python. Another person in a Github issue has identified which XML libraries add this space and which ones don't:
https://github.com/zeux/pugixml/issues/87#issuecomment-188621862
OPNsense can read config XML with these spaces, so it's irrelevant.
The only other difference is that the XML declaration at the very start has an encoding, but the one generated in OPNsense does not. Again, this has no effect on OPNsense's ability to import the config file.
Here is what it looks like from the script:
<?xml version='1.0' encoding='us-ascii'?>
Here is the native OPNsense:
<?xml version="1.0"?>
I may try to figure out how to get this output correct.
I have made a major update to the notebook. It was initially using a very kludgey way of modifying the config XML. Just jamming new XML in Python text formatting. This is all now totally replaced by code that operates natively on XML using Python's xml.etree.ElementTree library. There are only two tiny cosmetic differences between the output of this script and the output of OPNsense's own config manupulators: Python adds an extra space in tags like this:
<sometag/>
So, they look like this:
<sometag />
This is not configurable that I can see in Python. Another person in a Github issue has identified which XML libraries add this space and which ones don't:
https://github.com/zeux/pugixml/issues/87#issuecomment-188621862
OPNsense can read config XML with these spaces, so it's irrelevant.
The only other difference is that the XML declaration at the very start has an encoding, but the one generated in OPNsense does not. Again, this has no effect on OPNsense's ability to import the config file.
Here is what it looks like from the script:
<?xml version='1.0' encoding='us-ascii'?>
Here is the native OPNsense:
<?xml version="1.0"?>
I may try to figure out how to get this output correct.
"