theforeman/foreman · error · RuntimeError
no unused port found
Error message
no unused port found
What it means
Error "no unused port found" thrown in theforeman/foreman.
Source
Thrown at app/models/compute_resources/foreman/model/vmware.rb:812
case e.message
when /The remote system presented a public key with hash (\w+) but we're expecting a hash of/
raise Foreman::FingerprintException.new(
N_("The remote system presented a public key with hash %s but we're expecting a different hash. If you are sure the remote system is authentic, go to the compute resource edit page, press the 'Test Connection' or 'Load Datacenters' button and submit"), Regexp.last_match(1))
when /Cannot complete login due to an incorrect user name or password./
raise Foreman::UsernameOrPasswordException.new(
N_("Can not load datacenters due to an incorrect user name or password."))
else
raise e
end
end
def unused_vnc_port(ip)
10.times do
port = rand(5901..5964)
unused = (TCPSocket.connect(ip, port).close rescue true)
return port if unused
end
raise "no unused port found"
end
def vm_instance_defaults
super.merge(
:memory_mb => 2048,
:interfaces => [new_interface],
:volumes => [new_volume],
:scsi_controllers => [{ :type => scsi_controller_default_type }],
:nvme_controllers => [],
:datacenter => datacenter,
:firmware => 'automatic',
:boot_order => ['network', 'disk']
)
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)] }]View on GitHub (pinned to 6b05625475)
When it happens
Trigger: Thrown at app/models/compute_resources/foreman/model/vmware.rb:812 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of theforeman/foreman@6b05625475 (2026-08-23).
Data as JSON: /api/errors/fe0eff443edb41f2.
Report an issue: GitHub.