I try to generate host assets by reading a list of IPs and adding these by using “create_asset”. No problem so far. I also want to assign one or more tags to each host added.
I just can’t find the proper command…
I’m able to extract the uuid of a host and also the uuid of the desired tag. But how to attach the tag to the host asset?
Sorry, it might be obvious, but not for me
with the command
modify_tag you can assign resources to a tag.
Ahhh, great. Thank you - must change my glasses
I tried to get the proposed command to work - no success. It would be very helpful if you (or someone else) have a look at my humble attempt. As you might notice, I’m not an XML-genius …
I would like to add $host_id (holding the uuid of a host) to the tag $tag_id.
result=$(gvm-cli -c /home/administrator/.config/gvm-tools.conf socket \ --xml \ "<modify_tag tag_id=\"$tag_id\">\ <resources action=\"add\">\ <resource id=\"$host_id\">\ <type>\"host\"</type>\ </resources>\ <comment>TestTestTEST</comment>\ </modify_tag>")
gvm-cli just responses with “Invalid XML”. I think I have no understanding of the underlying RNC notation, but had no success in finding any example for this.
Your help is greatly appreciated
Many thanks in advance
Just had a quick look. Your resource element isn’t closed. Should be
<resource id=\"$host_id\" />\. Maybe it is easier for you to use our Python API via gvm-script?
Thank you so much. Yes, might be better to use the Python API. At this time it is not an option, but may be later on.
After removing also the quotes enclosing host it now works.
Thanks again & bye