Skip to content

Commit

Permalink
B #3103: Default constructor for LXDError. Remove method. Fix ext UUI…
Browse files Browse the repository at this point in the history
…D generation

(cherry picked from commit c5bcacf)
  • Loading branch information
rsmontero committed Mar 22, 2019
1 parent 1cc7113 commit c19f40e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
8 changes: 7 additions & 1 deletion src/vmm_mad/remotes/lib/lxd/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 20 additions & 9 deletions src/vmm_mad/remotes/lib/lxd/mapper/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit c19f40e

Please sign in to comment.