Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Jaime_Gonzalez_
Participant

Re: Python tool for exporting/importing a policy package or parts of it

Hello,

Also having problems while exporting package:

Login failed: APIResponse received a response which is not valid JSON.

I'm using Python:

Python 2.7.9 (default, Mar  1 2015, 12:57:24)

[GCC 4.9.2] on linux2

Against R80 - Build 101

Can you please help me with this?

Thank you in advance.

5 Replies
Carlos_Molina
Participant

Hello.

I think you have to enable access to the API from external PCs... (settings --> blade --> API)

If after that it works.. please tell me your sintax.. because I still have problems.

Thanks in advance.

Jaime_Gonzalez_
Participant

Thanks Carlos, that worked for me.

Now i'm facing another error:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u0431' in position 43: ordinal not in range(128)

That i hope is related to any unusual character on a policy object name, or to the encoding used on mi linux client.

I'll write here if i find how to solve it.

The syntax i used is:

python export_package.py -m 192.168.10.213 "2016-Septiembre01_1"

Where "2016-Septiembre01_1", is the access layer (policy) name i got from running "show packages", like the "Standard" one.

Thank you!

Jaime_Gonzalez_
Participant

Hello,

Solved the previous problem by adding:

     reload(sys)

     sys.setdefaultencoding('utf8')

To the beggining of export_package.py

Now lets see how i import it on the R80 management, as the python version is 2.7.3:

     /opt/CPsuite-R80/fw1/Python/bin/python -V

     Python 2.7.3

Kind regards.

Antonio_Rodrigu
Participant

Hi friend, im having the same issue you solved adding the two lines on the export_package.py, but when i run the script receive this message:

 

File "/home/admin/ExportImportPolicyPackage-master/exporting/export_package.py", line 1, in <module>
reload(sys)
NameError: name 'sys' is not defined

 

This is after I modify the export_package.py adding your suggested lines to the beginning to this script.

 

thanks for your help.

0 Kudos
Carlos_Molina
Participant

Hello.

finally it works after instsalling jumbo take 76

Thanks.