@@ -22,6 +22,16 @@ def volume_mount(self, server: str, volname: str,
22
22
server (str): Hostname or IP address
23
23
volname (str): Name of volume to be mounted
24
24
path (str): The path of the mount directory(mount point)
25
+
26
+ Returns:
27
+ ret: A dictionary consisting
28
+ - Flag : Flag to check if connection failed
29
+ - msg : message
30
+ - error_msg: error message
31
+ - error_code: error code returned
32
+ - cmd : command that got executed
33
+ - node : node on which the command got executed
34
+
25
35
"""
26
36
27
37
cmd = f"mount -t glusterfs { server } :/{ volname } { path } "
@@ -35,6 +45,8 @@ def volume_mount(self, server: str, volname: str,
35
45
raise Exception (ret ["error_msg" ])
36
46
37
47
self .logger .info (f"Successfully ran { cmd } on { node } " )
48
+
49
+ return ret
38
50
39
51
def volume_unmount (self , path : str , node : str = None ):
40
52
"""
@@ -45,6 +57,16 @@ def volume_unmount(self, path: str, node: str=None):
45
57
server (str): Hostname or IP address
46
58
volname (str): Name of volume to be mounted
47
59
path (str): The path of the mount directory(mount point)
60
+
61
+ Returns:
62
+ ret: A dictionary consisting
63
+ - Flag : Flag to check if connection failed
64
+ - msg : message
65
+ - error_msg: error message
66
+ - error_code: error code returned
67
+ - cmd : command that got executed
68
+ - node : node on which the command got executed
69
+
48
70
"""
49
71
50
72
cmd = f"umount { path } "
@@ -59,6 +81,7 @@ def volume_unmount(self, path: str, node: str=None):
59
81
60
82
self .logger .info (f"Successfully ran { cmd } on { node } " )
61
83
84
+ return ret
62
85
63
86
def volume_create (self , volname : str , bricks_list : list ,
64
87
node : str = None , force : bool = False ,
@@ -84,6 +107,15 @@ def volume_create(self, volname: str, bricks_list: list,
84
107
- redundancy_count : (int)|None
85
108
- transport_type : tcp|rdma|tcp,rdma|None
86
109
- ...
110
+ Returns:
111
+ ret: A dictionary consisting
112
+ - Flag : Flag to check if connection failed
113
+ - msg : message
114
+ - error_msg: error message
115
+ - error_code: error code returned
116
+ - cmd : command that got executed
117
+ - node : node on which the command got executed
118
+
87
119
"""
88
120
89
121
replica = arbiter = stripe = disperse = disperse_data = redundancy = ''
@@ -128,16 +160,28 @@ def volume_create(self, volname: str, bricks_list: list,
128
160
129
161
self .logger .info (f"Successfully ran { cmd } on { node } " )
130
162
163
+ return ret
164
+
131
165
def volume_start (self , volname : str , node : str = None , force : bool = False ):
132
166
"""
133
167
Starts the gluster volume
134
168
Args:
135
169
node (str): Node on which cmd has to be executed.
136
170
volname (str): volume name
171
+
137
172
Kwargs:
138
173
force (bool): If this option is set to True, then start volume
139
174
will get executed with force option. If it is set to False,
140
175
then start volume will get executed without force option
176
+ Returns:
177
+ ret: A dictionary consisting
178
+ - Flag : Flag to check if connection failed
179
+ - msg : message
180
+ - error_msg: error message
181
+ - error_code: error code returned
182
+ - cmd : command that got executed
183
+ - node : node on which the command got executed
184
+
141
185
"""
142
186
143
187
if force :
@@ -155,6 +199,8 @@ def volume_start(self, volname: str, node : str=None, force: bool = False):
155
199
156
200
self .logger .info (f"Successfully ran { cmd } on { node } " )
157
201
202
+ return ret
203
+
158
204
def volume_stop (self , volname : str , node : str = None , force : bool = False ):
159
205
"""
160
206
Stops the gluster volume
@@ -165,6 +211,15 @@ def volume_stop(self, volname: str, node : str=None, force: bool = False):
165
211
force (bool): If this option is set to True, then start volume
166
212
will get executed with force option. If it is set to False,
167
213
then start volume will get executed without force option
214
+ Returns:
215
+ ret: A dictionary consisting
216
+ - Flag : Flag to check if connection failed
217
+ - msg : message
218
+ - error_msg: error message
219
+ - error_code: error code returned
220
+ - cmd : command that got executed
221
+ - node : node on which the command got executed
222
+
168
223
"""
169
224
170
225
if force :
@@ -181,6 +236,7 @@ def volume_stop(self, volname: str, node : str=None, force: bool = False):
181
236
raise Exception (ret ['msg' ]['opErrstr' ])
182
237
183
238
self .logger .info (f"Successfully ran { cmd } on { node } " )
239
+ return ret
184
240
185
241
def volume_delete (self , volname : str ,node : str = None ):
186
242
"""
@@ -189,6 +245,15 @@ def volume_delete(self, volname: str,node : str=None):
189
245
Args:
190
246
node (str): Node on which cmd has to be executed.
191
247
volname (str): volume name
248
+ Returns:
249
+ ret: A dictionary consisting
250
+ - Flag : Flag to check if connection failed
251
+ - msg : message
252
+ - error_msg: error message
253
+ - error_code: error code returned
254
+ - cmd : command that got executed
255
+ - node : node on which the command got executed
256
+
192
257
"""
193
258
194
259
cmd = f"gluster volume delete { volname } --mode=script --xml"
@@ -203,6 +268,8 @@ def volume_delete(self, volname: str,node : str=None):
203
268
204
269
self .logger .info (f"Successfully ran { cmd } on { node } " )
205
270
271
+ return ret
272
+
206
273
def get_volume_info (self , node : str = None , volname : str = 'all' ) -> dict :
207
274
"""
208
275
Gives volume information
@@ -347,6 +414,15 @@ def volume_reset(self, volname: str, node : str=None, force : bool=False):
347
414
then reset volume will get executed without force option
348
415
Example:
349
416
volume_reset("testvol",server)
417
+
418
+ Returns:
419
+ ret: A dictionary consisting
420
+ - Flag : Flag to check if connection failed
421
+ - msg : message
422
+ - error_msg: error message
423
+ - error_code: error code returned
424
+ - cmd : command that got executed
425
+ - node : node on which the command got executed
350
426
351
427
"""
352
428
if force :
@@ -363,6 +439,8 @@ def volume_reset(self, volname: str, node : str=None, force : bool=False):
363
439
raise Exception (ret ['msg' ]['opErrstr' ])
364
440
365
441
self .logger .info (f"Successfully ran { cmd } on { node } " )
442
+
443
+ return ret
366
444
367
445
def get_volume_status (self ,node : str = None ,volname : str = 'all' ,
368
446
service : str = '' ,options : str = '' ) -> dict :
@@ -520,6 +598,16 @@ def set_volume_options(self, volname : str, options : str, node : str=None):
520
598
Example:
521
599
options = {"user.cifs":"enable","user.smb":"enable"}
522
600
set_volume_options("test-vol1", options, server)
601
+
602
+ Returns:
603
+ ret: A dictionary consisting
604
+ - Flag : Flag to check if connection failed
605
+ - msg : message
606
+ - error_msg: error message
607
+ - error_code: error code returned
608
+ - cmd : command that got executed
609
+ - node : node on which the command got executed
610
+
523
611
"""
524
612
525
613
volume_options = options
@@ -552,6 +640,8 @@ def set_volume_options(self, volname : str, options : str, node : str=None):
552
640
raise Exception (ret ['msg' ]['opErrstr' ])
553
641
554
642
self .logger .info (f"Successfully ran { cmd } on { node } " )
643
+
644
+ return ret
555
645
556
646
def reset_volume_option (self , volname : str , option : str ,
557
647
node : str = None , force : bool = False ):
@@ -567,6 +657,16 @@ def reset_volume_option(self, volname : str, option : str,
567
657
then reset volume will get executed without force option
568
658
Example:
569
659
reset_volume_option("test-vol1", "option", server)
660
+
661
+ Returns:
662
+ ret: A dictionary consisting
663
+ - Flag : Flag to check if connection failed
664
+ - msg : message
665
+ - error_msg: error message
666
+ - error_code: error code returned
667
+ - cmd : command that got executed
668
+ - node : node on which the command got executed
669
+
570
670
"""
571
671
572
672
if force :
@@ -582,7 +682,9 @@ def reset_volume_option(self, volname : str, option : str,
582
682
raise Exception (ret ['msg' ]['opErrstr' ])
583
683
584
684
self .logger .info (f"Successfully ran { cmd } on { node } " )
585
-
685
+
686
+ return ret
687
+
586
688
def volume_sync (self , hostname : str , node : str , volname : str = 'all' ):
587
689
"""
588
690
Sync the volume to the specified host
@@ -593,6 +695,16 @@ def volume_sync(self, hostname : str, node: str, volname : str='all'):
593
695
volname (str): volume name. Defaults to 'all'.
594
696
Example:
595
697
volume_sync(volname="testvol",server)
698
+
699
+ Returns:
700
+ ret: A dictionary consisting
701
+ - Flag : Flag to check if connection failed
702
+ - msg : message
703
+ - error_msg: error message
704
+ - error_code: error code returned
705
+ - cmd : command that got executed
706
+ - node : node on which the command got executed
707
+
596
708
"""
597
709
598
710
cmd = f"gluster volume sync { hostname } { volname } --mode=script --xml"
@@ -605,3 +717,5 @@ def volume_sync(self, hostname : str, node: str, volname : str='all'):
605
717
raise Exception (ret ['msg' ]['opErrstr' ])
606
718
607
719
self .logger .info (f"Successfully ran { cmd } on { node } " )
720
+
721
+ return ret
0 commit comments