This commit is contained in:
asteam
2024-12-04 13:18:58 +03:00
parent 003e4d656e
commit 76ea459b3d
417 changed files with 30051 additions and 975 deletions

View File

@@ -189,24 +189,27 @@ func flattenInterfaces(ctx context.Context, items *vins.ListVNFInterfaces) types
tempSlice := make([]types.Object, 0, len(*items))
for _, item := range *items {
temp := models.VNFInterfaceModel{
ConnID: types.Int64Value(int64(item.ConnID)),
ConnType: types.StringValue(item.ConnType),
DefGW: types.StringValue(item.DefGW),
Enabled: types.BoolValue(item.Enabled),
FLIPGroupID: types.Int64Value(int64(item.FLIPGroupID)),
GUID: types.StringValue(item.GUID),
IPAddress: types.StringValue(item.IPAddress),
ListenSSH: types.BoolValue(item.ListenSSH),
MAC: types.StringValue(item.MAC),
Name: types.StringValue(item.Name),
NetID: types.Int64Value(int64(item.NetID)),
NetMask: types.Int64Value(int64(item.NetMask)),
NetType: types.StringValue(item.NetType),
NodeID: types.Int64Value(int64(item.NodeID)),
PCISlot: types.Int64Value(int64(item.PCISlot)),
QOS: flattenQOS(ctx, &item.QOS),
Target: types.StringValue(item.Target),
Type: types.StringValue(item.Type),
BusNumber: types.Int64Value(int64(item.BusNumber)),
ConnID: types.Int64Value(int64(item.ConnID)),
ConnType: types.StringValue(item.ConnType),
DefGW: types.StringValue(item.DefGW),
Enabled: types.BoolValue(item.Enabled),
FLIPGroupID: types.Int64Value(int64(item.FLIPGroupID)),
GUID: types.StringValue(item.GUID),
IPAddress: types.StringValue(item.IPAddress),
ListenSSH: types.BoolValue(item.ListenSSH),
MAC: types.StringValue(item.MAC),
MTU: types.Int64Value(int64(item.MTU)),
Libvirtsettings: flattenLibvirtSettings(ctx, &item.LibvirtSettings),
Name: types.StringValue(item.Name),
NetID: types.Int64Value(int64(item.NetID)),
NetMask: types.Int64Value(int64(item.NetMask)),
NetType: types.StringValue(item.NetType),
NodeID: types.Int64Value(int64(item.NodeID)),
PCISlot: types.Int64Value(int64(item.PCISlot)),
QOS: flattenQOS(ctx, &item.QOS),
Target: types.StringValue(item.Target),
Type: types.StringValue(item.Type),
}
temp.VNFs, diags = types.ListValueFrom(ctx, types.Int64Type, item.VNFs)
@@ -230,6 +233,28 @@ func flattenInterfaces(ctx context.Context, items *vins.ListVNFInterfaces) types
return res
}
func flattenLibvirtSettings(ctx context.Context, settings *vins.LibvirtSettings) types.Object {
tflog.Info(ctx, "Start flattenLibvirtSettings")
temp := models.LibvirtSettingsModel{
TXMode: types.StringValue(settings.TXMode),
IOEventFD: types.StringValue(settings.IOEventFD),
EventIDx: types.StringValue(settings.EventIDx),
Queues: types.Int64Value(int64(settings.Queues)),
RXQueueSize: types.Int64Value(int64(settings.RXQueueSize)),
TXQueueSize: types.Int64Value(int64(settings.TXQueueSize)),
GUID: types.StringValue(settings.GUID),
}
res, err := types.ObjectValueFrom(ctx, models.LibvirtSettings, temp)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenLibvirtSettings struct to obj", err))
}
tflog.Info(ctx, "End flattenLibvirtSettings")
return res
}
// flattenQOS flattens QOS.
// Flatten errors are added to tflog.
func flattenQOS(ctx context.Context, qos *vins.QOS) types.Object {

View File

@@ -89,25 +89,48 @@ type RecordResourcesModel struct {
}
type VNFInterfaceModel struct {
ConnID types.Int64 `tfsdk:"conn_id"`
ConnType types.String `tfsdk:"conn_type"`
DefGW types.String `tfsdk:"def_gw"`
Enabled types.Bool `tfsdk:"enabled"`
FLIPGroupID types.Int64 `tfsdk:"flipgroup_id"`
BusNumber types.Int64 `tfsdk:"bus_number"`
ConnID types.Int64 `tfsdk:"conn_id"`
ConnType types.String `tfsdk:"conn_type"`
DefGW types.String `tfsdk:"def_gw"`
Enabled types.Bool `tfsdk:"enabled"`
FLIPGroupID types.Int64 `tfsdk:"flipgroup_id"`
GUID types.String `tfsdk:"guid"`
IPAddress types.String `tfsdk:"ip_address"`
Libvirtsettings types.Object `tfsdk:"libvirt_settings"`
ListenSSH types.Bool `tfsdk:"listen_ssh"`
MAC types.String `tfsdk:"mac"`
MTU types.Int64 `tfsdk:"mtu"`
Name types.String `tfsdk:"name"`
NetID types.Int64 `tfsdk:"net_id"`
NetMask types.Int64 `tfsdk:"net_mask"`
NetType types.String `tfsdk:"net_type"`
NodeID types.Int64 `tfsdk:"node_id"`
PCISlot types.Int64 `tfsdk:"pci_slot"`
QOS types.Object `tfsdk:"qos"`
Target types.String `tfsdk:"target"`
Type types.String `tfsdk:"type"`
VNFs types.List `tfsdk:"vnfs"`
}
type LibvirtSettingsModel struct {
TXMode types.String `tfsdk:"txmode"`
IOEventFD types.String `tfsdk:"ioeventfd"`
EventIDx types.String `tfsdk:"event_idx"`
Queues types.Int64 `tfsdk:"queues"`
RXQueueSize types.Int64 `tfsdk:"rx_queue_size"`
TXQueueSize types.Int64 `tfsdk:"tx_queue_size"`
GUID types.String `tfsdk:"guid"`
IPAddress types.String `tfsdk:"ip_address"`
ListenSSH types.Bool `tfsdk:"listen_ssh"`
MAC types.String `tfsdk:"mac"`
Name types.String `tfsdk:"name"`
NetID types.Int64 `tfsdk:"net_id"`
NetMask types.Int64 `tfsdk:"net_mask"`
NetType types.String `tfsdk:"net_type"`
NodeID types.Int64 `tfsdk:"node_id"`
PCISlot types.Int64 `tfsdk:"pci_slot"`
QOS types.Object `tfsdk:"qos"`
Target types.String `tfsdk:"target"`
Type types.String `tfsdk:"type"`
VNFs types.List `tfsdk:"vnfs"`
}
var LibvirtSettings = map[string]attr.Type{
"txmode": types.StringType,
"ioeventfd": types.StringType,
"event_idx": types.StringType,
"queues": types.Int64Type,
"rx_queue_size": types.Int64Type,
"tx_queue_size": types.Int64Type,
"guid": types.StringType,
}
type QOSModel struct {
@@ -278,25 +301,28 @@ var ItemVNFDev = map[string]attr.Type{
}
var ItemInterface = map[string]attr.Type{
"conn_id": types.Int64Type,
"conn_type": types.StringType,
"def_gw": types.StringType,
"enabled": types.BoolType,
"flipgroup_id": types.Int64Type,
"guid": types.StringType,
"ip_address": types.StringType,
"listen_ssh": types.BoolType,
"mac": types.StringType,
"name": types.StringType,
"net_id": types.Int64Type,
"net_mask": types.Int64Type,
"net_type": types.StringType,
"node_id": types.Int64Type,
"pci_slot": types.Int64Type,
"qos": types.ObjectType{AttrTypes: ItemQOS},
"target": types.StringType,
"type": types.StringType,
"vnfs": types.ListType{ElemType: types.Int64Type},
"bus_number": types.Int64Type,
"conn_id": types.Int64Type,
"conn_type": types.StringType,
"def_gw": types.StringType,
"enabled": types.BoolType,
"flipgroup_id": types.Int64Type,
"guid": types.StringType,
"ip_address": types.StringType,
"libvirt_settings": types.ObjectType{AttrTypes: LibvirtSettings},
"listen_ssh": types.BoolType,
"mac": types.StringType,
"mtu": types.Int64Type,
"name": types.StringType,
"net_id": types.Int64Type,
"net_mask": types.Int64Type,
"net_type": types.StringType,
"node_id": types.Int64Type,
"pci_slot": types.Int64Type,
"qos": types.ObjectType{AttrTypes: ItemQOS},
"target": types.StringType,
"type": types.StringType,
"vnfs": types.ListType{ElemType: types.Int64Type},
}
var ItemQOS = map[string]attr.Type{

View File

@@ -12,6 +12,7 @@ type DataSourceVINSListModel struct {
AccountID types.Int64 `tfsdk:"account_id"`
RGID types.Int64 `tfsdk:"rg_id"`
ExtIP types.String `tfsdk:"ext_ip"`
VNFDevID types.Int64 `tfsdk:"vnf_dev_id"`
IncludeDeleted types.Bool `tfsdk:"include_deleted"`
Page types.Int64 `tfsdk:"page"`
SortBy types.String `tfsdk:"sort_by"`

View File

@@ -91,6 +91,9 @@ func MakeSchemaDataSourceVINS() map[string]schema.Attribute {
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"bus_number": schema.Int64Attribute{
Computed: true,
},
"conn_id": schema.Int64Attribute{
Computed: true,
},
@@ -112,12 +115,41 @@ func MakeSchemaDataSourceVINS() map[string]schema.Attribute {
"ip_address": schema.StringAttribute{
Computed: true,
},
"libvirt_settings": schema.SingleNestedAttribute{
Computed: true,
Attributes: map[string]schema.Attribute{
"txmode": schema.StringAttribute{
Computed: true,
},
"ioeventfd": schema.StringAttribute{
Computed: true,
},
"event_idx": schema.StringAttribute{
Computed: true,
},
"queues": schema.Int64Attribute{
Computed: true,
},
"rx_queue_size": schema.Int64Attribute{
Computed: true,
},
"tx_queue_size": schema.Int64Attribute{
Computed: true,
},
"guid": schema.StringAttribute{
Computed: true,
},
},
},
"listen_ssh": schema.BoolAttribute{
Computed: true,
},
"mac": schema.StringAttribute{
Computed: true,
},
"mtu": schema.Int64Attribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},

View File

@@ -27,6 +27,10 @@ func MakeSchemaDataSourceVINSList() map[string]schema.Attribute {
Optional: true,
Description: "Filter by external IP address",
},
"vnf_dev_id": schema.Int64Attribute{
Optional: true,
Description: "Filter by VNF Device id",
},
"include_deleted": schema.BoolAttribute{
Optional: true,
Description: "Include deleted computes",

View File

@@ -258,6 +258,9 @@ func MakeSchemaResourceVINS() map[string]schema.Attribute {
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"bus_number": schema.Int64Attribute{
Computed: true,
},
"conn_id": schema.Int64Attribute{
Computed: true,
},
@@ -279,12 +282,41 @@ func MakeSchemaResourceVINS() map[string]schema.Attribute {
"ip_address": schema.StringAttribute{
Computed: true,
},
"libvirt_settings": schema.SingleNestedAttribute{
Computed: true,
Attributes: map[string]schema.Attribute{
"txmode": schema.StringAttribute{
Computed: true,
},
"ioeventfd": schema.StringAttribute{
Computed: true,
},
"event_idx": schema.StringAttribute{
Computed: true,
},
"queues": schema.Int64Attribute{
Computed: true,
},
"rx_queue_size": schema.Int64Attribute{
Computed: true,
},
"tx_queue_size": schema.Int64Attribute{
Computed: true,
},
"guid": schema.StringAttribute{
Computed: true,
},
},
},
"listen_ssh": schema.BoolAttribute{
Computed: true,
},
"mac": schema.StringAttribute{
Computed: true,
},
"mtu": schema.Int64Attribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},

View File

@@ -31,6 +31,9 @@ func VINSListDataSourceCheckPresence(ctx context.Context, plan *models.DataSourc
if !plan.ExtIP.IsNull() {
listReq.ExtIP = plan.ExtIP.ValueString()
}
if !plan.VNFDevID.IsNull() {
listReq.VNFDevId = uint64(plan.VNFDevID.ValueInt64())
}
if !plan.IncludeDeleted.IsNull() {
listReq.IncludeDeleted = plan.IncludeDeleted.ValueBool()
}