- CheckMates
- :
- Products
- :
- Developers
- :
- API / CLI Discussion
- :
- Re: Exporting large group of IPs into a file from ...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Are you a member of CheckMates?
×- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Exporting large group of IPs into a file from mgmt_cli
Hey guys,
Apologies if this may sound like a really silly question, but Im trying to figure out if Im doing this right. To make a long story short, I imported customer's config into my lab and trying to see if I can export large group with about 5000 IPs into csv format file via cli, but not having much luck so far. Below is command I ran:
mgmt_cli show group name "Block" > block.csv
It seems like it did take it and after I logged in, its just "sitting" there for 20 mins and file size is not moving at all.
If someone could confirm if this is correct, would be awesome.
Tx as always.
Andy
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Andy,
did you try to execute it without redirecting to a file?
what exactly do you want/need to achieve?
as output would be like this:
name: "net_auto_feed_zoom-221.122.64.0-24"
type: "network"
domain:
uid: "41e821a0-3720-11e3-aa6e-0800200c9fde"
name: "SMC User"
domain-type: "domain"
subnet4: "221.122.64.0"
mask-length4: 24
subnet-mask: "255.255.255.0"
icon: "NetworkObjects/network"
color: "blue"
when having so much objects, maybe using async-response would help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey @Nüüül
Tx a lot for responding, appreciated! Yes, without redirecting to a file, works fine, but reason why I need a file is because we are trying to get right CSV file that can be imported into S1C portal for the customer, but only TAC can do it, since there is no regular ssh access.
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, i would go with the web API - exporting all the objects and reimporting them to smart1cloud. As web API should still be there (another argument necessary "context" if i remember correctly)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you have an example? I tried exporting from smart console, but does NOT let you export only single group, even from object explorer : - (
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how urgent is this? can send you something tomorrow if thats ok?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Its not urgent, no rush. Im just trying to see if I can get this exported from the lab, but so far, no luck.
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tx mate, will definitely test it Monday.
Have an awesome weekend 🙂
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, you too..
additionally - i checked about the smart-1 cloud api. import to / export from there is possible, see README at the repo. it´s working - at least what i was able to test.
(currently only works with new to-create network objects/hosts. maybe will adjust that at a later moment. )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
TAC told me as long as they can get right CSV file, they can import it easily, so I think we are good.
Tx a lot!
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
