hpi-swt2/vm-portal

Rethink name uniqueness validation of VM requests

Opened this issue · 0 comments

Seems like in order to check whether a name is already taken, all VMs are queried from the API, and then their names extracted to check if a given name is included.

app/models/request.rb:

errors.add(:name, ': vSphere already has a VM with the same name') if VSphere::VirtualMachine.all.map(&:name).include?(name)

should be more efficient to ask the vSphere API whether A VM with the chose name already exists