1
1
import logging
2
- import ibmsecurity .utilities .tools
2
+ import ibmsecurity .utilities .tools as _tools
3
3
import json
4
4
5
5
logger = logging .getLogger (__name__ )
@@ -29,13 +29,13 @@ def set_pw(isamAppliance, oldPassword, newPassword, sessionTimeout="30", httpsPo
29
29
"sessionTimeout" : sessionTimeout
30
30
}
31
31
if httpsPort is not None :
32
- if ibmsecurity . utilities . tools .version_compare (isamAppliance .facts ['version' ], "9.0.1.0" ) < 0 :
32
+ if _tools .version_compare (isamAppliance .facts ['version' ], "9.0.1.0" ) < 0 :
33
33
warnings .append (
34
34
"Appliance at version: {0}, httpsPort not supported. Needs 9.0.1.0 or higher. Ignoring httpsPort for this call." )
35
35
else :
36
36
json_data ['httpsPort' ] = httpsPort
37
37
else :
38
- if ibmsecurity . utilities . tools .version_compare (isamAppliance .facts ['version' ], "9.0.1.0" ) < 0 :
38
+ if _tools .version_compare (isamAppliance .facts ['version' ], "9.0.1.0" ) < 0 :
39
39
pass # Can safely ignore httpsPort
40
40
else :
41
41
warnings .append ("Default httpsPort of 443 will be set on the appliance." )
@@ -168,67 +168,56 @@ def _check(isamAppliance,
168
168
json_data ["confirmPassword" ] = v
169
169
if k in ["minHeapSize" , "maxHeapSize" , "httpPort" , "httpsPort" , "minThreads" , "maxThreads" , "maxPoolSize" , "maxFiles" , "maxFileSize" , "sshdPort" , "sessionCachePurge" , "sessionInactivityTimeout" , "sshdClientAliveInterval" , "baSessionTimeout" ]:
170
170
# int values
171
- if k == "sshdPort" and ibmsecurity . utilities . tools .version_compare (iviaVersion , "9.0.3.0" ) < 0 :
171
+ if k == "sshdPort" and _tools .version_compare (iviaVersion , "9.0.3.0" ) < 0 :
172
172
warnings .append (f"Appliance at version: { iviaVersion } , sshdPort: { v } is not supported. Needs 9.0.3.0 or higher. Ignoring sshdPort for this call." )
173
173
continue
174
- if k in ["sessionCachePurge" , "sessionInactivityTimeout" , "sshdClientAliveInterval" ] and ibmsecurity . utilities . tools .version_compare (iviaVersion , "9.0.5.0" ) < 0 :
174
+ if k in ["sessionCachePurge" , "sessionInactivityTimeout" , "sshdClientAliveInterval" ] and _tools .version_compare (iviaVersion , "9.0.5.0" ) < 0 :
175
175
warnings .append (f"Appliance at version: { iviaVersion } , { k } : { v } is not supported. Needs 9.0.5.0 or higher. Ignoring." )
176
176
continue
177
- if k in ["baSessionTimeout" ] and ibmsecurity . utilities . tools .version_compare (iviaVersion , "10.0.2.0" ) < 0 :
177
+ if k in ["baSessionTimeout" ] and _tools .version_compare (iviaVersion , "10.0.2.0" ) < 0 :
178
178
warnings .append (
179
179
f"Appliance at version: { iviaVersion } , { k } : { v } is not supported. Needs 10.0.2.0 or higher. Ignoring." )
180
180
continue
181
181
json_data [k ] = int (v )
182
182
continue
183
183
if k == "enableSSLv3" :
184
- if ibmsecurity . utilities . tools .version_compare (iviaVersion , "10.0.3.0" ) >= 0 :
184
+ if _tools .version_compare (iviaVersion , "10.0.3.0" ) >= 0 :
185
185
warnings .append (f"Appliance at version: { iviaVersion } , enableSSLv3: { v } is not supported. Needs max. 10.0.2.0. Ignoring for this call." )
186
186
continue
187
187
if k == "consoleLogLevel" :
188
188
if 'consoleLogLevel' in ret_obj ['data' ] and ret_obj ['data' ]['consoleLogLevel' ] == 'OFF' :
189
189
ret_obj ['data' ]['consoleLogLevel' ] = 'OFF'
190
190
if k == "enabledTLS" :
191
- if ibmsecurity . utilities . tools .version_compare (iviaVersion , "9.0.4.0" ) < 0 :
191
+ if _tools .version_compare (iviaVersion , "9.0.4.0" ) < 0 :
192
192
warnings .append (f"Appliance at version: { iviaVersion } , enabledTLS: { v } is not supported. Needs 9.0.4.0 or higher. Ignoring enabledTLS for this call." )
193
193
continue
194
194
if k in ["swapFileSize" , "httpProxy" ]:
195
- if ibmsecurity . utilities . tools .version_compare (iviaVersion , "9.0.5.0" ) < 0 :
195
+ if _tools .version_compare (iviaVersion , "9.0.5.0" ) < 0 :
196
196
warnings .append (f"Appliance at version: { iviaVersion } , { k } : { v } is not supported. Needs 9.0.5.0 or higher. Ignoring." )
197
197
continue
198
198
if k in ["enabledServerProtocols" , "loginHeader" , "loginMessage" , "pendingChangesLifetime" , "httpsProxy" ]:
199
- if ibmsecurity . utilities . tools .version_compare (iviaVersion , "9.0.7.0" ) < 0 :
199
+ if _tools .version_compare (iviaVersion , "9.0.7.0" ) < 0 :
200
200
warnings .append (
201
201
f"Appliance at version: { iviaVersion } , { k } : { v } is not supported. Needs 9.0.7.0 or higher. Ignoring." )
202
202
continue
203
203
if k in ["accessLogFormat" ]:
204
- if ibmsecurity . utilities . tools .version_compare (iviaVersion , "10.0.0.0" ) < 0 :
204
+ if _tools .version_compare (iviaVersion , "10.0.0.0" ) < 0 :
205
205
warnings .append (f"Appliance at version: { iviaVersion } , { k } : { v } is not supported. Needs 10.0.0.0 or higher. Ignoring." )
206
206
continue
207
207
if k in ["lmiMessageTimeout" , "validVerifyDomains" ]:
208
- if ibmsecurity . utilities . tools .version_compare (iviaVersion , "10.0.2.0" ) < 0 :
208
+ if _tools .version_compare (iviaVersion , "10.0.2.0" ) < 0 :
209
209
warnings .append (f"Appliance at version: { iviaVersion } , { k } : { v } is not supported. Needs 10.0.0.0 or higher. Ignoring." )
210
210
continue
211
211
if k == "jsVersion" :
212
- if ibmsecurity . utilities . tools .version_compare (iviaVersion , "10.0.9.0" ) < 0 :
212
+ if _tools .version_compare (iviaVersion , "10.0.9.0" ) < 0 :
213
213
warnings .append (f"Appliance at version: { iviaVersion } , { k } : { v } is not supported. Needs 10.0.9.0 or higher. Ignoring." )
214
214
continue
215
215
216
216
# Add to the json_data dict
217
217
json_data [k ] = v
218
218
219
- # Remove keys from ret_obj that are not in json_data
220
- fCurrentEntries = {k : v for k , v in ret_obj ["data" ].items () if k in json_data .keys ()}
221
- #
222
- sorted_ret_obj = json .dumps (fCurrentEntries , skipkeys = True , sort_keys = True )
223
- sorted_json_data = json .dumps (json_data , skipkeys = True , sort_keys = True )
224
- logger .debug (f"Sorted Existing Data:\n \n { sorted_ret_obj } " )
225
- logger .debug (f"Sorted Desired Data:\n \n { sorted_json_data } " )
226
- if sorted_ret_obj != sorted_json_data :
219
+ if not _tools .json_equals (ret_obj , json_data ):
227
220
logger .debug ("Admin Settings are found to be different. See above JSON for difference." )
228
- # Ensure users know how REST API handles httpsPort default value - I think everybody should know this by now
229
- # if json_data.get("httpsPort", "") == "" and ibmsecurity.utilities.tools.version_compare(isamAppliance.facts['version'],
230
- # "9.0.1.0") >= 0:
231
- # warnings.append("Default httpsPort of 443 will be set on the appliance.")
232
221
return True , warnings , json_data
233
222
else : # No changes required
234
223
return False , warnings , json_data
@@ -241,4 +230,4 @@ def compare(isamAppliance1, isamAppliance2):
241
230
ret_obj1 = get (isamAppliance1 )
242
231
ret_obj2 = get (isamAppliance2 )
243
232
244
- return ibmsecurity . utilities . tools .json_compare (ret_obj1 , ret_obj2 )
233
+ return _tools .json_compare (ret_obj1 , ret_obj2 )
0 commit comments