Skip to end of metadata
Go to start of metadata

The following example demonstrates how to use the API to delete a server and its associated policies and disk safes.

You can find the PHP file DeleteManaged_Agent_And_Its_Association.php at the following locations:

  • for Windows: <installdir>\apisamples
  • for Linux: <installdir>/apisamples

For more information about using the Server Backup Manager API, see Access example API functions.

The PHP script finds and deletes objects in the system, and then displays the following information:

  • "Successfully retrieved all the Agents" / "No Agent out with the specified ID" / "Failed to get the specified Agent"
  • "Successfully retrieved all the Disk Safes" / "Failed to get all Disk Safes"
  • "Successfully retrieved all the Policies" / "Failed to get all the Policies"
  • "Failed to delete all policie(s)" / "All policie(s) deleted successfully"
  • "Failed to delete all DiskSafe(s)" / All DiskSafe(s) deleted successfully"
  • "Failed to delete Agent" / "Agent deleted successfully"

Sequence of automated actions

This script allows you to:

  1. Find a Backup Agent containing the specified ID. If such Agent does not exist, then exit or save the Server ID.
  2. Find all disk safes associated with the specified Server ID. Save the found Disk Safe IDs.
  3. Find all policies associated with the found disk safes. Save the found Policy IDs.
  4. Delete found policies.
  5. Delete found disk safes.
  6. Delete found Backup Agent.

How to fulfill the appropriate actions in the Server Backup Manager user interface

The following steps help you to perform the same actions as the script, along with screen-shots illustrating every step in scripts.



First step

date_default_timezone_set('America/Chicago'); ########====CDP Server Configuration Start====######## #set CDP server host name $HOST="10.230.100.207"; #set CDP server to access API $PORT="9443"; #set CDP user $USER="admin"; #set CDP user password $PASS="admin"; ########====CDP Server Configuration End====######## ########====SetAgent ID to be deleted Start====######## $ID = "a6215c5f-6827-4260-956c-5ea14e6a8296"; ########====SetAgent ID to be deleted End====########

Retrieving the server and associated disk safes and policies

########====Get DiskSafes Start====######## try{ $diskSafeClient = new soapclient("https://$HOST:$PORT/DiskSafe?wsdl", array('login'=>"$USER", 'password'=>"$PASS", 'trace'=>1, 'cache_wsdl' => WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS) ); // retrive all the ids $allDiskSafes = $diskSafeClient->getDiskSafes(); echo "Successfully retrived all the diskSafes \n"; $selectedDiskSafeIDs = array(); foreach($allDiskSafes->return as $tmp) { // check if the disksafe has a valid agent set and it's id == the agent to be deleted if (isset($tmp->agentID) && $tmp->agentID == $selectedAgentID){ // if the condition is true store then store the ids array_push($selectedDiskSafeIDs, $tmp->id); } } } catch (SoapFault $exception) { echo "Failed to get all diskSafes \n"; echo $exception; exit(1); } ########====Get DiskSafes End====######## ########====Get policies Start====######## if (count($selectedDiskSafeIDs) > 0){ try{ $policyClient = new soapclient("https://$HOST:$PORT/Policy2?wsdl", array( 'login'=>"$USER", 'password'=>"$PASS", 'cache_wsdl' => WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'trace'=>1 ) ); // get all the policies $allPolicies = $policyClient->getPolicies(); echo "Successfully retrived all the diskSafes \n"; $selectedPolicyIDs = array(); foreach($allPolicies->return as $tmp) { // check to see if disksafe id of the policy belongs in the list selectedDiskSafeIDs if (in_array($tmp->diskSafeID, $selectedDiskSafeIDs)){ // if the condition is true save the policy id array_push($selectedPolicyIDs, $tmp->id); } } } catch (SoapFault $exception) { echo "Failed to get all the policies \n"; echo $exception; exit(1); } } ########====Get Policies End====######## ########====Get Agent Start====######## try{ $agentClient = new soapclient("https://$HOST:$PORT/Agent?wsdl", array('login'=>"$USER", 'password'=>"$PASS", 'trace'=>1, 'cache_wsdl' => WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS) ); # get all the agents $allAgents=$agentClient->getAgents(); echo "Successfully retrived all the agents \n"; foreach($allAgents->return as $tmp) { // check to see if the specified agent id matches the any of the retrived ids if ($tmp->id == $ID){ // if it matches store the id $selectedAgentID = $tmp->id; break; } } // if nothing matches then exit the program if (!isset($selectedAgentID)){ echo " No Agent out with the specified ID $ID" ; exit(1); } } catch (SoapFault $exception) { echo "Failed to get the specified agent \n"; echo $exception; exit(1); } ########====Get Agent End====########

1. Click on "Servers" in the Main Menu to access the Servers page.

2. Then click "Basic List Filter" in the Servers menu located in the top left area of the interface.

3. Specify the Server name and click "Filter" to apply the search filter.

Note
While the script searches by Server ID, we search by Server name in the Backup Manager interface.

 

4. The found Server will be displayed in the list.

5. The Server's Disk Safes and Policies can be found via the Details pane once the Server is selected in the list.

Deleting Policies, Disk Safes, and the Server

########====Delete DiskSafes Start====######## // check to see if there are any disksafes to be deleted if (count($selectedDiskSafeIDs) > 0){ try { // iterate over the list of disksafe IDs and delete them foreach($selectedDiskSafeIDs as $tmp) { $diskSafeClient->deleteDiskSafeByID(array('diskSafeID'=>$tmp)); } } catch (SoapFault $exception) { echo "Failed to delete all DiskSafe(s) \n"; echo $exception; exit(1); } echo "All DiskSafe(s) deleted successfully \n"; } ########====Delete DiskSafe End====######## ########====Delete Agent Start====######## try { # finally delete the specified agent $agentClient->deleteAgentByID(array('id'=>$selectedAgentID)); } catch (SoapFault $exception) { echo "Failed to delete agent\n"; echo $exception; exit(1); } echo "Agent deleted Successfully \n"; ########====Delete Agent End====######## ########====Delete Policies Start====######## // check to see if there are any policies to be deleted if (count($selectedPolicyIDs) > 0){ try { // iterate over the list of policy IDs and delete them foreach($selectedPolicyIDs as $tmp) { $policyClient->deletePolicyByID(array('policyID'=>$tmp)); } } catch (SoapFault $exception) { echo "Failed to delete all policie(s) \n"; echo $exception; exit(1); } echo "All policie(s) deleted successfully \n"; } ########====Delete Policies End====########

1. Click on the "Delete" (red X) icon under "Actions" for the corresponding Server in the list.

Alternatively, select the check-box(es) in front of the Server(s) and click on the "Delete Selected" button.

2. Familiarize yourself with the information displayed on the pop-up. Check the "Delete disk safes from disk" option. Click "Delete".

3. The Server and its associated Disk Safes and Policies will disappear from the system.

Labels:
api api Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.