@@ -21,6 +21,7 @@ import sys
21
21
22
22
cmd = cli_auth_utils .cmd_decorator
23
23
24
+
24
25
@cmd
25
26
def set_param (mc , type , key , val ):
26
27
engine_param = None
@@ -42,43 +43,45 @@ def set_param(mc, type, key, val):
42
43
43
44
if key == "mem_high_wat" or key == "mem_low_wat" :
44
45
if val .endswith ("%" ):
45
- _x_ = (val [:len (val )- 1 ])
46
+ _x_ = (val [:len (val ) - 1 ])
46
47
if not _x_ .isdigit ():
47
48
print ('Error: Invalid parameter %s' % val )
48
49
return
49
50
if float (_x_ ) > 100 :
50
51
print ('Error: Bad parameter %s' % val )
51
52
return
52
53
_quota_ = int (mc .stats ()['ep_max_size' ])
53
- val = str (int (float (_x_ )* (_quota_ )/ 100 ))
54
+ val = str (int (float (_x_ ) * (_quota_ ) / 100 ))
54
55
if (key == "mem_used_merge_threshold_percent" and
55
- (float (val ) > 100.0 or float (val ) < 0.0 )):
56
+ (float (val ) > 100.0 or float (val ) < 0.0 )):
56
57
print ('Error: Invalid mem_used_merge_threshold_percent value %s' % val )
57
58
return
58
59
try :
59
60
mc .set_param (0 , key , val , engine_param )
60
- print ('set %s to %s' % (key , val ))
61
+ print ('set %s to %s' % (key , val ))
61
62
except mc_bin_client .MemcachedError as error :
62
63
print ('Error: %s' % error .msg )
63
64
except mc_bin_client .TimeoutError as error :
64
65
print (error )
65
66
except Exception as e :
66
67
print ('Generic error (%s)' % e )
67
68
69
+
68
70
@cmd
69
71
def set_vbucket_param (mc , key , vbucket , val ):
70
72
engine_param = memcacheConstants .ENGINE_PARAM_VBUCKET
71
73
72
74
try :
73
75
mc .set_param (int (vbucket ), key , val , engine_param )
74
- print ('set %s to %s' % (key , val ))
76
+ print ('set %s to %s' % (key , val ))
75
77
except mc_bin_client .MemcachedError as error :
76
78
print ('Error: %s' % error .msg )
77
79
except mc_bin_client .TimeoutError as error :
78
80
print (error )
79
81
except Exception as e :
80
82
print ('Generic error (%s)' % e )
81
83
84
+
82
85
@cmd
83
86
def stop (mc ):
84
87
try :
@@ -89,7 +92,7 @@ def stop(mc):
89
92
try :
90
93
stats = mc .stats ()
91
94
success = True
92
- except :
95
+ except BaseException :
93
96
if success :
94
97
mc = mc_bin_client .MemcachedClient (mc .host , mc .port )
95
98
raise
@@ -106,6 +109,7 @@ def stop(mc):
106
109
except Exception as e :
107
110
print ('Generic error (%s)' % e )
108
111
112
+
109
113
@cmd
110
114
def start (mc ):
111
115
try :
@@ -118,6 +122,7 @@ def start(mc):
118
122
except Exception as e :
119
123
print ('Generic error (%s)' % e )
120
124
125
+
121
126
@cmd
122
127
def drain (mc ):
123
128
try :
@@ -137,6 +142,7 @@ def drain(mc):
137
142
except Exception as e :
138
143
print ('Generic error (%s)' % e )
139
144
145
+
140
146
@cmd
141
147
def set_collections (mc , filename ):
142
148
@@ -154,6 +160,7 @@ def set_collections(mc, filename):
154
160
except Exception as e :
155
161
print ('Generic error (%s)' % e )
156
162
163
+
157
164
@cmd
158
165
def get_collections (mc ):
159
166
@@ -167,12 +174,17 @@ def get_collections(mc):
167
174
except Exception as e :
168
175
print ('Generic error (%s)' % e )
169
176
177
+
170
178
@cmd
171
179
def run_compaction (mc , vbucket , purgeBeforeTs , purgeBeforeSeq , dropDeletes ):
172
180
engine_param = memcacheConstants .ENGINE_PARAM_VBUCKET
173
181
174
182
try :
175
- mc .compact_db (int (vbucket ), int (purgeBeforeTs ), int (purgeBeforeSeq ), int (dropDeletes ))
183
+ mc .compact_db (
184
+ int (vbucket ),
185
+ int (purgeBeforeTs ),
186
+ int (purgeBeforeSeq ),
187
+ int (dropDeletes ))
176
188
print ('compaction started on vbucket {}' .format (vbucket ))
177
189
except mc_bin_client .MemcachedError as error :
178
190
print ('Error: %s' % error .msg )
@@ -181,6 +193,7 @@ def run_compaction(mc, vbucket, purgeBeforeTs, purgeBeforeSeq, dropDeletes):
181
193
except Exception as e :
182
194
print ('Generic error (%s)' % e )
183
195
196
+
184
197
if __name__ == '__main__' :
185
198
186
199
c = cli_auth_utils .get_authed_clitool ("""
@@ -351,7 +364,10 @@ Available params for "set":
351
364
c .addCommand ('set_vbucket_param' , set_vbucket_param , 'type vbucket value' )
352
365
c .addCommand ('start' , start , 'start' )
353
366
c .addCommand ('stop' , stop , 'stop' )
354
- c .addCommand ('compact' , run_compaction , 'vbucket purgeBeforeTs purgeBeforeSeq dropDeletes' )
367
+ c .addCommand (
368
+ 'compact' ,
369
+ run_compaction ,
370
+ 'vbucket purgeBeforeTs purgeBeforeSeq dropDeletes' )
355
371
356
372
# Add collection get manifest methods - These should not be executed
357
373
# except for when required by support/development
0 commit comments