<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SmartMove usage assistance in SmartMove</title>
    <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161595#M502</link>
    <description>&lt;P&gt;I took the latest Windows SmartMove build from the download centre a few days ago.&lt;/P&gt;&lt;P&gt;v9.40.8333.17361&lt;/P&gt;</description>
    <pubDate>Tue, 08 Nov 2022 15:46:44 GMT</pubDate>
    <dc:creator>Neil_Deane</dc:creator>
    <dc:date>2022-11-08T15:46:44Z</dc:date>
    <item>
      <title>SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161482#M495</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;looking for some assistance with running the SmartMove process.&lt;/P&gt;&lt;P&gt;So far I've completed the following&lt;BR /&gt;- Migrated a policy with SmartMove, created a smartconnect_policy.tar.gz file&lt;BR /&gt;- Copied smartconnect_.tar.gz to management server temp dir and extracted to get these files cp_objects.json, cp_objects_opt.json, smartconnector.py&lt;BR /&gt;- SmartMove documentation indicated to add SDK library from github.com/CheckPointSW/cp_mgmt_api_python_sdk&lt;BR /&gt;- added the library and set Python env variable according to Github notes&lt;/P&gt;&lt;P&gt;Now when I run smartconnector script I get the following:&lt;/P&gt;&lt;P&gt;[Expert@hostname:0]# ./smartconnector.py&lt;BR /&gt;: No such file or directory&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm stuck here ... any ideas please ?&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Neil&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 16:51:56 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161482#M495</guid>
      <dc:creator>Neil_Deane</dc:creator>
      <dc:date>2022-11-07T16:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161484#M496</link>
      <description>&lt;P&gt;Does it run if you try it with #&lt;EM&gt;python3&lt;/EM&gt; &lt;EM&gt;./smartconnecter.py ?&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 18:06:17 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161484#M496</guid>
      <dc:creator>masher</dc:creator>
      <dc:date>2022-11-07T18:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161486#M497</link>
      <description>&lt;P&gt;Just wondering, from what vendor? As an idea, can you run below from expert mode and see what it gives you?&lt;/P&gt;
&lt;P&gt;find / -name&amp;nbsp;&lt;SPAN&gt;smartconnector.py&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 18:34:43 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161486#M497</guid>
      <dc:creator>the_rock</dc:creator>
      <dc:date>2022-11-07T18:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161530#M498</link>
      <description>&lt;P&gt;Thanks Masher.&lt;/P&gt;&lt;P&gt;Same / similar error unfortunately ...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;[Expert@hostname:0]# python3 ./smartconnecter.py&lt;BR /&gt;python3: can't open file './smartconnecter.py': [Errno 2] No such file or directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although your suggestion made me think to check the file permissions for migrate script, json files and SDK assets. All look ok to me, I added execute bits to SDK scripts just in case but makes no difference.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 10:12:12 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161530#M498</guid>
      <dc:creator>Neil_Deane</dc:creator>
      <dc:date>2022-11-08T10:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161533#M499</link>
      <description>&lt;P&gt;Thanks Rock.&lt;/P&gt;&lt;P&gt;Its a Fortigate migration.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Expert@hostname:0]# find / -name smartconnector.py&lt;BR /&gt;/home/admin/mig/smartconnector.py&lt;BR /&gt;find: /proc/6852/task/16074: No such file or directory&lt;BR /&gt;find: /proc/6852/task/1396: No such file or directory&lt;BR /&gt;/var/tmp/migrate/smartconnector.py&lt;BR /&gt;[Expert@hostname:0]#&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I copied the SmartMove output to /home first, then copied to /var/tmp. I wanted to keep the SDK in that path as well.&lt;/P&gt;&lt;P&gt;I'm running the smartconnector script from within the local directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 10:32:27 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161533#M499</guid>
      <dc:creator>Neil_Deane</dc:creator>
      <dc:date>2022-11-08T10:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161588#M500</link>
      <description>&lt;P&gt;Hm, thats odd. From my experience, I always found smart move works best with CP if you are converting from Cisco. IN all honesty, I find same for any other vendor...if you are moving from Cisco, converter tools never have any issues. Sadly, other vendors are different story. Anyway, thats totally different topic : - )&lt;/P&gt;
&lt;P&gt;Now, on to your actual issue...so, put aside technical aspect, thinking of this just purely from logical side, it clearly shows file is there when you do find command, so to me personally, IF you are in right directory when you run a script (which I will take your word for it that you indeed are), then it makes no sense why it would say "no such file or directory". Are you able to attach that file here? I would like to take a look at it.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 14:57:48 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161588#M500</guid>
      <dc:creator>the_rock</dc:creator>
      <dc:date>2022-11-08T14:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161592#M501</link>
      <description>&lt;P&gt;Which version of SmartMove did you use ?&amp;nbsp; Did you build it yourself or use the revision from download center?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 15:36:26 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161592#M501</guid>
      <dc:creator>masher</dc:creator>
      <dc:date>2022-11-08T15:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161595#M502</link>
      <description>&lt;P&gt;I took the latest Windows SmartMove build from the download centre a few days ago.&lt;/P&gt;&lt;P&gt;v9.40.8333.17361&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 15:46:44 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161595#M502</guid>
      <dc:creator>Neil_Deane</dc:creator>
      <dc:date>2022-11-08T15:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161601#M503</link>
      <description>&lt;P&gt;Think its maybe a bug in the Python script. I see its a canned file, nothing customer related in it so I'll post. I see its a fairly new script (25th Oct) version .&lt;/P&gt;&lt;P&gt;I'm looking to install strace package on my Gaia box to try debug it - good luck if you spot something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the raw script smartconnector.py, it wouldnt attach so just pasted it in&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#!/usr/bin/env python&lt;/P&gt;&lt;P&gt;import sys&lt;BR /&gt;import argparse&lt;BR /&gt;import json&lt;BR /&gt;import os&lt;BR /&gt;import re&lt;BR /&gt;import operator&lt;BR /&gt;import uuid&lt;/P&gt;&lt;P&gt;sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '.')))&lt;BR /&gt;from cpapi import APIClient, APIClientArgs&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# printing messages to console and log file&lt;BR /&gt;# res_action - response from server, used if response is not OK&lt;BR /&gt;# message - message to inform user&lt;BR /&gt;# error - message with mark to inform user about issue&lt;BR /&gt;# ---&lt;BR /&gt;# returns: nothing&lt;BR /&gt;def printStatus(res_action, message, error=None):&lt;BR /&gt;line = ""&lt;BR /&gt;if res_action is not None and res_action.success is False:&lt;BR /&gt;if 'errors' in res_action.data:&lt;BR /&gt;for msg_err in res_action.data['errors']:&lt;BR /&gt;line += "WARN:" + "\t" + msg_err['message'] + "\n"&lt;BR /&gt;if 'warnings' in res_action.data:&lt;BR /&gt;for msg_wrn in res_action.data['warnings']:&lt;BR /&gt;line += "WARN:" + "\t" + msg_wrn['message'] + "\n"&lt;BR /&gt;if line == "":&lt;BR /&gt;if "message" in res_action.data:&lt;BR /&gt;line = "WARN:" + "\t" + res_action.data['message'] + "\n"&lt;BR /&gt;else:&lt;BR /&gt;line = "WARN:" + "\t" + "Err of getting message from the mgmt server" + "\n"&lt;BR /&gt;elif message is not None:&lt;BR /&gt;line += "\t" + message + "\n"&lt;BR /&gt;elif error is not None:&lt;BR /&gt;line += "WARN:" + "\t" + error + "\n"&lt;BR /&gt;if line != "":&lt;BR /&gt;print(line.rstrip())&lt;BR /&gt;file_log.write(line)&lt;BR /&gt;file_log.flush()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# printing info message "process..." with delimeters&lt;BR /&gt;# objectsType - string of objects type&lt;BR /&gt;# ---&lt;BR /&gt;# returns: nothing&lt;BR /&gt;def printMessageProcessObjects(objectsType):&lt;BR /&gt;printStatus(None, "==========")&lt;BR /&gt;printStatus(None, "process " + objectsType + " ...")&lt;BR /&gt;printStatus(None, "")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# publishing to database new updates by condition; increasing counter by 1&lt;BR /&gt;# counter - is number of new updates. if it equals threshold then updates will be published&lt;BR /&gt;# isForced - publishing to database anyway&lt;BR /&gt;# ---&lt;BR /&gt;# returns: updated counter&lt;BR /&gt;def publishUpdate(counter, isForced):&lt;BR /&gt;if counter &amp;lt; 0:&lt;BR /&gt;counter = 0&lt;BR /&gt;counter += 1&lt;BR /&gt;if isForced or counter &amp;gt;= args.threshold:&lt;BR /&gt;if not isForced:&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;printStatus(None, "----------")&lt;BR /&gt;printStatus(None, "publishing to database...")&lt;BR /&gt;res_publish = client.api_call("publish", {})&lt;BR /&gt;if res_publish.success:&lt;BR /&gt;counter = 0&lt;BR /&gt;printStatus(res_publish, "publish is completed")&lt;BR /&gt;printStatus(None, "----------")&lt;BR /&gt;if isForced:&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;return counter&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# check if response contains message that name of "new" object exists in database&lt;BR /&gt;# res_add_obj - response from server&lt;BR /&gt;# ---&lt;BR /&gt;# returns: True - if the name is duplicated, False - otherwise&lt;BR /&gt;def isNameDuplicated(res_add_obj):&lt;BR /&gt;isNameDuplicated = False&lt;BR /&gt;if 'errors' in res_add_obj.data:&lt;BR /&gt;for msg in res_add_obj.data['errors']:&lt;BR /&gt;if msg['message'].startswith("More than one object named") and msg['message'].endswith("exists."):&lt;BR /&gt;isNameDuplicated = True&lt;BR /&gt;return isNameDuplicated&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# check if response contains message that IP of "new" object exists in database&lt;BR /&gt;# res_add_obj - response from server&lt;BR /&gt;# ---&lt;BR /&gt;# returns: True - if the IP is duplicated, False - otherwise&lt;BR /&gt;def isIpDuplicated(res_add_obj):&lt;BR /&gt;isIpDuplicated = False&lt;BR /&gt;if 'warnings' in res_add_obj.data:&lt;BR /&gt;messagePrefixes = ("Multiple objects have the same IP address",)&lt;BR /&gt;messagePrefixes += ("More than one network have the same IP",)&lt;BR /&gt;messagePrefixes += ("More than one network has the same IP",)&lt;BR /&gt;messagePrefixes += ("More than one object have the same IPv6",)&lt;BR /&gt;messagePrefixes += ("More than one object has the same IPv6",)&lt;BR /&gt;for msg in res_add_obj.data['warnings']:&lt;BR /&gt;if msg['message'].startswith(messagePrefixes):&lt;BR /&gt;isIpDuplicated = True&lt;BR /&gt;return isIpDuplicated&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# check if object from server comes from "global" domain&lt;BR /&gt;# serverObject - JSON presentation of object&lt;BR /&gt;# ---&lt;BR /&gt;# returns: True - if object comes from "global" domain, False - otherwise&lt;BR /&gt;def isServerObjectGlobal(serverObject):&lt;BR /&gt;return serverObject['domain']['domain-type'] == "global domain"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# check if object from server comes from "local" domain&lt;BR /&gt;# serverObject - JSON presentation of object&lt;BR /&gt;# ---&lt;BR /&gt;# returns: True - if object comes from "local" domain, False - otherwise&lt;BR /&gt;def isServerObjectLocal(serverObject):&lt;BR /&gt;return serverObject['domain']['domain-type'] == "domain"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# adding "new" object to server&lt;BR /&gt;# adjusting the name if object with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# client - client object&lt;BR /&gt;# apiCommand - short string which indicates what should be done&lt;BR /&gt;# payload - JSON representation of "new" object&lt;BR /&gt;# userObjectNamePostfix - postfix as number&lt;BR /&gt;# changeName=True - True: to try to add object and adjust the name; False: to try to add object and NOT adjust the name&lt;BR /&gt;# ---&lt;BR /&gt;# returns: added object from server in JSON format, None - otherwise&lt;BR /&gt;def addUserObjectToServer(client, apiCommand, payload, userObjectNamePostfix=1, changeName=True):&lt;BR /&gt;isObjectAdded = False&lt;BR /&gt;userObjectNameInitial = ""&lt;BR /&gt;if changeName:&lt;BR /&gt;userObjectNameInitial = payload['name']&lt;BR /&gt;addedObject = None&lt;BR /&gt;while not isObjectAdded:&lt;BR /&gt;res_add_obj = client.api_call(apiCommand, payload)&lt;BR /&gt;printStatus(res_add_obj, None)&lt;BR /&gt;if res_add_obj.success is False:&lt;BR /&gt;if not changeName:&lt;BR /&gt;addedObject = None&lt;BR /&gt;break&lt;BR /&gt;if isNameDuplicated(res_add_obj):&lt;BR /&gt;if (apiCommand == 'add-time' or apiCommand == 'add-time-group') and (len(str(userObjectNamePostfix)) + len(userObjectNameInitial) + 1) &amp;gt; 11:&lt;BR /&gt;#if we have time object need to fill name with condition 11 symbols as max length&lt;BR /&gt;payload['name'] = userObjectNameInitial[:-(len(str(userObjectNamePostfix))+1)] + '_' + str(userObjectNamePostfix)&lt;BR /&gt;userObjectNamePostfix += 1&lt;BR /&gt;elif args.reuse_group_name.lower() == "true" and \&lt;BR /&gt;(apiCommand == 'add-group'&lt;BR /&gt;or apiCommand == 'add-service-group'&lt;BR /&gt;or apiCommand == 'add-time-group'&lt;BR /&gt;or apiCommand == 'add-group-with-exclusion'&lt;BR /&gt;or apiCommand == 'add-application-site-group'):&lt;BR /&gt;# In the case of duplicate names and the user uses the 'reuse-group-name' flag,&lt;BR /&gt;# the smartconnector will not create a new name, it will add the data to the existing name&lt;BR /&gt;addedObject = res_add_obj.data&lt;BR /&gt;isObjectAdded = True&lt;BR /&gt;addedObject["name"] = payload['name']&lt;BR /&gt;else:&lt;BR /&gt;payload['name'] = userObjectNameInitial + '_' + str(userObjectNamePostfix)&lt;BR /&gt;userObjectNamePostfix += 1&lt;BR /&gt;else:&lt;BR /&gt;break&lt;BR /&gt;else:&lt;BR /&gt;addedObject = res_add_obj.data&lt;BR /&gt;isObjectAdded = True&lt;/P&gt;&lt;P&gt;return addedObject&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# adding to server the object which contains fields with IP: hosts, networks&lt;BR /&gt;# adjusting the name if object with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# using the object from server side if object exits with the same IP at server&lt;BR /&gt;# client - client object&lt;BR /&gt;# payload - JSON representation of "new" object&lt;BR /&gt;# userObjectType - the type of object: host or network&lt;BR /&gt;# userObjectIp - IP which will be used as filter in request to server&lt;BR /&gt;# mergedObjectsNamesMap - the map which contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;# ---&lt;BR /&gt;# returns: updated mergedObjectsNamesMap&lt;BR /&gt;def addCpObjectWithIpToServer(client, payload, userObjectType, userObjectIp, mergedObjectsNamesMap):&lt;BR /&gt;printStatus(None, "processing " + userObjectType + ": " + payload['name'])&lt;BR /&gt;userObjectNameInitial = payload['name']&lt;BR /&gt;userObjectNamePostfix = 1&lt;BR /&gt;isFinished = False&lt;BR /&gt;isIgnoreWarnings = False&lt;BR /&gt;while not isFinished:&lt;BR /&gt;payload["ignore-warnings"] = isIgnoreWarnings&lt;BR /&gt;# payload["--user-agent"] = "mgmt_cli_smartmove";&lt;BR /&gt;res_add_obj_with_ip = client.api_call("add-" + userObjectType, payload)&lt;BR /&gt;print("add-" + userObjectType, payload)&lt;BR /&gt;printStatus(res_add_obj_with_ip, "REPORT: " + userObjectNameInitial + " is added as " + payload['name'])&lt;BR /&gt;if res_add_obj_with_ip.success is False:&lt;BR /&gt;if isIpDuplicated(res_add_obj_with_ip) and not isIgnoreWarnings:&lt;BR /&gt;res_get_obj_with_ip = client.api_query("show-objects", payload={"filter": userObjectIp, "ip-only": False,&lt;BR /&gt;"type": userObjectType})&lt;BR /&gt;printStatus(res_get_obj_with_ip, None)&lt;BR /&gt;if res_get_obj_with_ip.success is True:&lt;BR /&gt;if len(res_get_obj_with_ip.data) &amp;gt; 0:&lt;BR /&gt;if userObjectType == "network" and next((x for x in res_get_obj_with_ip.data if x['subnet4' if is_valid_ipv4(payload['subnet']) else 'subnet6'] == payload['subnet'] and (x['subnet-mask'] == payload['subnet-mask']) if is_valid_ipv4(payload['subnet'])), None) is None:&lt;BR /&gt;isIgnoreWarnings = True&lt;BR /&gt;else:&lt;BR /&gt;if userObjectType == "host":&lt;BR /&gt;mergedObjectsNamesMap[userObjectNameInitial] = res_get_obj_with_ip.data[0]['name']&lt;BR /&gt;printStatus(None, "REPORT: " + "CP object " + mergedObjectsNamesMap[&lt;BR /&gt;userObjectNameInitial] + " is used instead of " + userObjectNameInitial)&lt;BR /&gt;isFinished = True&lt;BR /&gt;break&lt;BR /&gt;for serverObject in res_get_obj_with_ip.data:&lt;BR /&gt;# if more then one network in res_get_obj_with_ip, map to the one that matches subnet&lt;BR /&gt;mergedObjectsNamesMap[userObjectNameInitial] = next(x['name'] for x in res_get_obj_with_ip.data if x['subnet4' if is_valid_ipv4(payload['subnet']) else 'subnet6'] == payload['subnet'] and (x['subnet-mask'] == payload['subnet-mask']) if is_valid_ipv4(payload['subnet']))&lt;BR /&gt;if (isServerObjectLocal(serverObject) and not isReplaceFromGlobalFirst) or (&lt;BR /&gt;isServerObjectGlobal(serverObject) and isReplaceFromGlobalFirst):&lt;BR /&gt;break&lt;BR /&gt;printStatus(None, "REPORT: " + "CP object " + mergedObjectsNamesMap[&lt;BR /&gt;userObjectNameInitial] + " is used instead of " + userObjectNameInitial)&lt;BR /&gt;isFinished = True&lt;BR /&gt;else:&lt;BR /&gt;isIgnoreWarnings = True&lt;BR /&gt;else:&lt;BR /&gt;isFinished = True&lt;BR /&gt;elif isNameDuplicated(res_add_obj_with_ip):&lt;BR /&gt;payload['name'] = userObjectNameInitial + '_' + str(userObjectNamePostfix)&lt;BR /&gt;userObjectNamePostfix += 1&lt;BR /&gt;else:&lt;BR /&gt;isFinished = True&lt;BR /&gt;else:&lt;BR /&gt;mergedObjectsNamesMap[userObjectNameInitial] = payload['name']&lt;BR /&gt;isFinished = True&lt;BR /&gt;return mergedObjectsNamesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the groups which contains list of members&lt;BR /&gt;# adjusting the name if group with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# client - client object&lt;BR /&gt;# apiCommand - short string which indicates what should be done&lt;BR /&gt;# userGroup - group which will be processed and added to server&lt;BR /&gt;# mergedObjectsMap - map of objects which will be used for replacing&lt;BR /&gt;# mergedGroupsNamesMap - the map which contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;# ---&lt;BR /&gt;# returns: updated mergedGroupsNamesMap&lt;BR /&gt;def processGroupWithMembers(client, apiCommand, userGroup, mergedObjectsMap, mergedGroupsNamesMap, isNeedSplitted):&lt;BR /&gt;apiSetCommand = "set-group"&lt;BR /&gt;addedGroup = None&lt;BR /&gt;if "time" in apiCommand:&lt;BR /&gt;apiSetCommand = "set-time-group"&lt;BR /&gt;elif "service" in apiCommand:&lt;BR /&gt;apiSetCommand = "set-service-group"&lt;/P&gt;&lt;P&gt;if isNeedSplitted:&lt;BR /&gt;if ("Members" in userGroup): #group with list of members&lt;BR /&gt;for i, userGroupMember in enumerate(userGroup['Members']):&lt;BR /&gt;print(userGroupMember)&lt;BR /&gt;if userGroupMember in mergedObjectsMap:&lt;BR /&gt;userGroupMember = mergedObjectsMap[userGroupMember]&lt;BR /&gt;res_add_obj = client.api_call(&lt;BR /&gt;apiSetCommand,&lt;BR /&gt;{&lt;BR /&gt;"name": userGroup['Name'],&lt;BR /&gt;"members": {"add": userGroupMember}&lt;BR /&gt;})&lt;BR /&gt;printStatus(None, "REPORT: " + userGroup['Name'] + " is set with new member " + str(userGroupMember))&lt;BR /&gt;else: #group with exclusion with include/exclude fields with groups name&lt;BR /&gt;printStatus(None, "WARN: " + userGroup['Name'] + " hasn't any member by the type GroupWithExlusions")&lt;BR /&gt;else:&lt;BR /&gt;addedGroup = addUserObjectToServer(&lt;BR /&gt;client,&lt;BR /&gt;apiCommand,&lt;BR /&gt;{&lt;BR /&gt;"name": userGroup['Name'],&lt;BR /&gt;"comments": userGroup['Comments'],&lt;BR /&gt;"tags": userGroup['Tags']&lt;BR /&gt;}&lt;BR /&gt;)&lt;BR /&gt;return addedGroup&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Domains&lt;BR /&gt;# adjusting the name if domain with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# client - client object&lt;BR /&gt;# userDomains - the list of domains which will be processed and added to server&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedDomainsNamesMap dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processDomains(client, userDomains):&lt;BR /&gt;printMessageProcessObjects("domains...")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedDomainsNamesMap = {}&lt;BR /&gt;if len(userDomains) == 0:&lt;BR /&gt;return mergedDomainsNamesMap&lt;BR /&gt;for userDomain in userDomains:&lt;BR /&gt;userDomainNameInitial = userDomain['Name']&lt;BR /&gt;printStatus(None, "processing domain: " + userDomain['Name'])&lt;BR /&gt;addedDomain = addUserObjectToServer(&lt;BR /&gt;client,&lt;BR /&gt;"add-dns-domain",&lt;BR /&gt;{&lt;BR /&gt;"name": userDomain['Name'],&lt;BR /&gt;"is-sub-domain": userDomain['IsSubDomain'],&lt;BR /&gt;"comments": userDomain['Comments'],&lt;BR /&gt;"tags": userDomain['Tags']&lt;BR /&gt;},&lt;BR /&gt;changeName = False&lt;BR /&gt;)&lt;BR /&gt;if addedDomain is not None:&lt;BR /&gt;mergedDomainsNamesMap[userDomainNameInitial] = addedDomain['name']&lt;BR /&gt;printStatus(None, "REPORT: " + userDomainNameInitial + " is added as " + addedDomain['name'])&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, False)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userDomainNameInitial + ' is not added.')&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedDomainsNamesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Hosts&lt;BR /&gt;# adjusting the name if host with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# if host contains existing IP address then Host object from server will be used instead&lt;BR /&gt;# client - client object&lt;BR /&gt;# userHosts - the list of hosts which will be processed and added to server&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedHostsNamesMap dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processHosts(client, userHosts):&lt;BR /&gt;printMessageProcessObjects("hosts")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedHostsNamesMap = {}&lt;BR /&gt;if len(userHosts) == 0:&lt;BR /&gt;return mergedHostsNamesMap&lt;BR /&gt;for userHost in userHosts:&lt;BR /&gt;payload = {&lt;BR /&gt;"name": userHost['Name'],&lt;BR /&gt;"ip-address": userHost['IpAddress'],&lt;BR /&gt;"comments": userHost['Comments'],&lt;BR /&gt;"tags": userHost['Tags']&lt;BR /&gt;}&lt;BR /&gt;initialMapLength = len(mergedHostsNamesMap)&lt;BR /&gt;mergedHostsNamesMap = addCpObjectWithIpToServer(client, payload, "host", userHost['IpAddress'],&lt;BR /&gt;mergedHostsNamesMap)&lt;BR /&gt;if initialMapLength == len(mergedHostsNamesMap):&lt;BR /&gt;printStatus(None, "REPORT: " + userHost['Name'] + ' is not added.')&lt;BR /&gt;else:&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, False)&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedHostsNamesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def is_valid_ipv4(ip):&lt;BR /&gt;pattern = re.compile(r"""&lt;BR /&gt;^&lt;BR /&gt;(?:&lt;BR /&gt;# Dotted variants:&lt;BR /&gt;(?:&lt;BR /&gt;# Decimal 1-255 (no leading 0's)&lt;BR /&gt;[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}&lt;BR /&gt;|&lt;BR /&gt;0x0*[0-9a-f]{1,2} # Hexadecimal 0x0 - 0xFF (possible leading 0's)&lt;BR /&gt;|&lt;BR /&gt;0+[1-3]?[0-7]{0,2} # Octal 0 - 0377 (possible leading 0's)&lt;BR /&gt;)&lt;BR /&gt;(?: # Repeat 0-3 times, separated by a dot&lt;BR /&gt;\.&lt;BR /&gt;(?:&lt;BR /&gt;[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}&lt;BR /&gt;|&lt;BR /&gt;0x0*[0-9a-f]{1,2}&lt;BR /&gt;|&lt;BR /&gt;0+[1-3]?[0-7]{0,2}&lt;BR /&gt;)&lt;BR /&gt;){0,3}&lt;BR /&gt;|&lt;BR /&gt;0x0*[0-9a-f]{1,8} # Hexadecimal notation, 0x0 - 0xffffffff&lt;BR /&gt;|&lt;BR /&gt;0+[0-3]?[0-7]{0,10} # Octal notation, 0 - 037777777777&lt;BR /&gt;|&lt;BR /&gt;# Decimal notation, 1-4294967295:&lt;BR /&gt;429496729[0-5]|42949672[0-8]\d|4294967[01]\d\d|429496[0-6]\d{3}|&lt;BR /&gt;42949[0-5]\d{4}|4294[0-8]\d{5}|429[0-3]\d{6}|42[0-8]\d{7}|&lt;BR /&gt;4[01]\d{8}|[1-3]\d{0,9}|[4-9]\d{0,8}&lt;BR /&gt;)&lt;BR /&gt;$&lt;BR /&gt;""", re.VERBOSE | re.IGNORECASE)&lt;BR /&gt;return pattern.match(ip) is not None&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def is_valid_ipv6(ip):&lt;BR /&gt;pattern = re.compile(r"""&lt;BR /&gt;^&lt;BR /&gt;\s* # Leading whitespace&lt;BR /&gt;(?!.*::.*::) # Only a single whildcard allowed&lt;BR /&gt;(?:(?!:)|:(?=:)) # Colon iff it would be part of a wildcard&lt;BR /&gt;(?: # Repeat 6 times:&lt;BR /&gt;[0-9a-f]{0,4} # A group of at most four hexadecimal digits&lt;BR /&gt;(?:(?&amp;lt;=::)|(?&amp;lt;!::):) # Colon unless preceeded by wildcard&lt;BR /&gt;){6} #&lt;BR /&gt;(?: # Either&lt;BR /&gt;[0-9a-f]{0,4} # Another group&lt;BR /&gt;(?:(?&amp;lt;=::)|(?&amp;lt;!::):) # Colon unless preceeded by wildcard&lt;BR /&gt;[0-9a-f]{0,4} # Last group&lt;BR /&gt;(?: (?&amp;lt;=::) # Colon iff preceeded by exacly one colon&lt;BR /&gt;| (?&amp;lt;!:) #&lt;BR /&gt;| (?&amp;lt;=:) (?&amp;lt;!::) : #&lt;BR /&gt;) # OR&lt;BR /&gt;| # A v4 address with NO leading zeros&lt;BR /&gt;(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d)&lt;BR /&gt;(?: \.&lt;BR /&gt;(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d)&lt;BR /&gt;){3}&lt;BR /&gt;)&lt;BR /&gt;\s* # Trailing whitespace&lt;BR /&gt;$&lt;BR /&gt;""", re.VERBOSE | re.IGNORECASE | re.DOTALL)&lt;BR /&gt;return pattern.match(ip) is not None&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Networks&lt;BR /&gt;# adjusting the name if network with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# if network contains existing IP subnet then Network object from server will be used instead&lt;BR /&gt;# client - client object&lt;BR /&gt;# userNetworks - the list of networks which will be processed and added to server&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedNetworksNamesMap dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processNetworks(client, userNetworks):&lt;BR /&gt;printMessageProcessObjects("networks")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedNetworksNamesMap = {}&lt;BR /&gt;userNetworks = sorted(userNetworks, key=lambda K: ('' if K['Netmask'] is None else K['Netmask'], '' if K['MaskLength'] is None else K['MaskLength']), reverse=True)&lt;BR /&gt;if len(userNetworks) == 0:&lt;BR /&gt;return mergedNetworksNamesMap&lt;BR /&gt;for userNetwork in userNetworks:&lt;BR /&gt;payload = {&lt;BR /&gt;"name": userNetwork['Name'],&lt;BR /&gt;"comments": userNetwork['Comments'],&lt;BR /&gt;"tags": userNetwork['Tags'],&lt;BR /&gt;"subnet": userNetwork['Subnet']&lt;BR /&gt;}&lt;BR /&gt;if is_valid_ipv4(userNetwork['Subnet']):&lt;BR /&gt;payload["subnet-mask"] = userNetwork['Netmask']&lt;BR /&gt;else:&lt;BR /&gt;payload["mask-length6"] = userNetwork['MaskLength']&lt;BR /&gt;initialMapLength = len(mergedNetworksNamesMap)&lt;BR /&gt;mergedNetworksNamesMap = addCpObjectWithIpToServer(client, payload, "network", userNetwork['Subnet'],&lt;BR /&gt;mergedNetworksNamesMap)&lt;BR /&gt;if initialMapLength == len(mergedNetworksNamesMap):&lt;BR /&gt;printStatus(None, "REPORT: " + userNetwork['Name'] + ' is not added.')&lt;BR /&gt;else:&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, False)&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedNetworksNamesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Ranges&lt;BR /&gt;# adjusting the name if range with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# if range contains existing IP start and end then Range object from server will be used instead&lt;BR /&gt;# client - client object&lt;BR /&gt;# userRanges - the list of ranges which will be processed and added to server&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedRangesNamesMap dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processRanges(client, userRanges):&lt;BR /&gt;printMessageProcessObjects("ranges")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedRangesNamesMap = {}&lt;BR /&gt;if len(userRanges) == 0:&lt;BR /&gt;return mergedRangesNamesMap&lt;BR /&gt;serverRangesMap = {}&lt;BR /&gt;serverRangesMapGlobal = {}&lt;BR /&gt;serverRangesMapLocal = {}&lt;BR /&gt;printStatus(None, "reading address ranges from server")&lt;BR /&gt;res_get_ranges = client.api_query("show-address-ranges")&lt;BR /&gt;printStatus(res_get_ranges, None)&lt;BR /&gt;for serverRange in res_get_ranges.data:&lt;BR /&gt;key = ''&lt;BR /&gt;if 'ipv4-address-first' in serverRange:&lt;BR /&gt;key = serverRange['ipv4-address-first'] + '_' + serverRange['ipv4-address-last']&lt;BR /&gt;else:&lt;BR /&gt;key = serverRange['ipv6-address-first'] + '_' + serverRange['ipv6-address-last']&lt;/P&gt;&lt;P&gt;if isServerObjectGlobal(serverRange) and key not in serverRangesMapGlobal:&lt;BR /&gt;serverRangesMapGlobal[key] = serverRange['name']&lt;BR /&gt;elif isServerObjectLocal(serverRange) and key not in serverRangesMapLocal:&lt;BR /&gt;serverRangesMapLocal[key] = serverRange['name']&lt;BR /&gt;elif key not in serverRangesMapGlobal and key not in serverRangesMapLocal and key not in serverRangesMap:&lt;BR /&gt;serverRangesMap[key] = serverRange['name']&lt;/P&gt;&lt;P&gt;printStatus(None, "")&lt;BR /&gt;if sys.version_info &amp;gt;= (3, 0):&lt;BR /&gt;serverRangesMap = serverRangesMap.copy()&lt;BR /&gt;if isReplaceFromGlobalFirst:&lt;BR /&gt;serverRangesMap.update(serverRangesMapLocal)&lt;BR /&gt;serverRangesMap.update(serverRangesMapGlobal)&lt;BR /&gt;else:&lt;BR /&gt;serverRangesMap.update(serverRangesMapGlobal)&lt;BR /&gt;serverRangesMap.update(serverRangesMapLocal)&lt;BR /&gt;else:&lt;BR /&gt;if isReplaceFromGlobalFirst:&lt;BR /&gt;serverRangesMap = dict(&lt;BR /&gt;serverRangesMap.items() + serverRangesMapLocal.items() + serverRangesMapGlobal.items())&lt;BR /&gt;else:&lt;BR /&gt;serverRangesMap = dict(&lt;BR /&gt;serverRangesMap.items() + serverRangesMapGlobal.items() + serverRangesMapLocal.items())&lt;BR /&gt;for userRange in userRanges:&lt;BR /&gt;printStatus(None, "processing range: " + userRange['Name'])&lt;BR /&gt;userRangeNameInitial = userRange['Name']&lt;BR /&gt;rngFrom = '' if userRange['RangeFrom'] is None else userRange['RangeFrom']&lt;BR /&gt;rngTo = '' if userRange['RangeTo'] is None else userRange['RangeTo']&lt;BR /&gt;key = rngFrom + '_' + rngTo&lt;BR /&gt;if key in serverRangesMap:&lt;BR /&gt;printStatus(None, None,&lt;BR /&gt;"More than one range has the same ip: '" + userRange['RangeFrom'] + "' and '" + userRange[&lt;BR /&gt;'RangeTo'] + "'")&lt;BR /&gt;mergedRangesNamesMap[userRangeNameInitial] = serverRangesMap[key]&lt;BR /&gt;printStatus(None, "REPORT: " + "CP object " + mergedRangesNamesMap[&lt;BR /&gt;userRangeNameInitial] + " is used instead of " + userRangeNameInitial)&lt;BR /&gt;else:&lt;BR /&gt;userRangeNamePostfix = 1&lt;BR /&gt;if userRange['Name'] in serverRangesMap.values():&lt;BR /&gt;printStatus(None, None, "More than one object named '" + userRange['Name'] + "' exists.")&lt;BR /&gt;while userRange['Name'] in serverRangesMap.values():&lt;BR /&gt;userRange['Name'] = userRangeNameInitial + '_' + str(userRangeNamePostfix)&lt;BR /&gt;userRangeNamePostfix += 1&lt;BR /&gt;payload = {&lt;BR /&gt;"name": userRange['Name'],&lt;BR /&gt;"ip-address-first": userRange['RangeFrom'],&lt;BR /&gt;"ip-address-last": userRange['RangeTo'],&lt;BR /&gt;"comments": userRange['Comments'],&lt;BR /&gt;"tags": userRange['Tags'],&lt;BR /&gt;"ignore-warnings": True&lt;BR /&gt;}&lt;BR /&gt;addedRange = addUserObjectToServer(client, "add-address-range", payload, userRangeNamePostfix)&lt;BR /&gt;if addedRange is not None:&lt;BR /&gt;mergedRangesNamesMap[userRangeNameInitial] = addedRange['name']&lt;BR /&gt;key = ''&lt;BR /&gt;if 'ipv4-address-first' in addedRange:&lt;BR /&gt;key = addedRange['ipv4-address-first'] + '_' + addedRange['ipv4-address-last']&lt;BR /&gt;else:&lt;BR /&gt;key = addedRange['ipv6-address-first'] + '_' + addedRange['ipv6-address-last']&lt;BR /&gt;serverRangesMap[key] = addedRange['name']&lt;BR /&gt;printStatus(None, "REPORT: " + userRangeNameInitial + " is added as " + addedRange['name'])&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, False)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userRangeNameInitial + ' is not added.')&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedRangesNamesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Network Groups&lt;BR /&gt;# adjusting the name if network group with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# client - client object&lt;BR /&gt;# userNetworkGroups - the list of network groups which will be processed and added to server&lt;BR /&gt;# mergedNetworkObjectsMap - map of network objects which will be used for replacing&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedGroupsNamesDict dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processNetGroups(client, userNetworkGroups, mergedNetworkObjectsMap):&lt;BR /&gt;printMessageProcessObjects("network groups")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedGroupsNamesDict = {}&lt;BR /&gt;if len(userNetworkGroups) == 0:&lt;BR /&gt;return mergedGroupsNamesDict&lt;BR /&gt;for userNetworkGroup in userNetworkGroups:&lt;BR /&gt;userNetworkGroupNameInitial = userNetworkGroup['Name']&lt;BR /&gt;addedNetworkGroup = None&lt;BR /&gt;if userNetworkGroup['TypeName'] == 'CheckPoint_GroupWithExclusion':&lt;BR /&gt;printStatus(None, "processing network group with exclusion: " + userNetworkGroup['Name'])&lt;BR /&gt;if userNetworkGroup['Include'] in mergedGroupsNamesDict:&lt;BR /&gt;userNetworkGroup['Include'] = mergedGroupsNamesDict[userNetworkGroup['Include']]&lt;BR /&gt;if userNetworkGroup['Except'] in mergedGroupsNamesDict:&lt;BR /&gt;userNetworkGroup['Except'] = mergedGroupsNamesDict[userNetworkGroup['Except']]&lt;BR /&gt;addedNetworkGroup = addUserObjectToServer(&lt;BR /&gt;client,&lt;BR /&gt;"add-group-with-exclusion",&lt;BR /&gt;{&lt;BR /&gt;"name": userNetworkGroup['Name'],&lt;BR /&gt;"include": userNetworkGroup['Include'],&lt;BR /&gt;"except": userNetworkGroup['Except'],&lt;BR /&gt;"comments": userNetworkGroup['Comments'],&lt;BR /&gt;"tags": userNetworkGroup['Tags']&lt;BR /&gt;}&lt;BR /&gt;)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "processing network group: " + userNetworkGroup['Name'])&lt;BR /&gt;addedNetworkGroup = processGroupWithMembers(client, "add-group", userNetworkGroup, mergedNetworkObjectsMap,&lt;BR /&gt;mergedGroupsNamesDict, False)&lt;BR /&gt;if addedNetworkGroup is not None:&lt;BR /&gt;mergedGroupsNamesDict[userNetworkGroupNameInitial] = addedNetworkGroup['name']&lt;BR /&gt;if 'errors' in addedNetworkGroup:&lt;BR /&gt;if 'More than one object' in addedNetworkGroup['errors'][0]['message']:&lt;BR /&gt;printStatus(None, "REPORT: Using the existing object '{}'".format(addedNetworkGroup['name']))&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userNetworkGroupNameInitial + " is added as " + addedNetworkGroup['name'])&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, True)&lt;BR /&gt;userNetworkGroup["Name"] = addedNetworkGroup['name']&lt;BR /&gt;if userNetworkGroup['TypeName'] != 'CheckPoint_GroupWithExclusion':&lt;BR /&gt;processGroupWithMembers(client, "add-group", userNetworkGroup, mergedNetworkObjectsMap,&lt;BR /&gt;mergedGroupsNamesDict, True)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userNetworkGroupNameInitial + " is not added.")&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedGroupsNamesDict&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Simple Gateways&lt;BR /&gt;# adjusting the name if simple gateway with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# client - client object&lt;BR /&gt;# userSimpleGateways - the list of simple gateways which will be processed and added to server&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedSimpleGatewaysNamesMap dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processSimpleGateways(client, userSimpleGateways):&lt;BR /&gt;printMessageProcessObjects("simple gateways")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedSimpleGatewaysNamesMap = {}&lt;BR /&gt;if len(userSimpleGateways) == 0:&lt;BR /&gt;return mergedSimpleGatewaysNamesMap&lt;BR /&gt;for userSimpleGateway in userSimpleGateways:&lt;BR /&gt;printStatus(None, "processing simple gateway: " + userSimpleGateway['Name'])&lt;BR /&gt;userSimpleGatewayNameInitial = userSimpleGateway['Name']&lt;BR /&gt;addedSimpleGateway = addUserObjectToServer(&lt;BR /&gt;client,&lt;BR /&gt;"add-simple-gateway",&lt;BR /&gt;{&lt;BR /&gt;"name": userSimpleGateway['Name'],&lt;BR /&gt;"ip-address": userSimpleGateway['IpAddress'],&lt;BR /&gt;"comments": userSimpleGateway['Comments'],&lt;BR /&gt;"tags": userSimpleGateway['Tags']&lt;BR /&gt;}&lt;BR /&gt;)&lt;BR /&gt;if addedSimpleGateway is not None:&lt;BR /&gt;mergedSimpleGatewaysNamesMap[userSimpleGatewayNameInitial] = addedSimpleGateway['name']&lt;BR /&gt;printStatus(None, "REPORT: " + userSimpleGatewayNameInitial + " is added as " + addedSimpleGateway['name'])&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, False)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userSimpleGatewayNameInitial + ' is not added.')&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedSimpleGatewaysNamesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Zones&lt;BR /&gt;# adjusting the name if zone with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# client - client object&lt;BR /&gt;# userZones - the list of zones which will be processed and added to server&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedZonesNamesMap dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processZones(client, userZones):&lt;BR /&gt;printMessageProcessObjects("zones")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedZonesNamesMap = {}&lt;BR /&gt;if len(userZones) == 0:&lt;BR /&gt;return mergedZonesNamesMap&lt;BR /&gt;for userZone in userZones:&lt;BR /&gt;printStatus(None, "processing zone: " + userZone['Name'])&lt;BR /&gt;userZoneNameInitial = userZone['Name']&lt;BR /&gt;addedZone = addUserObjectToServer(&lt;BR /&gt;client,&lt;BR /&gt;"add-security-zone",&lt;BR /&gt;{&lt;BR /&gt;"name": userZone['Name'],&lt;BR /&gt;"comments": userZone['Comments'],&lt;BR /&gt;"tags": userZone['Tags']&lt;BR /&gt;}&lt;BR /&gt;)&lt;BR /&gt;if addedZone is not None:&lt;BR /&gt;mergedZonesNamesMap[userZoneNameInitial] = addedZone['name']&lt;BR /&gt;printStatus(None, "REPORT: " + userZoneNameInitial + " is added as " + addedZone['name'])&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, False)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userZoneNameInitial + ' is not added.')&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedZonesNamesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# generate and provide key for Services dictionary&lt;BR /&gt;# serverService - service in JSON format&lt;BR /&gt;# ---&lt;BR /&gt;# returns: string as key&lt;BR /&gt;def provideServerServiceKey(serverService):&lt;BR /&gt;key = ""&lt;BR /&gt;if 'port' in serverService: # key for TCP or UDP or SCTP&lt;BR /&gt;key = serverService['port']&lt;BR /&gt;elif 'icmp-type' in serverService: # key for ICMP&lt;BR /&gt;key = str(serverService['icmp-type'])&lt;BR /&gt;if 'icmp-code' in serverService and serverService['icmp-code'] != 'null':&lt;BR /&gt;key += "_" + str(serverService['icmp-code'])&lt;BR /&gt;elif 'ip-protocol' in serverService: # key for Other&lt;BR /&gt;key = serverService['ip-protocol']&lt;BR /&gt;return key&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Services (TCP, UDP, SCTP, ICMP or Other)&lt;BR /&gt;# adjusting the name if service with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# if service contains existing port then Service object from server will be used instead&lt;BR /&gt;# client - client object&lt;BR /&gt;# userServices - the list of services which will be processed and added to server&lt;BR /&gt;# userServiceType - the type of service which should be processed&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedServicesMap dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processServices(client, userServices, userServiceType):&lt;BR /&gt;printMessageProcessObjects(userServiceType + " services")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedServicesMap = {}&lt;BR /&gt;serverServicesMap = {}&lt;BR /&gt;serverServicesMapGlobal = {}&lt;BR /&gt;serverServicesMapLocal = {}&lt;BR /&gt;printStatus(None, "reading " + userServiceType + " services from server")&lt;BR /&gt;res_get_services = client.api_query("show-services-" + userServiceType)&lt;BR /&gt;printStatus(res_get_services, None)&lt;BR /&gt;for serverService in res_get_services.data:&lt;BR /&gt;mergedServicesMap[serverService['name']] = serverService['uid']&lt;BR /&gt;key = provideServerServiceKey(serverService)&lt;BR /&gt;isServiceReplacing = False&lt;BR /&gt;if 'port' in serverService and ('protocol' not in serverService or serverService['protocol'] == 'null'):&lt;BR /&gt;isServiceReplacing = True&lt;BR /&gt;if isServerObjectGlobal(serverService) and (key not in serverServicesMapGlobal or isServiceReplacing):&lt;BR /&gt;serverServicesMapGlobal[key] = (serverService['name'], serverService['uid'])&lt;BR /&gt;elif isServerObjectLocal(serverService) and (key not in serverServicesMapLocal or isServiceReplacing):&lt;BR /&gt;serverServicesMapLocal[key] = (serverService['name'], serverService['uid'])&lt;BR /&gt;elif not isServerObjectGlobal(serverService) and not isServerObjectLocal(serverService) and (&lt;BR /&gt;key not in serverServicesMap or isServiceReplacing):&lt;BR /&gt;serverServicesMap[key] = (serverService['name'], serverService['uid'])&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;if sys.version_info &amp;gt;= (3, 0):&lt;BR /&gt;serverServicesMap = serverServicesMap.copy()&lt;BR /&gt;if isReplaceFromGlobalFirst:&lt;BR /&gt;serverServicesMap.update(serverServicesMapLocal)&lt;BR /&gt;serverServicesMap.update(serverServicesMapGlobal)&lt;BR /&gt;else:&lt;BR /&gt;serverServicesMap.update(serverServicesMapGlobal)&lt;BR /&gt;serverServicesMap.update(serverServicesMapLocal)&lt;BR /&gt;else:&lt;BR /&gt;if isReplaceFromGlobalFirst:&lt;BR /&gt;serverServicesMap = dict(&lt;BR /&gt;serverServicesMap.items() + serverServicesMapLocal.items() + serverServicesMapGlobal.items())&lt;BR /&gt;else:&lt;BR /&gt;serverServicesMap = dict(&lt;BR /&gt;serverServicesMap.items() + serverServicesMapGlobal.items() + serverServicesMapLocal.items())&lt;BR /&gt;if len(userServices) == 0:&lt;BR /&gt;return mergedServicesMap&lt;BR /&gt;for userService in userServices:&lt;BR /&gt;printStatus(None, "processing " + userServiceType + " service: " + userService['Name'])&lt;BR /&gt;userServiceNameInitial = userService['Name']&lt;BR /&gt;key = ""&lt;BR /&gt;duplicationValueMessagePostfix = ""&lt;BR /&gt;if 'Port' in userService:&lt;BR /&gt;key = userService['Port']&lt;BR /&gt;duplicationValueMessagePostfix = "port: " + userService['Port']&lt;BR /&gt;elif 'Type' in userService:&lt;BR /&gt;key = userService['Type']&lt;BR /&gt;duplicationValueMessagePostfix = "type: " + userService['Type']&lt;BR /&gt;if 'Code' in userService and userService['Code'] != 'null':&lt;BR /&gt;key += "_" + userService['Code']&lt;BR /&gt;duplicationValueMessagePostfix = "type / code: " + userService['Type'] + " / " + userService['Code']&lt;BR /&gt;elif 'IpProtocol' in userService:&lt;BR /&gt;key = userService['IpProtocol']&lt;BR /&gt;duplicationValueMessagePostfix = "ip-protocol: " + userService['IpProtocol']&lt;BR /&gt;if key in serverServicesMap:&lt;BR /&gt;printStatus(None, None,&lt;BR /&gt;"More than one " + userServiceType + " service has the same " + duplicationValueMessagePostfix)&lt;BR /&gt;mergedServicesMap[userServiceNameInitial] = serverServicesMap[key][1]&lt;BR /&gt;printStatus(None, "REPORT: " + "CP object " + serverServicesMap[key][&lt;BR /&gt;0] + " is used instead of " + userServiceNameInitial)&lt;BR /&gt;else:&lt;BR /&gt;userServiceNamePostfix = 1&lt;BR /&gt;serverServicesNames = [serverServiceNameUid[0] for serverServiceNameUid in serverServicesMap.values()]&lt;BR /&gt;if userService['Name'] in serverServicesNames:&lt;BR /&gt;printStatus(None, None, "More than one object named '" + userService['Name'] + "' exists.")&lt;BR /&gt;while userService['Name'] in serverServicesNames:&lt;BR /&gt;userService['Name'] = userServiceNameInitial + '_' + str(userServiceNamePostfix)&lt;BR /&gt;userServiceNamePostfix += 1&lt;BR /&gt;payload = {}&lt;BR /&gt;payload["name"] = userService['Name']&lt;BR /&gt;payload["comments"] = userService['Comments']&lt;BR /&gt;payload["tags"] = userService['Tags']&lt;BR /&gt;payload["ignore-warnings"] = True&lt;BR /&gt;if 'Port' in userService:&lt;BR /&gt;payload["port"] = userService['Port']&lt;BR /&gt;payload["source-port"] = userService['SourcePort']&lt;BR /&gt;payload["session-timeout"] = userService['SessionTimeout']&lt;BR /&gt;elif 'Type' in userService:&lt;BR /&gt;payload["icmp-type"] = userService['Type']&lt;BR /&gt;if 'Code' in userService and userService['Code'] != 'null':&lt;BR /&gt;payload["icmp-code"] = userService['Code']&lt;BR /&gt;elif 'IpProtocol' in userService:&lt;BR /&gt;payload["ip-protocol"] = userService['IpProtocol']&lt;BR /&gt;payload["match-for-any"] = True&lt;BR /&gt;addedService = addUserObjectToServer(client, "add-service-" + userServiceType, payload,&lt;BR /&gt;userServiceNamePostfix)&lt;BR /&gt;if addedService is not None:&lt;BR /&gt;mergedServicesMap[userServiceNameInitial] = addedService['uid']&lt;BR /&gt;key = provideServerServiceKey(addedService)&lt;BR /&gt;serverServicesMap[key] = (addedService['name'], addedService['uid'])&lt;BR /&gt;printStatus(None, "REPORT: " + userServiceNameInitial + " is added as " + addedService['name'])&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, False)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userServiceNameInitial + ' is not added.')&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedServicesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Service Groups&lt;BR /&gt;# adjusting the name if service group with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# client - client object&lt;BR /&gt;# userServicesGroups - the list of service groups which will be processed and added to server&lt;BR /&gt;# mergedServicesMap - map of service objects which will be used for replacing&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedServicesGroupsNamesMap dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processServicesGroups(client, userServicesGroups, mergedServicesMap):&lt;BR /&gt;printMessageProcessObjects("services groups")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedServicesGroupsNamesMap = {}&lt;BR /&gt;if len(userServicesGroups) == 0:&lt;BR /&gt;return mergedServicesGroupsNamesMap&lt;BR /&gt;for userServicesGroup in userServicesGroups:&lt;BR /&gt;printStatus(None, "processing services group: " + userServicesGroup['Name'])&lt;BR /&gt;userServicesGroupNameInitial = userServicesGroup['Name']&lt;BR /&gt;addedServicesGroup = processGroupWithMembers(client, "add-service-group", userServicesGroup, mergedServicesMap,&lt;BR /&gt;mergedServicesGroupsNamesMap, False)&lt;BR /&gt;if addedServicesGroup is not None:&lt;BR /&gt;mergedServicesGroupsNamesMap[userServicesGroupNameInitial] = addedServicesGroup['name']&lt;BR /&gt;if 'errors' in addedServicesGroup:&lt;BR /&gt;if 'More than one object' in addedServicesGroup['errors'][0]['message']:&lt;BR /&gt;printStatus(None, "REPORT: Using the existing object '{}'".format(addedServicesGroup['name']))&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userServicesGroupNameInitial + " is added as " + addedServicesGroup['name'])&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, True)&lt;BR /&gt;userServicesGroup["Name"] = addedServicesGroup['name']&lt;BR /&gt;processGroupWithMembers(client, "add-service-group", userServicesGroup, mergedServicesMap,&lt;BR /&gt;mergedServicesGroupsNamesMap, True)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userServicesGroupNameInitial + " is not added.")&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedServicesGroupsNamesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Time Groups&lt;BR /&gt;# adjusting the name if time group with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# client - client object&lt;BR /&gt;# userTimesGroups - the list of time groups which will be processed and added to server&lt;BR /&gt;# mergedTimesNamesMap - the list of the time names&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedTimesGroupsNamesMap dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processTimesGroups(client, userTimesGroups, mergedTimesNamesMap):&lt;BR /&gt;printMessageProcessObjects("times groups")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedTimesGroupsNamesMap = {}&lt;BR /&gt;if len(userTimesGroups) == 0:&lt;BR /&gt;return mergedTimesGroupsNamesMap&lt;BR /&gt;for userTimesGroup in userTimesGroups:&lt;BR /&gt;printStatus(None, "processing times group: " + userTimesGroup['Name'])&lt;BR /&gt;userTimesGroupNameInitial = userTimesGroup['Name']&lt;BR /&gt;addedTimesGroup = processGroupWithMembers(client, "add-time-group", userTimesGroup, mergedTimesNamesMap,&lt;BR /&gt;mergedTimesGroupsNamesMap, False)&lt;BR /&gt;if addedTimesGroup is not None:&lt;BR /&gt;mergedTimesGroupsNamesMap[userTimesGroupNameInitial] = addedTimesGroup['name']&lt;BR /&gt;if 'errors' in addedTimesGroup:&lt;BR /&gt;if 'More than one object' in addedTimesGroup['errors'][0]['message']:&lt;BR /&gt;printStatus(None, "REPORT: Using the existing object '{}'".format(addedTimesGroup['name']))&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userTimesGroupNameInitial + " is added as " + addedTimesGroup['name'])&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, True)&lt;BR /&gt;userTimesGroup["Name"] = addedTimesGroup['name']&lt;BR /&gt;processGroupWithMembers(client, "add-time-group", userTimesGroup, mergedTimesNamesMap,&lt;BR /&gt;mergedTimesGroupsNamesMap, True)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userTimesGroupNameInitial + ' is not added.')&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedTimesGroupsNamesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Time objects&lt;BR /&gt;# adjusting the name if time object with the name exists at server: &amp;lt;initial_object_name&amp;gt;_&amp;lt;postfix&amp;gt;&lt;BR /&gt;# client - client object&lt;BR /&gt;# userTimes - the list of time objects which will be processed and added to server&lt;BR /&gt;# ---&lt;BR /&gt;# returns: mergedTimesNamesMap dictionary&lt;BR /&gt;# the map contains name of user's object (key) and name of resulting object (value)&lt;BR /&gt;def processTimes(client, userTimes):&lt;BR /&gt;printMessageProcessObjects("times")&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;mergedTimesNamesMap = {}&lt;BR /&gt;payload = {}&lt;BR /&gt;if len(userTimes) == 0:&lt;BR /&gt;return mergedTimesNamesMap&lt;BR /&gt;weekdays = {0: "Sun", 1: "Mon", 2: "Tue", 3: "Wed", 4: "Thu", 5: "Fri", 6: "Sat"}&lt;BR /&gt;for userTime in userTimes:&lt;BR /&gt;printStatus(None, "processing time: " + userTime['Name'])&lt;BR /&gt;userTimeNameInitial = userTime['Name']&lt;/P&gt;&lt;P&gt;payload["name"] = userTime['Name']&lt;BR /&gt;payload["comments"] = userTime['Comments']&lt;/P&gt;&lt;P&gt;payload["start-now"] = userTime['StartNow']&lt;BR /&gt;payload["start"] = {&lt;BR /&gt;"date": userTime['StartDate'],&lt;BR /&gt;"time": userTime['StartTime']&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;payload["end-never"] = userTime['EndNever']&lt;BR /&gt;payload["end"] = {&lt;BR /&gt;"date": userTime['EndDate'],&lt;BR /&gt;"time": userTime['EndTime']&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;payload["hours-ranges"] = [&lt;BR /&gt;{&lt;BR /&gt;"enabled": userTime['HoursRangesEnabled_1'],&lt;BR /&gt;"from": userTime['HoursRangesFrom_1'] if userTime['HoursRangesFrom_1'] is not None else "00:00",&lt;BR /&gt;"to": userTime['HoursRangesTo_1'] if userTime['HoursRangesTo_1'] is not None else "00:00",&lt;BR /&gt;"index": 1&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"enabled": userTime['HoursRangesEnabled_2'],&lt;BR /&gt;"from": userTime['HoursRangesFrom_2'] if userTime['HoursRangesFrom_2'] is not None else "00:00",&lt;BR /&gt;"to": userTime['HoursRangesTo_2'] if userTime['HoursRangesTo_2'] is not None else "00:00",&lt;BR /&gt;"index": 2&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"enabled": userTime['HoursRangesEnabled_3'],&lt;BR /&gt;"from": userTime['HoursRangesFrom_3'] if userTime['HoursRangesFrom_3'] is not None else "00:00",&lt;BR /&gt;"to": userTime['HoursRangesTo_3'] if userTime['HoursRangesTo_3'] is not None else "00:00",&lt;BR /&gt;"index": 3&lt;BR /&gt;}&lt;BR /&gt;]&lt;/P&gt;&lt;P&gt;daysNames = [] # list of weekdays names e.g. "Sun", "Mon"...&lt;BR /&gt;# weekdays are presented as [1,2,3.. ] in userTime['RecurrenceWeekdays']&lt;BR /&gt;for day in userTime['RecurrenceWeekdays']:&lt;BR /&gt;daysNames.append(weekdays[day])&lt;/P&gt;&lt;P&gt;payload["recurrence"] = {&lt;BR /&gt;"pattern": "Daily" if userTime['RecurrencePattern'] == 1 else (&lt;BR /&gt;"Weekly" if userTime['RecurrencePattern'] == 2 else (&lt;BR /&gt;"Monthly" if userTime['RecurrencePattern'] == 3 else None)),&lt;BR /&gt;"weekdays": daysNames&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;payload["tags"] = userTime['Tags']&lt;/P&gt;&lt;P&gt;addedTime = addUserObjectToServer(&lt;BR /&gt;client,&lt;BR /&gt;"add-time",&lt;BR /&gt;payload&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;if addedTime is not None:&lt;BR /&gt;mergedTimesNamesMap[userTimeNameInitial] = addedTime['name']&lt;BR /&gt;printStatus(None, "REPORT: " + userTimeNameInitial + " is added as " + addedTime['name'])&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, False)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: " + userTimeNameInitial + ' is not added.')&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;BR /&gt;return mergedTimesNamesMap&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Access Rules&lt;BR /&gt;# the rules is added in back order: the last item of list goes first and the first item goes last&lt;BR /&gt;# client - client object&lt;BR /&gt;# userRules - the list of access rules which will be processed and added to server&lt;BR /&gt;# userLayerName - the name of layer where access rules will be added&lt;BR /&gt;# skipCleanUpRule - the flag which indicates to exclude "Clean up" rule from layer or not; "Clean up" rule is the last rule in the layer always&lt;BR /&gt;# mergedNetworkObjectsMap - map of all network objects (groups is included) which will be used for replacing&lt;BR /&gt;# mergedServiceObjectsMap - map of all services objects (groups is included) which will be used for replacing&lt;BR /&gt;# mergedTimesGroupsNamesMap - map of time groups objects which will be used for replacing&lt;BR /&gt;# ---&lt;BR /&gt;# returns: nothing&lt;BR /&gt;def addAccessRules(client, userRules, userLayerName, skipCleanUpRule, mergedNetworkObjectsMap, mergedServiceObjectsMap,&lt;BR /&gt;mergedTimesGroupsNamesMap, mergedTimesNamesMap):&lt;BR /&gt;if userRules is not None:&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;printStatus(None, "processing access rules to " + userLayerName + " layer")&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;userRulesStartPosition = -2 if skipCleanUpRule else -1&lt;BR /&gt;# userRules[userRulesStartPosition::-1]:&lt;BR /&gt;# -1 - minus means to iterate backwards, 1 means step&lt;BR /&gt;# userRulesStartPosition - start point, length of list "- userRulesStartPosition" because reverse mode is specified&lt;BR /&gt;# end point is not specified - all elements&lt;BR /&gt;for i, userRule in enumerate(userRules[userRulesStartPosition::-1]):&lt;BR /&gt;printStatus(None, "processing access rule: #" + str(len(userRules) - i) + ", " + (&lt;BR /&gt;userRule['Name'] if userRule['Name'] is not None else ""))&lt;BR /&gt;# JSON access rules contain "action" as number&lt;BR /&gt;# "action" number points to the next list of values from SmartMove:&lt;BR /&gt;# 0 = Accept&lt;BR /&gt;# 1 = Drop&lt;BR /&gt;# 2 = Reject&lt;BR /&gt;# 3 = SubPolicy&lt;BR /&gt;actions = {0: "accept", 1: "drop", 2: "reject", 3: "apply layer"}&lt;BR /&gt;sources = []&lt;BR /&gt;for source in userRule['Source']:&lt;BR /&gt;sourceName = source['Name']&lt;BR /&gt;sourceName = mergedNetworkObjectsMap[&lt;BR /&gt;sourceName] if sourceName in mergedNetworkObjectsMap else sourceName&lt;BR /&gt;sources.append(sourceName)&lt;BR /&gt;destinations = []&lt;BR /&gt;for destination in userRule['Destination']:&lt;BR /&gt;destinationName = destination['Name']&lt;BR /&gt;destinationName = mergedNetworkObjectsMap[&lt;BR /&gt;destinationName] if destinationName in mergedNetworkObjectsMap else destinationName&lt;BR /&gt;destinations.append(destinationName)&lt;BR /&gt;services = []&lt;BR /&gt;for service in userRule['Service']:&lt;BR /&gt;serviceName = service['Name']&lt;BR /&gt;serviceName = mergedServiceObjectsMap[&lt;BR /&gt;serviceName] if serviceName in mergedServiceObjectsMap else serviceName&lt;BR /&gt;services.append(serviceName)&lt;BR /&gt;times = []&lt;BR /&gt;for time in userRule['Time']:&lt;BR /&gt;timeName = time['Name']&lt;/P&gt;&lt;P&gt;# support of time-ranges along with time-groups is added&lt;BR /&gt;if timeName in mergedTimesGroupsNamesMap:&lt;BR /&gt;timeName = mergedTimesGroupsNamesMap[timeName]&lt;BR /&gt;elif timeName in mergedTimesNamesMap:&lt;BR /&gt;timeName = mergedTimesNamesMap[timeName]&lt;BR /&gt;else:&lt;BR /&gt;timeName = timeName&lt;BR /&gt;# timeName = mergedTimesGroupsNamesMap[timeName] if timeName in mergedTimesGroupsNamesMap else timeName&lt;/P&gt;&lt;P&gt;times.append(timeName)&lt;BR /&gt;payload = {&lt;BR /&gt;"layer": userRule['Layer'],&lt;BR /&gt;"position": "top",&lt;BR /&gt;"name": userRule['Name'],&lt;BR /&gt;"action": actions[userRule['Action']],&lt;BR /&gt;"destination": destinations,&lt;BR /&gt;"destination-negate": userRule['DestinationNegated'],&lt;BR /&gt;"enabled": userRule['Enabled'],&lt;BR /&gt;"service": services,&lt;BR /&gt;"source": sources,&lt;BR /&gt;"source-negate": userRule['SourceNegated'],&lt;BR /&gt;"time": times,&lt;BR /&gt;"track": {"type": "None" if userRule['Track'] == 0 else "Log"},&lt;BR /&gt;"comments": userRule['Comments']&lt;BR /&gt;}&lt;BR /&gt;if userRule['Action'] == 3:&lt;BR /&gt;payload["inline-layer"] = userRule['SubPolicyName']&lt;BR /&gt;if userRule['ConversionComments'].strip() != "":&lt;BR /&gt;payload["custom-fields"] = {"field-1": userRule['ConversionComments']}&lt;BR /&gt;addedRule = addUserObjectToServer(client, "add-access-rule", payload, changeName=False)&lt;BR /&gt;if addedRule is not None:&lt;BR /&gt;printStatus(None, "REPORT: access rule is added")&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, False)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: access rule is not added")&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishUpdate(publishCounter, True)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint Package with Layers and Access Rules&lt;BR /&gt;# client - client object&lt;BR /&gt;# userPackage - the package which contains layers and access rules&lt;BR /&gt;# mergedNetworkObjectsMap - map of all network objects (groups is included) which will be used for replacing&lt;BR /&gt;# mergedServiceObjectsMap - map of all services objects (groups is included) which will be used for replacing&lt;BR /&gt;# mergedTimesGroupsNamesMap - map of time groups objects which will be used for replacing&lt;BR /&gt;# ---&lt;BR /&gt;# returns: added package in JSON format&lt;BR /&gt;def processPackage(client, userPackage, mergedNetworkObjectsMap, mergedServiceObjectsMap, mergedTimesGroupsNamesMap,&lt;BR /&gt;mergedTimesNamesMap):&lt;BR /&gt;printMessageProcessObjects("package")&lt;BR /&gt;allExistingLayers = {}&lt;BR /&gt;addedPackage = None&lt;BR /&gt;if userPackage is not None:&lt;BR /&gt;original_package_name = userPackage['Name']&lt;BR /&gt;userPackage['Name'] = userPackage['Name'] + "_" + str(uuid.uuid4().hex[:3].upper())&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;printStatus(None, "processing package: " + userPackage['Name'])&lt;BR /&gt;addedPackage = addUserObjectToServer(&lt;BR /&gt;client,&lt;BR /&gt;"add-package",&lt;BR /&gt;{&lt;BR /&gt;"name": userPackage['Name'],&lt;BR /&gt;"threat-prevention": False,&lt;BR /&gt;"tags": userPackage['Tags']&lt;BR /&gt;},&lt;BR /&gt;changeName=False&lt;BR /&gt;)&lt;BR /&gt;if addedPackage is None:&lt;BR /&gt;printStatus(None, "REPORT: " + userPackage['Name'] + " package is not added")&lt;BR /&gt;return addedPackage&lt;BR /&gt;printStatus(None, "REPORT: " + userPackage['Name'] + " package is added")&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, True)&lt;BR /&gt;if userPackage['SubPolicies'] is not None:&lt;BR /&gt;for userSubLayer in userPackage['SubPolicies']:&lt;BR /&gt;originalName = userSubLayer['Name']&lt;BR /&gt;userSubLayer['Name'] = userSubLayer['Name'] + "_" + str(uuid.uuid4().hex[:3].upper())&lt;BR /&gt;allExistingLayers[originalName] = userSubLayer['Name']&lt;BR /&gt;for rule in userSubLayer['Rules']:&lt;BR /&gt;rule['Layer'] = userSubLayer['Name']&lt;BR /&gt;if rule['SubPolicyName'] != "":&lt;BR /&gt;rule['SubPolicyName'] = allExistingLayers[rule['SubPolicyName']]&lt;BR /&gt;printStatus(None, "processing access layer: " + userSubLayer['Name'])&lt;/P&gt;&lt;P&gt;addedSubLayer = addUserObjectToServer(&lt;BR /&gt;client,&lt;BR /&gt;"add-access-layer",&lt;BR /&gt;{&lt;BR /&gt;"name": userSubLayer['Name'],&lt;BR /&gt;"add-default-rule": False,&lt;BR /&gt;"applications-and-url-filtering": userSubLayer['ApplicationsAndUrlFiltering'],&lt;BR /&gt;"comments": userSubLayer['Comments'],&lt;BR /&gt;"tags": userSubLayer['Tags']&lt;BR /&gt;},&lt;BR /&gt;changeName=False&lt;BR /&gt;)&lt;BR /&gt;if addedSubLayer is None:&lt;BR /&gt;printStatus(None, "REPORT: " + userSubLayer['Name'] + " layer is not added")&lt;BR /&gt;continue&lt;BR /&gt;printStatus(None, "REPORT: " + userSubLayer['Name'] + " layer is added")&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, True)&lt;BR /&gt;addAccessRules(client, userSubLayer['Rules'], userSubLayer['Name'], False, mergedNetworkObjectsMap,&lt;BR /&gt;mergedServiceObjectsMap, mergedTimesGroupsNamesMap, mergedTimesNamesMap)&lt;BR /&gt;if userPackage['ParentLayer'] is not None:&lt;BR /&gt;userPackage['ParentLayer']['Name'] = userPackage['ParentLayer']['Name'].replace(original_package_name,&lt;BR /&gt;userPackage['Name'])&lt;BR /&gt;for parentRule in userPackage['ParentLayer']['Rules']:&lt;BR /&gt;parentRule['Layer'] = userPackage['ParentLayer']['Name']&lt;BR /&gt;if parentRule['SubPolicyName'] != "":&lt;BR /&gt;parentRule['SubPolicyName'] = allExistingLayers[parentRule['SubPolicyName']]&lt;BR /&gt;addAccessRules(client, userPackage['ParentLayer']['Rules'], "parent", True, mergedNetworkObjectsMap,&lt;BR /&gt;mergedServiceObjectsMap, mergedTimesGroupsNamesMap, mergedTimesNamesMap)&lt;BR /&gt;return addedPackage&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# resolver for nat method type&lt;BR /&gt;# typeValue - number of type [ static, hide, nat64, nat46 ]&lt;BR /&gt;def getMethodType(typeValue):&lt;BR /&gt;_type = "static"&lt;BR /&gt;if typeValue == 1:&lt;BR /&gt;_type = "hide"&lt;BR /&gt;elif typeValue == 2:&lt;BR /&gt;_type = "nat64"&lt;BR /&gt;elif typeValue == 3:&lt;BR /&gt;_type = "nat46"&lt;BR /&gt;return _type&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# processing and adding to server the CheckPoint NAT rules&lt;BR /&gt;# NAT rules are added if package has been added&lt;BR /&gt;# client - client object&lt;BR /&gt;# addedPackage - added package in JSON format&lt;BR /&gt;# userNatRules - the list of NAT rules which will be processed and added to server&lt;BR /&gt;# mergedNetworkObjectsMap - map of all network objects (groups is included) which will be used for replacing&lt;BR /&gt;# mergedServiceObjectsMap - map of all services objects (groups is included) which will be used for replacing&lt;BR /&gt;# ---&lt;BR /&gt;# returns: nothing&lt;BR /&gt;def processNatRules(client, addedPackage, userNatRules, mergedNetworkObjectsMap, mergedServiceObjectsMap):&lt;BR /&gt;printMessageProcessObjects("nat rules")&lt;BR /&gt;if addedPackage is None:&lt;BR /&gt;printStatus(None, "REPORT: nat rules can not been added because package was not added")&lt;BR /&gt;return&lt;BR /&gt;publishCounter = 0&lt;BR /&gt;for i, userNatRule in enumerate(userNatRules):&lt;BR /&gt;userNatRule['Package'] = addedPackage['name']&lt;BR /&gt;printStatus(None, "processing nat rule: #" + str(i))&lt;BR /&gt;sourceOrig = ""&lt;BR /&gt;if userNatRule['Source'] is not None:&lt;BR /&gt;sourceOrig = userNatRule['Source']['Name']&lt;BR /&gt;sourceOrig = mergedNetworkObjectsMap[sourceOrig] if sourceOrig in mergedNetworkObjectsMap else sourceOrig&lt;BR /&gt;destinationOrig = ""&lt;BR /&gt;if userNatRule['Destination'] is not None:&lt;BR /&gt;destinationOrig = userNatRule['Destination']['Name']&lt;BR /&gt;destinationOrig = mergedNetworkObjectsMap[&lt;BR /&gt;destinationOrig] if destinationOrig in mergedNetworkObjectsMap else destinationOrig&lt;BR /&gt;serviceOrig = ""&lt;BR /&gt;if userNatRule['Service'] is not None:&lt;BR /&gt;serviceOrig = userNatRule['Service']['Name']&lt;BR /&gt;serviceOrig = mergedServiceObjectsMap[&lt;BR /&gt;serviceOrig] if serviceOrig in mergedServiceObjectsMap else serviceOrig&lt;BR /&gt;sourceTrans = ""&lt;BR /&gt;if userNatRule['TranslatedSource'] is not None:&lt;BR /&gt;sourceTrans = userNatRule['TranslatedSource']['Name']&lt;BR /&gt;sourceTrans = mergedNetworkObjectsMap[&lt;BR /&gt;sourceTrans] if sourceTrans in mergedNetworkObjectsMap else sourceTrans&lt;BR /&gt;destinationTrans = ""&lt;BR /&gt;if userNatRule['TranslatedDestination'] is not None:&lt;BR /&gt;destinationTrans = userNatRule['TranslatedDestination']['Name']&lt;BR /&gt;destinationTrans = mergedNetworkObjectsMap[&lt;BR /&gt;destinationTrans] if destinationTrans in mergedNetworkObjectsMap else destinationTrans&lt;BR /&gt;serviceTrans = ""&lt;BR /&gt;if userNatRule['TranslatedService'] is not None:&lt;BR /&gt;serviceTrans = userNatRule['TranslatedService']['Name']&lt;BR /&gt;serviceTrans = mergedServiceObjectsMap[&lt;BR /&gt;serviceTrans] if serviceTrans in mergedServiceObjectsMap else serviceTrans&lt;BR /&gt;payload = {&lt;BR /&gt;"package": userNatRule['Package'],&lt;BR /&gt;"position": "bottom",&lt;BR /&gt;"comments": userNatRule['Comments'],&lt;BR /&gt;"enabled": userNatRule['Enabled'],&lt;BR /&gt;"method": getMethodType(userNatRule['Method']),&lt;BR /&gt;"original-source": sourceOrig,&lt;BR /&gt;"original-destination": destinationOrig,&lt;BR /&gt;"original-service": serviceOrig,&lt;BR /&gt;"translated-source": sourceTrans,&lt;BR /&gt;"translated-destination": destinationTrans,&lt;BR /&gt;"translated-service": serviceTrans&lt;BR /&gt;}&lt;BR /&gt;addedNatRule = addUserObjectToServer(client, "add-nat-rule", payload, changeName=False)&lt;BR /&gt;if addedNatRule is not None:&lt;BR /&gt;printStatus(None, "REPORT: nat rule is added")&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, False)&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "REPORT: nat rule is not added")&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;publishCounter = publishUpdate(publishCounter, True)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# START&lt;/P&gt;&lt;P&gt;args_parser = argparse.ArgumentParser()&lt;/P&gt;&lt;P&gt;args_parser._optionals.title = "arguments"&lt;/P&gt;&lt;P&gt;args_parser.add_argument('-m', '--management', default='127.0.0.1',&lt;BR /&gt;help="Management server IP address or name. Default: 127.0.0.1")&lt;BR /&gt;args_parser.add_argument('--port', type=int,&lt;BR /&gt;help="Server port. Default: 443")&lt;BR /&gt;mxg = args_parser.add_mutually_exclusive_group(required=True)&lt;BR /&gt;mxg.add_argument('-r', '--root', action="store_true",&lt;BR /&gt;help="For a logged in administrator that wants to receive SuperUser permissions. Additional login credentials are not required.")&lt;BR /&gt;mxg.add_argument('-k', '--key',&lt;BR /&gt;help="api_key")&lt;BR /&gt;mxg.add_argument('-u', '--user',&lt;BR /&gt;help="User name")&lt;BR /&gt;args_parser.add_argument('-p', '--password',&lt;BR /&gt;help="User password")&lt;BR /&gt;args_parser.add_argument('-f', '--file', default='cp_objects.json',&lt;BR /&gt;help="JSON file with CheckPoint Objects. Default: cp_objects.json")&lt;BR /&gt;args_parser.add_argument('-c', '--context', default='web_api',&lt;BR /&gt;help="Context of WebAPI.")&lt;BR /&gt;args_parser.add_argument('-t', '--threshold', type=int, default=100,&lt;BR /&gt;help="Parameter specifies maximum number of Check Point objects/rules to add before starting publish operation. Default: 100")&lt;BR /&gt;args_parser.add_argument('-d', '--domain', default=None,&lt;BR /&gt;help="The name/uid of the domain you want to log into in an MDS environment.")&lt;BR /&gt;args_parser.add_argument('--replace-from-global-first', default="false",&lt;BR /&gt;help="The argument indicates that SmartConnector should use 'Global' objects at first, by default it uses 'Local' objects. [true, false]")&lt;BR /&gt;args_parser.add_argument('--reuse-group-name', default="false",&lt;BR /&gt;help="The argument indicates that SmartConnector should use reuse the group by name instead "&lt;BR /&gt;"of creating a new group, take cautions. [true, false]")&lt;/P&gt;&lt;P&gt;args = args_parser.parse_args()&lt;/P&gt;&lt;P&gt;file_name_log = "smartconnector"&lt;BR /&gt;if args.file != "cp_objects.json":&lt;BR /&gt;file_name_log += "_" + os.path.splitext(args.file)[0]&lt;BR /&gt;file_name_log += ".log"&lt;BR /&gt;if os.path.exists(file_name_log):&lt;BR /&gt;os.remove(file_name_log)&lt;BR /&gt;file_log = open(file_name_log, "w+")&lt;/P&gt;&lt;P&gt;if args.root and args.user and args.key is not None:&lt;BR /&gt;print("")&lt;BR /&gt;printStatus(None, None, "Command contains ambiguous parameters. User is unexpected when logging in as root.")&lt;BR /&gt;print("")&lt;BR /&gt;args_parser.print_help()&lt;BR /&gt;elif args.root and args.management != '127.0.0.1':&lt;BR /&gt;print("")&lt;BR /&gt;printStatus(None, None, "Command contains ambiguous parameters. Management is unexpected when logging in as root.")&lt;BR /&gt;print("")&lt;BR /&gt;args_parser.print_help()&lt;BR /&gt;elif not args.root and args.password is None and args.user is not None:&lt;BR /&gt;print("")&lt;BR /&gt;printStatus(None, None, "No password option is specified.")&lt;BR /&gt;print("")&lt;BR /&gt;args_parser.print_help()&lt;BR /&gt;elif not os.path.isfile(args.file):&lt;BR /&gt;print("")&lt;BR /&gt;printStatus(None, None, "The file does not exists")&lt;BR /&gt;print("")&lt;BR /&gt;args_parser.print_help()&lt;BR /&gt;elif args.replace_from_global_first.lower() != "true" and args.replace_from_global_first.lower() != "false":&lt;BR /&gt;print("")&lt;BR /&gt;printStatus(None, None,&lt;BR /&gt;"smartconnector.py: error: argument --replace-from-global-first: invalid boolean value: '" + args.replace_from_global_first + "'")&lt;BR /&gt;print("")&lt;BR /&gt;args_parser.print_help()&lt;BR /&gt;elif args.reuse_group_name.lower() != "true" and args.reuse_group_name.lower() != "false":&lt;BR /&gt;print("")&lt;BR /&gt;printStatus(None, None, "smartconnector.py: error: argument --reuse-group-name: invalid boolean value: '" + args.reuse_group_name + "'")&lt;BR /&gt;print("")&lt;BR /&gt;else:&lt;BR /&gt;if args.replace_from_global_first.lower() == "true":&lt;BR /&gt;isReplaceFromGlobalFirst = True&lt;BR /&gt;elif args.replace_from_global_first.lower() == "false":&lt;BR /&gt;isReplaceFromGlobalFirst = False&lt;BR /&gt;printStatus(None, "Input arguments:")&lt;BR /&gt;printStatus(None, "root flag is set" if args.root else "root flag is not set")&lt;BR /&gt;printStatus(None, "management: " + args.management)&lt;BR /&gt;printStatus(None,&lt;BR /&gt;"port: " + str(args.port) if args.port is not None else "port: is not set, default value will be used")&lt;BR /&gt;printStatus(None, "domain: " + args.domain if args.domain is not None else "domain: is not set")&lt;BR /&gt;printStatus(None, "user: " + args.user if args.user is not None else "user: is not set")&lt;BR /&gt;printStatus(None, "password: ***" if args.password is not None else "password: is not set")&lt;BR /&gt;printStatus(None, "API_KEY: " + args.key if args.key is not None else "API_KEY: is not set")&lt;BR /&gt;printStatus(None, "file: " + args.file)&lt;BR /&gt;printStatus(None, "threshold: " + str(args.threshold))&lt;BR /&gt;printStatus(None, "replace-from-global-first: " + str(isReplaceFromGlobalFirst))&lt;BR /&gt;printStatus(None, "reuse-group-name: " + str(args.reuse_group_name).lower())&lt;BR /&gt;printStatus(None, "===========================================")&lt;BR /&gt;printStatus(None, "reading and parsing processes are started for JSON file: " + args.file)&lt;BR /&gt;with open(args.file) as json_file:&lt;BR /&gt;json_data = json.load(json_file)&lt;BR /&gt;# define lists of CheckPoint Objects&lt;BR /&gt;userDomains = []&lt;BR /&gt;userHosts = []&lt;BR /&gt;userNetworks = []&lt;BR /&gt;userRanges = []&lt;BR /&gt;userNetGroups = []&lt;BR /&gt;userSimpleGateways = []&lt;BR /&gt;userZones = []&lt;BR /&gt;userServicesTcp = []&lt;BR /&gt;userServicesUdp = []&lt;BR /&gt;userServicesSctp = [] # is not used in Cisco&lt;BR /&gt;userServicesIcmp = [] # is not used in Cisco&lt;BR /&gt;userServicesOther = []&lt;BR /&gt;userServicesGroups = []&lt;BR /&gt;userTimesGroups = []&lt;BR /&gt;userTimes = []&lt;BR /&gt;userPackage = None&lt;BR /&gt;userNatRules = []&lt;BR /&gt;for jsonObject in json_data:&lt;BR /&gt;if jsonObject is None or 'TypeName' not in jsonObject:&lt;BR /&gt;continue&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_Domain':&lt;BR /&gt;userDomains.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_Host':&lt;BR /&gt;userHosts.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_Network':&lt;BR /&gt;userNetworks.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_Range':&lt;BR /&gt;userRanges.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_NetworkGroup' or jsonObject['TypeName'] == 'CheckPoint_GroupWithExclusion':&lt;BR /&gt;userNetGroups.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_SimpleGateway':&lt;BR /&gt;userSimpleGateways.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_Zone':&lt;BR /&gt;userZones.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_TcpService':&lt;BR /&gt;userServicesTcp.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_UdpService':&lt;BR /&gt;userServicesUdp.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_SctpService':&lt;BR /&gt;userServicesSctp.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_IcmpService':&lt;BR /&gt;userServicesIcmp.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_OtherService':&lt;BR /&gt;userServicesOther.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_ServiceGroup':&lt;BR /&gt;userServicesGroups.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_TimeGroup':&lt;BR /&gt;userTimesGroups.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_Time':&lt;BR /&gt;userTimes.append(jsonObject)&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_Package':&lt;BR /&gt;userPackage = jsonObject&lt;BR /&gt;if jsonObject['TypeName'] == 'CheckPoint_NAT_Rule':&lt;BR /&gt;userNatRules.append(jsonObject)&lt;/P&gt;&lt;P&gt;printStatus(None, "reading and parsing processes are completed for JSON file: " + args.file)&lt;BR /&gt;client_args = None&lt;BR /&gt;if args.port is not None:&lt;BR /&gt;client_args = APIClientArgs(server=args.management, port=args.port, context=args.context, user_agent="mgmt_cli_smartmove")&lt;BR /&gt;else:&lt;BR /&gt;client_args = APIClientArgs(server=args.management, context=args.context, user_agent="mgmt_cli_smartmove")&lt;BR /&gt;with APIClient(client_args) as client:&lt;BR /&gt;client.debug_file = "api_calls.json"&lt;BR /&gt;printStatus(None, "checking fingerprint")&lt;BR /&gt;if client.check_fingerprint() is False:&lt;BR /&gt;printStatus(None, "Could not get the server's fingerprint - Check connectivity with the server.")&lt;BR /&gt;else:&lt;BR /&gt;if args.root:&lt;BR /&gt;msg = "login as root to "&lt;BR /&gt;if args.domain is not None:&lt;BR /&gt;msg += args.domain + " domain of local server"&lt;BR /&gt;else:&lt;BR /&gt;msg += "local server"&lt;BR /&gt;printStatus(None, msg)&lt;BR /&gt;login_res = client.login_as_root(domain=args.domain)&lt;BR /&gt;elif args.user:&lt;BR /&gt;msg = "login as " + args.user + " to "&lt;BR /&gt;if args.domain is not None:&lt;BR /&gt;msg += args.domain + " domain of " + args.management + " server"&lt;BR /&gt;else:&lt;BR /&gt;msg += args.management + " server"&lt;BR /&gt;printStatus(None, msg)&lt;BR /&gt;login_res = client.login(args.user, args.password, domain=args.domain)&lt;BR /&gt;else:&lt;BR /&gt;msg = "login by api key to "&lt;BR /&gt;if args.domain is not None:&lt;BR /&gt;msg += args.domain + " domain of " + args.management + " server"&lt;BR /&gt;else:&lt;BR /&gt;msg += args.management + " server"&lt;BR /&gt;printStatus(None, msg)&lt;/P&gt;&lt;P&gt;login_res = client.login_with_api_key(args.key, domain=args.domain)&lt;/P&gt;&lt;P&gt;if login_res.success is False:&lt;BR /&gt;printStatus(None, f"Login failed: {login_res.error_message}")&lt;BR /&gt;else:&lt;BR /&gt;printStatus(None, "")&lt;BR /&gt;mergedNetworkObjectsMap = {}&lt;BR /&gt;mergedNetworkObjectsMap.update(processDomains(client, userDomains))&lt;BR /&gt;mergedNetworkObjectsMap.update(processHosts(client, userHosts))&lt;BR /&gt;mergedNetworkObjectsMap.update(processNetworks(client, userNetworks))&lt;BR /&gt;mergedNetworkObjectsMap.update(processRanges(client, userRanges))&lt;BR /&gt;mergedNetworkObjectsMap.update(processNetGroups(client, userNetGroups, mergedNetworkObjectsMap))&lt;BR /&gt;mergedNetworkObjectsMap.update(processSimpleGateways(client, userSimpleGateways))&lt;BR /&gt;mergedNetworkObjectsMap.update(processZones(client, userZones))&lt;BR /&gt;mergedServicesObjectsMap = {}&lt;BR /&gt;mergedServicesObjectsMap.update(processServices(client, userServicesTcp, "tcp"))&lt;BR /&gt;mergedServicesObjectsMap.update(processServices(client, userServicesUdp, "udp"))&lt;BR /&gt;mergedServicesObjectsMap.update(processServices(client, userServicesSctp, "sctp"))&lt;BR /&gt;mergedServicesObjectsMap.update(processServices(client, userServicesIcmp, "icmp"))&lt;BR /&gt;mergedServicesObjectsMap.update(processServices(client, userServicesOther, "other"))&lt;BR /&gt;mergedServicesObjectsMap.update(&lt;BR /&gt;processServicesGroups(client, userServicesGroups, mergedServicesObjectsMap))&lt;BR /&gt;mergedTimesMap = processTimes(client, userTimes)&lt;BR /&gt;mergedTimesGroupsMap = processTimesGroups(client, userTimesGroups, mergedTimesMap)&lt;BR /&gt;addedPackage = processPackage(client, userPackage, mergedNetworkObjectsMap, mergedServicesObjectsMap,&lt;BR /&gt;mergedTimesGroupsMap, mergedTimesMap)&lt;BR /&gt;processNatRules(client, addedPackage, userNatRules, mergedNetworkObjectsMap, mergedServicesObjectsMap)&lt;BR /&gt;printStatus(None, "==========")&lt;BR /&gt;file_log.close()&lt;BR /&gt;# END&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 16:29:33 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161601#M503</guid>
      <dc:creator>Neil_Deane</dc:creator>
      <dc:date>2022-11-08T16:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161602#M504</link>
      <description>&lt;P&gt;You can contact me offline &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="mailto:ofirs@checkpoint.com" target="_blank"&gt;ofirs@checkpoint.com&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 16:30:01 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161602#M504</guid>
      <dc:creator>Ofir_Shikolski</dc:creator>
      <dc:date>2022-11-08T16:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161803#M505</link>
      <description>&lt;P&gt;Thanks Ofir, your suggestion via mail worked for me.&lt;/P&gt;&lt;P&gt;In case anyone else has this problem this is what worked when running on a Management server&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on documentation I first used this and got an error&lt;/P&gt;&lt;P&gt;[Expert@hostname:0]# ./smartconnector.py -r&lt;BR /&gt;: No such file or directory&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/1030"&gt;@masher&lt;/a&gt;&amp;nbsp; your suggestion - python3 prefix, should have worked (likely a user problem here&amp;nbsp; ..)&lt;/P&gt;&lt;P&gt;[Expert@hostname:0]# python3 ./smartconnector.py -r&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "./smartconnector.py", line 12, in &amp;lt;module&amp;gt;&lt;BR /&gt;from cpapi import APIClient, APIClientArgs&lt;BR /&gt;ModuleNotFoundError: No module named 'cpapi'&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Above error is because no env variable is set for PYTHONPATH and you must download the SDK from : &lt;A href="https://github.com/CheckPointSW/cp_mgmt_api_python_sdk#sdk-usage-from-a-management-machine" target="_blank"&gt;https://github.com/CheckPointSW/cp_mgmt_api_python_sdk#sdk-usage-from-a-management-machine&lt;/A&gt; and add it to some directory on management server&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;[Expert@hostname:0]# export PYTHONPATH=$PYTHONPATH:/var/tmp/migrate/sdk/cp_mgmt_api_python_sdk-master&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Now the CLI works:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;[Expert@hostname:0]# python3 ./smartconnector.py -r&lt;BR /&gt;Input arguments:&lt;BR /&gt;root flag is set&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;lt;working&amp;gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Ofir suggests: "cp_objects_opt.json is the recommended policy – usually more optimized "&lt;/P&gt;&lt;P&gt;So ideal command is:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;python3 ./smartconnector.py -r -f cp_objects_opt.json&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 18:18:50 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/161803#M505</guid>
      <dc:creator>Neil_Deane</dc:creator>
      <dc:date>2022-11-10T18:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/163431#M507</link>
      <description>&lt;P&gt;Hi, We hade the same issue, can you share the solution??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 23:58:40 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/163431#M507</guid>
      <dc:creator>CSSBE_Avenger</dc:creator>
      <dc:date>2022-11-28T23:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/163432#M508</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/85463"&gt;@CSSBE_Avenger&lt;/a&gt;&amp;nbsp;...if you look at last reply from&amp;nbsp;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/10104"&gt;@Neil_Deane&lt;/a&gt;&amp;nbsp;, thats what worked for him.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 00:56:28 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/163432#M508</guid>
      <dc:creator>the_rock</dc:creator>
      <dc:date>2022-11-29T00:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: SmartMove usage assistance</title>
      <link>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/259534#M600</link>
      <description>&lt;P&gt;Hi, the solution worked for me.&lt;/P&gt;&lt;P&gt;There is a brief recap:&lt;/P&gt;&lt;P&gt;- Tested on R81.20&lt;/P&gt;&lt;P&gt;- download the&amp;nbsp;cp_mgmt_api_python_sdk-master.zip from&amp;nbsp;&lt;A href="https://github.com/CheckPointSW/cp_mgmt_api_python_sdk" target="_blank"&gt;https://github.com/CheckPointSW/cp_mgmt_api_python_sdk&lt;/A&gt;&amp;nbsp;(buton "code" then "Download ZIP")&lt;/P&gt;&lt;P&gt;- upload to CheckPoint management server and unpack&lt;/P&gt;&lt;P&gt;-run:&amp;nbsp;export PYTHONPATH=$PYTHONPATH:/home/admin/cp_mgmt_api_python_sdk-master (or where you have uploaded)&lt;/P&gt;&lt;P&gt;- run:python3 ./smartconnector.py -r&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2025 09:13:20 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/SmartMove/SmartMove-usage-assistance/m-p/259534#M600</guid>
      <dc:creator>Bronislav_Nemec</dc:creator>
      <dc:date>2025-10-09T09:13:20Z</dc:date>
    </item>
  </channel>
</rss>

