From 5843a35ae37071b42f65673a707c1f067b25865c Mon Sep 17 00:00:00 2001 From: altf4arnold Date: Sun, 18 Dec 2022 03:23:29 +0100 Subject: [PATCH] refactoring --- .idea/.gitignore | 8 +++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 +++++++ .idea/vcs.xml | 6 +++++ .idea/voip-generator.iml | 8 +++++++ Phones/7940-7960/README.md | 18 +++++++++++--- Scripts/c79117906.py | 2 ++ Scripts/c79407960.py | 24 ++++++++++++++++++- gen.py | 17 +++++++++++-- 10 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/voip-generator.iml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -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 diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ddd6400 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/voip-generator.iml b/.idea/voip-generator.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/voip-generator.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Phones/7940-7960/README.md b/Phones/7940-7960/README.md index 4994d33..e9ae9b9 100644 --- a/Phones/7940-7960/README.md +++ b/Phones/7940-7960/README.md @@ -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.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. \ No newline at end of file +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.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.cnf.xml`` to see what firmware is needed. Then `SIPDefault.cnf` and then `SIP.cnf`. \ No newline at end of file diff --git a/Scripts/c79117906.py b/Scripts/c79117906.py index e69de29..3e3446a 100644 --- a/Scripts/c79117906.py +++ b/Scripts/c79117906.py @@ -0,0 +1,2 @@ +def main(): + print("not yet coded") \ No newline at end of file diff --git a/Scripts/c79407960.py b/Scripts/c79407960.py index 5784897..83f9251 100644 --- a/Scripts/c79407960.py +++ b/Scripts/c79407960.py @@ -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") \ No newline at end of file + mac_address = mac() + print(mac_address) \ No newline at end of file diff --git a/gen.py b/gen.py index 5c6964b..64aa1d8 100644 --- a/gen.py +++ b/gen.py @@ -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() \ No newline at end of file