cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
891
Views
0
Helpful
4
Replies
Highlighted
Cisco Employee

Prime 3.0/3.1 ShadowDirectory & more

Shadowdirectory IS NATIVELY AVAILABLE in PI 3.1.3 (look for Background Task 'Device Config Backup-External')

Sometimes functionality that is missing from the GUI still is available through the API as a workaround. A good example is the Shadow Directory, which was available in Cisco Prime LMS and is not yet available in Prime Infrastructure. However still through the API configurations can get pulled and stored in a directory to mimic this. This functionality is often requested by customers hence I putted together this short example.

Zip File contains 2 folders 'prime' & 'clitools'. The folder 'prime' contains the files 'PrimeBasicTools', 'PrimeShadowDirectory' and 'UserTrackingUtility'. In 'clitools' you will find 'PrimeShadowDirectoryRunner' and 'UserTrackingUtilityRunner'.

ToolCLITested on
ShadowDirectory

python3 clitools/PrimeShadowDirectoryRunner.py [-h] [-d DIRECTORY] -u USERNAME -p PASSWORD [-t {RUN,START}] [-i IDENTIFIER] [-v] hostname

example (one device).:

python3 clitools/PrimeShadowDirectoryRunner.py mypiserver -u myapiuser -p Prime123 -i mydevicename

example (all device).:

python3 clitools/PrimeShadowDirectoryRunner.py mypiserver -u myapiuser -p Prime123

Prime 3.0.2

3.1.1

UserTrackingUtility

python3 clitools/UserTrackingUtilityRunner.py [-h] -u USERNAME -p PASSWORD [-i IDENTIFIER] [-v] hostname

example.: python3 clitools/UserTrackingUtilityRunner.py mypiserver -u myapiuser -p Prime123$ -i jdoe

Prime 3.0.2

3.1.1

Disclaimer: Use at your own risk / no support offered

4 REPLIES 4
Beginner

Re: Prime 3.0 ShadowDirectory & more

Hello Stefan,

Thank you very much for such important topic.

But can you please share step by step guide to upload those codes on the prime infrastructure, as I am not familiar with python programming.

Thanks in advance.

Cisco Employee

Re: Prime 3.0 ShadowDirectory & more

Hello Mahmoud,

actually it is not meant to run this directly on PI. Basically you can run this on any PC/Workstation/Server you like. You would only need to have IP connectivity from this station to PI and install Python 3 on it. After that, you can then execute those commands above manually or also schedule a cron job to do it regularly to back up your configs.

Hope that helps, if anything unclear, just let me know.

regards,

stefan

Beginner

Re: Prime 3.0/3.1 ShadowDirectory & more

Hello Stefan,

first, I would like to thank you for your work. It has elimented a real problem for me in recent years.

Since yesterday I did an inline update to Prime Infrastructure 3.5 and unfortunatly your tool is not working anymore.

Maybe you can help me:

 

C:\Tools>"C:\Program Files\Python\Python37\python.exe" "C:\Program Files\Python\clitools\PrimeShadowDirectoryRunner.py" -d D:\ConfigBackup\PrimeConfigExport -u <user> -p <password> <servername>
Start executing...
ERROR:root:Error: <class 'UnicodeEncodeError'> Details: 'charmap' codec can't encode characters in position 0-2: character maps to <undefined> StackTrace: Traceback (most recent call last):
File "C:\Program Files\Python\clitools\prime\PrimeShadowDirectory.py", line 247, in writeLatestConfigOfAllDevices
f.write(configs[dev])
File "C:\Program Files\Python\Python37\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-2: character maps to <undefined>

...something went wrong!

C:\Tools>

 

with kind regards,

Bernd

Cisco Employee

Re: Prime 3.0/3.1 ShadowDirectory & more

Hi Bernd,

 

unfortunately it seems that the API now returns the data not in 'string' format but in a different one, which leads to problems when writing it into a file.

 

Example from my PI3.5

...

<fileData>SE�U��+A�ܼRa�0m!5Dם"�й#L�,�Z�Pxʚ��V|�����3��n�|����ǶSL��m��Ʈ�x�V�Y�Dƌ�ˑ#�2������~+`yd��]�u������{�"�@e�
���/�m����`�ޯ���v;���=V�...

 

I have to check if I can get this solved. In the meantime I would recommend to use the build in function under Administration > Job Dashboard > System Jobs > Infrastructure >  Device Config Backup-External

Click the checkmark on the left side of the Job, and select the Pencil at the top, that allows you to configure the Destination and schedule.

 

regards,

stefan

Content for Community-Ad
July's Community Spotlight Awards
This widget could not be displayed.