SpriteLink / NIPAP

Neat IP Address Planner - NIPAP is the best open source IPAM in the known universe, challenging classical IP address management (IPAM) systems in many areas.
https://spritelink.github.io/NIPAP/
MIT License
539 stars 131 forks source link

Not possible to add a tag with the cli tool #1084

Open jvalcke opened 8 years ago

jvalcke commented 8 years ago

I noticed that it's not possible to add tags to a prefix. The only option via the cli is to set tags, which removes previously defined tags.

Adding tag 'test1'

~$ nipap address modify 67.215.80.0/24 set tags 'service_list=resolver|neteng,location=sin^C
:~$ nipap address modify 1.1.1.1/32 set tags 'test1'
Prefix 1.1.1.1/32 in VRF 'default' [RT: -] saved.
~$ nipap address view 1.1.1.1/32
-- Address
  Prefix                     : 1.1.1.1/32
  Display prefix             : 1.1.1.1
<snip>
-- Extra Attributes
-- Tags
  test1
-- Inherited Tags
-- Comment

Adding, actually setting tag 'test2', removes tag 'test1'

~$ nipap address modify 1.1.1.1/32 set tags 'test2'
Prefix 1.1.1.1/32 in VRF 'default' [RT: -] saved.
~$ nipap address view 1.1.1.1/32
-- Address
  Prefix                     : 1.1.1.1/32
  Display prefix             : 1.1.1.1
<snip>
-- Extra Attributes
-- Tags
  test2
-- Inherited Tags
-- Comment

Is their a way to add tags (keep the existing tags untouched)? Looks like the only add option is extra-attribute

~$ nipap address modify 1.1.1.1/32 add extra-attribute

Am I overlooking something?

plajjan commented 8 years ago

You are correct and you are not overlooking anything.

Unlike pretty much all other attributes, tags is an array and so setting the array value means simply that you set the entire array to a given value (which is also an array). This would overwrite any previous value, much like setting the description would overwrite the old description value.

We could definitely add it so that the list of tags can be modified much like extra-attributes can be added / removed individually.