We could have, 99xx, 78xx, 89xx, et al type phones and with this code block.we don’t have to rewrite any part of the application (you’ll definitely have to think of the construct of the code though.so it’s not as easy straight out of the box as I make it sound of course.). Ph_nav = etree.Element('CiscoIPPhoneExecute')Įxeitem_e = etree.SubElement(ph_nav,'ExecuteItem')Īnd it is here where we achieve the Modular Reuseable Code balance in order to please the code gods (technically it isn’t because what we are doing is procedural and not Object Oriented.eventually that post will come.if I last long enough). We want to make our code modular.and as I spelled out in the commented line in the import statements.we are being self-righteous and not creating xml documents like the above.So.what does that document look like.and why is it “modular” like I say.Let’s go back to the code. The main reason we are using the list above.as opposed to the way in which the “commands” are entered in the image below that depicts an excerpt of that Perl script: 'Key:KeyPadStar','Key:KeyPadPound','Key:Soft4', 'Key:KeyPad5','Key:KeyPad2','Key:KeyPadStar', _79xx_keynavlist=['Init:Settings','Key:Settings','Key:KeyPad4', I’m not sure how beneficial it is for me to post all of the code here let me know on twitter or elsewhere whether or not you like it or not!!.I definitely can’t explain everything (even though I’m about to explain the following).about how when you assign a new dict type (in Python) into an existing dict type, if you change the existing dict then it also changes the new one (even after you assigned the values hash2 = hash1), so we need to import the deepcopy code into this project.so we can truly create a “new” copy of the existing values.Let’s take a look now at the life’s blood of this program: the Key:CMD list for the 79xx Phone. #To POST this to the IP Phone We Send the XML as a String #We are Self-Righteous and Will Construct the Docs Properly Now lets look at some of the code: first the Libraries we will use for this tool: With the pseudo code, you should be able to reconstruct this application in most languages (especially after looking at the code I will provide). Perform HTTP POST of the keyact Data to the Phone Remove the Current Item(String) from the "Copied"įOR Loop Incrementing a "counter" By Range(0-2)įOREACH action(string) in the Previously COPIED dict:Ĭreate Another DICT (keyact) Set Value to KEY:Action Send HTTP POST to the Phone with the KEY:CMD Set its value to 0įOREACH String in PythonDict with Key:PairĬreate another Dict.Set it's Key to XML and it first Initialize a String that will be the KEY for our KEY:PAIRĬreate a Python dict (hashmap) with key: (list)Ĭreate the XML Object We Will Pass to the PhoneĬreate a "complete" copy of the dict from above (usingĬreate the Username and Password (CCMEndUser)Ĭreate a Headers dict type with content:type Initialize a List that contains our KeyPress Commands Today’s version will be just a couple more.because we are going to add some window dressing to the process: Performing ScreenShots of the Phone’s Background as the Commands Are Executed. It started with 123 lines of code in Perl.and it was written by 2 esteemed individuals at Cisco.not sure how.but I got my hands on it in circa 2011 or so.Then I ported that code to Python in a completely different implementation.Lines of Code: 77 Eventually it whittled itself down to 62 lines, then 55 lines.until today via Pythons LXML ’s a short and sweet 47 Lines of code. Let’s get started. If I showed you the progression of this script from version 0.1 you’d probably be amazed. In todays installment we are going to dive into Cisco IP Phone Services Development we aren’t going to develop any Services, but we will do something that might be somewhat useful for everyone interested in this blog.I am going to demonstrate the remote deletion of an ITL file “just like they do” with the paid applications and just as an FYI, PhoneView’s secret sauce to sending commands like Backgrounds et al is XSI Object Passthrough.Ok now that that is out of the way.today we are just going to POST XML objects straight to a Cisco IP Phone.So, there are a few things that have to be in order before we can get this to work: Web Access has to enabled on the Phone, the CUCM end user account you will use will need to be associated to the phones you are going to “touch”, and the Authentication URL needs to be pointing to a CUCM Node. Can you guess what type of phone is depicted in the Image above? First one to guess correctly.wins…
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |