-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.1.10 no more frontend api required
- Loading branch information
1 parent
0446009
commit 32ac9d3
Showing
15 changed files
with
580 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ | |
*.crt | ||
*.certbot | ||
|
||
*.build | ||
*.egg-info | ||
*.__pycache__ | ||
|
||
# Kompilierte Dateien | ||
__pycache__ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# opnsense-helper | ||
assign lan interfaces, create vlans, vlan-interfaces and setup dhcp in a single script. | ||
assign lan interfaces, create vlans, vlan-interfaces and setup dhcp in a single script using the opnsense backend. | ||
## install | ||
## pip | ||
```bash | ||
|
@@ -10,52 +10,78 @@ pip install opnsense-helper | |
- rn i try to find out how to reconfigure the vlans using the backend, but this is on todo list | ||
|
||
```python | ||
from opnsense_helper.classes import Opnsense_Helper | ||
|
||
filepath = '/home/ji/confignew.xml' | ||
ffrom opnsense_helper.classes import Opnsense_Helper | ||
output="./config.xml" | ||
conf_path="/conf/config.xml" | ||
host= "192.168.1.103" | ||
vlans=[ | ||
{'if': 'vtnet1', 'tag': '1', 'pcp': '0', 'proto': None, 'descr': 'vlan1', 'vlanif': 'vlan0.1'}, | ||
{'if': 'vtnet1', 'tag': '2', 'pcp': '0', 'proto': None, 'descr': 'vlan2', 'vlanif': 'vlan0.2'} | ||
] | ||
dhcp={ | ||
"opt2": {'enable': '1', 'ddnsdomainalgorithm': 'hmac-md', "range":{'from': '200.0.3.10', '_to': '200.0.3.100'}}, | ||
"opt3": {'enable': '1', 'ddnsdomainalgorithm': 'hmac-md', "range":{'from': '200.0.4.10', '_to': '200.0.4.100'}} | ||
} | ||
interfaces={ | ||
"opt1": {'descr': 'router', 'enable': '1', 'ipaddr': None, 'subnet': None, 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:02:01',"interface":"vtnet1"}, | ||
"opt2": {'descr': 'vlan1', 'enable': '1', 'ipaddr': '200.0.3.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:01',"interface":"vlan0.1"}, | ||
"opt3": {'descr': 'vlan2', 'enable': '1', 'ipaddr': '200.0.4.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:02', "interface":"vlan0.2"} | ||
} | ||
ssh_auth={ | ||
{"id":"vlan1",'parent': 'vtnet1', 'tag': '1', 'pcp': '0', 'proto': None, 'descr': 'vlan1', 'vlanif': 'vlan0.1'}, | ||
{"id":"vlan2",'parent': 'vtnet1', 'tag': '2', 'pcp': '0', 'proto': None, 'descr': 'vlan2', 'vlanif': 'vlan0.2'}, | ||
{"id":"vlan3",'parent': 'vtnet1', 'tag': '3', 'pcp': '0', 'proto': None, 'descr': 'vlan3', 'vlanif': 'vlan0.3'} | ||
|
||
] | ||
dhcp=[ | ||
{"id":"opt2",'enable': '1', 'ddnsdomainalgorithm': 'hmac-md', "range":{'from': '200.0.3.10', '_to': '200.0.3.100'}}, | ||
{"id":"opt3",'enable': '1', 'ddnsdomainalgorithm': 'hmac-md', "range":{'from': '200.0.4.10', '_to': '200.0.4.100'}} | ||
] | ||
interfaces=[ | ||
{"id":"opt1",'descr': 'router', 'enable': '1', 'ipaddr': None, 'subnet': None, 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:02:01',"interface":"vtnet1"}, | ||
{"id":"opt2",'descr': 'vlan1', 'enable': '1', 'ipaddr': '200.0.3.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:01',"interface":"vlan0.1"}, | ||
{"id":"opt3",'descr': 'vlan2', 'enable': '1', 'ipaddr': '200.0.4.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:02', "interface":"vlan0.2"}, | ||
{"id":"opt4",'descr': 'vlan3', 'enable': '1', 'ipaddr': '200.0.5.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:03', "interface":"vlan0.3"} | ||
|
||
] | ||
auth={ | ||
"user":"root", | ||
"passw":"opnsense", | ||
} | ||
api_auth={ | ||
# ONLY NEED WHEN YOU USE THE API | ||
"api_key" :'ejl4fIU9yfNk+gaQmPk/rqIa15f1yX1snIKgcIEl2QNoJwhbekraWIE0ANRYceh9hey5IFGzlf3da4yJ', | ||
"api_secret" : '5JVVGoatPbaAA+FozLDQY92/T6sRlmKD1+aRNl/YI8KA9/0TNiTDboLveqvd9FU8wFeDo3D3DY5wrUtF', | ||
"ssl": True, | ||
"verify": False | ||
} | ||
host= "192.168.1.103" | ||
def test(): | ||
helper=Opnsense_Helper(host=host,ssh_auth=ssh_auth,api_auth=api_auth,filepath=output, verbose=False) | ||
helper.add_vlans(vlans) | ||
#helper.set_vlans(vlans) | ||
helper.get_conf(conf_path) | ||
helper.initialize() | ||
helper.add_Items("interfaces",interfaces) | ||
helper.add_Items("dhcpd",dhcp) | ||
helper.save(output) | ||
helper.put_file(output,conf_path) | ||
helper.close_con() | ||
|
||
if __name__ == "__main__": | ||
test() | ||
helper=Opnsense_Helper(host=host,ssh_auth=auth,filepath=output, verbose=False) | ||
#helper.set_vlans(vlans) | ||
helper.get_conf(conf_path) | ||
helper.initialize() | ||
helper.add_Items("interfaces",interfaces) | ||
helper.add_Items("dhcpd",dhcp) | ||
helper.add_Items("vlans",vlans) | ||
helper.save(output) | ||
helper.put_file(output,conf_path) | ||
helper.close_con() | ||
``` | ||
|
||
### Frontend Api | ||
```python | ||
def using_api(): | ||
vlans_api=[ | ||
{'if': 'vtnet1', 'tag': '1', 'pcp': '0', 'proto': None, 'descr': 'vlan1', 'vlanif': 'vlan0.1'}, | ||
{'if': 'vtnet1', 'tag': '2', 'pcp': '0', 'proto': None, 'descr': 'vlan2', 'vlanif': 'vlan0.2'} | ||
] | ||
api_auth={ | ||
"api_key" :'ejl4fIU9yfNk+gaQmPk/rqIa15f1yX1snIKgcIEl2QNoJwhbekraWIE0ANRYceh9hey5IFGzlf3da4yJ', | ||
"api_secret":'5JVVGoatPbaAA+FozLDQY92/T6sRlmKD1+aRNl/YI8KA9/0TNiTDboLveqvd9FU8wFeDo3D3DY5wrUtF', | ||
"ssl": True, | ||
"verify": False | ||
} | ||
helper=Opnsense_Helper(host=host,api_auth=api_auth,filepath=output, verbose=False) | ||
helper.vlans_api(vlans_api,"add") | ||
``` | ||
### Variables | ||
#### Opnsense_Helper | ||
(host=host,ssh_auth=auth,filepath=output, verbose=False) | ||
| var | type | description | | ||
| --- | --- | --- | | ||
| host| str | ip or hostname | | ||
| auth | dict {user: str, passw: str} | SSH authentication dictionary | | ||
|
||
|
||
|
||
#### Module Args | ||
| var | type | elements | | ||
| --- | --- | --- | | ||
| vlans | list[dict] | {id: str, parent: str, tag: int, pcp: str, proto: str } | None, descr: str, vlanif: str} | | ||
| interfaces | list[dict] | {id: str, descr: str, enable: int, ipaddr: str, subnet: str, type: str, virtual: bool, spoofmac: str, interface: str} | | ||
| dhcp | list[dict] | {id: str, enable: str, ddnsdomainalgorithm: str, range: {from: str, _to: str}} | | ||
|
||
|
||
|
||
### contribute | ||
- clone, or fork `[email protected]:the-pod-shop/opnsense-helper.git` | ||
- build when made changes | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# opnsense-helper | ||
assign lan interfaces, create vlans, vlan-interfaces and setup dhcp in a single script. | ||
assign lan interfaces, create vlans, vlan-interfaces and setup dhcp in a single script using the opnsense backend. | ||
## install | ||
## pip | ||
```bash | ||
|
@@ -10,52 +10,78 @@ pip install opnsense-helper | |
- rn i try to find out how to reconfigure the vlans using the backend, but this is on todo list | ||
|
||
```python | ||
from opnsense_helper.classes import Opnsense_Helper | ||
|
||
filepath = '/home/ji/confignew.xml' | ||
ffrom opnsense_helper.classes import Opnsense_Helper | ||
output="./config.xml" | ||
conf_path="/conf/config.xml" | ||
host= "192.168.1.103" | ||
vlans=[ | ||
{'if': 'vtnet1', 'tag': '1', 'pcp': '0', 'proto': None, 'descr': 'vlan1', 'vlanif': 'vlan0.1'}, | ||
{'if': 'vtnet1', 'tag': '2', 'pcp': '0', 'proto': None, 'descr': 'vlan2', 'vlanif': 'vlan0.2'} | ||
] | ||
dhcp={ | ||
"opt2": {'enable': '1', 'ddnsdomainalgorithm': 'hmac-md', "range":{'from': '200.0.3.10', '_to': '200.0.3.100'}}, | ||
"opt3": {'enable': '1', 'ddnsdomainalgorithm': 'hmac-md', "range":{'from': '200.0.4.10', '_to': '200.0.4.100'}} | ||
} | ||
interfaces={ | ||
"opt1": {'descr': 'router', 'enable': '1', 'ipaddr': None, 'subnet': None, 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:02:01',"interface":"vtnet1"}, | ||
"opt2": {'descr': 'vlan1', 'enable': '1', 'ipaddr': '200.0.3.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:01',"interface":"vlan0.1"}, | ||
"opt3": {'descr': 'vlan2', 'enable': '1', 'ipaddr': '200.0.4.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:02', "interface":"vlan0.2"} | ||
} | ||
ssh_auth={ | ||
{"id":"vlan1",'parent': 'vtnet1', 'tag': '1', 'pcp': '0', 'proto': None, 'descr': 'vlan1', 'vlanif': 'vlan0.1'}, | ||
{"id":"vlan2",'parent': 'vtnet1', 'tag': '2', 'pcp': '0', 'proto': None, 'descr': 'vlan2', 'vlanif': 'vlan0.2'}, | ||
{"id":"vlan3",'parent': 'vtnet1', 'tag': '3', 'pcp': '0', 'proto': None, 'descr': 'vlan3', 'vlanif': 'vlan0.3'} | ||
|
||
] | ||
dhcp=[ | ||
{"id":"opt2",'enable': '1', 'ddnsdomainalgorithm': 'hmac-md', "range":{'from': '200.0.3.10', '_to': '200.0.3.100'}}, | ||
{"id":"opt3",'enable': '1', 'ddnsdomainalgorithm': 'hmac-md', "range":{'from': '200.0.4.10', '_to': '200.0.4.100'}} | ||
] | ||
interfaces=[ | ||
{"id":"opt1",'descr': 'router', 'enable': '1', 'ipaddr': None, 'subnet': None, 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:02:01',"interface":"vtnet1"}, | ||
{"id":"opt2",'descr': 'vlan1', 'enable': '1', 'ipaddr': '200.0.3.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:01',"interface":"vlan0.1"}, | ||
{"id":"opt3",'descr': 'vlan2', 'enable': '1', 'ipaddr': '200.0.4.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:02', "interface":"vlan0.2"}, | ||
{"id":"opt4",'descr': 'vlan3', 'enable': '1', 'ipaddr': '200.0.5.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:03', "interface":"vlan0.3"} | ||
|
||
] | ||
auth={ | ||
"user":"root", | ||
"passw":"opnsense", | ||
} | ||
api_auth={ | ||
# ONLY NEED WHEN YOU USE THE API | ||
"api_key" :'ejl4fIU9yfNk+gaQmPk/rqIa15f1yX1snIKgcIEl2QNoJwhbekraWIE0ANRYceh9hey5IFGzlf3da4yJ', | ||
"api_secret" : '5JVVGoatPbaAA+FozLDQY92/T6sRlmKD1+aRNl/YI8KA9/0TNiTDboLveqvd9FU8wFeDo3D3DY5wrUtF', | ||
"ssl": True, | ||
"verify": False | ||
} | ||
host= "192.168.1.103" | ||
def test(): | ||
helper=Opnsense_Helper(host=host,ssh_auth=ssh_auth,api_auth=api_auth,filepath=output, verbose=False) | ||
helper.add_vlans(vlans) | ||
#helper.set_vlans(vlans) | ||
helper.get_conf(conf_path) | ||
helper.initialize() | ||
helper.add_Items("interfaces",interfaces) | ||
helper.add_Items("dhcpd",dhcp) | ||
helper.save(output) | ||
helper.put_file(output,conf_path) | ||
helper.close_con() | ||
|
||
if __name__ == "__main__": | ||
test() | ||
helper=Opnsense_Helper(host=host,ssh_auth=auth,filepath=output, verbose=False) | ||
#helper.set_vlans(vlans) | ||
helper.get_conf(conf_path) | ||
helper.initialize() | ||
helper.add_Items("interfaces",interfaces) | ||
helper.add_Items("dhcpd",dhcp) | ||
helper.add_Items("vlans",vlans) | ||
helper.save(output) | ||
helper.put_file(output,conf_path) | ||
helper.close_con() | ||
``` | ||
|
||
### Frontend Api | ||
```python | ||
def using_api(): | ||
vlans_api=[ | ||
{'if': 'vtnet1', 'tag': '1', 'pcp': '0', 'proto': None, 'descr': 'vlan1', 'vlanif': 'vlan0.1'}, | ||
{'if': 'vtnet1', 'tag': '2', 'pcp': '0', 'proto': None, 'descr': 'vlan2', 'vlanif': 'vlan0.2'} | ||
] | ||
api_auth={ | ||
"api_key" :'ejl4fIU9yfNk+gaQmPk/rqIa15f1yX1snIKgcIEl2QNoJwhbekraWIE0ANRYceh9hey5IFGzlf3da4yJ', | ||
"api_secret":'5JVVGoatPbaAA+FozLDQY92/T6sRlmKD1+aRNl/YI8KA9/0TNiTDboLveqvd9FU8wFeDo3D3DY5wrUtF', | ||
"ssl": True, | ||
"verify": False | ||
} | ||
helper=Opnsense_Helper(host=host,api_auth=api_auth,filepath=output, verbose=False) | ||
helper.vlans_api(vlans_api,"add") | ||
``` | ||
### Variables | ||
#### Opnsense_Helper | ||
(host=host,ssh_auth=auth,filepath=output, verbose=False) | ||
| var | type | description | | ||
| --- | --- | --- | | ||
| host| str | ip or hostname | | ||
| auth | dict {user: str, passw: str} | SSH authentication dictionary | | ||
|
||
|
||
|
||
#### Module Args | ||
| var | type | elements | | ||
| --- | --- | --- | | ||
| vlans | list[dict] | {id: str, parent: str, tag: int, pcp: str, proto: str } | None, descr: str, vlanif: str} | | ||
| interfaces | list[dict] | {id: str, descr: str, enable: int, ipaddr: str, subnet: str, type: str, virtual: bool, spoofmac: str, interface: str} | | ||
| dhcp | list[dict] | {id: str, enable: str, ddnsdomainalgorithm: str, range: {from: str, _to: str}} | | ||
|
||
|
||
|
||
### contribute | ||
- clone, or fork `[email protected]:the-pod-shop/opnsense-helper.git` | ||
- build when made changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/sh | ||
python setup.py bdist_wheel | ||
pip install --upgrade . | ||
pip install --upgrade build --force | ||
pip install --upgrade build --force | ||
python /home/ji/Dokumente/podshop-org/opnsense-helper/python/opnsense_helper/examples/add_vlans.py |
Oops, something went wrong.