My colleague, who is Linux GENIUS (everyone says that about him), helped me figure it out. Anyway, creds are just my lab, so you get an idea 🙂
He will also send me info how he converted the file to fit into when you try import hosts into another mgmt.
mgmt_cli show group -u admin -p 'maxwe!!' name "Block" > blockips.csv --format json
Command to import the file:
mgmt_cli add host --batch block.csv
Example (it HAS TO look like something below)
#cat test.csv
name,ip-address
obj1,192.168.1.1
Btw, here is example how to get right file format that can be used right away to add via mgmt_cli:
example for hosts, but you get an idea for ranges or subnets:
mgmt_cli -r true show-group name "Block" --format json | jq '.members[] | [.name, ."ipv4-address"] | @csv' -r >> ip_block_test.csv
--->To add address-range via API:
mgmt_cli add address-range --batch address-ranges_full.csv
#cat address-ranges_full.csv
name,ip-address-first,ip-address-last
range1,10.0.0.0,10.0.0.100
---> To add a network via API:
mgmt_cli add network --batch networks.csv
#cat networks.csv
name,subnet,subnet-mask
network1,10.10.10.0,255.255.255.0
network2,20.20.20.0,255.255.255.0
network3,30.30.30.0,255.255.255.0
---> To add a host
mgmt_cli add host --batch test.csv
#cat test.csv
name,ip-address
obj1,192.168.1.1
Hope this saves a headache for whoever has to do this in the future 🙂
Andy