1
1
#!/bin/python3
2
- ## Copyright (c) 2021, Oracle and/or its affiliates.
2
+ ## Copyright (c) 2021, 2024, Oracle and/or its affiliates.
3
3
4
4
##
5
5
## d e p l o y m e n t - i n i t . p y
@@ -134,9 +134,22 @@ def get_digest_authentication():
134
134
return requests .auth .HTTPDigestAuth (userName , credential )
135
135
136
136
137
- def get_service_config (serviceName ):
137
+ def get_ogg_version ():
138
+ """Retrieve the version of the Oracle GoldenGate installation"""
139
+ url = 'http://' + service_address + ':' + str (service_ports ['ServiceManager' ]) + '/services/v2/config/summary'
140
+ response = get_requests_session ().get (url , headers = rest_call_headers , auth = get_digest_authentication ())
141
+ if response .status_code == 200 :
142
+ response_json = response .json ()
143
+ if 'response' in response_json and \
144
+ 'build' in response_json ['response' ] and \
145
+ 'version' in response_json ['response' ]['build' ]:
146
+ return response_json ['response' ]['build' ]['version' ]
147
+ return None
148
+
149
+
150
+ def get_service_config (deploymentName , serviceName ):
138
151
"""Retrieve the configuration of a service from Service Manager"""
139
- url = 'http://' + service_address + ':' + str (service_ports ['ServiceManager' ]) + '/services/v2/deployments/' + os . environ [ 'OGG_DEPLOYMENT' ] + '/services/' + serviceName
152
+ url = 'http://' + service_address + ':' + str (service_ports ['ServiceManager' ]) + '/services/v2/deployments/' + deploymentName + '/services/' + serviceName
140
153
response = get_requests_session ().get (url , headers = rest_call_headers , auth = get_digest_authentication ())
141
154
if response .status_code == 200 :
142
155
response_json = response .json ()
@@ -146,9 +159,9 @@ def get_service_config(serviceName):
146
159
return None
147
160
148
161
149
- def set_service_config (serviceName , config ):
162
+ def set_service_config (deploymentName , serviceName , config ):
150
163
"""Sets the configuration of a service in Service Manager and restart the service"""
151
- url = 'http://' + service_address + ':' + str (service_ports ['ServiceManager' ]) + '/services/v2/deployments/' + os . environ [ 'OGG_DEPLOYMENT' ] + '/services/' + serviceName
164
+ url = 'http://' + service_address + ':' + str (service_ports ['ServiceManager' ]) + '/services/v2/deployments/' + deploymentName + '/services/' + serviceName
152
165
body = {
153
166
'config' : config ,
154
167
'status' : 'restart'
@@ -161,11 +174,11 @@ def set_service_config(serviceName, config):
161
174
return None
162
175
163
176
164
- def reset_service_configuration (serviceName ):
177
+ def reset_service_configuration (deploymentName , serviceName ):
165
178
"""Reset the network configuration for a service to listen on and accept connections from the service host address only"""
166
- config = get_service_config (serviceName )
179
+ config = get_service_config (deploymentName , serviceName )
167
180
config ['network' ] = get_network_config (service_ports [serviceName ])
168
- set_service_config (serviceName , config )
181
+ set_service_config (deploymentName , serviceName , config )
169
182
170
183
171
184
def option (name , value = None ):
@@ -203,8 +216,12 @@ def establish_service_manager(hasServiceManager):
203
216
option ('nonsecure' )
204
217
subprocess .call (shell_command , shell = True , env = deployment_env )
205
218
wait_for_service (service_ports ['ServiceManager' ])
219
+ version = get_ogg_version ()
220
+ if version [0 :2 ] >= '23' :
221
+ reset_service_configuration ('ServiceManager' , 'ServiceManager' )
206
222
terminate_process ('ServiceManager' )
207
- reset_servicemanager_configuration ()
223
+ if version [0 :2 ] <= '21' :
224
+ reset_servicemanager_configuration ()
208
225
209
226
return subprocess .call (os .path .join (deployment_env ['OGG_HOME' ], 'bin' , 'ServiceManager' ), env = deployment_env )
210
227
@@ -249,7 +266,7 @@ def create_ogg_deployment():
249
266
250
267
for serviceName in ('adminsrvr' , 'distsrvr' , 'recvsrvr' , 'pmsrvr' ):
251
268
wait_for_service (service_ports [serviceName ])
252
- reset_service_configuration (serviceName )
269
+ reset_service_configuration (deployment_env [ 'OGG_DEPLOYMENT' ], serviceName )
253
270
254
271
255
272
def main ():
0 commit comments