11-15-2023 07:53 AM
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?
Solved! Go to Solution.
11-15-2023 11:08 AM
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
11-16-2023 08:02 AM
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)
11-15-2023 11:08 AM
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
11-15-2023 03:57 PM
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!
11-16-2023 08:02 AM
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)
11-16-2023 09:06 AM
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?
11-16-2023 09:10 AM
Not sure TBH, but sounds right..?
11-16-2023 10:45 AM
Yes, updatePhone works on phone templates. I didn't try doing an apply since that isn't relevant.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide