This commit is contained in:
2026-09-21 11:51:12 +03:00
parent 9cd93e4277
commit 2b229a84fb
240 changed files with 7735 additions and 3166 deletions

View File

@@ -62,6 +62,8 @@ func flattenNode(d *schema.ResourceData, item *node.RecordNode) {
d.Set("nic_info", flattenNicInfo(item.NicInfo))
d.Set("numa_topology", flattenNumaTopology(item.NumaTopology))
d.Set("reserved_cpus", flattenNodeItem(item.ReservedCPUs))
d.Set("reserved_cpu", item.ReservedCPU)
d.Set("reserved_ram", item.ReservedRAM)
d.Set("roles", item.Roles)
d.Set("sdn_hypervisor_name", item.SDNHypervisorName)
d.Set("sriov_enabled", item.SriovEnabled)
@@ -135,6 +137,7 @@ func flattenNodeList(nodes *node.ListNodes) []map[string]interface{} {
"ipaddr": item.IPAddr,
"isolated_cpus": flattenNodeItem(item.IsolatedCpus),
"lastcheck": item.LastCheck,
"machine_id": item.MachineID,
"machine_guid": item.MachineGUID,
"mainboard_sn": item.MainboardSN,
"memory": item.Memory,
@@ -154,6 +157,8 @@ func flattenNodeList(nodes *node.ListNodes) []map[string]interface{} {
"public_keys": item.PublicKeys,
"release": item.Release,
"reserved_cpus": flattenNodeItem(item.ReservedCPUs),
"reserved_cpu": int(item.ReservedCPU),
"reserved_ram": int(item.ReservedRAM),
"roles": item.Roles,
"sdn_hypervisor_name": item.SDNHypervisorName,
"seps": item.Seps,
@@ -173,6 +178,7 @@ func flattenNodeList(nodes *node.ListNodes) []map[string]interface{} {
"cpu_allocation_ratio": item.CPUAllocationRatio,
"mem_allocation_ratio": item.MemAllocationRatio,
"packages": flattenPackages(item.Packages),
"pci_devices": flattenNodePCIDevices(item.PCIDevices),
}
res = append(res, temp)
}
@@ -188,9 +194,18 @@ func flattenNumaTopology(info node.NumaTopologyInfo) []map[string]interface{} {
for _, item := range info.Nodes {
memoryTemp := []map[string]interface{}{
{
"one_g": item.Memory.OneG,
"two_m": item.Memory.TwoM,
"total": item.Memory.Total,
"one_g": item.Memory.OneG,
"one_g_free": item.Memory.OneGFree,
"one_g_reserved": item.Memory.OneGReserved,
"one_g_available": item.Memory.OneGAvailable,
"one_g_used": item.Memory.OneGUsed,
"one_g_dpdk_reserved": item.Memory.OneGDPDKReserved,
"two_m": item.Memory.TwoM,
"two_m_free": item.Memory.TwoMFree,
"two_m_reserved": item.Memory.TwoMReserved,
"two_m_available": item.Memory.TwoMAvailable,
"two_m_used": item.Memory.TwoMUsed,
"total": item.Memory.Total,
},
}
temp := map[string]interface{}{
@@ -321,9 +336,9 @@ func flattenDPDKItem(dpdk node.DPDK) []map[string]interface{} {
}
res[0] = map[string]interface{}{
"bridges": bridges,
"hp_memory": dpdk.HPMemory,
"pmd_cpu": dpdk.PMDCPU,
"bridges": bridges,
"ovs_dpdk_cores": dpdk.OVSDPDKCores,
"hp_memory": dpdk.HPMemory,
}
return res
@@ -339,3 +354,178 @@ func flattenRole(role node.Role) []map[string]interface{} {
res[0] = temp
return res
}
func flattenSystemNetworksInfo(m map[string]node.SystemNetworkInfo) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(m))
for name, info := range m {
res = append(res, map[string]interface{}{
"name": name,
"mtu": info.MTU,
"speed": info.Speed,
"bridge_id": info.BridgeID,
"bport_id": info.BPortID,
"mac": info.MAC,
})
}
return res
}
func flattenOVSNetworksInfo(items []node.OVSNetworkInfo) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(items))
for _, item := range items {
res = append(res, map[string]interface{}{
"bridge_name": item.BridgeName,
"bridge_tag": item.BridgeTag,
"interface_uuid": item.InterfaceUUID,
"interface_type": item.InterfaceType,
"interface_name": item.InterfaceName,
"interface_mtu": item.InterfaceMTU,
"interface_ip": item.InterfaceIP,
"interface_mac": item.InterfaceMAC,
"interface_peer": item.InterfacePeer,
})
}
return res
}
func flattenLibvirtNetworksInfo(items []node.LibvirtNetworkInfo) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(items))
for _, item := range items {
res = append(res, map[string]interface{}{
"vm_name": item.VMName,
"interface": item.Interface,
"interface_type": item.InterfaceType,
"interface_source": item.InterfaceSource,
})
}
return res
}
func flattenNetworkTopology(t node.NetworkTopology) []map[string]interface{} {
return []map[string]interface{}{
{
"interfaces": flattenTopologyInterfaces(t.Interfaces),
},
}
}
func flattenTopologyInterfaces(m map[string]node.TopologyInterface) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(m))
for name, iface := range m {
res = append(res, map[string]interface{}{
"name": name,
"type": iface.Type,
"mtu": iface.MTU,
"speed": iface.Speed,
"vlans": iface.VLANs,
"bridge_id": iface.BridgeID,
"peer": iface.Peer,
"uuid": iface.UUID,
"connected_interfaces": iface.ConnectedInterfaces,
"connections": flattenTopologyConnections(iface.Connections),
"bridge_info": flattenTopologyBridgeInfo(iface.BridgeInfo),
"bridge_connections": flattenTopologyBridgeRefs(iface.BridgeConnections),
})
}
return res
}
func flattenTopologyConnections(c node.TopologyInterfaceConnections) []map[string]interface{} {
vms := make([]map[string]interface{}, 0, len(c.VMs))
for _, vm := range c.VMs {
vms = append(vms, map[string]interface{}{
"name": vm.Name,
"vm_interface": vm.VMInterface,
"vm_interface_type": vm.VMInterfaceType,
"connection_type": vm.ConnectionType,
"via_bridge": vm.ViaBridge,
})
}
bridges := make([]map[string]interface{}, 0, len(c.Bridges))
for _, b := range c.Bridges {
portInfo := flattenTopologyPortInfo(b.PortInfo)
bridges = append(bridges, map[string]interface{}{
"name": b.Name,
"type": b.Type,
"via": b.Via,
"bport_id": b.BPortID,
"port_info": portInfo,
})
}
return []map[string]interface{}{
{
"vms": vms,
"bridges": bridges,
},
}
}
func flattenTopologyPortInfo(p *node.TopologyPortInfo) []map[string]interface{} {
if p == nil {
return nil
}
return []map[string]interface{}{
{
"name": p.Name,
"type": p.Type,
"mtu": p.MTU,
"vlan": p.VLAN,
"uuid": p.UUID,
},
}
}
func flattenTopologyBridgeInfo(b *node.TopologyBridgeInfo) []map[string]interface{} {
if b == nil {
return nil
}
ports := make([]map[string]interface{}, 0, len(b.Ports))
for _, p := range b.Ports {
ports = append(ports, map[string]interface{}{
"name": p.Name,
"type": p.Type,
"mtu": p.MTU,
"vlan": p.VLAN,
"uuid": p.UUID,
"ip": p.IP,
"mac": p.MAC,
})
}
return []map[string]interface{}{
{
"type": b.Type,
"ports": ports,
},
}
}
func flattenTopologyBridgeRefs(refs []node.TopologyBridgeRef) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(refs))
for _, r := range refs {
res = append(res, map[string]interface{}{
"name": r.Name,
"via": r.Via,
"vlan": r.VLAN,
})
}
return res
}
func flattenNodePCIDevices(items []node.ItemPCIDevice) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(items))
for _, item := range items {
res = append(res, map[string]interface{}{
"hw_path": item.HWPath,
"current_driver": item.CurrentDriver,
"numa_node": item.NUMANode,
"product_id": item.ProductID,
"product_name": item.ProductName,
"vendor_id": item.VendorID,
"vendor_name": item.VendorName,
"iommu_group": item.IOMMUGroup,
})
}
return res
}