Good morning again! (5:30am here) Thanks for your help, guys. The sad news is that the list has always been a list before I can get my hands on it. It’s actually the web_sites_list generated via xpath.evaluate on the MetaBase.xml file for IIS. Its function is analogous to grepping out the VSites in httpd.conf – one can see what web sites are served by this particular IIS server. Here’s that snippet of IIS.tpl:
website_bindings := xpath.evaluate(metabase_file.content, raw"/configuration/MBProperty/IIsWebServer/@ServerBindings");
// Iterate over the bindings and extract the name of the website that the binding corresponds to.
for binding in website_bindings do
websites := xpath.evaluate(metabase_file.content, raw"/configuration/MBProperty/IIsWebServer[@ServerBindings = '" + binding + "']/@ServerComment");
for website in websites do
// For each website found check if it is already in the list, if not then add it to the string
// list and list.
if not(website in web_sites) then
log.debug("Added &#xwe;bsite% to web_sites list.");
web_sites := "&#xwe;bsites%, &#xwe;bsite%";
web_sites_list := web_sites_list + [website];
end if;
end for;
end for;
So in this particular case, I can see exactly how many instances of the “Cleaner” application are in existence, because the web_sites_list will have several entries, like “CleanerDEV”,“CleanerQAS”,“CleanerPRD” and so on. The instance names of the Cleaner application are always the three letters after the word “Cleaner” in each item in the web_sites_list attribute. So the intent really in my original post was to simply search that list for the word “Cleaner”, then iterate through that subset creating BusinessApplicationInstance nodes for DEV,QAS,PRD, etc. Here’s my more-or-less actual code:
type := "Cleaner";
log.info("triggered Cleaner");
web_sis := search(SoftwareInstance
where type = "Microsoft IIS Service" and web_sites_list has substring "Cleaner");
instances := [];
for web_si in web_sis do
siteslist := web_si.web_sites_list;
for site in siteslist do
if site matches "(?i)Cleaner" then
site_instance := regex.extract(site,
regex "(?<=Cleaner)(\w{3})", raw'\1');
if not site_instance then
continue;
end if;
if site_instance not in instances then
instances := instances + [site_instance];
end if;
end if;
end for;
end for;
if instances then
for instance in instances
bai_name := "&#xty;pe% &#xin;stance%";
model.BusinessApplicationInstance(name := bai_name,
type := type
... and so on);
I don’t particularly like this method because web_sites_list can sometimes be dozens of items, and I perceive that looping through each one is inefficient. I guess this is the only way to go…?