<?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 - Add SNMP community string via API in Management</title>
    <link>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969770#M4159</link>
    <description>&lt;P&gt;OMG, I can't believe how much time this cost me. The biggest problem was that I was calling AddSNMPCommunityString (note first capital letter) which failed with not very helpful messages. What I should have been doing was calling&amp;nbsp;addSNMPCommunityString (note first lower case letter). Argh! Here is what (finally) worked.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;            # version 2
            SNMP_new = {
                'communityName': snmp_val,
                'accessPrivilege': SNMP_privilege,
                'ArrayOfHosts': {
                    'item': allowedhostarray
                }
            }

            if not ReadOnly:
                try:
                    retval = source_axl.addSNMPCommunityString(CommunityString=SNMP_new)
                except Fault as err:
                    print('Fault',err)&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 01 Dec 2023 12:24:49 GMT</pubDate>
    <dc:creator>Elliot Dierksen</dc:creator>
    <dc:date>2023-12-01T12:24:49Z</dc:date>
    <item>
      <title>CUCM - Add SNMP community string via API</title>
      <link>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4968476#M4148</link>
      <description>&lt;P&gt;My Google-foo is failing me. I am looking for a way to add SNMP community strings to CUCM (versions 10.5 and 12.5) via an API. This is to support a multiple cluster CER deployment, so I want to automate it avoid missing and of the 24 source IP's involved. I have tried several different search terms, but come up empty. Is there a way to do this via API?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 22:49:21 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4968476#M4148</guid>
      <dc:creator>Elliot Dierksen</dc:creator>
      <dc:date>2023-11-29T22:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM - Add SNMP community string via API</title>
      <link>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4968478#M4149</link>
      <description>&lt;P&gt;Unfortunately this is not possible via API.&lt;/P&gt;
&lt;P&gt;You may be able to automate the configuration via SSH/CLI scraping/scripting.&amp;nbsp; This isn't really an officially blessed mechanism - and can be hit-or-miss/unreliable - but I understand it's common enough in practice.&amp;nbsp; There are several community maintained tools focused on SSH/CLI automation out there.&lt;/P&gt;
&lt;P&gt;I've personally worked on a sample that includes a Python-based library (using the &lt;A href="https://pypi.org/project/netmiko/" target="_self"&gt;Netmiko&lt;/A&gt; SSH/CLI automation library) for Ansible to do CUCM CLI-related automation - you might find it an interesting basis for doing some scripting: &lt;A href="https://github.com/CiscoDevNet/axl-ansible-examples" target="_blank"&gt;https://github.com/CiscoDevNet/axl-ansible-examples&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 23:05:12 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4968478#M4149</guid>
      <dc:creator>dstaudt</dc:creator>
      <dc:date>2023-11-29T23:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM - Add SNMP community string via API</title>
      <link>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4968481#M4150</link>
      <description>&lt;P&gt;After some further searching I did find references to AddSNMPCommunity in the AXL API guide, but wasn't seeing how I needed to format the "&lt;SPAN class="textContents"&gt;ArrayOfHosts&lt;/SPAN&gt;" element in &lt;SPAN class="elementHeader2"&gt;AddSNMPCommunityStringReq/CommunityString. I see that referenced in the xsd files, but not in the wsdl ones.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 23:11:36 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4968481#M4150</guid>
      <dc:creator>Elliot Dierksen</dc:creator>
      <dc:date>2023-11-29T23:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM - Add SNMP community string via API</title>
      <link>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969036#M4151</link>
      <description>&lt;P&gt;I was able to retrieve an SNMP community this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ssnmp_val = source_axl.getSNMPCommunityString(communityName=snmp_val)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Here is the output of a community name that has restrictions on the host IP addresses that may use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ssnmp_val {
    'return': {
        'SNMPCommunityString': {
            'communityName': 'cce-SNMP01!',
            'version': 'both',
            'accessPrivilege': 'ReadOnly',
            'ArrayOfHosts': {
                'item': [
                    '10.236.12.35',
                    '10.236.13.35'
                ]
            }
        }
    },
    'sequence': None
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am going to guess that I should be able to do it like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;newcomm = 'Test Community'
newpriv = 'ReadOnly'
newhosts = [ '10.236.12.35', '10.236.13.35' ]
retval = source_axl.AddSNMPCommunityString(communityName=newcomm,accessPrivilege=newpriv,ArrayOfHosts=newhosts)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I guess we'll know soon enough. I don't see an option to apply to all hosts which exists in the GUI. I'll assume I need to add it to each CUCM host individually.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 13:56:30 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969036#M4151</guid>
      <dc:creator>Elliot Dierksen</dc:creator>
      <dc:date>2023-11-30T13:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM - Add SNMP community string via API</title>
      <link>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969200#M4153</link>
      <description>&lt;P&gt;Clearly I am not formatting something correctly, but I am not able to figure out what is intended from the AXL schema. Here are two different ways I have to to format this.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# version 1
SNMP_new = {
        'CommunityString': {
                'communityName': snmp_val,
                #'version': SNMP_version,
                'accessPrivilege': SNMP_privilege,
                'ArrayOfHosts': {
                        'item': allowedhostarray
                }
        }
}
# version 2
SNMP_new = {
        'communityName': snmp_val,
        #'version': SNMP_version,
        'accessPrivilege': SNMP_privilege,
        'ArrayOfHosts': {
                'item': allowedhostarray
        }
}
if Debug:
        print('SNMP_new',SNMP_new)

if not ReadOnly:
        retval = source_axl.AddSNMPCommunityString(CommunityString=SNMP_new)
&lt;/LI-CODE&gt;
&lt;P&gt;Regardless of how I create the variable SNMP_new, I get this error.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/zeep/proxy.py", line 97, in __getitem__
    return self._operations[key]
KeyError: 'AddSNMPCommunityString'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/home/ebd/CLAUTO/CUCM/./add_snmp.py", line 139, in &amp;lt;module&amp;gt;
    main()
  File "/usr/home/ebd/CLAUTO/CUCM/./add_snmp.py", line 128, in main
    retval = source_axl.AddSNMPCommunityString(CommunityString=SNMP_new)
  File "/usr/local/lib/python3.9/site-packages/zeep/proxy.py", line 88, in __getattr__
    return self[key]
  File "/usr/local/lib/python3.9/site-packages/zeep/proxy.py", line 99, in __getitem__
    raise AttributeError("Service has no operation %r" % key)
AttributeError: Service has no operation 'AddSNMPCommunityString'&lt;/LI-CODE&gt;
&lt;P&gt;Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 17:23:32 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969200#M4153</guid>
      <dc:creator>Elliot Dierksen</dc:creator>
      <dc:date>2023-11-30T17:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM - Add SNMP community string via API</title>
      <link>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969263#M4156</link>
      <description>&lt;P&gt;Still really struggling with this. I notice that the return value from getSNMPCommunityString is a type "zeep.objects.GetSNMPCommunityStringRes", but the object&amp;nbsp;SNMP_new I am building is a type 'dict'. I see in the xsd file that there is a type of 'AddSNMPCommunityStringReq' which is what I need. How do I build an object and force it to be of that type?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 19:50:43 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969263#M4156</guid>
      <dc:creator>Elliot Dierksen</dc:creator>
      <dc:date>2023-11-30T19:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM - Add SNMP community string via API</title>
      <link>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969307#M4157</link>
      <description>&lt;P&gt;I am giving up for today. I am still mostly getting the same error.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/zeep/proxy.py", line 97, in __getitem__
    return self._operations[key]
KeyError: 'AddSNMPCommunityString'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/home/ebd/CLAUTO/CUCM/./add_snmp.py", line 180, in &amp;lt;module&amp;gt;
    main()
  File "/usr/home/ebd/CLAUTO/CUCM/./add_snmp.py", line 166, in main
    retval = source_axl.AddSNMPCommunityString(CommunityString=ofoo)
  File "/usr/local/lib/python3.9/site-packages/zeep/proxy.py", line 88, in __getattr__
    return self[key]
  File "/usr/local/lib/python3.9/site-packages/zeep/proxy.py", line 99, in __getitem__
    raise AttributeError("Service has no operation %r" % key)
AttributeError: Service has no operation 'AddSNMPCommunityString'
&lt;/LI-CODE&gt;
&lt;P&gt;I got past some of the data typing issues this way.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;            zfoo = source_client.get_type('ns0:AddSNMPCommunityStringReq')
            zfoo2 = source_client.get_type('ns0:RCommunityString')
            zfoo3 = source_client.get_type('ns0:RArrayOfHosts')

            ofoo3 = zfoo3(item=allowedhostarray)
            ofoo2 = zfoo2(communityName=snmp_val,accessPrivilege=SNMP_privilege,
ArrayOfHosts=ofoo3)
            ofoo = zfoo(CommunityString=ofoo2,sequence=1)&lt;/LI-CODE&gt;
&lt;P&gt;It sure does look like I have built the data elements correctly based on the debug output.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;class of ofoo &amp;lt;class 'zeep.objects.AddSNMPCommunityStringReq'&amp;gt;
ofoo {
    'CommunityString': {
        'communityName': 'foo',
        'accessPrivilege': 'ReadOnly',
        'ArrayOfHosts': {
            'item': [
                '10.236.13.57',
                '10.93.199.22'
            ]
        }
    },
    'sequence': 1
}
class of ofoo2 &amp;lt;class 'zeep.objects.RCommunityString'&amp;gt;
ofoo2 {
    'communityName': 'foo',
    'accessPrivilege': 'ReadOnly',
    'ArrayOfHosts': {
        'item': [
            '10.236.13.57',
            '10.93.199.22'
        ]
    }
}
class of ofoo3 &amp;lt;class 'zeep.objects.RArrayOfHosts'&amp;gt;
ofoo3 {
    'item': [
        '10.236.13.57',
        '10.93.199.22'
    ]
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 30 Nov 2023 21:33:05 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969307#M4157</guid>
      <dc:creator>Elliot Dierksen</dc:creator>
      <dc:date>2023-11-30T21:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: CUCM - Add SNMP community string via API</title>
      <link>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969770#M4159</link>
      <description>&lt;P&gt;OMG, I can't believe how much time this cost me. The biggest problem was that I was calling AddSNMPCommunityString (note first capital letter) which failed with not very helpful messages. What I should have been doing was calling&amp;nbsp;addSNMPCommunityString (note first lower case letter). Argh! Here is what (finally) worked.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;            # version 2
            SNMP_new = {
                'communityName': snmp_val,
                'accessPrivilege': SNMP_privilege,
                'ArrayOfHosts': {
                    'item': allowedhostarray
                }
            }

            if not ReadOnly:
                try:
                    retval = source_axl.addSNMPCommunityString(CommunityString=SNMP_new)
                except Fault as err:
                    print('Fault',err)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 01 Dec 2023 12:24:49 GMT</pubDate>
      <guid>https://community.cisco.com/t5/management/cucm-add-snmp-community-string-via-api/m-p/4969770#M4159</guid>
      <dc:creator>Elliot Dierksen</dc:creator>
      <dc:date>2023-12-01T12:24:49Z</dc:date>
    </item>
  </channel>
</rss>

