Hi Stuart,
Currently I have the same issue where I get a list of IP addresses I need to get info from so this seems to be similar in terms of find out which ones on the list are in Spectrum and which are not.
The way I do it is to dynamically create the XML file used in the search criteria. e.g.:
REST 'POST' http://<SERVER>:<PORT>/spectrum/restful/models
<rs:model-request throttlesize="1000"
xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd">
<rs:target-models>
<rs:models-search>
<rs:search-criteria
xmlns="http://www.ca.com/spectrum/restful/schema/filter">
<devices-only-search/>
<filtered-models>
<or>
<equals>
<attribute id="0x12d7f">
<value>10.10.10.10</value>
</attribute>
</equals>
<equals>
<attribute id="0x12d7f">
<value>11.11.11.11</value>
</attribute>
</equals>
<equals>
<attribute id="0x12d7f">
<value>12.12.12.12</value>
</attribute>
</equals>
</or>
</filtered-models>
</rs:search-criteria>
</rs:models-search>
</rs:target-models>
<rs:requested-attribute id="0x12d7f"/>
<rs:requested-attribute id="0x1006e"/>
<rs:requested-attribute id="0x12de0"/>
</rs:model-request>
In the code above you just add a new
<equals>
<attribute id="0x12d7f">
<value>10.10.10.10</value>
</attribute>
</equals>
for each IP address. You have to watch out you don't add to many as this used to crash SpectroSERVER (I have scripts which split up big jobs into batches of maximum 500 logic operations to counter this crash!).
So steps would be to add the top section up to the 'or' tag. Then read the CSV line by line, adding the above section. Then after you have all the IP's add the closing 'or' tag and include the rest adding any other attributes if you need them (in your case for a delete action you might not care about the attributes).
So this will return all attributes for matching devices. You will then need to iterate through the original list and remove matched items so you are left with a list of devices that are not in Spectrum.
You could simply perform a REST mass DELETE using the same method above (i.e. instead of listing the devices, you just delete all the devices.). I think in this case it will provide output of which model handles were deleted. (Always wanted to add a delete function for this but never had to delete so many in one go - just had to list the devices we find/don't find).
Regarding your comment about slick ways to do things, I think you are right but I think it is difficult for Kiran and his team to add features for everything that everyone wants. If it's registered idea and everyone has this issue and it's a big one that many people have, then it will get resolved.
For me Spectrum is a good product that does a lot of things very well. For the more 'advanced' or 'custom' things that you might want to do, you need to invest in the time (which is sadly what many people don't have) to learn things like REST, perl/python/bash/etc, VNM Shell, etc and then to build onto the already provided toolset.
This is what I've been doing for some time, and from the looks of it, you seem to be doing a lot of this already. I'm sure though you have a lot of tools you need to maintain so I feel your pain there as we have so much I'd like to do but there needs to be a good case to invest in the time and that time needs to exist in the first place.
While I understand your frustration I don't think the Spectrum dev team can fix all of these. There is so much Spectrum can do if you can invest in tinkering with it. I've been able to bear the fruits of some of that labour but then I've been working on my automation/scripts for some years and tweak them almost weekly.
REST is underrated, really it is. It's kind of like when Darth Vader says 'You underestimate the power of the Dark Side'. CA don't 'pimp' the REST enough in my opinion, and it's not only REST but many features of Spectrum.
Hope this helps you or someone else at least!
Regards,
Frank