/* updateCommunityList.asl
* Copyright © 2005, EMC/SMARTS
* All Rights Reserved
*
* RCS $Id: updateCommunityList.asl,v 1.0 2005/07/20 18:35:00 cranea Exp $
*
* Rule set for adding community strings to the DM in a specific order.
*
* NOTE: If the number of community strings in the seedfile exceed the
* maximum number of entries defined in the discovery.conf, the
* script will generate an error and NOT update the list.
*
* To execute the script,
* 1. copy it to BASEDIR/smarts/local/rules/utils
* 2. change to the BASEDIR/smarts/bin directory
* 3. execute the following
* sm_adapter -s <server_name> -f <path_and_file>
utils/updateCommunityList.asl
*/
ASLNAME = " ".getRuleFileName().": ";
default debug = FALSE;
inputCount = 0;
commList = list();
if (debug) { print(time().ASLNAME."Started.."); }
START {
READ_COMMUNITY_STRING
.. eol
}
DEFAULT {
line:{ .. eol }
} do {
if (debug) {print(time().ASLNAME."Unprocessed: ".line);}
}
COMMENT { "#" .. eol }
BLANK { rep(" ") eol }
EMPTY { eol }
READ_COMMUNITY_STRING {
community:word
} do {
inputCount = inputCount + 1;
commList += community;
if (debug){ print(time().ASLNAME."Input #: ".inputCount.", community string = ".community);}
}
UPDATE_COMMUNITY_LIST
do {
if (sizeOf(commList) > 0) {
print("Updating community list..");
manager = object("ICF-TopologyManager");
manager->setCommunities(commList);
}
}
EOF {
UPDATE_COMMUNITY_LIST
do {
print("# Community strings read: ".inputCount);
if (debug) { print(time().ASLNAME."Completed.."); }
}
}