diff --git a/src/vmm_mad/remotes/lib/lxd/client.rb b/src/vmm_mad/remotes/lib/lxd/client.rb index 5785a29f8d0..0d0fd3301b7 100644 --- a/src/vmm_mad/remotes/lib/lxd/client.rb +++ b/src/vmm_mad/remotes/lib/lxd/client.rb @@ -144,7 +144,13 @@ class LXDError < StandardError attr_reader :body, :error, :code, :type - def initialize(response) + INTERNAL_ERROR = { + 'error_code' => 500, + 'type' => 'driver', + 'error' => 'driver unknown error' + } + + def initialize(response = INTERNAL_ERROR) raise "Got wrong argument class: #{response.class}, expecting Hash" \ unless response.class == Hash diff --git a/src/vmm_mad/remotes/lib/lxd/mapper/mapper.rb b/src/vmm_mad/remotes/lib/lxd/mapper/mapper.rb index 3c4a0b9c435..c39925d2861 100644 --- a/src/vmm_mad/remotes/lib/lxd/mapper/mapper.rb +++ b/src/vmm_mad/remotes/lib/lxd/mapper/mapper.rb @@ -459,8 +459,8 @@ def parse_fstab(partitions, path, fstab) # @param size, osize [Integer] disk size and original size # @return true if success def mount_resize_fs(device, directory, fs_type, disk) - size = disk['SIZE'].to_i if disk['SIZE'] - osize = disk['ORIGINAL_SIZE'].to_i if disk['ORIGINAL_SIZE'] + size = disk['SIZE'].to_i if disk['SIZE'] + osize = disk['ORIGINAL_SIZE'].to_i if disk['ORIGINAL_SIZE'] # TODO: osize is always < size after 1st resize during deployment return mount_dev(device, directory) unless size > osize @@ -474,13 +474,22 @@ 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" + + cmd = "#{COMMANDS[:e2fsck]} -f -y #{device}" + _rc, o, e = Command.execute(cmd, false) if o.empty? - err = "#{__method__}: failed to resize #{device}\n#{e}" - OpenNebula.log_error err + OpenNebula.log_error("#{err}#{e}") + return false 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 false + end end rc = mount_dev(device, directory) @@ -502,15 +511,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}" + Command.execute("#{COMMANDS[:e2fsck]} -f -y #{device}", false) + 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" + false end def get_fstype(device)