Problems and suggestions for Tags in v1.2 beta

Hello everyone,

I have some issues with Tags

The idea to make Tags is interesting but today, with the 1.2 beta, Tags are boolean parameters. So when you create a tag named for example “Test”, you will see it in the window “All Parameter” : Tags.Test and has as value : true.

And in “Presets” when you want to set a “Precondition” with “Tags IS NOT NULL” or by a regex "Tags LIKE “T%” " it does not work. Whereas “Tags IS NULL” works.

And something more curious is : when you want to display a graph which represents device with and without tag, with filters “Tags IS NOT NULL” and “Tags IS NULL”, the graph is able to clearly make the different then to show you the correct information.

So I want to know with, by default, the value of a tag is a boolean ? And as an improvement for the v1.2 beta, why not keep the “global” parameter “Tags” then creates childparameter “Tags.1”,“Tags.2” … that have as value the name for the tag. For example : “Tags.1” has as value “Test_1” and “Tags.2” has as value “Test_2”.

Have a nice day :slight_smile:

Hello,

I think you are using tags wrong … if you want to trigger a present on the presence of a ‘Test’ tag you will use the following condition:
Tags.Test IS NOT NULL
and if you want the other way around:
Tags.Test IS NULL

Hello, thanks for your reply,

I know that this fonction works but my situation is :

I have 4 devices : two with a tag and two without tag :

  • Device_A with the following tag : “Tag_A”
  • Device_B with the following tag : “Tag_B”
  • Device_C
  • Device_D

The devices with a tag are saved as describe in the window All Parameter below :

  • Device_A : Tags.Tag_A true
  • Device_B : Tags.Tag_B true

And my problem is : I want to define a Preset that will apply a specific Provisions to devices that have a tag. So a Provision that will apply to Device_A and Device_B. But I have not been able to find the correct Precondition.

Do you have any idea to solve this problem or to get around ?

One workaround will be to use:
Tags.Tag_A IS NOT NULL OR Tags.Tag_B IS NOT NULL OR ...

Ooof I have more than 200 devices ^^" …

you are using a different tag for each device? IMHO this is wrong … you should use generic tags for what you want to accomplish and add the individual settings in the provision script, based on Serial number/device IP/mac/whatever.

Yup I admit it’s not the correct way to use tags but as I am trying to fix it, I want to know if other solutions than recreate correct tag exist … maybe through MongoDB ?

If it’s strict one time thing, to fix the tags, you could do it from the mongo console, but it depends on what you want to do. To find all devices that have at least one tag, you could use this on the mongo console:
db.devices.find({_tags: {$gt: []}}, {_tags: 1})

to remove all tags that start with “Tag_” from all devices that have just 2 tags :
db.devices.update({_tags: {$size: 2 }} , {$pull: {_tags: /Tag_.*/} }, {multi: 1})

to add test2 tag to all devices:
db.devices.update({}, {$addToSet: {_tags: 'test2'} }, {multi: 1})

to add test3 just for device with id xxxx-xxx-xxxxxxx:
db.devices.update({_id:"xxxx-xxx-xxxxxxx"}, {$addToSet: {_tags: 'test3'} })

hope you got the ideea, but please be carefull because you could lose all your data, backup first and use this at your own risk. :grimacing:

1 Like