Fix read_file and add write_file methods of Node class
Due to usage of '&&' in bash command joining, if file is missing, read_file method skips umount step. As result we have a problem with "busy" mounts. Add write_file method to complete file manipulation toolbox. Change-Id: I1f2957c9e6b697b00868c3592ed67e6912b190af
This commit is contained in:
parent
25b14a7f9c
commit
5bb7d8fd3c
|
@ -96,7 +96,14 @@ class Node(base.LibvirtBase):
|
|||
out, ret_code = self.run_cmd(
|
||||
'mount -t {part_type} {partition} /mnt '
|
||||
'&& cat /mnt/{file} '
|
||||
'&& umount /mnt'.format(**locals()))
|
||||
'; umount /mnt'.format(**locals()))
|
||||
return out
|
||||
|
||||
def write_file(self, partition, file, contents, part_type='ext4'):
|
||||
out, ret_code = self.run_cmd(
|
||||
'mount -t {part_type} {partition} /mnt '
|
||||
'&& echo \'{contents}\' > /mnt/{file} '
|
||||
'; umount /mnt'.format(**locals()))
|
||||
return out
|
||||
|
||||
def run_cmd(self, cmd, check_ret_code=False, get_bareon_log=False):
|
||||
|
|
Loading…
Reference in New Issue