<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: CUCM Device Registration Status from RIS via zeep in Management</title>
    <link>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3989922#M3253</link>
    <description>&lt;P&gt;I know it's an old thread but I didn't see anyone post a working example of navigating the response in zeep so here's what worked for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;result = client.service.selectCmDevice(stateInfo, criteria)&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;for node in result.SelectCmDeviceResult.CmNodes.item:&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; for device in node.CmDevices.item:&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; print (device.Name)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Nov 2019 03:54:38 GMT</pubDate>
    <dc:creator>ceephax</dc:creator>
    <dc:date>2019-11-27T03:54:38Z</dc:date>
    <item>
      <title>CUCM Device Registration Status from RIS via zeep</title>
      <link>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3451641#M566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There a couple client choices for python to generate a soap request to access data from CUCM. Not trying to reinvent the wheel I used examples that were readily available online for another client that hasn't been updated/supported in a while.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the recommendation of another engineer I wanted to challenge myself to migrate to a modern/actively maintained soap client for python, which leads us to zeep.&amp;nbsp; Some benefits of zeep is the project is actively maintained, python2/3 support, faster than other clients (definitely noticeable on larger UC clusters), good documentation and some nice helper features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are limited examples available with zeep (especially UC related) so I thought I'd share a RISPort70 request to CUCM 11.5 and some of the hurdles I had getting it working in hopes it might benefit others.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First off, read the docs.&amp;nbsp; Zeep has some good documentation and an active community.&amp;nbsp; Familiarize yourself with the wsdl you're working with, Cisco provides really nice docs in the DevNet API Developer Guide:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developer.cisco.com/site/sxml/documents/api-reference/risport/"&gt;https://developer.cisco.com/site/sxml/documents/api-reference/risport/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another tool that helped me out was using SoapUI to examine the wsdl, zeep also comes bundled with a wsdl inspector that helps view the client operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_15257125594748194" jivemacro_uid="_15257125594748194"&gt;
&lt;P&gt;python -mzeep &amp;lt;wsdl&amp;gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got tripped up on selectCmDevice as it has some nested complex data objects.&amp;nbsp; I tried passing the client straight kwargs for the selection criteria, which worked but did not honor the complex data "SelectItems" (at least with child dictionaries in the parent kwargs).&amp;nbsp; This led me to creating a factory with zeep that we can use to send the nested data to CUCM.&amp;nbsp; The zeep history plugin really helped me out, you can view your sent/received soap envelope to see if your constructing the xml the way the DevNet guide expects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My use case is more focused towards all registered phones in the cluster, but included is a loop to iterate over a list of mac addresses in case individual devices are desired.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully the below can help, thanks again for the great community!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Python 3.5.2&lt;/P&gt;&lt;P&gt;Zeep 2.5.0&lt;/P&gt;&lt;P&gt;CUCM 11.5.1(SU4)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_15257135249784017" jivemacro_uid="_15257135249784017"&gt;
&lt;P&gt;from zeep import Client&lt;/P&gt;
&lt;P&gt;from zeep.cache import SqliteCache&lt;/P&gt;
&lt;P&gt;from zeep.transports import Transport&lt;/P&gt;
&lt;P&gt;from zeep.plugins import HistoryPlugin&lt;/P&gt;
&lt;P&gt;from requests import Session&lt;/P&gt;
&lt;P&gt;from requests.auth import HTTPBasicAuth&lt;/P&gt;
&lt;P&gt;from lxml import etree&lt;/P&gt;
&lt;P&gt;import urllib3&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;username = 'username'&lt;/P&gt;
&lt;P&gt;password = 'password'&lt;/P&gt;
&lt;P&gt;wsdl = 'file:///path/to/RISService70.wsdl'&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;session = Session()&lt;/P&gt;
&lt;P&gt;session.verify = False&lt;/P&gt;
&lt;P&gt;session.auth = HTTPBasicAuth(username, password)&lt;/P&gt;
&lt;P&gt;transport = Transport(cache=SqliteCache(), session=session, timeout=20)&lt;/P&gt;
&lt;P&gt;history = HistoryPlugin()&lt;/P&gt;
&lt;P&gt;client = Client(wsdl=wsdl, transport=transport, plugins=[history])&lt;/P&gt;
&lt;P&gt;factory = client.type_factory('ns0')&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;macs = ['SEP111122223333', 'SEP222233334444'] #'*' for all&lt;/P&gt;
&lt;P&gt;item=[]&lt;/P&gt;
&lt;P&gt;for mac in macs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; item.append(factory.SelectItem(Item=mac))&lt;/P&gt;
&lt;P&gt;Item = factory.ArrayOfSelectItem(item)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;stateInfo = ''&lt;/P&gt;
&lt;P&gt;criteria = factory.CmSelectionCriteria(&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MaxReturnedDevices = 1000,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DeviceClass='Phone',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Model=537,&amp;nbsp;&amp;nbsp;&amp;nbsp; #255 for all&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Status='Registered',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NodeName='',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SelectBy='Name',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SelectItems=Item,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Protocol='Any',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DownloadStatus='Any'&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;result = client.service.selectCmDevice(stateInfo, criteria)&lt;/P&gt;
&lt;P&gt;print(result)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;#troubleshooting soap envelope&lt;/P&gt;
&lt;P&gt;for hist in [history.last_sent, history.last_received]:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(etree.tostring(hist["envelope"], encoding="unicode", pretty_print=True))&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2018 17:27:27 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3451641#M566</guid>
      <dc:creator>derek.fraser</dc:creator>
      <dc:date>2018-05-07T17:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM Device Registration Status from RIS via zeep</title>
      <link>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3451642#M567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for posting the code. I have tried running it, but get an error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ValueError: No visitor defined for '{&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema" rel="nofollow" target="_blank"&gt;http://www.w3.org/2001/XMLSchema&lt;/A&gt;&lt;SPAN&gt;}documentation'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you ever see this error? The only Google references are for the zeep project, it is listed as a closed bug on Github.&lt;/P&gt;&lt;P&gt;I am running zeep 2.5.0, python 3.6.0, CUCM 10.5(2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, Randy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2018 17:23:11 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3451642#M567</guid>
      <dc:creator>Randall White</dc:creator>
      <dc:date>2018-05-30T17:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM Device Registration Status from RIS via zeep</title>
      <link>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3767617#M3003</link>
      <description>&lt;P&gt;I was getting this error as well and it was because I was referencing the wrong RIS WSDL file.&amp;nbsp; I was referencing the RPC/Encoded WSDL file found at&amp;nbsp;&lt;SPAN&gt;https://&amp;lt;ServerName&amp;gt;&lt;/SPAN&gt;&lt;EM class="cEmphasis"&gt;:&lt;/EM&gt;&lt;SPAN&gt;8443/realtimeservice/services/RisPort70?wsdl and I&lt;/SPAN&gt;&amp;nbsp;needed to use the Doc/Literal version found at&amp;nbsp;&lt;SPAN&gt;https://&amp;lt;ServerName&amp;gt;:8443/realtimeservice2/services/RISService70?wsdl.&amp;nbsp; Once I pointed to the correct WSDL file I was able to get&amp;nbsp;the connection to work.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 22:40:03 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3767617#M3003</guid>
      <dc:creator>sjdamme</dc:creator>
      <dc:date>2018-12-20T22:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM Device Registration Status from RIS via zeep</title>
      <link>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3877296#M3077</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;This is working perfectly with print(result)&lt;/P&gt;&lt;P&gt;However, I have added few lines to display output in table format, so that I can copy the output and open it in CSV.&lt;/P&gt;&lt;P&gt;Added few lines as below&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;result = client.service.selectCmDevice(stateInfo, criteria)&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;for node in (result['SelectCmDeviceResult']['CmNodes']):&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;for device in node['CmDevices']:&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;print (device['Name'], device['IpAddress'], device['DirNumber'], device['Description'])&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I just &lt;U&gt;&lt;EM&gt;print (result)&lt;/EM&gt;&lt;/U&gt; I am getting output as below output, I want to display output in proper way, onlt name, IP address, directory number and description&lt;BR /&gt;But while adding "for device in node" I am getting error on this line as below;&lt;BR /&gt;for device in node['CmDevices']:&lt;BR /&gt;&lt;STRONG&gt;error is:&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "phone2.py", line 40, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;for device in node['CmDevices']:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;TypeError: string indices must be integers&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pls. advice why TypeError: string indices must be integers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 08:55:11 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3877296#M3077</guid>
      <dc:creator>rajesh.kumar</dc:creator>
      <dc:date>2019-06-21T08:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM Device Registration Status from RIS via zeep</title>
      <link>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3877298#M3078</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Thanks a lot, it helped me.&lt;/P&gt;&lt;P&gt;This is working perfectly with &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;print(result)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;However, I have added few lines to display output in table format, so that I can copy the output and open it in CSV.&lt;/P&gt;&lt;P&gt;Added few lines as below&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;result = client.service.selectCmDevice(stateInfo, criteria)&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;for node in (result['SelectCmDeviceResult']['CmNodes']):&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;for device in node['CmDevices']:&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;print (device['Name'], device['IpAddress'], device['DirNumber'], device['Description'])&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I just &lt;U&gt;&lt;EM&gt;print (result)&lt;/EM&gt;&lt;/U&gt; I am getting output as below output, I want to display output in proper way, onlt name, IP address, directory number and description&lt;BR /&gt;But while adding "for device in node" I am getting error on this line as below;&lt;BR /&gt;for device in node['CmDevices']:&lt;BR /&gt;&lt;STRONG&gt;error is:&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "phone2.py", line 40, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;for device in node['CmDevices']:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;TypeError: string indices must be integers&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pls. advice why TypeError: string indices must be integers&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 08:56:32 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3877298#M3078</guid>
      <dc:creator>rajesh.kumar</dc:creator>
      <dc:date>2019-06-21T08:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM Device Registration Status from RIS via zeep</title>
      <link>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3989922#M3253</link>
      <description>&lt;P&gt;I know it's an old thread but I didn't see anyone post a working example of navigating the response in zeep so here's what worked for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;result = client.service.selectCmDevice(stateInfo, criteria)&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;for node in result.SelectCmDeviceResult.CmNodes.item:&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; for device in node.CmDevices.item:&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; print (device.Name)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 03:54:38 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-device-registration-status-from-ris-via-zeep/m-p/3989922#M3253</guid>
      <dc:creator>ceephax</dc:creator>
      <dc:date>2019-11-27T03:54:38Z</dc:date>
    </item>
  </channel>
</rss>

