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

Script for multiple network/host/group object creation


Hello

We recently started with R80 Management.

One thing we would like to use is api scripts. we would like to create script that can read from csv/txt file and create network/host/group object. we have dynamic environment and new rules are requested all the time. this would reduce our time creating objects.

Is this something possible to create and could we have some example?

Thank you

Ismar

11 Replies
Employee+
Employee+

Re: Script for multiple network/host/group object creation

Check out the the Management API guide:

Check Point - Management API reference

0 Kudos

Re: Script for multiple network/host/group object creation

yes i have seen that and use many command to run manual from smartconsole cli.

would you be able to address to this automated object creation from template?

what scripting language is advised to be used etc...

some basic example would be great

thank you

0 Kudos
Highlighted

Re: Script for multiple network/host/group object creation

In this PHP code example, we are making a call to the search endpoint and searching for the string 'Toy Story'.  With the search results, we then echo out an html list of the movies and their year.

01<?php

02$apikey = 'insert_your_api_key_here';

03$q = urlencode('Toy Story'); // make sure to url encode an query parameters

04

05// construct the query with our apikey and the query we want to make

06$endpoint = 'http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=' . $apikey . '&q=' . $q;

07

08// setup curl to make a call to the endpoint

09$session = curl_init($endpoint);

10

11// indicates that we want the response back

12curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

13

14// exec curl and get the data back

15$data = curl_exec($session);

16

17// remember to close the curl session once we are finished retrieveing the data

18curl_close($session);

19

20// decode the json data to make it easier to parse the php

21$search_results = json_decode($data);

22if ($search_results === NULL) die('Error parsing json');

23

24// play with the data!

25$movies = $search_results->movies;

26echo '<ul>';

27foreach ($movies as $movie) {

28  echo '<li><a href="' . $movie->links->alternate . '">' . $movie->title . " (" . $movie->year . ")</a></li>";

29}

30echo '</ul>';

31

32

33?>

Once you load up this code, you should see something similar to the following:

dissertation writing service

Employee+
Employee+

Re: Script for multiple network/host/group object creation

Hi Ismar,

In the mgmt_cli there is a batch mode flag [-b] allowing you to specify a csv file to read the arguments from

All the mgmt_cli commands can use csv files instead if arguments using the -b flag

Raj_Khatri
Copper

Re: Script for multiple network/host/group object creation

When performing an import from CSV, how do you bypass the warning message for duplicate object (same IP, but different host name)?

0 Kudos

Re: Script for multiple network/host/group object creation

add this to your API request:

ignore-warnings true

Re: Script for multiple network/host/group object creation

yes, i have seen that and use many commands to run manually from smartconsole cli.

would you be able to address to this automated object creation from a template?

0 Kudos
Employee+
Employee+

Re: Script for multiple network/host/group object creation

Re: Script for multiple network/host/group object creation

I created some steps which is effective and useful. I am using it in all my projects its simple and in PHP scrip you can check here.http://github.com/sebas5384/VirtualHost-Manager and please, help me to make it better! AssignmentBox

0 Kudos
Tim_Koopman
Nickel

Re: Script for multiple network/host/group object creation

HI,

I am writing a PowerShell module to interface with the API. One of the examples I have already written using this module is for importing group, hosts & networks into Check Point from a Excel file (Could by CSV or anything else PowerShell supports)

Links:

R80 PowerShell Module 

GitHub psCheckPoint Module 

Import from Excel example 

Hope it helps.

Regards

Tim

0 Kudos

Re: Script for multiple network/host/group object creation

Hi Guys

Just wondering if somebody knows how to add groups with group members by importing a csv file.

So for example I need to create loads of UDP and TCP services which is no problem using mgmt_cli and csv file, but how do you add these newly created services to groups?

Let me know if further clarification to the question is needed.

0 Kudos