Skip to content

Commit 484d377

Browse files
committed
hostname modified dynamically and comment updated
1 parent 24b5f3c commit 484d377

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

examples_python2/modify_hostname.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
# management server.
2222
from cpapi import APIClient, APIClientArgs
2323

24-
# new hostname value to be defined
25-
HOSTNAME = "my-new-hostname"
26-
2724

2825
def main():
2926
# getting details from the user
@@ -35,6 +32,8 @@ def main():
3532
print("Attention! Your password will be shown on the screen!")
3633
password = raw_input("Enter password: ")
3734

35+
hostname = raw_input("hostname value to be defined:")
36+
3837
client_args = APIClientArgs(server=api_server,
3938
api_version="1",
4039
unsafe=True,
@@ -57,7 +56,7 @@ def main():
5756
print("Failed to get hostname '{}'".format(api_res.data))
5857

5958
# request to set hostname
60-
api_res = client.api_call("set-hostname", {"name": HOSTNAME})
59+
api_res = client.api_call("set-hostname", {"name": hostname})
6160
if api_res.success:
6261
print("Hostname name changed to '{}'".format(api_res.data["name"]))
6362
else:

examples_python2/show_physical_interface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def main():
5151
if api_res.success:
5252
# in order to access any field within the data that had
5353
# returned, simple use api_res.data["field name"] or refer to
54-
# the documentation page - https://<your-server-ip>/gaia_docs/
54+
# the documentation page -
55+
# https://sc1.checkpoint.com/documents/latest/GaiaAPIs/
5556
print(
5657
"Physical interface name is '{}' , ipv4 address is '{}', "
5758
"interface mtu is '{}' ".format(api_res.data["name"],

examples_python3/modify_hostname.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
# management server.
2222
from cpapi import APIClient, APIClientArgs
2323

24-
HOSTNAME = "my-new-hostname"
25-
2624

2725
def main():
2826
# getting details from the user
@@ -34,6 +32,8 @@ def main():
3432
print("Attention! Your password will be shown on the screen!")
3533
password = input("Enter password: ")
3634

35+
hostname = input("hostname value to be defined:")
36+
3737
client_args = APIClientArgs(server=api_server, api_version="1",
3838
unsafe=True, context="gaia_api")
3939

@@ -54,7 +54,7 @@ def main():
5454
print("Failed to get hostname '{}'".format(api_res.data))
5555

5656
# request to set hostname
57-
api_res = client.api_call("set-hostname", {"name": HOSTNAME})
57+
api_res = client.api_call("set-hostname", {"name": hostname})
5858
if api_res.success:
5959
print("Hostname name changed to '{}'".format(api_res.data["name"]))
6060
else:

examples_python3/show_physical_interface.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def main():
5050
})
5151
if api_res.success:
5252
# in order to access any field within the data that had
53-
# returned, simple use api_res.data["field name"]
53+
# returned, simple use api_res.data["field name"] or refer to
54+
# the documentation page -
55+
# https://sc1.checkpoint.com/documents/latest/GaiaAPIs/
5456
print(
5557
"Physical interface name is '{}' , ipv4 address is '{}', "
5658
"interface mtu is '{}' ".format(api_res.data["name"],

0 commit comments

Comments
 (0)