@@ -236,7 +236,7 @@ def add_host(module, client, host_name, host_port, host_type, timeout=180, **kwa
236
236
cfg ['members' ].append (new_host )
237
237
admin_db .command ('replSetReconfig' , cfg )
238
238
return
239
- except (OperationFailure , AutoReconnect ), e :
239
+ except (OperationFailure , AutoReconnect ) as e :
240
240
timeout = timeout - 5
241
241
if timeout <= 0 :
242
242
module .fail_json (msg = 'reached timeout while waiting for rs.reconfig(): %s' % str (e ))
@@ -265,7 +265,7 @@ def remove_host(module, client, host_name, timeout=180):
265
265
else :
266
266
fail_msg = "couldn't find member with hostname: {0} in replica set members list" .format (host_name )
267
267
module .fail_json (msg = fail_msg )
268
- except (OperationFailure , AutoReconnect ), e :
268
+ except (OperationFailure , AutoReconnect ) as e :
269
269
timeout = timeout - 5
270
270
if timeout <= 0 :
271
271
module .fail_json (msg = 'reached timeout while waiting for rs.reconfig(): %s' % str (e ))
@@ -374,9 +374,9 @@ def main():
374
374
wait_for_ok_and_master (module , client )
375
375
replica_set_created = True
376
376
module .exit_json (changed = True , host_name = host_name , host_port = host_port , host_type = host_type )
377
- except OperationFailure , e :
377
+ except OperationFailure as e :
378
378
module .fail_json (msg = 'Unable to initiate replica set: %s' % str (e ))
379
- except ConnectionFailure , e :
379
+ except ConnectionFailure as e :
380
380
module .fail_json (msg = 'unable to connect to database: %s' % str (e ))
381
381
382
382
check_compatibility (module , client )
@@ -394,13 +394,13 @@ def main():
394
394
priority = float (module .params ['priority' ]),
395
395
slave_delay = module .params ['slave_delay' ],
396
396
votes = module .params ['votes' ])
397
- except OperationFailure , e :
397
+ except OperationFailure as e :
398
398
module .fail_json (msg = 'Unable to add new member to replica set: %s' % str (e ))
399
399
400
400
elif state == 'absent' :
401
401
try :
402
402
remove_host (module , client , host_name )
403
- except OperationFailure , e :
403
+ except OperationFailure as e :
404
404
module .fail_json (msg = 'Unable to remove member of replica set: %s' % str (e ))
405
405
406
406
module .exit_json (changed = True , host_name = host_name , host_port = host_port , host_type = host_type )
0 commit comments