@@ -2383,24 +2383,26 @@ def connection_exists(self):
23832383 def down_connection (self ):
23842384 cmd = [self .nmcli_bin , "con" , "down" , self .conn_name ]
23852385 return self .execute_command (cmd )
2386+
23862387 def get_connection_state (self ):
23872388 """Get the current state of the connection"""
23882389 cmd = [self .nmcli_bin , "--terse" , "--fields" , "GENERAL.STATE" , "con" , "show" , self .conn_name ]
23892390 (rc , out , err ) = self .execute_command (cmd )
23902391 if rc != 0 :
23912392 raise None
23922393
2393- lines = out .strip ().split (' \n ' )
2394+ lines = out .strip ().split (" \n " )
23942395 for line in lines :
2395- if ' GENERAL.STATE' in line :
2396- state = line .split (':' )[- 1 ].strip ()
2396+ if " GENERAL.STATE" in line :
2397+ state = line .split (":" )[- 1 ].strip ()
23972398 return state
23982399 return None
23992400
24002401 def is_connection_active (self ):
24012402 """Check if the connection is currently active"""
24022403 state = self .get_connection_state ()
24032404 return state == "activated"
2405+
24042406 def up_connection (self ):
24052407 cmd = [self .nmcli_bin , "con" , "up" , self .conn_name ]
24062408 return self .execute_command (cmd )
@@ -2965,12 +2967,16 @@ def main():
29652967 if nmcli .conn_reload :
29662968 (rc , out , err ) = nmcli .reload_connection ()
29672969 if rc != 0 :
2968- module .fail_json (name = f"Error bringing up connection named { nmcli .conn_name } " , msg = err , rc = rc )
2970+ module .fail_json (
2971+ name = f"Error bringing up connection named { nmcli .conn_name } " , msg = err , rc = rc
2972+ )
29692973
29702974 if not is_active or nmcli .conn_reload :
29712975 (rc , out , err ) = nmcli .up_connection ()
29722976 if rc != 0 :
2973- module .fail_json (name = f"Error bringing up connection named { nmcli .conn_name } " , msg = err , rc = rc )
2977+ module .fail_json (
2978+ name = f"Error bringing up connection named { nmcli .conn_name } " , msg = err , rc = rc
2979+ )
29742980 result ["changed" ] = True
29752981 else :
29762982 module .fail_json (
@@ -2999,7 +3005,9 @@ def main():
29993005 if is_active or nmcli .conn_reload :
30003006 (rc , out , err ) = nmcli .down_connection ()
30013007 if rc != 0 :
3002- module .fail_json (name = f"Error bringing down connection named { nmcli .conn_name } " , msg = err , rc = rc )
3008+ module .fail_json (
3009+ name = f"Error bringing down connection named { nmcli .conn_name } " , msg = err , rc = rc
3010+ )
30033011 result ["changed" ] = True
30043012 else :
30053013 module .fail_json (msg = f"Connection { nmcli .conn_name } does not exist" )
0 commit comments