File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,15 @@ def __init__(self, name=None):
22
22
23
23
@property
24
24
def exists (self ):
25
+ """Test if group exists
26
+
27
+ >>> host.group("wheel").exists
28
+ True
29
+ >>> host.group("nosuchgroup").exists
30
+ False
31
+
32
+ """
33
+
25
34
return self .run_expect ([0 , 2 ], "getent group %s" , self .name ).rc == 0
26
35
27
36
@property
Original file line number Diff line number Diff line change @@ -34,6 +34,15 @@ def name(self):
34
34
35
35
@property
36
36
def exists (self ):
37
+ """Test if user exists
38
+
39
+ >>> host.user("root").exists
40
+ True
41
+ >>> host.user("nosuchuser").exists
42
+ False
43
+
44
+ """
45
+
37
46
return self .run_test ("id %s" , self .name ).rc == 0
38
47
39
48
@property
@@ -145,6 +154,15 @@ def name(self):
145
154
146
155
@property
147
156
def exists (self ):
157
+ """Test if user exists
158
+
159
+ >>> host.user("Administrator").exists
160
+ True
161
+ >>> host.user("nosuchuser").exists
162
+ False
163
+
164
+ """
165
+
148
166
return self .run_test ("net user %s" , self .name ).rc == 0
149
167
150
168
@property
You can’t perform that action at this time.
0 commit comments