Repository navigation
Expand file tree
/
Copy pathcp_api_sample.py
More file actions
58 lines (48 loc) · 1.69 KB
/
Copy pathcp_api_sample.py
File metadata and controls
58 lines (48 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#
# Script that will perform API calls based on the user's input
#
import api_functions as functions, getpass as gp, sys, time
print("\n***********************************************")
print("*************** Check Point API ***************")
print("***********************************************\n")
sid = None
login_attempts = 0
# Presents login screen until the login is successful or fails 3 times
while(sid is None):
if(login_attempts >= 0 and login_attempts < 3):
login_attempts += 1
else:
print("You have exceeded your login attempts")
print("Goodbye")
time.sleep(5)
sys.exit()
mgmt_ip = raw_input("Please enter the Management IP Address: ")
user = raw_input("Username: ")
password = gp.getpass()
print("\n")
sid = functions.login(user, password, mgmt_ip)
if(sid is None):
print("The information you have entered is incorrect.\n")
exit = 0
first_iteration = 1
while(exit == 0):
if(first_iteration == 1):
print("Welcome " + user)
print("Configuration Options:")
print("----------------------")
print("(1)\tAdd Host")
print("(2)\tDelete Host")
print("(3)\tAdd Network")
print("(4)\tDelete Network")
print("(5)\tPublish")
print("(6)\tLogout\n")
response = raw_input("Enter your choice number: ")
if(response == '1'):
name = raw_input("Enter Host Name: ")
host_addr = raw_input("\nEnter Host IP Address: ")
response = functions.add_host(name, host_addr, mgmt_ip, sid)
if(response == '5'):
functions.publish(mgmt_ip, sid)
if(response == '6'):
exit = 1
first_iteration += 1