Skip to content

Commit 15cbb9c

Browse files
committed
resolve conflicts
2 parents 730f2f4 + 54b79fe commit 15cbb9c

27 files changed

+2200
-74
lines changed

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,39 @@ Contains code samples to invoke NetBackup REST API using different programming l
55
#### Disclaimer
66
These scripts are only meant to be used as a reference. Please do not use these in production.
77

8-
#### Executing the snippets in PowerShell
9-
Pre-requisites:
10-
- NetBackup 8.1.1 or higher
11-
- Powershell 5.0 or higher
8+
#### Executing the snippets for different programming languages
129

13-
Use the following commands to run the powershell samples.
14-
- `.\Get-NB-Images.ps1 -nbmaster <masterServer> -username <username> -password <password>`
15-
- `.\Get-NB-Jobs.ps1 -nbmaster <masterServer> -username <username> -password <password>`
10+
The `snippets` folder contains code samples to invoke NetBackup REST API using different programming languages.
1611

17-
#### Executing the snippets in Python
1812
Pre-requisites:
13+
1914
- NetBackup 8.1.1 or higher
20-
- python 3.5 or higher
21-
- python modules: `requests, texttable`
15+
- See the script's README for the corresponding requirements and usage
2216

23-
Use the following commands to run the python samples.
24-
- `python -W ignore get_nb_images.py -nbmaster <masterServer> -username <username> -password <password>`
25-
- `python -W ignore get_nb_jobs.py -nbmaster <masterServer> -username <username> -password <password>`
17+
#### Executing the recipes in Python
2618

27-
#### Executing the snippets in Perl
2819
Pre-requisites:
29-
- NetBackup 8.1.1 or higher
30-
- See script README for perl requirements and usage
20+
- NetBackup 8.1.2 or higher
21+
- python 3.5 or higher
22+
- python modules: `requests`
3123

24+
<<<<<<< HEAD
3225
#### Executing the recipes in PowerShell
3326
Pre-requisites:
3427
- NetBackup 8.1.2 or higher
3528
- PowerShell 4.0 or higher
3629

3730
Use the following commands to run the PowerShell samples.
3831
- `.\create_policy_in_one_step.ps1 -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
39-
- `.\rbac_filtering_in_policy.ps1 -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
32+
- `.\rbac_filtering_in_policy.ps1 -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
33+
=======
34+
Use the following commands to run the python samples.
35+
- `python -W ignore create_policy_step_by_step.py -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
36+
- `python -W ignore create_policy_in_one_step.py -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
37+
- `python -W ignore rbac_filtering_in_policy.py -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
38+
39+
#### Tools
40+
The `tools` folder contains utilities that have proven useful in the development of projects using
41+
NetBackup REST APIs, but do not provide any API usage examples. Again, these tools are not for
42+
production use, but they may be of some use in your work.
43+
>>>>>>> master
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import sys
2+
import policy_api_requests
3+
import json
4+
5+
protocol = "https"
6+
nbmaster = ""
7+
username = ""
8+
password = ""
9+
domainName = ""
10+
domainType = ""
11+
port = 1556
12+
13+
def print_disclaimer():
14+
print("-------------------------------------------------------------------------------------------------")
15+
print("-- This script requires Python3.5 or higher. --")
16+
print("-- If your current system does not have Python3.5 or higher installed, this will not work. --")
17+
print("-------------------------------------------------------------------------------------------------\n")
18+
print("Executing this library requires some additional python3.5 libraries like \n\t'requests'.\n\n")
19+
print("You will, however, require 'requests' library to make the API calls.\n")
20+
print("You can install the dependent libraries using the following commands: ")
21+
print("pip install requests")
22+
print("-------------------------------------------------------------------------------------------------\n\n\n")
23+
print("You can specify the 'nbmaster', 'username', 'password', 'domainName' and 'domainType' as command-line parameters\n")
24+
print_usage()
25+
26+
def print_usage():
27+
print("Example:")
28+
print("python -W ignore create_policy_in_one_step.py -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]\n\n\n")
29+
30+
def read_command_line_arguments():
31+
if len(sys.argv)%2 == 0:
32+
print_usage()
33+
exit()
34+
35+
global nbmaster
36+
global username
37+
global password
38+
global domainName
39+
global domainType
40+
41+
for i in range(1, len(sys.argv), 2):
42+
if sys.argv[i] == "-nbmaster":
43+
nbmaster = sys.argv[i + 1]
44+
elif sys.argv[i] == "-username":
45+
username = sys.argv[i + 1]
46+
elif sys.argv[i] == "-password":
47+
password = sys.argv[i + 1]
48+
elif sys.argv[i] == "-domainName":
49+
domainName = sys.argv[i + 1]
50+
elif sys.argv[i] == "-domainType":
51+
domainType = sys.argv[i + 1]
52+
else:
53+
print_usage()
54+
exit()
55+
56+
if nbmaster == "":
57+
print("Please provide the value for 'nbmaster'")
58+
exit()
59+
elif username == "":
60+
print("Please provide the value for 'username'")
61+
exit()
62+
elif password == "":
63+
print("Please provide the value for 'password'")
64+
exit()
65+
elif domainName == "":
66+
print("Please provide the value for 'domainName'")
67+
exit()
68+
elif domainType == "":
69+
print("Please provide the value for 'domainType'")
70+
exit()
71+
72+
print_disclaimer()
73+
74+
read_command_line_arguments()
75+
76+
base_url = protocol + "://" + nbmaster + ":" + str(port) + "/netbackup"
77+
78+
jwt = policy_api_requests.perform_login(username, password, domainName, domainType, base_url)
79+
80+
policy_api_requests.post_netbackup_VMwarePolicy(jwt, base_url)
81+
82+
policy_api_requests.get_netbackup_policies(jwt, base_url)
83+
84+
policy_api_requests.get_netbackup_policy(jwt, base_url)
85+
86+
policy_api_requests.put_netbackup_policy(jwt, base_url)
87+
88+
policy_api_requests.get_netbackup_policy(jwt, base_url)
89+
90+
policy_api_requests.delete_VMware_netbackup_policy(jwt, base_url)
91+
92+
policy_api_requests.get_netbackup_policies(jwt, base_url)
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import sys
2+
import policy_api_requests
3+
import json
4+
5+
protocol = "https"
6+
nbmaster = ""
7+
username = ""
8+
password = ""
9+
domainName = ""
10+
domainType = ""
11+
port = 1556
12+
13+
def print_disclaimer():
14+
print("-------------------------------------------------------------------------------------------------")
15+
print("-- This script requires Python3.5 or higher. --")
16+
print("-- If your current system does not have Python3.5 or higher installed, this will not work. --")
17+
print("-------------------------------------------------------------------------------------------------\n")
18+
print("Executing this library requires some additional python3.5 libraries like \n\t'requests'.\n\n")
19+
print("You will, however, require 'requests' library to make the API calls.\n")
20+
print("You can install the dependent libraries using the following commands: ")
21+
print("pip install requests ")
22+
print("-------------------------------------------------------------------------------------------------\n\n\n")
23+
print("You can specify the 'nbmaster', 'username', 'password', 'domainName' and 'domainType' as command-line parameters\n")
24+
print_usage()
25+
26+
def print_usage():
27+
print("Example:")
28+
print("python -W ignore create_policy_step_by_step.py -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]\n\n\n")
29+
30+
def read_command_line_arguments():
31+
if len(sys.argv)%2 == 0:
32+
print_usage()
33+
exit()
34+
35+
global nbmaster
36+
global username
37+
global password
38+
global domainName
39+
global domainType
40+
41+
for i in range(1, len(sys.argv), 2):
42+
if sys.argv[i] == "-nbmaster":
43+
nbmaster = sys.argv[i + 1]
44+
elif sys.argv[i] == "-username":
45+
username = sys.argv[i + 1]
46+
elif sys.argv[i] == "-password":
47+
password = sys.argv[i + 1]
48+
elif sys.argv[i] == "-domainName":
49+
domainName = sys.argv[i + 1]
50+
elif sys.argv[i] == "-domainType":
51+
domainType = sys.argv[i + 1]
52+
else:
53+
print_usage()
54+
exit()
55+
56+
if nbmaster == "":
57+
print("Please provide the value for 'nbmaster'")
58+
exit()
59+
elif username == "":
60+
print("Please provide the value for 'username'")
61+
exit()
62+
elif password == "":
63+
print("Please provide the value for 'password'")
64+
exit()
65+
elif domainName == "":
66+
print("Please provide the value for 'domainName'")
67+
exit()
68+
elif domainType == "":
69+
print("Please provide the value for 'domainType'")
70+
exit()
71+
72+
print_disclaimer()
73+
74+
read_command_line_arguments()
75+
76+
base_url = protocol + "://" + nbmaster + ":" + str(port) + "/netbackup"
77+
78+
jwt = policy_api_requests.perform_login(username, password, domainName, domainType, base_url)
79+
80+
policy_api_requests.post_netbackup_VMwarePolicy_defaults(jwt, base_url)
81+
82+
policy_api_requests.get_netbackup_policies(jwt, base_url)
83+
84+
policy_api_requests.get_netbackup_policy(jwt, base_url)
85+
86+
policy_api_requests.put_netbackup_policy(jwt, base_url)
87+
88+
policy_api_requests.put_netbackup_client(jwt, base_url)
89+
90+
policy_api_requests.put_netbackup_backupselections(jwt, base_url)
91+
92+
policy_api_requests.put_netbackup_schedule(jwt, base_url)
93+
94+
policy_api_requests.get_netbackup_policy(jwt, base_url)
95+
96+
policy_api_requests.delete_netbackup_client(jwt, base_url)
97+
98+
policy_api_requests.delete_netbackup_schedule(jwt, base_url)
99+
100+
policy_api_requests.delete_VMware_netbackup_policy(jwt, base_url)
101+
102+
policy_api_requests.get_netbackup_policies(jwt, base_url)

0 commit comments

Comments
 (0)