removing multiple devices
search cancel

removing multiple devices

book

Article ID: 332094

calendar_today

Updated On:

Products

VMware Smart Assurance

Issue/Introduction

Deleting multiple devices in a Smarts IP domain?
Utilizing batch topology remove devices in a Smarts AM domain?

Environment

10.x and 2.x

Resolution

Attach to the IP domain using the Domain Manager Administration Console and then select Administer Instances from the Edit menu. This will allow multiple instances to be selected using filters and deleted.

The below scripted resolution is not a GA Supported Script.  While it has been tested, customers must understand that they accept all risk that may be associated with using this script.  If you are not familiar with scripting in asl, VMWare recommends that you see the additional notes below that may be helpful to provide helpful tips on making sure your IP domain rps file is backed up before you apply this solution:   

1. Run from the smarts\bin directory   ./dmctl -s AMPM geti UnitaryComputerSystem  This will list out all the devices in the IP domain.  Copy this output into a notepad file. 
2.Create a node_delete.txt  in my smarts\bin directory
a. Use vi node_delete.txt from the smarts\bin directory
b.and insert the names of the devices that you want to remove with data with the output from Step 1.  
3.       The node_delete.txt file is to be filled with the respective UCS name to be deleted and each device name must be on separate line. This is mainly to delete the UCS (UnitaryCompyterSystems) in batch

Create the asl below.  The script can be placed in the <Basedir\IP\smarts\local\script folder.  I found that placing the node_delete.txt  in the bin directory, where the sm_adapter command is run works as well.  

After creating the file with the asl script, I did a chmod 777 on the file, and applied the sm_adapter command to run the script.

To run the batch and delete multiple devices, run the following:

<BASEDIR>/smarts/bin/sm_adapter -s <IP domain name> -b <broker_port> --file=node_delete.txt  <path>/node_delete.asl 

File: node_delete.asl 
topo_manager = object(getInstances("ICF_TopologyManager")[0]);
START {
    node:rep(word) eol
}
do {
    Node_obj = object();
    Node_obj = topo_manager->findComputerSystem(node);
    if (Node_obj->isNull()) {
        print("Cannot find node :: ".node);
    } else {
       print("Deleting NODE :: ".Node_obj);
       Node_obj->remove();
   }
}
EOF
do {
    print("Done with deleting the nodes");
}



Additional Information

Recommendations for back up to preserve the devices in your IP domain.

AM-PM domain repository save:
<BASEDIR>/IP/smarts/bin/sm_tpmgr -s <DomainName> --save
 
Save your IP domain rps with the above command.  Once this command is complete, make a backup copy of your IP domain just in case you need it.  Do a cp command to copy the rps and provide a new name.  The location for the saved repository file is:  <BASEDIR>/IP/smarts/local/repos/icf

Should you need to recover the IP domain, stop the IP domain, use the backup copy to overwrite the current file and restart the IP domain.
 
As another backup measure you can also create a seed file for the IP domain prior to running the script.  The use the seed file to rediscover the devices that you removed to restore the topology to the IP domain.  Review the following KB articles:
 

Creating a seedfile from existing topology


The command below will generate a seedfile consisting of SNMP Agent IP Addresses of devices present in the topology.

$cd <BASEDIR>/IP/smarts/bin
$./sm_tpmgr s <DM_Name> --dump-agents > <PATH>/seedfile
 

Smarts IP: How to discover the devices through seedfile from command line.  (303967)            

Discover devices using a seed file via command line and GUI

Store the seedfile in <BASEDIR>/IP/smarts/local/conf/ or <BASEDIR>/IP/smarts/conf
 
<BASEDIR>/IP/smarts/bin/sm_tpmgr -s <IP domain> --seed=<seedfile filename>
 
This will allow you to rediscover the devices back in the IP domain in case you deleted some that should not have been deleted.