Skip to content

Commit

Permalink
OpenNebula#3103 Fix ext4 uuidgen.
Browse files Browse the repository at this point in the history
  • Loading branch information
dann1 committed Mar 21, 2019
1 parent 6883f6a commit b3f7d78
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/vmm_mad/remotes/lib/lxd/mapper/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,21 @@ def mount_resize_fs(device, directory, fs_type, disk)

Command.execute("#{COMMANDS[:xfs_growfs]} -d #{directory}", false)
when /ext/
_rc, o, e = Command.execute("#{COMMANDS[:e2fsck]} -f -y #{device}", false)
err = "#{__method__}: failed to resize #{device}\n"

_rc, o, e = check_ext4(device)

if o.empty?
err = "#{__method__}: failed to resize #{device}\n#{e}"
OpenNebula.log_error err
OpenNebula.log_error("#{err}#{e}")
return
else
Command.execute("#{COMMANDS[:resize2fs]} #{device}", false)
cmd = "#{COMMANDS[:resize2fs]} #{device}"
rc, _o, e = Command.execute(cmd, false)

if rc != 0
OpenNebula.log_error("#{err}#{e}")
return
end
end

rc = mount_dev(device, directory)
Expand All @@ -502,15 +510,17 @@ def reset_fs_uuid(fs_type, device)
when /xfs/
cmd = "#{COMMANDS[:xfs_admin]} -U generate #{device}"
when /ext/
cmd = "#{COMMANDS[:tune2fs]} tune2fs -U random #{device}"
check_ext4(device)
cmd = "#{COMMANDS[:tune2fs]} -U random #{device}"
else
return true
end

rc, _o, e = Command.execute(cmd, false)
rc, o, e = Command.execute(cmd, false)
return true if rc.zero?

OpenNebula.log_error "#{__method__}: failed to change UUID: #{e}\n"
OpenNebula.log_error "#{__method__}: error changing UUID: #{o}\n#{e}\n"
nil
end

def get_fstype(device)
Expand All @@ -529,4 +539,8 @@ def get_fstype(device)
fstype
end

def check_ext4(part)
Command.execute("#{COMMANDS[:e2fsck]} -f -y #{part}", false)
end

end

0 comments on commit b3f7d78

Please sign in to comment.