File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -50,13 +50,11 @@ handled in code separately from `name` being a valid string.
50
50
A connector that implements execution requires a few more methods:
51
51
52
52
``` py
53
- class LocalConnector (BaseConnector ):
53
+ class MyConnector (BaseConnector ):
54
54
handles_execution = True
55
55
56
56
@ staticmethod
57
57
def make_names_data (_ = None ):
58
- # Unlike InventoryConnector above, this connector can only return one host each invocation of make_names_data().
59
-
60
58
... # see above
61
59
62
60
def run_shell_command (
@@ -113,6 +111,19 @@ class LocalConnector(BaseConnector):
113
111
Returns:
114
112
bool: indicating success or failure.
115
113
"""
114
+
115
+
116
+ # The following two optional methods can be used to hook into the connect/disconnect steps:
117
+ def connect (self ) -> None :
118
+ """
119
+ Connect this connector instance. Should raise pyinfra.api.exceptions.ConnectError exceptions
120
+ to indicate failure.
121
+ """
122
+
123
+ def disconnect (self ) -> None :
124
+ """
125
+ Disconnect this connector instance, should never fail.
126
+ """
116
127
```
117
128
118
129
## Where to make changes
You can’t perform that action at this time.
0 commit comments