Skip to content

Commit 6c29a9e

Browse files
author
mahalakg
committed
Initial Commit
1 parent 4783ad3 commit 6c29a9e

File tree

8 files changed

+199
-195
lines changed

8 files changed

+199
-195
lines changed

examples/python_client_library/cli_passthrough_samples_pcl/file_system_analytics.py renamed to examples/python_client_library/file_system_analytics_cli.py

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
#! /usr/bin/env python3
2-
3-
"""
4-
ONTAP REST API Python Client Library Sample Scripts
5-
This script was developed by NetApp to help demonstrate NetApp
6-
technologies. This script is not officially supported as a
7-
standard NetApp product.
8-
9-
Purpose: Script to list volumes using ONTAP REST API Python Client Library.
10-
11-
usage: python3 file_system_analytics.py [-h] -c CLUSTER -vs SVM_NAME [-u API_USER]
12-
[-p API_PASS]
13-
14-
Copyright (c) 2020 NetApp, Inc. All Rights Reserved.
15-
Licensed under the BSD 3-Clause "New" or "Revised" License (the "License");
16-
you may not use this file except in compliance with the License.
17-
You may obtain a copy of the License at
18-
https://opensource.org/licenses/BSD-3-Clause
19-
20-
"""
21-
22-
from netapp_ontap.resources import FileInfo
23-
from utils import Argument, parse_args, setup_logging, setup_connection, Volume
24-
25-
26-
def file_system_analytics_pycl(vol_name: str, svm_name: str, path: str) -> None:
27-
""" List File system analytics of a volume in an SVM """
28-
volume = Volume.find(**{'svm.name': svm_name, 'name': vol_name})
29-
30-
resource = FileInfo(volume.uuid, path)
31-
resource.get(return_metadata=True, fields="*")
32-
print()
33-
print("Path:", resource.path)
34-
print("Bytes Used:", resource.bytes_used)
35-
print("Accessed Time: ", resource.accessed_time)
36-
print("Changed Time: ", resource.changed_time)
37-
print("Inode: ", resource.inode_number)
38-
print("unix_permissions", resource.unix_permissions)
39-
40-
41-
def main() -> None:
42-
"""Main function"""
43-
arguments = [
44-
Argument("-c", "--cluster", "API server IP:port details"),
45-
Argument("-v", "--volume_name", "Volume Name"),
46-
Argument("-a", "--path", "path"),
47-
Argument("-vs", "--svm_name", "SVM Name")]
48-
args = parse_args(
49-
"This script will list analytics of a volume in an SVM", arguments)
50-
setup_logging()
51-
setup_connection(args.cluster, args.api_user, args.api_pass)
52-
file_system_analytics_pycl(args.volume_name, args.svm_name, args.path)
53-
54-
55-
if __name__ == "__main__":
56-
main()
1+
#! /usr/bin/env python3
2+
3+
"""
4+
ONTAP REST API Python Client Library Sample Scripts
5+
This script was developed by NetApp to help demonstrate NetApp
6+
technologies. This script is not officially supported as a
7+
standard NetApp product.
8+
9+
Purpose: Script to list volumes using ONTAP REST API Python Client Library.
10+
11+
usage: python3 file_system_analytics_cli.py [-h] -c CLUSTER -vs SVM_NAME [-u API_USER]
12+
[-p API_PASS]
13+
14+
Copyright (c) 2020 NetApp, Inc. All Rights Reserved.
15+
Licensed under the BSD 3-Clause "New" or "Revised" License (the "License");
16+
you may not use this file except in compliance with the License.
17+
You may obtain a copy of the License at
18+
https://opensource.org/licenses/BSD-3-Clause
19+
20+
"""
21+
22+
from netapp_ontap.resources import FileInfo
23+
from utils import Argument, parse_args, setup_logging, setup_connection, Volume
24+
25+
26+
def file_system_analytics_pycl(vol_name: str, svm_name: str, path: str) -> None:
27+
""" List File system analytics of a volume in an SVM """
28+
volume = Volume.find(**{'svm.name': svm_name, 'name': vol_name})
29+
30+
resource = FileInfo(volume.uuid, path)
31+
resource.get(return_metadata=True, fields="*")
32+
print()
33+
print("Path:", resource.path)
34+
print("Bytes Used:", resource.bytes_used)
35+
print("Accessed Time: ", resource.accessed_time)
36+
print("Changed Time: ", resource.changed_time)
37+
print("Inode: ", resource.inode_number)
38+
print("unix_permissions", resource.unix_permissions)
39+
40+
41+
def main() -> None:
42+
"""Main function"""
43+
arguments = [
44+
Argument("-c", "--cluster", "API server IP:port details"),
45+
Argument("-v", "--volume_name", "Volume Name"),
46+
Argument("-a", "--path", "path"),
47+
Argument("-vs", "--svm_name", "SVM Name")]
48+
args = parse_args(
49+
"This script will list analytics of a volume in an SVM", arguments)
50+
setup_logging()
51+
setup_connection(args.cluster, args.api_user, args.api_pass)
52+
file_system_analytics_pycl(args.volume_name, args.svm_name, args.path)
53+
54+
55+
if __name__ == "__main__":
56+
main()

examples/python_client_library/cli_passthrough_samples_pcl/system_node_power_update.py renamed to examples/python_client_library/system_node_power_update_cli.py

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,80 @@
1-
#! /usr/bin/env python3
2-
3-
"""
4-
ONTAP REST API Python Client Library Sample Scripts
5-
This script was developed by NetApp to help demonstrate NetApp
6-
technologies. This script is not officially supported as a
7-
standard NetApp product.
8-
9-
Purpose: Script to use CLI commands using ONTAP REST API Python Client Library.
10-
11-
usage: python3 system_node_power_update.py [-h] -c CLUSTER -vs SVM_NAME [-u API_USER]
12-
[-p API_PASS]
13-
14-
Copyright (c) 2020 NetApp, Inc. All Rights Reserved.
15-
Licensed under the BSD 3-Clause "New" or "Revised" License (the "License");
16-
you may not use this file except in compliance with the License.
17-
You may obtain a copy of the License at
18-
https://opensource.org/licenses/BSD-3-Clause
19-
20-
"""
21-
22-
import json
23-
import time
24-
from netapp_ontap.resources import CLI
25-
from utils import Argument, parse_args, setup_logging, setup_connection
26-
27-
28-
def system_node_power_on() -> None:
29-
""" system node power on module"""
30-
node_name = input("\n Enter the node name: ")
31-
response = CLI().execute(
32-
"system node power on",
33-
body={
34-
"node": node_name},
35-
privilege_level="diagnostic")
36-
time.sleep(15)
37-
response = CLI().execute(
38-
"system node power show", status="on")
39-
print(json.dumps(response.http_response.json(), indent=4))
40-
41-
42-
def system_node_power_off() -> None:
43-
""" System node power off module """
44-
node = input("\n Enter the node name: ")
45-
response = CLI().execute(
46-
"system node power off", body={
47-
"node": node}, privilege_level="diagnostic")
48-
time.sleep(5)
49-
response = CLI().execute(
50-
"system node power show", status="off")
51-
print(json.dumps(response.http_response.json(), indent=4))
52-
53-
54-
def check_system_power() -> None:
55-
"""Module to retrieve user input for system node power"""
56-
print("\n===============================================================")
57-
print("This Module covers System node power CLI command usage in PCL")
58-
print("===============================================================")
59-
print("\n 1. CLI Command >> system node power on")
60-
print("\n 2. CLI Command >> system node power off")
61-
option = input("\n\nEnter the option: ")
62-
if option == '1':
63-
system_node_power_on()
64-
if option == '2':
65-
system_node_power_off()
66-
67-
68-
def main() -> None:
69-
"""Main function"""
70-
arguments = [
71-
Argument("-c", "--cluster", "API server IP:port details")]
72-
args = parse_args(
73-
"This script will update system power status ON/OFF", arguments)
74-
setup_logging()
75-
setup_connection(args.cluster, args.api_user, args.api_pass)
76-
check_system_power()
77-
78-
79-
if __name__ == "__main__":
80-
main()
1+
#! /usr/bin/env python3
2+
3+
"""
4+
ONTAP REST API Python Client Library Sample Scripts
5+
This script was developed by NetApp to help demonstrate NetApp
6+
technologies. This script is not officially supported as a
7+
standard NetApp product.
8+
9+
Purpose: Script to use CLI commands using ONTAP REST API Python Client Library.
10+
11+
usage: python3 system_node_power_update_cli.py [-h] -c CLUSTER -vs SVM_NAME [-u API_USER]
12+
[-p API_PASS]
13+
14+
Copyright (c) 2020 NetApp, Inc. All Rights Reserved.
15+
Licensed under the BSD 3-Clause "New" or "Revised" License (the "License");
16+
you may not use this file except in compliance with the License.
17+
You may obtain a copy of the License at
18+
https://opensource.org/licenses/BSD-3-Clause
19+
20+
"""
21+
22+
import json
23+
import time
24+
from netapp_ontap.resources import CLI
25+
from utils import Argument, parse_args, setup_logging, setup_connection
26+
27+
28+
def system_node_power_on() -> None:
29+
""" system node power on module"""
30+
node_name = input("\n Enter the node name: ")
31+
response = CLI().execute(
32+
"system node power on",
33+
body={
34+
"node": node_name},
35+
privilege_level="diagnostic")
36+
time.sleep(15)
37+
response = CLI().execute(
38+
"system node power show", status="on")
39+
print(json.dumps(response.http_response.json(), indent=4))
40+
41+
42+
def system_node_power_off() -> None:
43+
""" System node power off module """
44+
node = input("\n Enter the node name: ")
45+
response = CLI().execute(
46+
"system node power off", body={
47+
"node": node}, privilege_level="diagnostic")
48+
time.sleep(5)
49+
response = CLI().execute(
50+
"system node power show", status="off")
51+
print(json.dumps(response.http_response.json(), indent=4))
52+
53+
54+
def check_system_power() -> None:
55+
"""Module to retrieve user input for system node power"""
56+
print("\n===============================================================")
57+
print("This Module covers System node power CLI command usage in PCL")
58+
print("===============================================================")
59+
print("\n 1. CLI Command >> system node power on")
60+
print("\n 2. CLI Command >> system node power off")
61+
option = input("\n\nEnter the option: ")
62+
if option == '1':
63+
system_node_power_on()
64+
if option == '2':
65+
system_node_power_off()
66+
67+
68+
def main() -> None:
69+
"""Main function"""
70+
arguments = [
71+
Argument("-c", "--cluster", "API server IP:port details")]
72+
args = parse_args(
73+
"This script will update system power status ON/OFF", arguments)
74+
setup_logging()
75+
setup_connection(args.cluster, args.api_user, args.api_pass)
76+
check_system_power()
77+
78+
79+
if __name__ == "__main__":
80+
main()

examples/python_client_library/cli_passthrough_samples_pcl/system_power_status.py renamed to examples/python_client_library/system_power_status_cli.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
#! /usr/bin/env python3
2-
3-
"""
4-
ONTAP REST API Python Client Library Sample Scripts
5-
This script was developed by NetApp to help demonstrate NetApp
6-
technologies. This script is not officially supported as a
7-
standard NetApp product.
8-
9-
Purpose: Script to use CLI commands using ONTAP REST API Python Client Library.
10-
11-
usage: python3 system_power_status.py [-h] -c CLUSTER -vs SVM_NAME [-u API_USER]
12-
[-p API_PASS]
13-
14-
Copyright (c) 2020 NetApp, Inc. All Rights Reserved.
15-
Licensed under the BSD 3-Clause "New" or "Revised" License (the "License");
16-
you may not use this file except in compliance with the License.
17-
You may obtain a copy of the License at
18-
https://opensource.org/licenses/BSD-3-Clause
19-
20-
"""
21-
import json
22-
from netapp_ontap.resources import CLI
23-
from utils import Argument, parse_args, setup_logging, setup_connection
24-
25-
26-
def system_power_status_pycl() -> None:
27-
""" list system power status """
28-
response = CLI().execute(
29-
"system node power show", status="on")
30-
print(json.dumps(response.http_response.json(), indent=4))
31-
32-
33-
def main() -> None:
34-
"""Main function"""
35-
arguments = [
36-
Argument("-c", "--cluster", "API server IP:port details")]
37-
args = parse_args(
38-
"This script will list ONTAP System Power status", arguments)
39-
setup_logging()
40-
setup_connection(args.cluster, args.api_user, args.api_pass)
41-
system_power_status_pycl()
42-
43-
44-
if __name__ == "__main__":
45-
main()
1+
#! /usr/bin/env python3
2+
3+
"""
4+
ONTAP REST API Python Client Library Sample Scripts
5+
This script was developed by NetApp to help demonstrate NetApp
6+
technologies. This script is not officially supported as a
7+
standard NetApp product.
8+
9+
Purpose: Script to use CLI commands using ONTAP REST API Python Client Library.
10+
11+
usage: python3 system_power_status_cli.py [-h] -c CLUSTER -vs SVM_NAME [-u API_USER]
12+
[-p API_PASS]
13+
14+
Copyright (c) 2020 NetApp, Inc. All Rights Reserved.
15+
Licensed under the BSD 3-Clause "New" or "Revised" License (the "License");
16+
you may not use this file except in compliance with the License.
17+
You may obtain a copy of the License at
18+
https://opensource.org/licenses/BSD-3-Clause
19+
20+
"""
21+
import json
22+
from netapp_ontap.resources import CLI
23+
from utils import Argument, parse_args, setup_logging, setup_connection
24+
25+
26+
def system_power_status_cli_pycl() -> None:
27+
""" list system power status """
28+
response = CLI().execute(
29+
"system node power show", status="on")
30+
print(json.dumps(response.http_response.json(), indent=4))
31+
32+
33+
def main() -> None:
34+
"""Main function"""
35+
arguments = [
36+
Argument("-c", "--cluster", "API server IP:port details")]
37+
args = parse_args(
38+
"This script will list ONTAP System Power status", arguments)
39+
setup_logging()
40+
setup_connection(args.cluster, args.api_user, args.api_pass)
41+
system_power_status_cli_pycl()
42+
43+
44+
if __name__ == "__main__":
45+
main()

0 commit comments

Comments
 (0)