4.13.0
This commit is contained in:
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func dataSourceNodeNetworkInfoRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := node.GetNetworkInfoRequest{
|
||||
NodeID: uint64(d.Get("node_id").(int)),
|
||||
}
|
||||
|
||||
info, err := c.CloudBroker().Node().GetNetworkInfo(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("system_networks_info", flattenSystemNetworksInfo(info.SystemNetworksInfo))
|
||||
d.Set("ovs_networks_info", flattenOVSNetworksInfo(info.OVSNetworksInfo))
|
||||
d.Set("libvirt_networks_info", flattenLibvirtNetworksInfo(info.LibvirtNetworksInfo))
|
||||
d.Set("topology", flattenNetworkTopology(info.Topology))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceNodeNetworkInfoSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Node ID",
|
||||
},
|
||||
"system_networks_info": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "System-level information about all network interfaces on the node",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface name",
|
||||
},
|
||||
"mtu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "MTU value",
|
||||
},
|
||||
"speed": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Interface link speed",
|
||||
},
|
||||
"bridge_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Linux bridge ID",
|
||||
},
|
||||
"bport_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Bridge port ID",
|
||||
},
|
||||
"mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "MAC address",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"ovs_networks_info": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "Raw OVS ports data",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"bridge_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Bridge name",
|
||||
},
|
||||
"bridge_tag": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Bridge tag",
|
||||
},
|
||||
"interface_uuid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface UUID",
|
||||
},
|
||||
"interface_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface type",
|
||||
},
|
||||
"interface_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface name",
|
||||
},
|
||||
"interface_mtu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Interface MTU value",
|
||||
},
|
||||
"interface_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface IP address",
|
||||
},
|
||||
"interface_mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface MAC address",
|
||||
},
|
||||
"interface_peer": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface peer name",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"libvirt_networks_info": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "VM network interface connections",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"vm_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "VM name",
|
||||
},
|
||||
"interface": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Host-side interface name used by the VM",
|
||||
},
|
||||
"interface_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface type",
|
||||
},
|
||||
"interface_source": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the bridge the VM interface is attached to",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"topology": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "Assembled network topology of the node",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"interfaces": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "Network interfaces and their topology details",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface name",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Interface type",
|
||||
},
|
||||
"mtu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Interface MTU value",
|
||||
},
|
||||
"speed": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Interface link speed",
|
||||
},
|
||||
"vlans": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Description: "VLANs associated with the interface",
|
||||
},
|
||||
"bridge_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Linux bridge ID",
|
||||
},
|
||||
"peer": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Peer interface name",
|
||||
},
|
||||
"uuid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "OVS UUID",
|
||||
},
|
||||
"connected_interfaces": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true, Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Description: "Names of interfaces attached to this bridge as ports",
|
||||
},
|
||||
"connections": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"vms": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {Type: schema.TypeString, Computed: true},
|
||||
"vm_interface": {Type: schema.TypeString, Computed: true},
|
||||
"vm_interface_type": {Type: schema.TypeString, Computed: true},
|
||||
"connection_type": {Type: schema.TypeString, Computed: true},
|
||||
"via_bridge": {Type: schema.TypeString, Computed: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
"bridges": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {Type: schema.TypeString, Computed: true},
|
||||
"type": {Type: schema.TypeString, Computed: true},
|
||||
"via": {Type: schema.TypeString, Computed: true},
|
||||
"bport_id": {Type: schema.TypeString, Computed: true},
|
||||
"port_info": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {Type: schema.TypeString, Computed: true},
|
||||
"type": {Type: schema.TypeString, Computed: true},
|
||||
"mtu": {Type: schema.TypeInt, Computed: true},
|
||||
"vlan": {Type: schema.TypeString, Computed: true},
|
||||
"uuid": {Type: schema.TypeString, Computed: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"bridge_info": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"type": {Type: schema.TypeString, Computed: true},
|
||||
"ports": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {Type: schema.TypeString, Computed: true},
|
||||
"type": {Type: schema.TypeString, Computed: true},
|
||||
"mtu": {Type: schema.TypeInt, Computed: true},
|
||||
"vlan": {Type: schema.TypeString, Computed: true},
|
||||
"uuid": {Type: schema.TypeString, Computed: true},
|
||||
"ip": {Type: schema.TypeString, Computed: true},
|
||||
"mac": {Type: schema.TypeString, Computed: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"bridge_connections": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {Type: schema.TypeString, Computed: true},
|
||||
"via": {Type: schema.TypeString, Computed: true},
|
||||
"vlan": {Type: schema.TypeString, Computed: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceNodeNetworkInfo() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
ReadContext: dataSourceNodeNetworkInfoRead,
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
Schema: dataSourceNodeNetworkInfoSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Sergey Kisil, <svkisil@digitalenergy.online>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
sdknode "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func dataSourceNodePCIDevicesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := sdknode.GetPCIDevicesRequest{
|
||||
NodeID: uint64(d.Get("node_id").(int)),
|
||||
}
|
||||
if v, ok := d.GetOk("search"); ok {
|
||||
req.Search = v.(string)
|
||||
}
|
||||
if v, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = v.(string)
|
||||
}
|
||||
if v, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(v.(int))
|
||||
}
|
||||
if v, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(v.(int))
|
||||
}
|
||||
|
||||
list, err := c.CloudBroker().Node().GetPCIDevices(ctx, req)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenNodePCIDevices(list.Data))
|
||||
d.Set("entry_count", list.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceNodePCIDevicesSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"node_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Node ID",
|
||||
},
|
||||
"search": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Search string",
|
||||
},
|
||||
"sort_by": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Sort by one of supported fields, format +|-(field)",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Total number of PCI devices",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Description: "List of PCI devices",
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"hw_path": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Hardware path",
|
||||
},
|
||||
"current_driver": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Current driver",
|
||||
},
|
||||
"numa_node": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "NUMA node",
|
||||
},
|
||||
"product_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Product ID",
|
||||
},
|
||||
"product_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Product name",
|
||||
},
|
||||
"vendor_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Vendor ID",
|
||||
},
|
||||
"vendor_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Vendor name",
|
||||
},
|
||||
"iommu_group": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "IOMMU group",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceNodePCIDevices() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
ReadContext: dataSourceNodePCIDevicesRead,
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
Schema: dataSourceNodePCIDevicesSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema {
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"vcpu": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"ram": {
|
||||
@@ -129,11 +129,11 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"mem_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"description": {
|
||||
@@ -172,15 +172,15 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"hp_memory": {
|
||||
Type: schema.TypeMap,
|
||||
"ovs_dpdk_cores": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"pmd_cpu": {
|
||||
Type: schema.TypeList,
|
||||
"hp_memory": {
|
||||
Type: schema.TypeMap,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
@@ -331,10 +331,46 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_free": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_available": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_used": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_dpdk_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_free": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_available": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_used": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"total": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -355,6 +391,14 @@ func dataSourceNodeSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"reserved_cpu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"reserved_ram": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"roles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -548,7 +592,7 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"cpu_info": {
|
||||
@@ -629,15 +673,15 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"hp_memory": {
|
||||
Type: schema.TypeMap,
|
||||
"ovs_dpdk_cores": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"pmd_cpu": {
|
||||
Type: schema.TypeList,
|
||||
"hp_memory": {
|
||||
Type: schema.TypeMap,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
@@ -680,6 +724,10 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"machine_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"machine_guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -689,7 +737,7 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"mem_allocation_ratio": {
|
||||
Type: schema.TypeFloat,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"memory": {
|
||||
@@ -848,10 +896,46 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_free": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_available": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_used": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"one_g_dpdk_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_free": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_reserved": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_available": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"two_m_used": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"total": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -918,6 +1002,14 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"reserved_cpu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"reserved_ram": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"roles": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -978,6 +1070,46 @@ func dataSourceNodeListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"pci_devices": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"hw_path": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"current_driver": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"numa_node": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"product_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"product_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vendor_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"iommu_group": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user