22import json
33
44content_type = "application/vnd.netbackup+json; version=2.0"
5- testPolicyName = "VMware_test_policy"
5+ testVMwarePolicyName = "VMware_test_policy"
6+ testOraclePolicyName = "Oracle_test_policy"
67testClientName = "MEDIA_SERVER"
78testScheduleName = "VMware_test_schedule"
89etag = ""
@@ -28,10 +29,10 @@ def post_netbackup_VMwarePolicy_defaults(jwt, base_url):
2829 req_body = {
2930 "data" : {
3031 "type" : "policy" ,
31- "id" : testPolicyName ,
32+ "id" : testVMwarePolicyName ,
3233 "attributes" : {
3334 "policy" : {
34- "policyName" : testPolicyName ,
35+ "policyName" : testVMwarePolicyName ,
3536 "policyType" : "VMware" ,
3637 "policyAttributes" : {},
3738 "clients" : [],
@@ -52,17 +53,48 @@ def post_netbackup_VMwarePolicy_defaults(jwt, base_url):
5253 if resp .status_code != 204 :
5354 raise Exception ('Create Policy API with defaults failed with status code {} and {}' .format (resp .status_code , resp .json ()))
5455
55- print ("\n {} with defaults is created with status code : {}\n " .format (testPolicyName ,resp .status_code ))
56+ print ("\n {} with defaults is created with status code : {}\n " .format (testVMwarePolicyName ,resp .status_code ))
57+
58+ def post_netbackup_OraclePolicy_defaults (jwt , base_url ):
59+ url = base_url + "/config/policies/"
60+ req_body = {
61+ "data" : {
62+ "type" : "policy" ,
63+ "id" : testOraclePolicyName ,
64+ "attributes" : {
65+ "policy" : {
66+ "policyName" : testOraclePolicyName ,
67+ "policyType" : "Oracle" ,
68+ "policyAttributes" : {},
69+ "clients" : [],
70+ "schedules" : [],
71+ "backupSelections" : {
72+ "selections" : []
73+ }
74+ }
75+ }
76+ }
77+ }
78+ headers = {'Content-Type' : content_type , 'Authorization' : jwt }
79+
80+ print ("\n Making POST Request to create VMware Policy with defaults \n " )
81+
82+ resp = requests .post (url , headers = headers , json = req_body , verify = False )
83+
84+ if resp .status_code != 204 :
85+ raise Exception ('Create Policy API with defaults failed with status code {} and {}' .format (resp .status_code , resp .json ()))
86+
87+ print ("\n {} with defaults is created with status code : {}\n " .format (testVMwarePolicyName ,resp .status_code ))
5688
5789def post_netbackup_VMwarePolicy (jwt , base_url ):
5890 url = base_url + "/config/policies/"
5991 req_body = {
6092 "data" : {
6193 "type" : "policy" ,
62- "id" : testPolicyName ,
94+ "id" : testVMwarePolicyName ,
6395 "attributes" : {
6496 "policy" : {
65- "policyName" : testPolicyName ,
97+ "policyName" : testVMwarePolicyName ,
6698 "policyType" : "VMware" ,
6799 "policyAttributes" : {
68100 "active" : True ,
@@ -192,7 +224,7 @@ def post_netbackup_VMwarePolicy(jwt, base_url):
192224 if resp .status_code != 204 :
193225 raise Exception ('Create Policy API failed with status code {} and {}' .format (resp .status_code , resp .json ()))
194226
195- print ("\n {} with out defaults is created with status code : {}\n " .format (testPolicyName ,resp .status_code ))
227+ print ("\n {} with out defaults is created with status code : {}\n " .format (testVMwarePolicyName ,resp .status_code ))
196228
197229def get_netbackup_policies (jwt , base_url ):
198230 url = base_url + "/config/policies"
@@ -210,7 +242,7 @@ def get_netbackup_policies(jwt, base_url):
210242
211243
212244def get_netbackup_policy (jwt , base_url ):
213- url = base_url + "/config/policies/" + testPolicyName
245+ url = base_url + "/config/policies/" + testVMwarePolicyName
214246 global etag
215247 headers = {'Content-Type' : content_type , 'Authorization' : jwt }
216248
@@ -221,17 +253,30 @@ def get_netbackup_policy(jwt, base_url):
221253 if resp .status_code != 200 :
222254 raise Exception ('GET Policy API failed with status code {} and {}' .format (resp .status_code , resp .json ()))
223255
224- print ("\n Get policy details on {} succeeded with status code: {}\n " .format (testPolicyName , resp .status_code ))
256+ print ("\n Get policy details on {} succeeded with status code: {}\n " .format (testVMwarePolicyName , resp .status_code ))
225257 print ("\n The E-tag for the get policy : {}\n " .format (resp .headers ['ETag' ]))
226258 etag = resp .headers ['ETag' ]
227259 print ("\n Json Response body for get policy : \n {}\n " .format (json .loads (resp .content )))
228260
229261
230- def delete_netbackup_policy (jwt , base_url ):
231- url = base_url + "/config/policies/" + testPolicyName
262+ def delete_VMware_netbackup_policy (jwt , base_url ):
263+ url = base_url + "/config/policies/" + testVMwarePolicyName
264+ headers = {'Content-Type' : content_type , 'Authorization' : jwt , 'If-Match' : etag }
265+
266+ print ("\n Making policy DELETE Request on {}" .format (testVMwarePolicyName ))
267+
268+ resp = requests .delete (url , headers = headers , verify = False )
269+
270+ if resp .status_code != 204 :
271+ raise Exception ('DELETE Policy API failed with status code {} and {}' .format (resp .status_code , resp .json ()))
272+
273+ print ("\n The policy is deleted with status code: {}\n " .format (resp .status_code ))
274+
275+ def delete_Oracle_netbackup_policy (jwt , base_url ):
276+ url = base_url + "/config/policies/" + testOraclePolicyName
232277 headers = {'Content-Type' : content_type , 'Authorization' : jwt , 'If-Match' : etag }
233278
234- print ("\n Making policy DELETE Request on {}" .format (testPolicyName ))
279+ print ("\n Making policy DELETE Request on {}" .format (testOraclePolicyName ))
235280
236281 resp = requests .delete (url , headers = headers , verify = False )
237282
@@ -241,15 +286,15 @@ def delete_netbackup_policy(jwt, base_url):
241286 print ("\n The policy is deleted with status code: {}\n " .format (resp .status_code ))
242287
243288def put_netbackup_policy (jwt , base_url ):
244- url = base_url + "/config/policies/" + testPolicyName
289+ url = base_url + "/config/policies/" + testVMwarePolicyName
245290 global etag
246291 req_body = {
247292 "data" : {
248293 "type" : "policy" ,
249- "id" : testPolicyName ,
294+ "id" : testVMwarePolicyName ,
250295 "attributes" : {
251296 "policy" : {
252- "policyName" : testPolicyName ,
297+ "policyName" : testVMwarePolicyName ,
253298 "policyType" : "VMware" ,
254299 "policyAttributes" : {
255300 "keyword" : "test"
@@ -265,17 +310,17 @@ def put_netbackup_policy(jwt, base_url):
265310 }
266311 headers = {'Content-Type' : content_type , 'Authorization' : jwt ,'If-Match' : etag }
267312
268- print ("\n Making Update Request on {} by changing few attributes of the policy" .format (testPolicyName ))
313+ print ("\n Making Update Request on {} by changing few attributes of the policy" .format (testVMwarePolicyName ))
269314
270315 resp = requests .put (url , headers = headers , json = req_body , verify = False )
271316
272317 if resp .status_code != 204 :
273318 raise Exception ('PUT Policy API failed with status code {} and {}' .format (resp .status_code , resp .json ()))
274319 etag = resp .headers ['ETag' ]
275- print ("\n {} Updated with status code : {}\n " .format (testPolicyName , resp .status_code ))
320+ print ("\n {} Updated with status code : {}\n " .format (testVMwarePolicyName , resp .status_code ))
276321
277322def put_netbackup_client (jwt , base_url ):
278- url = base_url + "/config/policies/" + testPolicyName + "/clients/" + testClientName
323+ url = base_url + "/config/policies/" + testVMwarePolicyName + "/clients/" + testClientName
279324 global etag
280325 req_body = {
281326 "data" : {
@@ -289,17 +334,17 @@ def put_netbackup_client(jwt, base_url):
289334 }
290335 headers = {'Content-Type' : content_type , 'Authorization' : jwt , 'If-Match' : etag }
291336
292- print ("\n Making PUT Request to add client to {}" .format (testPolicyName ))
337+ print ("\n Making PUT Request to add client to {}" .format (testVMwarePolicyName ))
293338
294339 resp = requests .put (url , headers = headers , json = req_body , verify = False )
295340
296341 if resp .status_code != 201 :
297342 raise Exception ('PUT Client API failed with status code {} and {}' .format (resp .status_code , resp .json ()))
298343 etag = resp .headers ['ETag' ]
299- print ("\n {} is added to {} with status code : {}\n " .format (testClientName , testPolicyName , resp .status_code ))
344+ print ("\n {} is added to {} with status code : {}\n " .format (testClientName , testVMwarePolicyName , resp .status_code ))
300345
301346def delete_netbackup_client (jwt , base_url ):
302- url = base_url + "/config/policies/" + testPolicyName + "/clients/" + testClientName
347+ url = base_url + "/config/policies/" + testVMwarePolicyName + "/clients/" + testClientName
303348 global etag
304349 headers = {'Content-Type' : content_type , 'Authorization' : jwt , 'If-Match' : etag }
305350
@@ -310,10 +355,10 @@ def delete_netbackup_client(jwt, base_url):
310355 if resp .status_code != 204 :
311356 raise Exception ('DELETE Client API failed with status code {} and {}' .format (resp .status_code , resp .json ()))
312357 etag = resp .headers ['ETag' ]
313- print ("\n Client {} is deleted from {} with status code: {}\n " .format (testClientName , testPolicyName , resp .status_code ))
358+ print ("\n Client {} is deleted from {} with status code: {}\n " .format (testClientName , testVMwarePolicyName , resp .status_code ))
314359
315360def delete_netbackup_schedule (jwt , base_url ):
316- url = base_url + "/config/policies/" + testPolicyName + "/schedules/" + testScheduleName
361+ url = base_url + "/config/policies/" + testVMwarePolicyName + "/schedules/" + testScheduleName
317362 global etag
318363 headers = {'Content-Type' : content_type , 'Authorization' : jwt , 'If-Match' : etag }
319364
@@ -324,10 +369,10 @@ def delete_netbackup_schedule(jwt, base_url):
324369 if resp .status_code != 204 :
325370 raise Exception ('DELETE schedule API failed with status code {} and {}' .format (resp .status_code , resp .json ()))
326371 etag = resp .headers ['ETag' ]
327- print ("\n {} is deleted from the {} with status code: {}\n " .format (testScheduleName , testPolicyName , resp .status_code ))
372+ print ("\n {} is deleted from the {} with status code: {}\n " .format (testScheduleName , testVMwarePolicyName , resp .status_code ))
328373
329374def delete_netbackup_backupselections (jwt , base_url ):
330- url = base_url + "/config/policies/" + testPolicyName + "/backupselections"
375+ url = base_url + "/config/policies/" + testVMwarePolicyName + "/backupselections"
331376 headers = {'Content-Type' : content_type , 'Authorization' : jwt }
332377
333378 print ("Making DELETE Request to remove Backupselections from the policy\n " )
@@ -337,10 +382,10 @@ def delete_netbackup_backupselections(jwt, base_url):
337382 if resp .status_code != 204 :
338383 raise Exception ('DELETE Backupselections API failed with status code {} and {}' .format (resp .status_code , resp .json ()))
339384
340- print ("\n BackupSelections is deleted for the {} with status code : {}\n " .format (testPolicyName , resp .status_code ))
385+ print ("\n BackupSelections is deleted for the {} with status code : {}\n " .format (testVMwarePolicyName , resp .status_code ))
341386
342387def put_netbackup_backupselections (jwt , base_url ):
343- url = base_url + "/config/policies/" + testPolicyName + "/backupselections"
388+ url = base_url + "/config/policies/" + testVMwarePolicyName + "/backupselections"
344389 global etag
345390 req_body = {
346391 "data" : {
@@ -354,17 +399,17 @@ def put_netbackup_backupselections(jwt, base_url):
354399 }
355400 headers = {'Content-Type' : content_type , 'Authorization' : jwt , 'If-Match' : etag }
356401
357- print ("\n Making PUT Request to add BackupSelections to {}\n " .format (testPolicyName ))
402+ print ("\n Making PUT Request to add BackupSelections to {}\n " .format (testVMwarePolicyName ))
358403
359404 resp = requests .put (url , headers = headers , json = req_body , verify = False )
360405
361406 if resp .status_code != 204 :
362407 raise Exception ('PUT Backupselections API failed with status code {} and {}' .format (resp .status_code , resp .json ()))
363408 etag = resp .headers ['ETag' ]
364- print ("\n Backupselections added to {} with status code: {}\n " .format (testPolicyName , resp .status_code ))
409+ print ("\n Backupselections added to {} with status code: {}\n " .format (testVMwarePolicyName , resp .status_code ))
365410
366411def put_netbackup_schedule (jwt , base_url ):
367- url = base_url + "/config/policies/" + testPolicyName + "/schedules/" + testScheduleName
412+ url = base_url + "/config/policies/" + testVMwarePolicyName + "/schedules/" + testScheduleName
368413 global etag
369414 req_body = {
370415 "data" : {
@@ -451,11 +496,11 @@ def put_netbackup_schedule(jwt, base_url):
451496 }
452497 headers = {'Content-Type' : content_type , 'Authorization' : jwt , 'If-Match' : etag }
453498
454- print ("\n Making PUT Request to add schedule to {}\n " .format (testPolicyName ))
499+ print ("\n Making PUT Request to add schedule to {}\n " .format (testVMwarePolicyName ))
455500
456501 resp = requests .put (url , headers = headers , json = req_body , verify = False )
457502
458503 if resp .status_code != 201 :
459504 raise Exception ('PUT Schedule API failed with status code {} and {}' .format (resp .status_code , resp .json ()))
460505 etag = resp .headers ['ETag' ]
461- print ("\n {} is added to {} with status code : {}\n " .format (testScheduleName , testPolicyName , resp .status_code ))
506+ print ("\n {} is added to {} with status code : {}\n " .format (testScheduleName , testVMwarePolicyName , resp .status_code ))
0 commit comments