M #-: fsck error VMs have same VNC port (#328)

This commit is contained in:
Alejandro Huertas Herrero authored and GitHub committed 2020-10-20 18:54:16 +02:00
1 parent c84fabd56c
commit 59570cd402
2 files changed
+25

No files matched your search

+1
View File
@@ -352,6 +352,7 @@ EOT
log_time
# VNC
check_vnc_ports
# DATA: VNC Bitmap
+24
View File
@@ -7,6 +7,8 @@ module OneDBFsck
@data_vm = {}
cluster_vnc = @data_vm[:vnc] = {}
@vms_ports = {}
# DATA: Aggregate information of the RUNNING vms
@db.fetch("SELECT oid,body FROM vm_pool WHERE state<>6") do |row|
vm_doc = nokogiri_doc(row[:body])
@@ -30,6 +32,14 @@ module OneDBFsck
cluster_vnc[cid] << port
end
# Check if two or more VMs have the same VNC port within a cluster
if cid && port && ![0, 1, 2, 4, 9].include?(state)
@vms_ports[port] = {} unless @vms_ports[port]
@vms_ports[port][cid] = [] unless @vms_ports[port][cid]
@vms_ports[port][cid] << vm_doc.root.at_xpath('ID').text.to_i
end
# DATA: Images used by this VM
vm_doc.root.xpath("TEMPLATE/DISK/IMAGE_ID").each do |e|
img_id = e.text.to_i
@@ -197,6 +207,20 @@ module OneDBFsck
end
end
def check_vnc_ports
@vms_ports.each do |port, cid|
cid.each do |cid, vms|
next if vms.size == 1
log_error(
"VMs #{vms.join(', ')} have the same VNC port #{port} " \
"in cluster #{cid}",
false
)
end
end
end
def fix_vm
# DATA: FIX: do vm_pool fixes
@db.transaction do