@@ -99,7 +99,7 @@ def setup_timeout(timeout: float) -> None | float:
9999 PluginParameter (
100100 name = "username" ,
101101 label = "Username" ,
102- description = "The username of which a connection will be instantiated." ,
102+ description = "The username with which a connection will be instantiated." ,
103103 ),
104104 PluginParameter (
105105 name = "authentication_method" ,
@@ -119,21 +119,25 @@ def setup_timeout(timeout: float) -> None | float:
119119 name = "password" ,
120120 label = "Password" ,
121121 description = "Depending on your authentication method this will either be used to"
122- "connect via password to SSH or is used to decrypt the SSH private key" ,
122+ "connect via password to SSH, or to decrypt the SSH private key" ,
123123 param_type = PasswordParameterType (),
124124 default_value = "" ,
125125 ),
126126 PluginParameter (
127127 name = "path" ,
128128 label = "Path" ,
129- description = "The currently selected path withing your SSH instance." ,
129+ description = (
130+ "The currently selected path within your SSH instance."
131+ " Auto-completion starts from user home folder, use '..' for parent directory"
132+ " or '/' for root directory."
133+ ),
130134 default_value = "" ,
131135 param_type = DirectoryParameterType ("directories" , "Folder" ),
132136 ),
133137 PluginParameter (
134138 name = "input_method" ,
135139 label = "Input method" ,
136- description = "Parameter to decide weather files will be used as stdin or no input is "
140+ description = "Parameter to decide whether files will be used as stdin or no input is "
137141 "needed. If 'File input' is chosen, the input port will open for all entities with"
138142 "the FileEntitySchema." ,
139143 param_type = ChoiceParameterType (COMMAND_INPUT_CHOICES ),
@@ -142,7 +146,7 @@ def setup_timeout(timeout: float) -> None | float:
142146 name = "output_method" ,
143147 label = "Output method" ,
144148 description = "Parameter to decide which type of output the user wants. This can be "
145- "either no output, a structured process output with its own schema or "
149+ "either no output, a structured process output with its own schema, or "
146150 "a file based output" ,
147151 param_type = ChoiceParameterType (COMMAND_OUTPUT_CHOICES ),
148152 ),
@@ -164,6 +168,9 @@ def setup_timeout(timeout: float) -> None | float:
164168class ExecuteCommands (WorkflowPlugin ):
165169 """Execute commands Plugin SSH"""
166170
171+ ssh_client : paramiko .SSHClient
172+ sftp : paramiko .SFTPClient
173+
167174 def __init__ ( # noqa: PLR0913
168175 self ,
169176 hostname : str ,
@@ -191,11 +198,8 @@ def __init__( # noqa: PLR0913
191198 self .timeout = setup_timeout (timeout )
192199 self .input_ports = self .setup_input_port ()
193200 self .output_port = self .setup_output_port ()
194- self .ssh_client = paramiko .SSHClient ()
195- self .connect_ssh_client ()
196- self .sftp = self .ssh_client .open_sftp ()
197201
198- def connect_ssh_client (self ) -> None :
202+ def establish_ssh_connection (self ) -> None :
199203 """Connect to the ssh client with the selected authentication method"""
200204 if self .authentication_method == "key" :
201205 self .ssh_client .set_missing_host_key_policy (paramiko .AutoAddPolicy ())
@@ -217,14 +221,21 @@ def connect_ssh_client(self) -> None:
217221 timeout = 20 ,
218222 )
219223
220- def close_connections (self ) -> None :
224+ def cleanup_ssh_connections (self ) -> None :
221225 """Close connection from sftp and ssh"""
222226 self .sftp .close ()
223227 self .ssh_client .close ()
224228
229+ def _initialize_ssh_and_sftp_connections (self ) -> None :
230+ self .ssh_client = paramiko .SSHClient ()
231+ self .establish_ssh_connection ()
232+ self .sftp = self .ssh_client .open_sftp ()
233+
225234 def execute (self , inputs : Sequence [Entities ], context : ExecutionContext ) -> Entities :
226235 """Execute the workflow task"""
227236 entities : list = []
237+
238+ self ._initialize_ssh_and_sftp_connections ()
228239 context .report .update (
229240 ExecutionReport (
230241 entity_count = len (entities ),
@@ -238,7 +249,7 @@ def execute(self, inputs: Sequence[Entities], context: ExecutionContext) -> Enti
238249 if self .input_method == "no_input" :
239250 self .no_input_execution (entities )
240251
241- self .close_connections ()
252+ self .cleanup_ssh_connections ()
242253
243254 operation_desc = (
244255 f"times executed '{ self .command } '"
0 commit comments