Python scripts to clone objects from local domain to global domain

Document created by Inbar Moskovich Employee on Jan 9, 2017Last modified by Inbar Moskovich Employee on Jul 11, 2017
Version 1Show Document
  • View in full screen mode

Overview

These scripts copy objects from a given local domain to the global domain.

These scripts use the Python library Python library for using the management APIs

 

Description

Each object type has a different script  'local_<object type>_to_global.py' that  is responsible for cloning that object.

If the object's type isn't known or more than one object needs to be cloned, the script 'local_object_to_global.py' gets the object

(or array of objects) info in json format (which has to include at least the object's uid) and clons all those local objects to the global domain.

Another option is to mark the objects needed to be cloned from the local to the global domain by tag (preferably a unique tag)- the script 'local_to_global_by_tag.py' will clone the relevant objects and delete the tag that was given as a marker.

 

Notes :

     1. The new global object name will be as follow : prefix_<local_object_name>, the prefix should be passed as an argument.

     2. The script supports only the following objects types: host, network, address_range, network group, tcp service, udp service, service group.

          For objects that are not one of these types, the script will not clone them and print an error.

     3. In case a group object needs to be cloned, the script will clone the group and all the objects it contains.

     4. Objects that contain the 'nat-settings' field will be cloned without this filed.

 

The scripts creates:

     1. logfile.txt

     2. json_objects.json contains list of  {<original object uid> : <cloned global object uid>}

     3. csv_file.csv contains {<original object uid>, <original object name>, <cloned global object name> <cloned global object uid>}

          In case the global object wasn't created the <cloned global object name> <cloned global object uid> will remain empty.

 

Instructions

Follow the steps below:

     1. Unzip attached zip file

     2. Download the Python library from the link above.

     3. Extract the Python library folder to the folder containing the script.

     4. Use the html guide (localToGlobal.html) to run the relevant script

 

Code Version

Code version 1.0.0

 

Tested on version

R80, API version 1.0

 

NOTICE: By using this sample code you agree to terms and conditions in this Terms and Conditions

...

Attachments

Outcomes