@@ -54,7 +54,7 @@ sub perform_login {
5454 }
5555}
5656
57- # create VMWare policy with the name veritas_policy1
57+ # create VMWare policy with the name veritas_policy1 with default values
5858sub create_policy_with_defaults {
5959
6060 my $url = " $base_url /config/policies" ;
@@ -81,6 +81,50 @@ sub create_policy_with_defaults {
8181 }
8282}
8383
84+ # create VMWare policy with the name veritas_policy1
85+ sub create_policy {
86+
87+ my $url = " $base_url /config/policies" ;
88+ my $policy_name = " veritas_policy1" ;
89+
90+ my $req = HTTP::Request-> new(POST => $url );
91+ $req -> header(' content-type' => $content_type_v2 );
92+ $req -> header(' Authorization' => $token );
93+
94+ my $backupSelections = qq( "backupSelections": {
95+ "selections": [ "vmware:/?filter=Displayname Equal \\\" Redacted-Test\\\" " ] }) ;
96+ my $clients = qq( "clients": [
97+ { "hardware": "VMware", "OS": "VMware", "hostName": "MEDIA_SERVER" } ]) ;
98+ my $schedules = qq( "schedules": [ {"acceleratorForcedRescan": false, "backupType": "Full Backup", "backupCopies": {
99+ "priority": 9999, "copies": [ { "mediaOwner": "owner1", "storage": null, "retentionPeriod": {
100+ "value": 9, "unit": "WEEKS" }, "volumePool": "NetBackup", "failStrategy": "Continue"}]},
101+ "excludeDates": { "lastDayOfMonth": true, "recurringDaysOfWeek": [ "4:6", "2:5" ], "recurringDaysOfMonth": [ 10 ],
102+ "specificDates": [ "2000-1-1", "2016-2-30" ] }, "frequencySeconds": 4800, "includeDates": {
103+ "lastDayOfMonth": true, "recurringDaysOfWeek": [ "2:3", "3:4" ], "recurringDaysOfMonth": [ 10,13], "specificDates": [
104+ "2016-12-31" ] }, "mediaMultiplexing":2, "retriesAllowedAfterRunDay": true, "scheduleType": "Calendar", "snapshotOnly": false,
105+ "startWindow": [ { "dayOfWeek": 1, "startSeconds": 14600, "durationSeconds": 24600 }, { "dayOfWeek": 2, "startSeconds": 14600, "durationSeconds": 24600 },
106+ { "dayOfWeek": 3, "startSeconds": 14600, "durationSeconds": 24600 }, { "dayOfWeek": 4, "startSeconds": 14600, "durationSeconds": 24600 },
107+ { "dayOfWeek": 5, "startSeconds": 14600, "durationSeconds": 24600 }, { "dayOfWeek": 6, "startSeconds": 14600, "durationSeconds": 24600 },
108+ { "dayOfWeek": 7, "startSeconds": 14600, "durationSeconds": 24600 } ], "syntheticBackup": false, "storageIsSLP": false, "scheduleName": "sched-9-weeks" } ]) ;
109+ my $policy_attributes = qq( "policyAttributes": { "active": true, "snapshotMethodArgs": "skipnodisk=0", "jobLimit": 10} ) ;
110+
111+ my $post_data = qq( { "data": { "type": "policy", "id": "$policy_name ", "attributes": {
112+ "policy": { "policyName": "$policy_name ", "policyType": "VMware", $policy_attributes , $clients , $backupSelections , $schedules } } } }) ;
113+ $req -> content($post_data );
114+
115+ print " \n\n **************************************************************" ;
116+ print " \n\n Making POST Request to create VMWare policy with defaults \n\n " ;
117+
118+ my $resp = $ua -> request($req );
119+ if ($resp -> is_success) {
120+ print " Policy [$policy_name ] with default values is create with status code: " , $resp -> code, " \n " ;
121+ }
122+ else {
123+ print " HTTP POST error code: " , $resp -> code, " \n " ;
124+ print " HTTP POST error message: " , $resp -> message, " \n " ;
125+ }
126+ }
127+
84128# subroutine to list policies
85129sub list_policies {
86130 my $url = " $base_url /config/policies" ;
0 commit comments