Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Achilles_Tagg
Participant

Script in creating object and add in a object group using CLI

What is the command line script to create object/object group and add object in an object group. Like hundred of objects (IPs).

I am using Checkpoint R80.10.

0 Kudos
11 Replies
G_W_Albrecht
Legend
Legend

There is no such CLI script - you have to write your own using CP commands from GAiA clish or the Management API.

CCSE CCTE SMB Specialist
Danny
Champion
Champion

mgmt add group name "group_name"

mgmt add host name "host_name_1" ip-address "x.x.x.1" groups.1 "group_name"
mgmt add host name "host_name_2" ip-address "x.x.x.2" groups.1 "group_name"
Achilles_Tagg
Participant

Thanks! Tested okay.

babasahebb
Participant

I need to add 100 new IPs in to group, how can I add in single command?

Art_Zalenekas
Employee
Employee

With 80.10 you cannot or else just create for loop in bash. Starting Mgmt API version 1.6 (R80.40) you can use API call add objects-batch do what you want.


Kind regards,
Arturas Zalenekas

babasahebb
Participant

Can you please give full syntex of this command- add objects-batch  ( i have 100 ips in .csv file and need to add in group)

0 Kudos
babasahebb
Participant

I am using R80.40, so i need full command syntex to add 100 jobects in to group.

0 Kudos
Art_Zalenekas
Employee
Employee

# cat hosts.csv
name,ip-address,groups
test1,192.2.0.1,gtest
test2,192.2.0.2,gtest
test3,192.2.0.3,gtest

# mgmt_cli -r true add host --batch hosts.csv

Danny
Champion
Champion

Gaia WebUi has a nice UI interface to allow adding routes in batch mode. I always missed a batch mode to add objects directly in SmartConsole. A SmartConsole Extension could solve this of course.

0 Kudos
babasahebb
Participant

Not working follwoing syntex in R80.40-# mgmt_cli -r true add host --batch hosts.csv

Following syntex working for creating object but if any object existing that time getting error, pls help for this.

mgmt_cli add host --batch filename.csv

 

 

0 Kudos
Jim_Oqvist
Employee
Employee

You can use the "set-if-exists true" parameter to handle such a situation

It is documented in the management API reference guide

https://sc1.checkpoint.com/documents/latest/APIs/index.html#cli/add-host~v1.8%20

 
set-if-exists boolean
Default: false
If another object with the same identifier already exists, it will be updated. The command behaviour will be the same as if originally a set command was called. Pay attention that original object's fields will be overwritten by the fields provided in the request payload!
 

 

Kind Regards

Jim

0 Kudos