Hello,
I’m writing a script to manage dynamic inventory and I need to use tags so hosts can be added to appropriate targets. When I export hosts from the web UI and open the XML the user_tags
field is correct:
<get_assets_response status="200" status_text="OK">
<asset id="5d61622a-2bbb-47f3-ada6-3eef453f3e9b">
<owner>
<name>admin</name>
</owner>
<name>XXX.XXX.XXX.XXX</name>
<comment>Project: XXX host: XXX</comment>
<creation_time>2023-02-21T16:01:46Z</creation_time>
<modification_time>2023-02-21T16:01:46Z</modification_time>
<writable>1</writable>
<in_use>0</in_use>
<permissions>
<permission>
<name>Everything</name>
</permission>
</permissions>
<user_tags>
<count>1</count>
<tag id="943381c0-f37d-4065-a542-a12996dab166">
<name>host:gke</name>
<value></value>
<comment></comment>
</tag>
</user_tags>
However when I query for hosts by using response = gmp.get_hosts(filter_string=f'first={first_element_index} rows=1000')
and look at the output XML I can see that the <tag>
is missing, there is only count value:
<get_assets_response status="200" status_text="OK">
<asset id="5d61622a-2bbb-47f3-ada6-3eef453f3e9b">
<owner>
<name>admin</name>
</owner>
<name>XXX.XXX.XXX.XXX</name>
<comment>Project: XXX host: XXX</comment>
<creation_time>2023-02-21T16:01:46Z</creation_time>
<modification_time>2023-02-21T16:01:46Z</modification_time>
<writable>1</writable>
<in_use>0</in_use>
<permissions>
<permission>
<name>Everything</name>
</permission>
</permissions>
<user_tags>
<count>1</count>
</user_tags>
Is this some kind of a bug? Or am I missing an anrgument that needs to be passed to get_hosts()
? The documentation mentions only filter_id
and filter_string
.