- CheckMates
- :
- Products
- :
- Developers
- :
- API / CLI Discussion
- :
- Re: Script in creating object and add in a object ...
- 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
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is no such CLI script - you have to write your own using CP commands from GAiA clish or the Management API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! Tested okay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to add 100 new IPs in to group, how can I add in single command?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using R80.40, so i need full command syntex to add 100 jobects in to group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
# 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Danny, I have to add over 200 IPs to an object group, but when I log into the MDS to run the commands mentioned above but get this error (see below) when trying to add an object group. I am Running R81.10.
Any thoughts?
Error:
MGMTXXX You are not logged in to management server, in order to log-in you will need to run "mgmt login user [user name]"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The error message is telling you how to resolve this issue: log into the management server using the specified command.
Note that this is required for any use of the API (including via mgmt and mgmt_cli).
Also note that changes must be published or they will not take effect: https://sc1.checkpoint.com/documents/latest/APIs/index.html#clish/publish~v1.9%20