refactoring

This commit is contained in:
Arnold Dechamps 2022-12-18 03:23:29 +01:00
parent b4d0302d76
commit 5843a35ae3
No known key found for this signature in database
GPG key ID: AE66543374E41C89
10 changed files with 95 additions and 6 deletions

8
.idea/.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View file

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/voip-generator.iml" filepath="$PROJECT_DIR$/.idea/voip-generator.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

8
.idea/voip-generator.iml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -2,8 +2,8 @@
## Intro :
You will need an IPv4 Network with :
* DHCP server
* TFTP server
* DHCP server (tested on tagged Voice-Vlan)
* TFTP server (option 66 configured in DHCP server)
* physical access to the phone
## Factory reset sequence :
@ -14,4 +14,16 @@ Dial 2 (network config erase).
## Flashing process :
After factory reset, the phone will look up in the TFTP server for his own config file (`SEP<mac-address>.cnf.xml`)
In the case of flashing to SIP firmware, that file has to contain the fact that it goes to SIP and a firmware version.
All system files must be stored at the root of the TFTP server.
All system files must be stored at the root of the TFTP server.
## SIP phone provisioning :
After the SIP firmware has been flashed, the phone will start to TFTP try `SIPDefault.cnf`.
`SIPDefault.cnf` is the file that contain's SIP options that will be used across all phones that can access that file.
(like NTP server's, time format etc.) so that the specific SIP file can be smaller (not that usefull on a modern server with 3 phones in the system. kind of a big deal on a big phone system on a small CME router)
Either `SIPDefault.cnf` gets found and the phone will load the options, either it's not and the phone jumps to the next file. `SIP<mac-address>.cnf`
That file contains the phone specific options. If some options were present in `SIPDefault.cnf`, they will be overwritten on the local phone.
## Startup Sequence :
At every reboot, the phone will look up for the ``SEP<mac-address>.cnf.xml`` to see what firmware is needed. Then `SIPDefault.cnf` and then `SIP<mac-address>.cnf`.

View file

@ -0,0 +1,2 @@
def main():
print("not yet coded")

View file

@ -1,2 +1,24 @@
"""
This module creates config files for the Cisco 7940 and Cisco 7960
"""
def mac():
"""
This takes the mac address and puts it into correct format for use
:return: raw mac
"""
mac = input("Phone mac address : ")
raw_mac = "none"
if len(mac) == 12:
raw_mac = mac.upper()
elif len(mac) == 17:
raw_mac = ""
for i in mac:
if i != ":":
raw_mac = raw_mac + i.upper()
return raw_mac
def main():
print("test")
mac_address = mac()
print(mac_address)

17
gen.py
View file

@ -3,18 +3,31 @@ Config Generator for VOIP Phones
Arnold Dechamps 2022
"""
from Scripts import c79407960
from Scripts import c79117906
def main():
"""
This function is the main one. Makes selections to choose what plugin to use
:return: 0
"""
print("Hello, what phone system would you like to provision?")
print(" * 1) Cisco 7940")
print(" * 2) Cisco 7960")
print(" * 3) Cisco 7911")
print(" * 4) Cisco 7906")
phone_choice = int(input("Choice : "))
phone_choice = input("Choice : ")
if phone_choice == 1 or phone_choice == 2:
if phone_choice == "1" or phone_choice == "2":
c79407960.main()
elif phone_choice == "3" or phone_choice == "4":
c79117906.main()
else:
print("Invalid option.")
return 0
if __name__ == '__main__':
main()