@@ -115,6 +115,7 @@ def setUp(self):
115
115
try : self .mem_resource = conf .args .mem_resource
116
116
except AttributeError :
117
117
self .mem_resource = 2048
118
+ self .dump_server_user = conf .args .dump_server_user if 'dump_server_user' in conf .args else 'root'
118
119
self .dump_server_ip = conf .args .dump_server_ip if 'dump_server_ip' in conf .args else ''
119
120
self .dump_server_pw = conf .args .dump_server_pw if 'dump_server_pw' in conf .args else ''
120
121
self .dump_path = conf .args .dump_path if 'dump_path' in conf .args else ''
@@ -147,7 +148,7 @@ def setup_test(self, dump_place="local"):
147
148
"ls -l /var/crash | grep '^d'| awk '{print $9}'" )
148
149
if dump_place == "net" :
149
150
self .crash_content = self .c .run_command (
150
- "ssh -i %s root @%s \" ls -l %s | grep '^d'\" | awk '{print $9}'" % (self .rsa_path , self .dump_server_ip , self .dump_path ))
151
+ "ssh -i %s %s @%s \" ls -l %s | grep '^d'\" | awk '{print $9}'" % (self .rsa_path , self . dump_server_user , self .dump_server_ip , self .dump_path ))
151
152
log .debug ("crash content is %s" % (self .crash_content ))
152
153
153
154
def setup_pwdless_auth (self ):
@@ -169,13 +170,13 @@ def setup_pwdless_auth(self):
169
170
self .c .run_command (
170
171
"ssh-keygen -q -t rsa -f %s -P ''" % self .rsa_path )
171
172
self .c .run_command ("chmod 400 %s" % self .rsa_path )
172
- self .c .run_command ("sshpass -p %s ssh-copy-id -o \" StrictHostKeyChecking no\" -i %s root @%s" %
173
- (self .dump_server_pw , self .rsa_path , self .dump_server_ip ))
173
+ self .c .run_command ("sshpass -p %s ssh-copy-id -o \" StrictHostKeyChecking no\" -i %s %s @%s" %
174
+ (self .dump_server_pw , self .rsa_path , self . dump_server_user , self .dump_server_ip ))
174
175
except CommandFailed :
175
176
self .fail (
176
177
"Failed to create/copy ssh key file" )
177
178
pwd_less = self .c .run_command (
178
- "ssh -i %s -o \" StrictHostKeyChecking no\" -o \" NumberOfPasswordPrompts=0\" %s \" echo\" " % (self .rsa_path , self .dump_server_ip ))
179
+ "ssh -i %s -o \" StrictHostKeyChecking no\" -o \" NumberOfPasswordPrompts=0\" %s@%s \" echo\" " % (self .rsa_path , self . dump_server_user , self .dump_server_ip ))
179
180
180
181
def is_fadump_param_enabled (self ):
181
182
'''
@@ -253,7 +254,7 @@ def verify_dump_file(self, boot_type=BootType.NORMAL, dump_place="local"):
253
254
"ls -l /var/crash | grep '^d'| awk '{print $9}'" )
254
255
if dump_place == "net" :
255
256
crash_content_after = self .c .run_command (
256
- "ssh root @%s -i %s \" ls -l %s | grep '^d'\" | awk '{print $9}'" % (self .dump_server_ip , self .rsa_path , self .dump_path ))
257
+ "ssh %s @%s -i %s \" ls -l %s | grep '^d'\" | awk '{print $9}'" % (self . dump_server_user , self .dump_server_ip , self .rsa_path , self .dump_path ))
257
258
self .crash_content = list (
258
259
set (crash_content_after ) - set (self .crash_content ))
259
260
if self .distro == "sles" :
@@ -262,32 +263,39 @@ def verify_dump_file(self, boot_type=BootType.NORMAL, dump_place="local"):
262
263
self .crash_content = list (filter (lambda x : re .search ('\d{4}-\d{2}-\d{2}-\d{2}:\d{2}' , x ), self .crash_content ))
263
264
if len (self .crash_content ):
264
265
if dump_place == "net" :
265
- self .c .run_command ('scp -i %s -r root@%s:/%s/%s /var/crash/' %
266
- (self .rsa_path , self .dump_server_ip , self .dump_path , self .crash_content [0 ]), timeout = 1200 )
266
+ #if user is not root, cannot copy/list vmcore files due to permission issue, because the owner of vmcore dir will be root.
267
+ if self .dump_server_user == 'root' :
268
+ self .c .run_command ('scp -i %s -r %s@%s:/%s/%s /var/crash/' %
269
+ (self .rsa_path , self .dump_server_user , self .dump_server_ip , self .dump_path , self .crash_content [0 ]), timeout = 1200 )
267
270
if self .distro == "ubuntu" :
268
271
self .c .run_command ("ls /var/crash/%s/dump*" %
269
272
self .crash_content [0 ])
270
273
else :
271
- res = self .c .run_command ("ls /var/crash/%s/vmcore*" %
272
- self .crash_content [0 ])
273
- paths = res [0 ].split ()
274
- file_names = [os .path .basename (path ) for path in paths ]
275
- # Check if vmcore-dmesg-incomplete.txt is present in file_names
276
- if "vmcore-dmesg-incomplete.txt" in file_names :
277
- raise OpTestError ("kdump failed to create vmcore file" )
274
+ if self .dump_server_user != 'root' :
275
+ res = self .c .run_command ("ssh %s@%s -i %s ls %s/%s/vmcore*" %
276
+ (self .dump_server_user , self .dump_server_ip , self .rsa_path , self .dump_path , self .crash_content [0 ]))
278
277
else :
279
- filtered_files = [f for f in file_names if f .startswith ("vmcore" ) and not f == "vmcore-dmesg.txt" ]
280
- if filtered_files :
281
- log .debug ("vmcore file %s exists in crash dir" % filtered_files )
282
- else :
278
+ res = self .c .run_command ("ls /var/crash/%s/vmcore*" %
279
+ self .crash_content [0 ])
280
+ paths = res [0 ].split ()
281
+ file_names = [os .path .basename (path ) for path in paths ]
282
+ # Check if vmcore-dmesg-incomplete.txt is present in file_names
283
+ if "vmcore-dmesg-incomplete.txt" in file_names :
283
284
raise OpTestError ("kdump failed to create vmcore file" )
285
+ else :
286
+ filtered_files = [f for f in file_names if f .startswith ("vmcore" ) and not f == "vmcore-dmesg.txt" ]
287
+ if filtered_files :
288
+ log .debug ("vmcore file %s exists in crash dir" % filtered_files )
289
+ else :
290
+ raise OpTestError ("kdump failed to create vmcore file" )
284
291
if boot_type == BootType .MPIPL :
285
292
self .c .run_command ("ls /var/crash/%s/opalcore*" %
286
293
self .crash_content [0 ])
287
294
else :
288
295
msg = "Dump directory not created"
289
296
raise OpTestError (msg )
290
- self .c .run_command ("rm -rf /var/crash/%s; sync" % self .crash_content [0 ])
297
+ if self .dump_server_user == 'root' :
298
+ self .c .run_command ("rm -rf /var/crash/%s; sync" % self .crash_content [0 ])
291
299
292
300
def verify_fadump_reg (self ):
293
301
'''
0 commit comments