@@ -103,33 +103,36 @@ def cleanup_connect_string(connect_string):
103103
104104 Input:
105105 (description= (address=(protocol=tcps)(port=1522)(host=*******.oraclecloud.com))(connect_data=(service_name=someservice-in.oraclecloud.com))(security=(ssl_server_cert_dn= "CN=somewhere-in.oraclecloud.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US")) )
106+ or
107+ (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=*******.oraclecloud.com))(connect_data=(service_name=someservice-in.oraclecloud.com))(security=(ssl_server_dn_match=yes)))
106108 Output Parts:
107109 1. (description=(address=(protocol=tcps)(port=1522)(host=*******.oraclecloud.com))(connect_data=(service_name=someservice-in.oraclecloud.com))(security=(
108110 2. ssl_server_cert_dn=
109111 3. "CN=somewhere-in.oraclecloud.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US"
110112 4. )))
111113 :param connect_string:
112- :return:
114+ :return: fixed connection string without white spaces
113115 """
114116
115- toks = connect_string .split ('(description=' )
116- pattern = "(.*)(ssl_server_cert_dn=)\s*(\" .*\" )(.*)"
117117 result = ''
118- for token in toks :
119- if token .find ("(ssl_server_cert_dn=" ) > 0 :
120- match = re .search (pattern , token )
121- if match :
122- part1 = match .group (1 ).replace (' ' ,'' )
123- part2 = match .group (2 ).replace (' ' , '' )
124- # We don't want to remove the spaces from serverDN part.
125- part3 = match .group (3 )
126- part4 = match .group (4 ).replace (' ' , '' )
127- result += "(description=%s%s%s%s" % (part1 , part2 , part3 , part4 )
128- else :
129- result += token .replace (' ' , '' )
130-
131- if result == '' :
132- result = connect_string
118+ if connect_string .find ("(ssl_server_cert_dn=" ) > 0 :
119+ toks = connect_string .split ('(description=' )
120+ # can have multiples
121+ pattern = "(.*)(ssl_server_cert_dn=)\s*(\" .*\" )(.*)"
122+ for token in toks :
123+ if token .find ("(ssl_server_cert_dn=" ) > 0 :
124+ match = re .search (pattern , token )
125+ if match :
126+ part1 = match .group (1 ).replace (' ' ,'' )
127+ part2 = match .group (2 ).replace (' ' , '' )
128+ # We don't want to remove the spaces from serverDN part.
129+ part3 = match .group (3 )
130+ part4 = match .group (4 ).replace (' ' , '' )
131+ result += "(description=%s%s%s%s" % (part1 , part2 , part3 , part4 )
132+ else :
133+ result += token .replace (' ' , '' )
134+ else :
135+ result = connect_string .replace (' ' ,'' )
133136
134137 return result
135138
0 commit comments