Dear Uri,
First, I would like to thanks you for this post, it's very usefull for us, especially for the customers that don't have yet the R80.20 running on the MGMT and GWs.
I ran the script against our MDM R80.10 however we were not able to see all the "azure" networks and then some of the azure_region groups are not populated either.
Looking on the API.ELG Files, I found these two lines (taking 1 subnet and 1 group as an example)
********************************* Creation of the azure network *********************************
ID: 3188
Address: http://127.0.0.1:50276/web_api/v1.1/add-network
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/json
Headers: {Accept=[*/*], accept-encoding=[identity], connection=[keep-alive], Content-Length=[86], content-type=[application/json], Host=[127.0.0.1:50276], User-Agent=[python-api-wrapper], X-chkp-sid=[************], X-Forwarded-For=[************], X-Forwarded-Host=[************], X-Forwarded-Host-Port=[443], X-Forwarded-Server=[************]}
Payload: {"subnet": "40.86.192.0", "name": "azure_network_40.86.192.0/18", "mask-length": "18"}
--------------------------------------
2019-08-01 08:53:12,721 INFO com.checkpoint.management.web_api_is.utils.helpers.ApiCache.:13 [qtp101599496-11543] - Cache created and initialized
2019-08-01 08:53:12,721 INFO com.checkpoint.management.web_api.web_services.WebApiEntryPoint.logRequestedCommandInfo:54 [qtp101599496-11543] - Executing [add-network] of version 1.1
2019-08-01 08:53:12,761 ERROR com.checkpoint.management.web_api.utils.WebApiCommandExceptionUtils.getErrorReply:110 [qtp101599496-11543] -
com.checkpoint.web_services.faults.ValidationRemoteFault: A blocking validation error was found: More than one network have the same IP 40.86.192.0/255.255.192.0
at sun.reflect.GeneratedConstructorAccessor463.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:437)
at org.apache.cxf.interceptor.ClientFaultConverter.processFaultDetail(ClientFaultConverter.java:182)
at org.apache.cxf.interceptor.ClientFaultConverter.handleMessage(ClientFaultConverter.java:82)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
**************** Addition of a subnet on the corresponding Region Group: ************
----------------------------
ID: 4335
Address: http://127.0.0.1:50276/web_api/v1.1/set-group
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/json
Headers: {Accept=[*/*], accept-encoding=[identity], connection=[keep-alive], Content-Length=[1089], content-type=[application/json], Host=[127.0.0.1:50276], User-Agent=[python-api-wrapper], X-chkp-sid=[********], X-Forwarded-For=[********], X-Forwarded-Host=[********], X-Forwarded-Host-Port=[443], X-Forwarded-Server=[********]}
Payload: {"name": "azure_region_canadaeast", "members": ["azure_network_40.86.192.0/18", "azure_network_40.90.147.32/27", "azure_network_104.44.93.64/27", "azure_network_40.90.138.64/27", "azure_network_52.108.232.0/23", "azure_network_52.245.32.0/22", "azure_network_52.139.64.0/18", "azure_network_40.80.40.0/22", "azure_network_52.114.164.0/22", "azure_network_13.104.154.128/25", "azure_network_40.90.17.128/28", "azure_network_40.89.0.0/19", "azure_network_40.90.130.192/28", "azure_network_52.235.0.0/18", "azure_network_52.239.164.128/26", "azure_network_52.109.96.0/22", "azure_network_52.229.64.0/18", "azure_network_20.38.121.128/25", "azure_network_40.79.217.0/24", "azure_network_52.232.128.0/21", "azure_network_40.126.11.128/25", "azure_network_52.136.22.0/24", "azure_network_40.90.156.96/27", "azure_network_40.90.140.0/27", "azure_network_40.80.240.0/20", "azure_network_40.69.96.0/19", "azure_network_20.190.139.128/25", "azure_network_52.242.0.0/18", "azure_network_52.155.0.0/19", "azure_network_104.44.95.32/28", "azure_network_20.150.1.0/25", "azure_network_52.239.190.0/25"]}
--------------------------------------
2019-08-01 09:07:45,671 INFO com.checkpoint.management.web_api_is.utils.helpers.ApiCache.:13 [qtp101599496-12497] - Cache created and initialized
2019-08-01 09:07:45,672 INFO com.checkpoint.management.web_api.web_services.WebApiEntryPoint.logRequestedCommandInfo:13 [qtp101599496-12497] - Executing [set-group] of version 1.1 (references 1)
2019-08-01 09:07:46,122 WARN com.checkpoint.management.web_api_is.utils.RemoteDetailsLevelUtils.getApiReplyObjectsByCpmObjects_aroundBody4:105 [qtp101599496-11677] - GatewayNonSupportedException was caught for object: [8c9abce5-c960-428d-a57a-0f50f2078cb8]
2019-08-01 09:07:46,223 ERROR com.checkpoint.management.web_api_is.exceptions.WebApiGeneralException.log:42 [qtp101599496-12497] - Error code: [GENERIC_ERR_OBJECT_NOT_FOUND]
2019-08-01 09:07:46,224 ERROR com.checkpoint.management.web_api_is.exceptions.WebApiGeneralException.log:43 [qtp101599496-12497] - Error message: [Requested object [azure_network_40.86.192.0/18] not found]
2019-08-01 09:07:46,224 ERROR com.checkpoint.management.web_api.utils.WebApiCommandExceptionUtils.getErrorReply:110 [qtp101599496-12497] -
com.checkpoint.management.web_api_is.exceptions.WebApiObjectNotFoundException
Looks like the issue is caused because there are many subnets which already exists on our MDM DB but with different name.
*** My question ***
Is there any way/parameter to force the creation of the duplicate entries trough the API ?
I have tested modifying the azure-py script. including the "ignore-warnings": true at the end of line 112,
-------------------------
for network_name in networks:
i=i+1
if network_name not in existing_networks:
#print str(i) + " " + network_name
res = client.api_call("add-network", {"name":network_name, "subnet": networks[network_name]["subnet"], "mask-length": networks[network_name]["mask-length"]}, "ignore-warnings": true)
if i % 50 == 0:
print "publishing " + str(i) + " out of " + str(len(networks))
res = client.api_call("publish",{})
print "Publishing last networks"
res = client.api_call("publish",{})
But I get an error saying that this parameter is not valid.
Traceback (most recent call last):
File "azure.py", line 112, in <module>
res = client.api_call("add-network", {"name":network_name, "subnet": networks[network_name]["subnet"], "mask-length": networks[network_name]["mask-length"], "ignore-warnings": true })
NameError: name 'true' is not defined
[Expert@HQEBGM0081:0]#
[Expert@HQEBGM0081:0]#
[Expert@HQEBGM0081:0]#
[Expert@HQEBGM0081:0]# vi azure.py
[Expert@HQEBGM0081:0]# /opt/CPsuite-R80/fw1/Python/bin/python azure.py
File "azure.py", line 112
res = client.api_call("add-network", {"name":network_name, "subnet": networks[network_name]["subnet"], "mask-length": networks[network_name]["mask-length"], "ignore-warnings" true })
^
thanks so much in advance!
Oscar