Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Simon_Macpherso
Advisor
Jump to solution

Checkpoint Python SDK

Hello,

Can the Checkpoint python sdk for the management api be installed or references on the management server itself? 

I want to automate the execution of some python scripts for policy maintenance from AWX against the management server using the ansible  cp_mgmt_run_script module. This module requires you to specify a target host in the playbook, which in this case is the management server itself.

It will then attempt to run the script locally from the target host (mgmt server).   

I've copied the scripts to a location on the management server, however when I try to run them the mgmt server report the require module cpapi is missing - which was expected as the sdk is not installed. 

The README.md in the github site (https://github.com/CheckPointSW/cp_mgmt_api_python_sdk) refers to configuring the sdk on a management machine - not sure 100 what this would be. It requires you to download then sdk (not install it using pip), then configure a reference to it in an environment variable.

export PYTHONPATH=$PYTHONPATH:/home/admin/cp_mgmt_api_python_sdk/

 

Regards,

Simon

0 Kudos
1 Solution

Accepted Solutions
Joseph_Audet
Ambassador
Ambassador

Hi Simon - Martin was saying to create a folder on your management server and call it "cpapi". Then download all of the files API into it like the instructions say on the github page.

Example CPAPI path: /home/admin/cpapi

If you put your script in this folder: /home/admin/

This should allow it to find the CPAPI module. See the example I did using the find_dup_ip.py sample script:

[Expert@mgmt-sa1:0]# pwd
/home/admin

[Expert@mgmt-sa1:0]# ls -d c*
cpapi

[Expert@mgmt-sa1:0]# cd cpapi/
[Expert@mgmt-sa1:0]# ls
__init__.py __init__.pyc api_exceptions.py api_exceptions.pyc api_response.py api_response.pyc cli.py mgmt_api.py mgmt_api.pyc utils.py utils.pyc

[Expert@mgmt-sa1:0]# cd ..
[Expert@mgmt-sa1:0]# python find_dup_ip.py
Enter server IP address or hostname:x.x.x.x
Enter username: admin
Enter password:
Processing. Please wait...

Saving data to debug file api_calls.json

 

List of Duplicate IP addresses:
-------------------------------


View solution in original post

0 Kudos
4 Replies
Martin_Valenta
Advisor

it's enough to create folder called "cpapi" and put those files to it and script which will be running in same folder where "cpapi" is located it will load it.

0 Kudos
Simon_Macpherso
Advisor

Hi Martin,

Can you please explain that in a bit more detail. 

Regards,

Simon

0 Kudos
Joseph_Audet
Ambassador
Ambassador

Hi Simon - Martin was saying to create a folder on your management server and call it "cpapi". Then download all of the files API into it like the instructions say on the github page.

Example CPAPI path: /home/admin/cpapi

If you put your script in this folder: /home/admin/

This should allow it to find the CPAPI module. See the example I did using the find_dup_ip.py sample script:

[Expert@mgmt-sa1:0]# pwd
/home/admin

[Expert@mgmt-sa1:0]# ls -d c*
cpapi

[Expert@mgmt-sa1:0]# cd cpapi/
[Expert@mgmt-sa1:0]# ls
__init__.py __init__.pyc api_exceptions.py api_exceptions.pyc api_response.py api_response.pyc cli.py mgmt_api.py mgmt_api.pyc utils.py utils.pyc

[Expert@mgmt-sa1:0]# cd ..
[Expert@mgmt-sa1:0]# python find_dup_ip.py
Enter server IP address or hostname:x.x.x.x
Enter username: admin
Enter password:
Processing. Please wait...

Saving data to debug file api_calls.json

 

List of Duplicate IP addresses:
-------------------------------


0 Kudos
Simon_Macpherso
Advisor

Hi @Joseph_Audet 

Thanks for your reply. 

I did this on Friday and it works.

Regards,

Simon

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events