Skip to end of metadata
Go to start of metadata

The following example demonstrates how to delete an Agent and its associated Policies and Disk Safes.

A PHP file called DeleteManaged_Agent_And_Its_Association.php can be found in <installdir>/apisamples. Read more in Accessing Example API Functions.

The PHP script finds and deletes objects in the system and prints the following result messages on the screen:

  • "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

The following steps can be accomplished by using this script:

  1. Find an Agent with the specified ID. If such Agent does not exist, then exit or save the Agent ID.
  2. Find all Disk Safes associated with the specified Agent ID. Save the found Disk Safe IDs.
  3. Find all Policies associated with the found Disk Safes. Save the found Policies' IDs.
  4. Delete found Policies.
  5. Delete found Disk Safes.
  6. Delete found Agent.

How to Fulfill Appropriate Actions in CDP User Interface

Below, you can find the steps to take in the program user interface in order 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 Agent, its Disk Safes, and its 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 "Agents" in the Main Menu to access the Agents page.

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

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

Note
While the script searches by Agent ID, we search by Agent name in the CDP interface.

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

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

Deleting Policies, Disk Safes, and the Agent

########====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 Agent in the list.

Alternatively, select the check-box(es) in front of the Agents 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 Agent and its associated Disk Safes and Policies will disappear from the system.

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