cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
configure & troubleshoot anyconnect
257
Views
5
Helpful
8
Replies
Highlighted
Enthusiast

Python Script to backup skills/teams/supervisor settings?

Just checking before I reinvent the wheel.

 

Has anyone written a script to backup and restore the user specific settings for UCCX via the API?

 

Running into a situation with a merged LDAP tree where some branches become unavailable at times. This causes the UCM users to go "Inactive". As long as the LDAP issue is resolved within the garbage collection window UCM is fine, but as soon as the users go "Inactive" on UCM, UCCX removes their skills/team/supervisor settings. I understand this is expected, but I'd rather not have to do a system restore every time that happens since the LDAP issues in this environment are outside of my control.

 

Thanks

Everyone's tags (3)
8 REPLIES 8
VIP Advisor

Re: Python Script to backup skills/teams/supervisor settings?

One way to avoid UCCX from deleting your Agents during the Inactive period, is to simply not access the RmCm > Resources web page. As far as I know, UCCX doesn't periodically sync with CUCM, it's on-demand, based on the triggering event of your access that page. So, control access to it, communicate with those who have access, or stop the Tomcat service on UCCX until LDAP is back. Ok, that last one might be a bit extreme, but you get the point: protect the page!

PS, are you looking for a ready-to-go solution, or did you just want to talk it through with someone, but are planning on writing your own?

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
Enthusiast

Re: Python Script to backup skills/teams/supervisor settings?

I'm pretty sure no-one accessed the page in the intervening time between the LDAP outage and the restoration. I did have to run a manual LDAP sync on UCM, and then logged into UCCX to make sure SSO was working again.

 

Anyway, it seems like that data is too precious not to protect in an easily accessible manner if it is possible for this to happen in this environment. I'll probably just write my own, I just wanted to make sure someone didn't have one tucked away on GitHub before doing so.

 

Looks like I can just do a get resource list, and then do a get resource for each name in the list and store the JSON response in a text file. Then reverse the process with a modify resource loop if we need to restore.

Hall of Fame Master

Re: Python Script to backup skills/teams/supervisor settings?

The CCX provisioning API is RESTFUL using XML, so writing a quick tool with Python should be simple. I don't have code to share but using Requests and one of the standard XML libraries should take little time to write something.  All necessary documentation can  be found on the Cisco DevNet pages.

VIP Advisor

Re: Python Script to backup skills/teams/supervisor settings?

What do you think would happen if you sent a REST API request to fix a user, who used to be a Supervisor, but after the deletion/re-sync, they lost their Supervisor role? I would think you would need to modify their role first, then send the request, but maybe I'm wrong, and the request would trigger an internal UCCX event to add that role to the user, to support the request? I don't know. I'll have to try it out.

 

EDIT

Just tried to do this and the API returned an error:

 

"errorData": "Trying to modify unmodifiable fields [type, secondrySupervisorOf]",

 

And from what I can tell, you cannot make someone a Supervisor with the API.  Unless I'm just not seeing it.  Do you know?

 

So if not, you'd just have to manually add the Supervisor role to all of the Supervisors quick, and then run your import script.

 

EDIT2:

 

Actually, even after updating the role of my user to be a Supervisor again, the export I took prior, cannot be imported, as I get the same error regardless.

 

I'm running 11.6(2)ES02.  So, it looks like you will have to strip out all of the XML for Supervising Teams first, then submit just the Agent specific config (RG, Skills, Team and Alias).  Followed by, having exported all of Teams, and re-importing the Teams to get this Supervisor back into the Team.  I did this and it worked.

 

High Level Steps

 

  1. Export Each Team (HTTP GET)
  2. Export Each Resource (HTTP GET)
  3. LDAP Issue Happens
  4. Access the RmCm page to confirm all of the users are missing
  5. LDAP Issue Fixed
  6. Access the RmCm page to load all the users in from CUCM
    1. There was a forum post how this was necessary, I can't find it at the moment
  7. Manually assign Supervisor role to all Supervisors
    1. Can we automate this?  API?
  8. Strip out Supervisor Team assignment from exported Resource data
  9. Import all Resource data (HTTP PUT)
  10. Import all Team data (HTTP PUT)

I think that's right, unless we can figure out how to make it more streamlined.

 

EDIT3:

 

From where and how often would you run the exports?


Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
Enthusiast

Re: Python Script to backup skills/teams/supervisor settings?

I would probably run it from an Ubuntu box we use as our SFTP server for backups. Probably once a day.

You are right, doesn’t look like you can modify the user role via API. Maybe generate a sql query for that to paste into the CLI for a restore. Or at least generate a list of all the people with supervisor access to make it easy to add that role back quickly via the web interface.
VIP Advisor

Re: Python Script to backup skills/teams/supervisor settings?

Or use something like the Python Requests module to create a browsing session to UCCX AppAdmin, and just submit the form yourself? I use Python Requests today, to login an pull data, but I haven't done it yet, to post data. Should be possible though.

 

EDIT:

 

Why stop at Resources and Teams?  Might as well make COBRAS for UCCX, am I right?  The ability to restore individual objects without restoring the entire server seems useful.


Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
Enthusiast

Re: Python Script to backup skills/teams/supervisor settings?

COBRAS for UCCX - That would be cool. I am using requests on the backside of Zeep for my UCM import script (phones, jabber, snr, internal masking, kem’s full of blfs, sd, and SURLs). It probably could handle posting the changes through the web interface. There probably is an API in use in the web interface. Before they released the API for DNA we had to pick apart the DNA web interface to figure out the internal API calls to provision switches via Python… Can’t be too hard to reverse engineer the UCCX web interface too.
Hall of Fame Master

Re: Python Script to backup skills/teams/supervisor settings?

Unlike SOAP API which is what CUCM uses, CCX uses REST API which makes it 1000% easier to write anything to update/export as it deals with XML rather than crazy SOAP data structure and there is no need for Zeep or Jurko-Suds Python libraries.  If you are proficient with Python or other language you can write something within minutes to export or update supported data.  Perhaps one of these days Cisco will switch from XML to JSON and makes it even easier on us, one can hope :-)

CreatePlease to create content
Content for Community-Ad
June's Community Spotlight Awards