Project

General

Profile

« Previous | Next » 

Revision 2309e9e1

Added by Adam, Till - D0249540 over 7 years ago

fixes #18216 - volume size editable for existing VMs one

View differences:

app/models/compute_resources/foreman/model/vmware.rb
client.servers.new opts
end
def save_vm(uuid, attr)
vm = find_vm_by_uuid(uuid)
vm.attributes.merge!(attr.deep_symbolize_keys)
#volumes are not part of vm.attributes so we have to set them seperately if needed
if attr.has_key?(:volumes_attributes)
vm.volumes.each do |vm_volume|
volume_attrs = attr[:volumes_attributes].values.detect {|vol| vol[:id] == vm_volume.id}
vm_volume.size_gb = volume_attrs[:size_gb]
end
end
vm.save
end
def destroy_vm(uuid)
find_vm_by_uuid(uuid).destroy :force => true
rescue ActiveRecord::RecordNotFound
......
true
end
def update_required?(old_attrs, new_attrs)
super(old_attrs.deep_merge(old_attrs) {|_,_,v| v.to_s}, new_attrs)
end
# === Power on
#
# Foreman will try and start this vm after clone in a seperate request.
......
return 'efi' if firmware_type == :uefi
'bios'
end
def set_vm_volumes_attributes(vm, vm_attrs)
volumes = vm.volumes || []
vm_attrs[:volumes_attributes] = Hash[volumes.each_with_index.map { |volume, idx| [idx.to_s, volume.attributes.merge(:size_gb => volume.size_gb)] }]
vm_attrs
end
end
end

Also available in: Unified diff