Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Ohad
Explorer

Trying to add hosts in mgmt_cli using csv file

Jump to solution

Dear all,

 

I have created a Black List group and every week I am adding roughly between 20 up to 40(ish) new hosts...

 

I have read that there is a possibility to use mgmt_cli in order to create all of them in one shot....

 

I have created the csv file in a UTF-8 format and used sk113078 as a guideline...

name,ip-address
Black_List_408,104.248.164.231
Black_List_409,118.70.113.1

 

These are the top three rows of the csv file...

when trying to execute the file I get the following:

[Expert@management:0]# mgmt_cli add host --batch blacklist.csv
Username: ohadadmin
Password:
Failed to read parameters file [blacklist.csv]: Failed to open file.

I have no idea what I am doing wrong here... and the Management API Reference is less than useless... There isnt even 1 example of how it should be...

 

Can anyone please assist...?

 

Also if anyone could educate me on how to add those objects to the "Black_List" group that I created (Preferably with the same csv file) I would really appreciate it

0 Kudos
1 Solution

Accepted Solutions
Maarten_Sjouw
Champion
Champion
Make sure to add the full path to the csv filename.
Check out this post:
https://community.checkpoint.com/t5/API-CLI-Discussion-and-Samples/Creating-multiple-object-via-CSV/...
Add a column in the csv named groups, and put the name of the group there.
Regards, Maarten

View solution in original post

9 Replies
_Val_
Admin
Admin

Check the file is in the right directory and has at least read-only permissions for your API user

0 Kudos
Ohad
Explorer

Hi Val,

Thanks for the quick reply 🙂

 

The file is in the right directory...

I also did a #cat Blacklist.csv and saw that the rows are as the mentioned SK should...

Furthermore I also gave the file full permissions #chmod +rwx

0 Kudos
Maarten_Sjouw
Champion
Champion
Make sure to add the full path to the csv filename.
Check out this post:
https://community.checkpoint.com/t5/API-CLI-Discussion-and-Samples/Creating-multiple-object-via-CSV/...
Add a column in the csv named groups, and put the name of the group there.
Regards, Maarten

View solution in original post

Ohad
Explorer
Full path did the trick!!!
Thank you so very much!
I've been wrecking my brain and it didnt even occur to me to try the full path....

And in sk113078 they dont use the full path.. Just the name.. Which is weird...
Also .\<Filename.csv> doesnt work either...
0 Kudos
Maarten_Sjouw
Champion
Champion
Most probable: the path is related to the location of the file mgmt_cli....
Regards, Maarten
0 Kudos
_Val_
Admin
Admin

Correct, I believe the full path was a miss here

0 Kudos
the_rock
Mentor
Mentor

Hey guys,

 

I know Im updating this thread late, but anyone has any idea as to what full path I should use to try import stuff from .csv file that I attached? By the way, I tried flags mentioned here, but sadly it failed.

 

Thanks

 

Andy

0 Kudos
Maarten_Sjouw
Champion
Champion

You store the file on the management server, ie in the /home/admin/ directory, tehn you use mgmt_cli add host --batch /home/admin/tarion.csv

However, the file you have posted is not going to be importable, you need these fields: name, ipv4-address 
in your file I see lines that have an IP block as the first field, the name always has to start with a Character, not a number. but hosts require IP addresses and I do not see any on these lines.

Regards, Maarten
0 Kudos
the_rock
Mentor
Mentor

Thanks Maarten. I consulted with Ottawa tac and guy saw what I was doing and confirmed process was definitely correct, but it looks like excel was inserting a character where it was not supposed to : ). What he did was create a new txt file and then either use that or convert it into .csv, but either one works.

Thanks again! I wish this was easy like back in R77 and before where you could simply copy and paste objects in dashboard...I do see there is an option now to export all the objects, but its sort of useless really if you can never import them.

 

Thank you for the response and be well!

 

Andy

0 Kudos