forked from ManageIQ/manageiq-providers-proxmox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollector.rb
More file actions
28 lines (24 loc) · 1.06 KB
/
collector.rb
File metadata and controls
28 lines (24 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class ManageIQ::Providers::Proxmox::Inventory::Collector < ManageIQ::Providers::Inventory::Collector
private
def collect_vm_details(vm)
base = "/nodes/#{vm["node"]}/qemu/#{vm["vmid"]}"
config = connection.request(:get, "#{base}/config")
status = connection.request(:get, "#{base}/status/current")
details = {
"config" => config,
"status" => status,
"name" => config&.dig("name"),
"template" => config&.dig("template")
}
if status&.dig("status") == "running" && config&.dig("agent")&.to_s&.start_with?("1")
begin
details["agent_info"] = connection.request(:get, "#{base}/agent/get-osinfo")&.dig("result")
details["networks"] = connection.request(:get, "#{base}/agent/network-get-interfaces")&.dig("result")
details["hostname"] = connection.request(:get, "#{base}/agent/get-host-name")&.dig("result", "host-name")
rescue RuntimeError => err
$proxmox_log.warn("Proxmox agent not responding for VM #{vm["vmid"]}: #{err.message}")
end
end
vm.merge(details)
end
end