SpriteLink/NIPAP — pull request #510 by edechaux (2014-05-13 11:17:37+00:00)
Title: Add user impersonation functionnality

I needed a way to use impersonation with the CLI. The easiest way I found is to add a specific verb in the add/modify/delete/resize function.

Where are some exemples I used to validate the changes :

$ nipap address add prefix 172.31.19.230 vrf 2885681152:666
WARNING: Parent prefix is of type 'assignment'. Automatically setting type 'host' for new prefix.
Prefix 172.31.19.230/22 added to VRF 'TEST-IPMS' [RT: 2885681152:666]

$ nipap address add prefix 172.31.19.231 vrf 2885681152:666 asuser eric.dechaux
WARNING: Parent prefix is of type 'assignment'. Automatically setting type 'host' for new prefix.
Prefix 172.31.19.231/22 added to VRF 'TEST-IPMS' [RT: 2885681152:666]

$ nipap address modify 172.31.19.231 vrf 2885681152:666 set prefix 172.31.19.232
Prefix 172.31.19.232/22 in VRF 'TEST-IPMS' [RT: 2885681152:666] saved.

$ nipap address modify 172.31.19.230 vrf 2885681152:666 as eric.dechaux set prefix 172.31.19.231
Prefix 172.31.19.231/22 in VRF 'TEST-IPMS' [RT: 2885681152:666] saved.

$ nipap address remove 172.31.19.231
Do you really want to remove the prefix 172.31.19.231/32 in VRF 'TEST-IPMS' [RT: 2885681152:666]? [y/n]: y
Prefix 172.31.19.231/32 in VRF 'TEST-IPMS' [RT: 2885681152:666] removed.

$ nipap address remove 172.31.19.232 asus eric.dehaux
Do you really want to remove the prefix 172.31.19.232/32 in VRF 'TEST-IPMS' [RT: 2885681152:666]? [y/n]: y
Prefix 172.31.19.232/32 in VRF 'TEST-IPMS' [RT: 2885681152:666] removed.

$ nipap vrf add rt 6:66
Added VRF 'None' [RT: 6:66]

$ nipap vrf add name toto rt 666:666 asuser eric.dechaux
Added VRF 'toto' [RT: 666:666]

$ nipap vrf modify 6:66 set name titi
VRF 'titi' [RT: 6:66] saved.

$ nipap vrf modify 666:666 asuser eric.dechaux set rt 999:666
VRF 'toto' [RT: 999:666] saved.

$ nipap vrf remove 999:666
RT: 999:666
Name: toto
Description: None

WARNING: THIS WILL REMOVE THE VRF INCLUDING ALL ITS ADDRESSES
Do you really want to remove VRF 'toto' [RT: 999:666]? [y/n]: y
VRF 'toto' [RT: 999:666] removed.

$ nipap vrf remove 6:66 asuser eric.dechaux
RT: 6:66
Name: titi
Description: None

WARNING: THIS WILL REMOVE THE VRF INCLUDING ALL ITS ADDRESSES
Do you really want to remove VRF 'titi' [RT: 6:66]? [y/n]: y
VRF 'titi' [RT: 6:66] removed.

$ nipap pool add name wizard
Pool 'wizard' created.

$ nipap pool add name warrior as eric.dechaux
Pool 'warrior' created.

$ nipap pool modify warrior set ipv6_default_prefix_length 128
Pool 'warrior' saved.

$ nipap pool modify warrior as eric.dechaux set ipv4_default_prefix_length 24
Pool 'warrior' saved.

$ nipap pool resize warrior as eric.dechaux add 172.31.16.0/22 vrf 2885681152:666
Prefix 172.31.16.0/22 in VRF 'TEST-IPMS' [RT: 2885681152:666] added to pool 'warrior'.

$ nipap pool resize warrior remove 172.31.16.0/22
Prefix 172.31.16.0/22 removed from pool 'warrior'.

$ nipap pool resize warrior add 172.31.16.0/22 vrf 2885681152:666
Prefix 172.31.16.0/22 in VRF 'TEST-IPMS' [RT: 2885681152:666] added to pool 'warrior'.

$ nipap pool resize warrior asuser eric.dechaux remove 172.31.16.0/22
Prefix 172.31.16.0/22 removed from pool 'warrior'.