cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
768
Views
1
Helpful
6
Replies

CUCM - update spanToPCPort - 10.5 and 12.5

I posted something in the UC infrastructure forum https://community.cisco.com/t5/unified-communications-infrastructure/cucm-db-where-is-span-to-pc-port-stored/td-p/4959456 but I think this might be a better place. I am trying to update specific phones to disable Span to PC port. I can't do a BAT update where device name begins with 'SEP' because some of the products that it matches don't support that so it doesn't offer that as an option to change. I have a query that finds the phones and templates I need to change.

run sql select fkdevice from devicexml4k where xml like '%<spanToPCPort>0</spanToPCPort>%'

 I was hoping to use the AXL updatePhone, but I am not seeing that in AXL schema on the Cisco developer site. Is there some way to do this other than doing the update in SQL?

2 Accepted Solutions

Accepted Solutions

dstaudt
Cisco Employee
Cisco Employee

Handling vendor specific configs can be tricky:
* All of the configs for a device are stored in the DB as a single XML document in one of the devicexml* fields
* The vendor config XML for a specific device may (likely does not) contain all of the actual available configs/values - only values that have been modified previously tend to be present.
* Modifying the XML requires figuring out if the element is even present, adding it if needed while keeping all the other elements, and writing it back
* The XML has a tiered structure with various sections to keep things interesting
* The vendor configs and the corresponding XML elements/values supported by a particular device type are not documented - it's pretty much a reverse engineering effort to figure out which models support which options, and what the XML elements/values need to be
So just using your SQL query above might not return all devices that support span to PC port - probably only those with a value that has been modified at some point.
All that being said, AXL would be the recommended/supported mechanism for affecting this kind of change, i.e. via <updatePhone><vendorConfig>, where the <vendorConfig> element contains the entire XML document.  This Python sample does some vendor config read/parse/update stuff: https://github.com/CiscoDevNet/axl-python-zeep-samples/blob/master/axl_add_Phone_vendorConfig.py

View solution in original post

This isn't the most elegant thing to be sure, but it does work. Thanks for the pointers!

    dphone = source_axl.getPhone(name=devname)
    vendorxml = dphone['return'].phone.vendorConfig._value_1

    loc = 0
    for elem in vendorxml:
        if elem.tag == 'spanToPCPort':
            if Debug:
                print('Found spanToPCPort',elem.text,'at loc',loc)
            vendorxml[loc].text = '1'
            break
        loc += 1

    if not ReadOnly:
        source_axl.updatePhone(name=devname,vendorConfig=vendorxml)
        source_axl.applyPhone(name=devname)

View solution in original post

6 Replies 6

dstaudt
Cisco Employee
Cisco Employee

Handling vendor specific configs can be tricky:
* All of the configs for a device are stored in the DB as a single XML document in one of the devicexml* fields
* The vendor config XML for a specific device may (likely does not) contain all of the actual available configs/values - only values that have been modified previously tend to be present.
* Modifying the XML requires figuring out if the element is even present, adding it if needed while keeping all the other elements, and writing it back
* The XML has a tiered structure with various sections to keep things interesting
* The vendor configs and the corresponding XML elements/values supported by a particular device type are not documented - it's pretty much a reverse engineering effort to figure out which models support which options, and what the XML elements/values need to be
So just using your SQL query above might not return all devices that support span to PC port - probably only those with a value that has been modified at some point.
All that being said, AXL would be the recommended/supported mechanism for affecting this kind of change, i.e. via <updatePhone><vendorConfig>, where the <vendorConfig> element contains the entire XML document.  This Python sample does some vendor config read/parse/update stuff: https://github.com/CiscoDevNet/axl-python-zeep-samples/blob/master/axl_add_Phone_vendorConfig.py

OK, I think I can work with that. I'll try a getPhone and check out one of the devices I want to change. I already found where I can use the lxml/etree libraries to change just XML element in question. I'll work on that tomorrow and update here. Thanks!

This isn't the most elegant thing to be sure, but it does work. Thanks for the pointers!

    dphone = source_axl.getPhone(name=devname)
    vendorxml = dphone['return'].phone.vendorConfig._value_1

    loc = 0
    for elem in vendorxml:
        if elem.tag == 'spanToPCPort':
            if Debug:
                print('Found spanToPCPort',elem.text,'at loc',loc)
            vendorxml[loc].text = '1'
            break
        loc += 1

    if not ReadOnly:
        source_axl.updatePhone(name=devname,vendorConfig=vendorxml)
        source_axl.applyPhone(name=devname)

I have one more question. Some of the devices where this is set are phone templates. I assume I can do an updatePhone on them, but wouldn't want to do an applyPhone there. Is that accurate?

Not sure TBH, but sounds right..?

Yes, updatePhone works on phone templates. I didn't try doing an apply since that isn't relevant.