1.1.0
This commit is contained in:
@@ -49,15 +49,17 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
|
||||
AffinityRules: plan.AffinityRules,
|
||||
AntiAffinityRules: plan.AntiAffinityRules,
|
||||
CustomFields: types.StringValue(string(customFields)),
|
||||
Chipset: types.StringValue(recordItemCompute.Chipset),
|
||||
Stateless: plan.Stateless,
|
||||
SepId: types.Int64Value(int64(bootdisk.SepID)),
|
||||
Pool: types.StringValue(bootdisk.Pool),
|
||||
ExtraDisks: plan.ExtraDisks,
|
||||
Network: flattenNetwork(ctx, &recordItemCompute.Interfaces),
|
||||
Network: flattenNetwork(ctx, plan.Network, &recordItemCompute.Interfaces),
|
||||
Tags: plan.Tags,
|
||||
PortForwarding: plan.PortForwarding,
|
||||
UserAccess: plan.UserAccess,
|
||||
Snapshot: plan.Snapshot,
|
||||
PCIDevices: plan.PCIDevices,
|
||||
Rollback: plan.Rollback,
|
||||
CD: plan.CD,
|
||||
PinToStack: plan.PinToStack,
|
||||
@@ -205,6 +207,7 @@ func flattenDisk(ctx context.Context, disk *compute.ItemComputeDisk) types.Objec
|
||||
ACL: types.StringValue(string(acl)),
|
||||
AccountID: types.Int64Value(int64(disk.AccountID)),
|
||||
BootPartition: types.Int64Value(int64(disk.BootPartition)),
|
||||
BusNumber: types.Int64Value(int64(disk.BusNumber)),
|
||||
CreatedTime: types.Int64Value(int64(disk.CreatedTime)),
|
||||
DeletedTime: types.Int64Value(int64(disk.DeletedTime)),
|
||||
Description: types.StringValue(disk.Description),
|
||||
@@ -385,25 +388,28 @@ func flattenResourceInterfaces(ctx context.Context, interfaces *compute.ListInte
|
||||
|
||||
for _, item := range *interfaces {
|
||||
temp := models.ItemResourceInterfacesModel{
|
||||
ConnID: types.Int64Value(int64(item.ConnID)),
|
||||
ConnType: types.StringValue(item.ConnType),
|
||||
GetGW: 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(item.PCISlot),
|
||||
QOS: flattenQOS(ctx, &item.QOS),
|
||||
Target: types.StringValue(item.Target),
|
||||
Type: types.StringValue(item.Type),
|
||||
VNFs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, item.VNFs),
|
||||
BusNumber: types.Int64Value(int64(item.BusNumber)),
|
||||
ConnID: types.Int64Value(int64(item.ConnID)),
|
||||
ConnType: types.StringValue(item.ConnType),
|
||||
GetGW: 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)),
|
||||
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(item.PCISlot),
|
||||
QOS: flattenQOS(ctx, &item.QOS),
|
||||
LibvirtSettings: flattenLibvirtSetttings(ctx, &item.LibvirtSettings),
|
||||
Target: types.StringValue(item.Target),
|
||||
Type: types.StringValue(item.Type),
|
||||
VNFs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, item.VNFs),
|
||||
}
|
||||
obj, err := types.ObjectValueFrom(ctx, models.ItemInterfaces, temp)
|
||||
if err != nil {
|
||||
@@ -439,6 +445,27 @@ func flattenQOS(ctx context.Context, QOS *compute.QOS) types.Object {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenLibvirtSetttings(ctx context.Context, settings *compute.LibvirtSettings) types.Object {
|
||||
tflog.Info(ctx, "Start flattenLibvirtSetttings")
|
||||
temp := models.LibvirtModel{
|
||||
GUID: types.StringValue(settings.GUID),
|
||||
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)),
|
||||
}
|
||||
|
||||
res, err := types.ObjectValueFrom(ctx, models.ItemLibvirtSettings, temp)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenLibvirtSetttings struct to obj", err))
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenLibvirtSetttings")
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenSnapSets(ctx context.Context, snapSets *compute.ListSnapSets) types.List {
|
||||
tflog.Info(ctx, "Start flattenSnapSets")
|
||||
tempSlice := make([]types.Object, 0, len(*snapSets))
|
||||
@@ -465,7 +492,7 @@ func flattenSnapSets(ctx context.Context, snapSets *compute.ListSnapSets) types.
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenNetwork(ctx context.Context, interfaces *compute.ListInterfaces) types.Set {
|
||||
func flattenNetwork(ctx context.Context, networks types.Set, interfaces *compute.ListInterfaces) types.Set {
|
||||
tflog.Info(ctx, "Start flattenNetwork")
|
||||
|
||||
tempSlice := make([]types.Object, 0, len(*interfaces))
|
||||
@@ -476,6 +503,8 @@ func flattenNetwork(ctx context.Context, interfaces *compute.ListInterfaces) typ
|
||||
NetId: types.Int64Value(int64(item.NetID)),
|
||||
IpAddress: types.StringValue(item.IPAddress),
|
||||
Mac: types.StringValue(item.MAC),
|
||||
Weight: flattenNetworkWeight(ctx, networks, item),
|
||||
MTU: types.Int64Value(int64(item.MTU)),
|
||||
}
|
||||
obj, err := types.ObjectValueFrom(ctx, models.ItemNetwork, temp)
|
||||
if err != nil {
|
||||
@@ -492,3 +521,16 @@ func flattenNetwork(ctx context.Context, interfaces *compute.ListInterfaces) typ
|
||||
tflog.Info(ctx, "End flattenNetwork")
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenNetworkWeight(ctx context.Context, networks types.Set, item compute.ItemVNFInterface) types.Int64 {
|
||||
tflog.Info(ctx, "Start flattenNetworkWeight")
|
||||
networkList := networks.Elements()
|
||||
for _, network := range networkList {
|
||||
networkMap := network.(types.Object).Attributes()
|
||||
if uint64(networkMap["net_id"].(types.Int64).ValueInt64()) == item.NetID && networkMap["net_type"].(types.String).ValueString() == item.NetType {
|
||||
return types.Int64Value(networkMap["weight"].(types.Int64).ValueInt64())
|
||||
}
|
||||
}
|
||||
tflog.Info(ctx, "End flattenNetworkWeight")
|
||||
return types.Int64Value(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user