This commit is contained in:
asteam
2025-07-01 13:44:09 +03:00
parent 5382579a5f
commit ddbb12996d
1041 changed files with 2842 additions and 96448 deletions

View File

@@ -51,6 +51,7 @@ func DataSourceCompute(ctx context.Context, state *models.RecordComputeModel, c
Chipset: types.StringValue(computeRecord.Chipset),
BootDiskSize: types.Int64Value(int64(computeRecord.BootDiskSize)),
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, &computeRecord.BootOrder),
BootType: types.StringValue(computeRecord.BootType),
CdImageId: types.Int64Value(int64(computeRecord.CdImageId)),
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.Clones),
CloneReference: types.Int64Value(int64(computeRecord.CloneReference)),
@@ -69,10 +70,12 @@ func DataSourceCompute(ctx context.Context, state *models.RecordComputeModel, c
GID: types.Int64Value(int64(computeRecord.GID)),
GUID: types.Int64Value(int64(computeRecord.GUID)),
HPBacked: types.BoolValue(computeRecord.HPBacked),
HotResize: types.BoolValue(computeRecord.HotResize),
ImageID: types.Int64Value(int64(computeRecord.ImageID)),
ImageName: types.StringValue(computeRecord.ImageName),
Interfaces: flattenInterfaces(ctx, &computeRecord.Interfaces),
LockStatus: types.StringValue(computeRecord.LockStatus),
LoaderType: types.StringValue(computeRecord.LoaderType),
ManagerID: types.Int64Value(int64(computeRecord.ManagerID)),
ManagerType: types.StringValue(computeRecord.ManagerType),
MigrationJob: types.Int64Value(int64(computeRecord.MigrationJob)),
@@ -84,32 +87,33 @@ func DataSourceCompute(ctx context.Context, state *models.RecordComputeModel, c
NatableVINSNetwork: types.StringValue(computeRecord.NatableVINSNetwork),
NatableVINSNetworkName: types.StringValue(computeRecord.NatableVINSNetworkName),
NeedReboot: types.BoolValue(computeRecord.NeedReboot),
NetworkInterfaceNaming: types.StringValue(computeRecord.NetworkInterfaceNaming),
NumaAffinity: types.StringValue(computeRecord.NumaAffinity),
NumaNodeId: types.Int64Value(int64(computeRecord.NumaNodeId)),
OSUsers: flattenOSUsers(ctx, &computeRecord.OSUsers),
Pinned: types.BoolValue(computeRecord.Pinned),
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.PreferredCPU),
PCIDevices: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, flattenPCI(ctx, pciDevicesList)),
RAM: types.Int64Value(int64(computeRecord.RAM)),
ReferenceID: types.StringValue(computeRecord.ReferenceID),
Registered: types.BoolValue(computeRecord.Registered),
ResName: types.StringValue(computeRecord.ResName),
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.ReservedNodeCpus),
RGID: types.Int64Value(int64(computeRecord.RGID)),
RGName: types.StringValue(computeRecord.RGName),
SnapSets: flattenSnapSet(ctx, &computeRecord.SnapSets),
StatelessSepID: types.Int64Value(int64(computeRecord.StatelessSepID)),
StatelessSepType: types.StringValue(computeRecord.StatelessSepType),
Status: types.StringValue(computeRecord.Status),
TechStatus: types.StringValue(computeRecord.TechStatus),
UpdatedBy: types.StringValue(computeRecord.UpdatedBy),
UpdatedTime: types.Int64Value(int64(computeRecord.UpdatedTime)),
UserManaged: types.BoolValue(computeRecord.UserManaged),
Userdata: types.StringValue(string(userdata)),
VirtualImageID: types.Int64Value(int64(computeRecord.VirtualImageID)),
VirtualImageName: types.StringValue(computeRecord.VirtualImageName),
VNCPassword: types.StringValue(computeRecord.VNCPassword),
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.VGPUs),
//Pinned: types.BoolValue(computeRecord.Pinned),
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.PreferredCPU),
PCIDevices: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, flattenPCI(ctx, pciDevicesList)),
RAM: types.Int64Value(int64(computeRecord.RAM)),
ReferenceID: types.StringValue(computeRecord.ReferenceID),
Registered: types.BoolValue(computeRecord.Registered),
ResName: types.StringValue(computeRecord.ResName),
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.ReservedNodeCpus),
RGID: types.Int64Value(int64(computeRecord.RGID)),
RGName: types.StringValue(computeRecord.RGName),
SnapSets: flattenSnapSet(ctx, &computeRecord.SnapSets),
StatelessSepID: types.Int64Value(int64(computeRecord.StatelessSepID)),
StatelessSepType: types.StringValue(computeRecord.StatelessSepType),
Status: types.StringValue(computeRecord.Status),
TechStatus: types.StringValue(computeRecord.TechStatus),
UpdatedBy: types.StringValue(computeRecord.UpdatedBy),
UpdatedTime: types.Int64Value(int64(computeRecord.UpdatedTime)),
UserManaged: types.BoolValue(computeRecord.UserManaged),
Userdata: types.StringValue(string(userdata)),
VirtualImageID: types.Int64Value(int64(computeRecord.VirtualImageID)),
VirtualImageName: types.StringValue(computeRecord.VirtualImageName),
VNCPassword: types.StringValue(computeRecord.VNCPassword),
VGPUs: flattenComputeVGPU(ctx, computeRecord.VGPUs),
}
state.Tags, diags = types.MapValueFrom(ctx, types.StringType, computeRecord.Tags)
@@ -232,23 +236,24 @@ func flattenDisks(ctx context.Context, disks *compute.ListComputeDisks) []models
StorageID: types.StringValue(item.Replication.StorageID),
VolumeID: types.StringValue(item.Replication.VolumeID),
},
ResID: types.StringValue(item.ResID),
Role: types.StringValue(item.Role),
SepID: types.Int64Value(int64(item.SepID)),
Shareable: types.BoolValue(item.Shareable),
SizeMax: types.Int64Value(int64(item.SizeMax)),
SizeUsed: types.Float64Value(item.SizeUsed),
Snapshots: flattenSnapshotExtend(ctx, &item.Snapshots),
Status: types.StringValue(item.Status),
TechStatus: types.StringValue(item.TechStatus),
Type: types.StringValue(item.Type),
VMID: types.Int64Value(int64(item.VMID)),
ResID: types.StringValue(item.ResID),
Role: types.StringValue(item.Role),
SepID: types.Int64Value(int64(item.SepID)),
Shareable: types.BoolValue(item.Shareable),
SizeAvailable: types.Float64Value(item.SizeAvailable),
SizeMax: types.Int64Value(int64(item.SizeMax)),
SizeUsed: types.Float64Value(item.SizeUsed),
Snapshots: flattenSnapshotExtend(ctx, &item.Snapshots),
Status: types.StringValue(item.Status),
TechStatus: types.StringValue(item.TechStatus),
Type: types.StringValue(item.Type),
VMID: types.Int64Value(int64(item.VMID)),
}
temp.Images, diags = types.ListValueFrom(ctx, types.Int64Type, item.Images)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenDisks", diags))
}
temp.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, item.PresentTo)
temp.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, item.PresentTo)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenDisks", diags))
}
@@ -387,3 +392,36 @@ func flattenPCI(ctx context.Context, pciList *compute.ListPCIDevices) []uint64 {
tflog.Info(ctx, "End flattenPCI")
return res
}
func flattenComputeVGPU(ctx context.Context, vgpuList []compute.VGPUItem) []models.VGPUModel {
tflog.Info(ctx, "Start flattenVGPU")
res := make([]models.VGPUModel, 0, len(vgpuList))
for _, item := range vgpuList {
temp := models.VGPUModel{
ID: types.Int64Value(int64(item.ID)),
GID: types.Int64Value(int64(item.GID)),
Type: types.StringValue(item.Type),
Mode: types.StringValue(item.Mode),
Status: types.StringValue(item.Status),
ProfileID: types.Int64Value(int64(item.ProfileID)),
RAM: types.Int64Value(int64(item.RAM)),
LastUpdateTime: types.Int64Value(int64(item.LastUpdateTime)),
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
VMID: types.Int64Value(int64(item.VMID)),
PGPUID: types.Int64Value(int64(item.PGPuid)),
ReferenceID: types.StringValue(item.ReferenceID),
AccountID: types.Int64Value(int64(item.AccountID)),
RGID: types.Int64Value(int64(item.RgID)),
LastClaimedBy: types.Int64Value(int64(item.LastClaimedBy)),
PCISlot: types.Int64Value(int64(item.PCISlot)),
BusNumber: types.Int64Value(int64(item.BusNumber)),
GUID: types.Int64Value(int64(item.GUID)),
}
res = append(res, temp)
}
tflog.Info(ctx, "End flattenVGPU")
return res
}

View File

@@ -65,69 +65,73 @@ func flattenItemsList(ctx context.Context, computes *compute.ListComputes) []mod
customFields, _ := json.Marshal(item.CustomFields)
devices, _ := json.Marshal(item.Devices)
temp := models.ItemComputeModel{
ACL: flattenACLInList(ctx, &item.ACL),
AccountID: types.Int64Value(int64(item.AccountID)),
AccountName: types.StringValue(item.AccountName),
AffinityLabel: types.StringValue(item.AffinityLabel),
AffinityRules: flattenAffinityRuleInList(ctx, &item.AffinityRules),
AffinityWeight: types.Int64Value(int64(item.AffinityWeight)),
AntiAffinityRules: flattenAffinityRuleInList(ctx, &item.AntiAffinityRules),
Architecture: types.StringValue(item.Architecture),
AutoStartWithNode: types.BoolValue(item.AutoStart),
BootDiskSize: types.Int64Value(int64(item.BootDiskSize)),
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, &item.BootOrder),
CdImageId: types.Int64Value(int64(item.CdImageId)),
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.Clones),
CloneReference: types.Int64Value(int64(item.CloneReference)),
Chipset: types.StringValue(item.Chipset),
ComputeCIID: types.Int64Value(int64(item.ComputeCIID)),
CPU: types.Int64Value(int64(item.CPU)),
CPUPin: types.BoolValue(item.CPUPin),
CreatedBy: types.StringValue(item.CreatedBy),
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
CustomFields: types.StringValue(string(customFields)),
DeletedBy: types.StringValue(item.DeletedBy),
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
Description: types.StringValue(item.Description),
Devices: types.StringValue(string(devices)),
Disks: flattenDisksInList(ctx, &item.Disks),
Driver: types.StringValue(item.Driver),
GID: types.Int64Value(int64(item.GID)),
GUID: types.Int64Value(int64(item.GUID)),
HPBacked: types.BoolValue(item.HPBacked),
ComputeId: types.Int64Value(int64(item.ID)),
ImageID: types.Int64Value(int64(item.ImageID)),
Interfaces: flattenInterfaceInList(ctx, &item.Interfaces),
LockStatus: types.StringValue(item.LockStatus),
ManagerID: types.Int64Value(int64(item.ManagerID)),
ManagerType: types.StringValue(item.ManagerType),
MigrationJob: types.Int64Value(int64(item.MigrationJob)),
Milestones: types.Int64Value(int64(item.Milestones)),
Name: types.StringValue(item.Name),
NeedReboot: types.BoolValue(item.NeedReboot),
NumaAffinity: types.StringValue(item.NumaAffinity),
NumaNodeId: types.Int64Value(int64(item.NumaNodeId)),
Pinned: types.BoolValue(item.Pinned),
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.PreferredCPU),
RAM: types.Int64Value(int64(item.RAM)),
ReferenceID: types.StringValue(item.ReferenceID),
Registered: types.BoolValue(item.Registered),
ResName: types.StringValue(item.ResName),
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.ReservedNodeCpus),
RGID: types.Int64Value(int64(item.RGID)),
RGName: types.StringValue(item.RGName),
SnapSets: flattenSnapSetInList(ctx, &item.SnapSets),
StatelessSepID: types.Int64Value(int64(item.StatelessSepID)),
StatelessSepType: types.StringValue(item.StatelessSepType),
Status: types.StringValue(item.Status),
TechStatus: types.StringValue(item.TechStatus),
TotalDiskSize: types.Int64Value(int64(item.TotalDiskSize)),
UpdatedBy: types.StringValue(item.UpdatedBy),
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
UserManaged: types.BoolValue(item.UserManaged),
VINSConnected: types.Int64Value(int64(item.VINSConnected)),
VirtualImageID: types.Int64Value(int64(item.VirtualImageID)),
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.VGPUs),
ACL: flattenACLInList(ctx, &item.ACL),
AccountID: types.Int64Value(int64(item.AccountID)),
AccountName: types.StringValue(item.AccountName),
AffinityLabel: types.StringValue(item.AffinityLabel),
AffinityRules: flattenAffinityRuleInList(ctx, &item.AffinityRules),
AffinityWeight: types.Int64Value(int64(item.AffinityWeight)),
AntiAffinityRules: flattenAffinityRuleInList(ctx, &item.AntiAffinityRules),
Architecture: types.StringValue(item.Architecture),
AutoStartWithNode: types.BoolValue(item.AutoStart),
BootDiskSize: types.Int64Value(int64(item.BootDiskSize)),
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, &item.BootOrder),
BootType: types.StringValue(item.BootType),
CdImageId: types.Int64Value(int64(item.CdImageId)),
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.Clones),
CloneReference: types.Int64Value(int64(item.CloneReference)),
Chipset: types.StringValue(item.Chipset),
ComputeCIID: types.Int64Value(int64(item.ComputeCIID)),
CPU: types.Int64Value(int64(item.CPU)),
CPUPin: types.BoolValue(item.CPUPin),
CreatedBy: types.StringValue(item.CreatedBy),
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
CustomFields: types.StringValue(string(customFields)),
DeletedBy: types.StringValue(item.DeletedBy),
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
Description: types.StringValue(item.Description),
Devices: types.StringValue(string(devices)),
Disks: flattenDisksInList(ctx, &item.Disks),
Driver: types.StringValue(item.Driver),
GID: types.Int64Value(int64(item.GID)),
GUID: types.Int64Value(int64(item.GUID)),
HPBacked: types.BoolValue(item.HPBacked),
HotResize: types.BoolValue(item.HotResize),
ComputeId: types.Int64Value(int64(item.ID)),
ImageID: types.Int64Value(int64(item.ImageID)),
Interfaces: flattenInterfaceInList(ctx, &item.Interfaces),
LockStatus: types.StringValue(item.LockStatus),
LoaderType: types.StringValue(item.LoaderType),
ManagerID: types.Int64Value(int64(item.ManagerID)),
ManagerType: types.StringValue(item.ManagerType),
MigrationJob: types.Int64Value(int64(item.MigrationJob)),
Milestones: types.Int64Value(int64(item.Milestones)),
Name: types.StringValue(item.Name),
NeedReboot: types.BoolValue(item.NeedReboot),
NetworkInterfaceNaming: types.StringValue(item.NetworkInterfaceNaming),
NumaAffinity: types.StringValue(item.NumaAffinity),
NumaNodeId: types.Int64Value(int64(item.NumaNodeId)),
//Pinned: types.BoolValue(item.Pinned),
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.PreferredCPU),
RAM: types.Int64Value(int64(item.RAM)),
ReferenceID: types.StringValue(item.ReferenceID),
Registered: types.BoolValue(item.Registered),
ResName: types.StringValue(item.ResName),
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.ReservedNodeCpus),
RGID: types.Int64Value(int64(item.RGID)),
RGName: types.StringValue(item.RGName),
SnapSets: flattenSnapSetInList(ctx, &item.SnapSets),
StatelessSepID: types.Int64Value(int64(item.StatelessSepID)),
StatelessSepType: types.StringValue(item.StatelessSepType),
Status: types.StringValue(item.Status),
TechStatus: types.StringValue(item.TechStatus),
TotalDiskSize: types.Int64Value(int64(item.TotalDiskSize)),
UpdatedBy: types.StringValue(item.UpdatedBy),
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
UserManaged: types.BoolValue(item.UserManaged),
VINSConnected: types.Int64Value(int64(item.VINSConnected)),
VirtualImageID: types.Int64Value(int64(item.VirtualImageID)),
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.VGPUs),
}
temp.Tags, diags = types.MapValueFrom(ctx, types.StringType, item.Tags)
@@ -187,9 +191,9 @@ func flattenDisksInList(ctx context.Context, disks *compute.ListInfoDisks) []mod
res := make([]models.DiskInListModel, 0, len(*disks))
for _, item := range *disks {
temp := models.DiskInListModel{
BusNumber: types.Int64Value(int64(item.BusNumber)),
DiskId: types.Int64Value(int64(item.ID)),
PCISlot: types.Int64Value(item.PCISlot),
//BusNumber: types.Int64Value(int64(item.BusNumber)),
DiskId: types.Int64Value(int64(item.ID)),
//PCISlot: types.Int64Value(item.PCISlot),
}
res = append(res, temp)
}

View File

@@ -63,69 +63,73 @@ func flattenItemsListDeleted(ctx context.Context, computes *compute.ListComputes
customFields, _ := json.Marshal(item.CustomFields)
devices, _ := json.Marshal(item.Devices)
temp := models.ItemListDeletedComputeModel{
ACL: flattenACLInListDeleted(ctx, &item.ACL),
AccountID: types.Int64Value(int64(item.AccountID)),
AccountName: types.StringValue(item.AccountName),
AffinityLabel: types.StringValue(item.AffinityLabel),
AffinityRules: flattenAffinityRuleInListDeleted(ctx, &item.AffinityRules),
AffinityWeight: types.Int64Value(int64(item.AffinityWeight)),
AntiAffinityRules: flattenAffinityRuleInListDeleted(ctx, &item.AntiAffinityRules),
Architecture: types.StringValue(item.Architecture),
AutoStartWithNode: types.BoolValue(item.AutoStart),
BootDiskSize: types.Int64Value(int64(item.BootDiskSize)),
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, &item.BootOrder),
CdImageId: types.Int64Value(int64(item.CdImageId)),
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.Clones),
Chipset: types.StringValue(item.Chipset),
CloneReference: types.Int64Value(int64(item.CloneReference)),
ComputeCIID: types.Int64Value(int64(item.ComputeCIID)),
CPU: types.Int64Value(int64(item.CPU)),
CPUPin: types.BoolValue(item.CPUPin),
CreatedBy: types.StringValue(item.CreatedBy),
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
CustomFields: types.StringValue(string(customFields)),
DeletedBy: types.StringValue(item.DeletedBy),
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
Description: types.StringValue(item.Description),
Devices: types.StringValue(string(devices)),
Disks: flattenDisksInListDeleted(ctx, &item.Disks),
Driver: types.StringValue(item.Driver),
GID: types.Int64Value(int64(item.GID)),
GUID: types.Int64Value(int64(item.GUID)),
HPBacked: types.BoolValue(item.HPBacked),
ComputeId: types.Int64Value(int64(item.ID)),
ImageID: types.Int64Value(int64(item.ImageID)),
Interfaces: flattenInterfaceInListDeleted(ctx, &item.Interfaces),
LockStatus: types.StringValue(item.LockStatus),
ManagerID: types.Int64Value(int64(item.ManagerID)),
ManagerType: types.StringValue(item.ManagerType),
MigrationJob: types.Int64Value(int64(item.MigrationJob)),
Milestones: types.Int64Value(int64(item.Milestones)),
Name: types.StringValue(item.Name),
NeedReboot: types.BoolValue(item.NeedReboot),
NumaAffinity: types.StringValue(item.NumaAffinity),
NumaNodeId: types.Int64Value(int64(item.NumaNodeId)),
Pinned: types.BoolValue(item.Pinned),
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.PreferredCPU),
RAM: types.Int64Value(int64(item.RAM)),
ReferenceID: types.StringValue(item.ReferenceID),
Registered: types.BoolValue(item.Registered),
ResName: types.StringValue(item.ResName),
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.ReservedNodeCpus),
RGID: types.Int64Value(int64(item.RGID)),
RGName: types.StringValue(item.RGName),
SnapSets: flattenSnapSetInListDeleted(ctx, &item.SnapSets),
StatelessSepID: types.Int64Value(int64(item.StatelessSepID)),
StatelessSepType: types.StringValue(item.StatelessSepType),
Status: types.StringValue(item.Status),
TechStatus: types.StringValue(item.TechStatus),
TotalDiskSize: types.Int64Value(int64(item.TotalDiskSize)),
UpdatedBy: types.StringValue(item.UpdatedBy),
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
UserManaged: types.BoolValue(item.UserManaged),
VINSConnected: types.Int64Value(int64(item.VINSConnected)),
VirtualImageID: types.Int64Value(int64(item.VirtualImageID)),
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.VGPUs),
ACL: flattenACLInListDeleted(ctx, &item.ACL),
AccountID: types.Int64Value(int64(item.AccountID)),
AccountName: types.StringValue(item.AccountName),
AffinityLabel: types.StringValue(item.AffinityLabel),
AffinityRules: flattenAffinityRuleInListDeleted(ctx, &item.AffinityRules),
AffinityWeight: types.Int64Value(int64(item.AffinityWeight)),
AntiAffinityRules: flattenAffinityRuleInListDeleted(ctx, &item.AntiAffinityRules),
Architecture: types.StringValue(item.Architecture),
AutoStartWithNode: types.BoolValue(item.AutoStart),
BootDiskSize: types.Int64Value(int64(item.BootDiskSize)),
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, &item.BootOrder),
BootType: types.StringValue(item.BootType),
CdImageId: types.Int64Value(int64(item.CdImageId)),
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.Clones),
Chipset: types.StringValue(item.Chipset),
CloneReference: types.Int64Value(int64(item.CloneReference)),
ComputeCIID: types.Int64Value(int64(item.ComputeCIID)),
CPU: types.Int64Value(int64(item.CPU)),
CPUPin: types.BoolValue(item.CPUPin),
CreatedBy: types.StringValue(item.CreatedBy),
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
CustomFields: types.StringValue(string(customFields)),
DeletedBy: types.StringValue(item.DeletedBy),
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
Description: types.StringValue(item.Description),
Devices: types.StringValue(string(devices)),
Disks: flattenDisksInListDeleted(ctx, &item.Disks),
Driver: types.StringValue(item.Driver),
GID: types.Int64Value(int64(item.GID)),
GUID: types.Int64Value(int64(item.GUID)),
HPBacked: types.BoolValue(item.HPBacked),
HotResize: types.BoolValue(item.HotResize),
ComputeId: types.Int64Value(int64(item.ID)),
ImageID: types.Int64Value(int64(item.ImageID)),
Interfaces: flattenInterfaceInListDeleted(ctx, &item.Interfaces),
LockStatus: types.StringValue(item.LockStatus),
LoaderType: types.StringValue(item.LoaderType),
ManagerID: types.Int64Value(int64(item.ManagerID)),
ManagerType: types.StringValue(item.ManagerType),
MigrationJob: types.Int64Value(int64(item.MigrationJob)),
Milestones: types.Int64Value(int64(item.Milestones)),
Name: types.StringValue(item.Name),
NeedReboot: types.BoolValue(item.NeedReboot),
NetworkInterfaceNaming: types.StringValue(item.NetworkInterfaceNaming),
NumaAffinity: types.StringValue(item.NumaAffinity),
NumaNodeId: types.Int64Value(int64(item.NumaNodeId)),
//Pinned: types.BoolValue(item.Pinned),
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.PreferredCPU),
RAM: types.Int64Value(int64(item.RAM)),
ReferenceID: types.StringValue(item.ReferenceID),
Registered: types.BoolValue(item.Registered),
ResName: types.StringValue(item.ResName),
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.ReservedNodeCpus),
RGID: types.Int64Value(int64(item.RGID)),
RGName: types.StringValue(item.RGName),
SnapSets: flattenSnapSetInListDeleted(ctx, &item.SnapSets),
StatelessSepID: types.Int64Value(int64(item.StatelessSepID)),
StatelessSepType: types.StringValue(item.StatelessSepType),
Status: types.StringValue(item.Status),
TechStatus: types.StringValue(item.TechStatus),
TotalDiskSize: types.Int64Value(int64(item.TotalDiskSize)),
UpdatedBy: types.StringValue(item.UpdatedBy),
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
UserManaged: types.BoolValue(item.UserManaged),
VINSConnected: types.Int64Value(int64(item.VINSConnected)),
VirtualImageID: types.Int64Value(int64(item.VirtualImageID)),
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.VGPUs),
}
temp.Tags, diags = types.MapValueFrom(ctx, types.StringType, item.Tags)
@@ -185,9 +189,9 @@ func flattenDisksInListDeleted(ctx context.Context, disks *compute.ListInfoDisks
res := make([]models.DiskInListDeletedModel, 0, len(*disks))
for _, item := range *disks {
temp := models.DiskInListDeletedModel{
BusNumber: types.Int64Value(int64(item.BusNumber)),
DiskId: types.Int64Value(int64(item.ID)),
PCISlot: types.Int64Value(item.PCISlot),
//BusNumber: types.Int64Value(int64(item.BusNumber)),
DiskId: types.Int64Value(int64(item.ID)),
//PCISlot: types.Int64Value(item.PCISlot),
}
res = append(res, temp)
}

View File

@@ -25,6 +25,24 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
if diags.HasError() {
return diags
}
pfwList, err := utilities.ComputeResourcePFWListGet(ctx, recordItemCompute.ID, c)
if err != nil {
if err != nil {
diags.AddError("ComputeResourcePFWListGet error: ", err.Error())
tflog.Error(ctx, fmt.Sprint("ComputeResourcePFWListGet error ", err))
}
}
userList, err := utilities.ComputeResourceUserAccessGet(ctx, recordItemCompute.ID, c)
if err != nil {
tflog.Error(ctx, fmt.Sprintf("Error getting user list: %v", err))
}
pciDevicesList, err := utilities.ResourceComputePCIDevicesListCheckPresence(ctx, recordItemCompute.ID, c)
if err != nil {
tflog.Error(ctx, fmt.Sprintf("Error getting pci list: %v", err))
}
bootdisk := findBootDisk(recordItemCompute.Disks)
devices, _ := json.Marshal(recordItemCompute.Devices)
userdata, _ := json.Marshal(recordItemCompute.Userdata)
@@ -32,57 +50,58 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
*plan = models.ResourceComputeModel{
// required fields
Name: plan.Name,
RGID: plan.RGID,
Driver: plan.Driver,
CPU: plan.CPU,
RAM: plan.RAM,
ID: plan.ID,
Name: types.StringValue(recordItemCompute.Name),
RGID: types.Int64Value(int64(recordItemCompute.RGID)),
Driver: types.StringValue(recordItemCompute.Driver),
CPU: types.Int64Value(int64(recordItemCompute.CPU)),
RAM: types.Int64Value(int64(recordItemCompute.RAM)),
Timeouts: plan.Timeouts,
// optional fields
ImageID: plan.ImageID,
ImageID: types.Int64Value(int64(bootdisk.ImageID)),
WithoutBootDisk: plan.WithoutBootDisk,
// we intentionally use the SizeMax field, do not change it until the BootDiskSize field is fixed on the platform
BootDiskSize: types.Int64Value(int64(bootdisk.SizeMax)),
AffinityLabel: types.StringValue(recordItemCompute.AffinityLabel),
AffinityRules: plan.AffinityRules,
AntiAffinityRules: plan.AntiAffinityRules,
AutoStartWithNode: types.BoolValue(recordItemCompute.AutoStart),
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, 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,
Description: types.StringValue(recordItemCompute.Description),
CloudInit: plan.CloudInit,
Enabled: plan.Enabled,
Pause: plan.Pause,
Reset: plan.Reset,
Restore: plan.Restore,
AutoStart: plan.AutoStart,
ForceStop: plan.ForceStop,
ForceResize: plan.ForceResize,
DataDisks: plan.DataDisks,
Started: plan.Started,
DetachDisks: plan.DetachDisks,
Permanently: plan.Permanently,
IS: plan.IS,
IpaType: plan.IpaType,
NumaAffinity: plan.NumaAffinity,
CPUPin: plan.CPUPin,
HPBacked: plan.HPBacked,
BootDiskSize: types.Int64Value(int64(bootdisk.SizeMax)),
AffinityLabel: types.StringValue(recordItemCompute.AffinityLabel),
AffinityRules: flattenComputeAffinityRule(ctx, &recordItemCompute.AffinityRules),
AntiAffinityRules: flattenComputeAffinityRule(ctx, &recordItemCompute.AntiAffinityRules),
AutoStartWithNode: types.BoolValue(recordItemCompute.AutoStart),
CustomFields: types.StringValue(string(customFields)),
Chipset: types.StringValue(recordItemCompute.Chipset),
SepId: types.Int64Value(int64(bootdisk.SepID)),
Pool: types.StringValue(bootdisk.Pool),
ExtraDisks: plan.ExtraDisks,
Network: flattenNetwork(ctx, plan.Network, &recordItemCompute.Interfaces),
Tags: flattenComputeTags(ctx, recordItemCompute.Tags),
PortForwarding: flattenComputePortForwarding(ctx, pfwList.Data),
UserAccess: flattenUserAccess(ctx, userList),
Snapshot: plan.Snapshot,
PCIDevices: flattens.FlattenSimpleTypeToSet(ctx, types.Int64Type, flattenPCIDevices(ctx, pciDevicesList)),
Rollback: plan.Rollback,
CDImageID: types.Int64Value(int64(recordItemCompute.CdImageId)),
PinToStack: types.BoolValue(recordItemCompute.PinnedToStack),
Description: types.StringValue(recordItemCompute.Description),
CloudInit: plan.CloudInit,
Enabled: types.BoolValue(recordItemCompute.Status == "ENABLED"),
Pause: types.BoolValue(recordItemCompute.TechStatus == "PAUSED"),
Reset: plan.Reset,
Restore: plan.Restore,
ForceStop: plan.ForceStop,
ForceResize: plan.ForceResize,
Started: types.BoolValue(recordItemCompute.TechStatus == "STARTED"),
DetachDisks: plan.DetachDisks,
Permanently: plan.Permanently,
IS: plan.IS,
IpaType: plan.IpaType,
NumaAffinity: types.StringValue(recordItemCompute.NumaAffinity),
CPUPin: types.BoolValue(recordItemCompute.CPUPin),
HPBacked: types.BoolValue(recordItemCompute.HPBacked),
SnapshotDeleteAsync: plan.SnapshotDeleteAsync,
LoaderType: types.StringValue(recordItemCompute.LoaderType),
BootType: types.StringValue(recordItemCompute.BootType),
HotResize: types.BoolValue(recordItemCompute.HotResize),
NetworkInterfaceNaming: types.StringValue(recordItemCompute.NetworkInterfaceNaming),
//computed fields
AccountId: types.Int64Value(int64(recordItemCompute.AccountID)),
AccountName: types.StringValue(recordItemCompute.AccountName),
@@ -92,7 +111,6 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, recordItemCompute.BootOrder),
BootDisk: flattenDisk(ctx, bootdisk),
BootDiskId: types.Int64Value(int64(bootdisk.ID)),
CdImageId: types.Int64Value(int64(recordItemCompute.CdImageId)),
CloneReference: types.Int64Value(int64(recordItemCompute.CloneReference)),
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordItemCompute.Clones),
ComputeCIID: types.Int64Value(int64(recordItemCompute.ComputeCIID)),
@@ -105,6 +123,7 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
Disks: flattenResourceDisks(ctx, &recordItemCompute.Disks),
GID: types.Int64Value(int64(recordItemCompute.GID)),
GUID: types.Int64Value(int64(recordItemCompute.GUID)),
ID: plan.ID,
ImageName: types.StringValue(recordItemCompute.ImageName),
Interfaces: flattenResourceInterfaces(ctx, &recordItemCompute.Interfaces),
LockStatus: types.StringValue(recordItemCompute.LockStatus),
@@ -120,7 +139,7 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
NeedReboot: types.BoolValue(recordItemCompute.NeedReboot),
NumaNodeId: types.Int64Value(int64(recordItemCompute.NumaNodeId)),
OSUsers: flattenResourceOSUsers(ctx, &recordItemCompute.OSUsers),
Pinned: types.BoolValue(recordItemCompute.Pinned),
Pinned: types.BoolValue(recordItemCompute.PinnedToStack),
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordItemCompute.PreferredCPU),
ReferenceID: types.StringValue(recordItemCompute.ReferenceID),
Registered: types.BoolValue(recordItemCompute.Registered),
@@ -136,7 +155,7 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
UpdatedTime: types.Int64Value(int64(recordItemCompute.UpdatedTime)),
UserManaged: types.BoolValue(recordItemCompute.UserManaged),
Userdata: types.StringValue(string(userdata)),
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordItemCompute.VGPUs),
VGPUs: flattenResourceComputeVGPU(ctx, recordItemCompute.VGPUs),
VirtualImageID: types.Int64Value(int64(recordItemCompute.VirtualImageID)),
VirtualImageName: types.StringValue(recordItemCompute.VirtualImageName),
VNCPassword: types.StringValue(recordItemCompute.VNCPassword),
@@ -204,9 +223,10 @@ func flattenACLItems(ctx context.Context, item *compute.ListACL) types.List {
func flattenDisk(ctx context.Context, disk *compute.ItemComputeDisk) types.Object {
tflog.Info(ctx, fmt.Sprintf("flattenDisk: start flatten disk with ID - %v", disk.ID))
diags := diag.Diagnostics{}
acl, _ := json.Marshal(disk.ACL)
temp := models.ItemResourceDiskModel{
CKey: types.StringValue(disk.CKey),
ACL: types.StringValue(string(acl)),
AccountID: types.Int64Value(int64(disk.AccountID)),
BootPartition: types.Int64Value(int64(disk.BootPartition)),
@@ -220,7 +240,7 @@ func flattenDisk(ctx context.Context, disk *compute.ItemComputeDisk) types.Objec
GUID: types.Int64Value(int64(disk.GUID)),
ID: types.Int64Value(int64(disk.ID)),
ImageID: types.Int64Value(int64(disk.ImageID)),
Images: flattens.FlattenSimpleTypeToList(ctx, types.StringType, disk.Images),
Images: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, disk.Images),
IOTune: flattensIOTune(ctx, &disk.IOTune),
IQN: types.StringValue(disk.IQN),
Login: types.StringValue(disk.Login),
@@ -232,7 +252,6 @@ func flattenDisk(ctx context.Context, disk *compute.ItemComputeDisk) types.Objec
Passwd: types.StringValue(disk.Passwd),
Pool: types.StringValue(disk.Pool),
PCISlot: types.Int64Value(disk.PCISlot),
PresentTo: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, disk.PresentTo),
PurgeTime: types.Int64Value(int64(disk.PurgeTime)),
RealityDeviceNumber: types.Int64Value(int64(disk.RealityDeviceNumber)),
Replication: flattenDiskReplication(ctx, &disk.Replication),
@@ -249,9 +268,14 @@ func flattenDisk(ctx context.Context, disk *compute.ItemComputeDisk) types.Objec
VMID: types.Int64Value(int64(disk.VMID)),
}
res, err := types.ObjectValueFrom(ctx, models.ItemDisk, temp)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenDisk struct to obj", err))
temp.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, disk.PresentTo)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenPresentTo", diags))
}
res, diags := types.ObjectValueFrom(ctx, models.ItemDisk, temp)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenDisk struct to obj", diags))
}
tflog.Info(ctx, fmt.Sprintf("flattenDisk: end flatten disk with ID - %v", disk.ID))
@@ -537,3 +561,165 @@ func flattenNetworkWeight(ctx context.Context, networks types.Set, item compute.
tflog.Info(ctx, "End flattenNetworkWeight")
return types.Int64Value(0)
}
func flattenComputeAffinityRule(ctx context.Context, rules *compute.ListRules) types.Set {
tflog.Info(ctx, "Start flattenAffinityRule")
tempSlice := make([]types.Object, 0, len(*rules))
for _, item := range *rules {
temp := models.ItemResourceRulesModel{
Key: types.StringValue(item.Key),
Mode: types.StringValue(item.Mode),
Policy: types.StringValue(item.Policy),
Topology: types.StringValue(item.Topology),
Value: types.StringValue(item.Value),
}
obj, err := types.ObjectValueFrom(ctx, models.ItemResourceRules, temp)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenComputeAffinityRule struct to obj", err))
}
tempSlice = append(tempSlice, obj)
}
res, err := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.ItemResourceRules}, tempSlice)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenComputeAffinityRule", err))
}
tflog.Info(ctx, "End flattenAffinityRule")
return res
}
func flattenComputeTags(ctx context.Context, tags map[string]string) types.Set {
tflog.Info(ctx, "Start flattenComputeTags")
tempSlice := make([]types.Object, 0, len(tags))
for key, value := range tags {
temp := models.ItemTagModel{
Key: types.StringValue(key),
Value: types.StringValue(value),
}
obj, err := types.ObjectValueFrom(ctx, models.ItemTag, temp)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenComputeTags struct to obj", err))
}
tempSlice = append(tempSlice, obj)
}
res, err := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.ItemTag}, tempSlice)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenComputeTags", err))
}
tflog.Info(ctx, "End flattenComputeTags")
return res
}
func flattenComputePortForwarding(ctx context.Context, list []compute.ItemPFW) types.Set {
tflog.Info(ctx, "Start flattenComputePortForwarding")
tempSlice := make([]types.Object, 0, len(list))
for _, item := range list {
temp := models.ItemPortForfardingModel{
PublicPortStart: types.Int64Value(int64(item.PublicPortStart)),
PublicPortEnd: types.Int64Value(int64(item.PublicPortEnd)),
LocalPort: types.Int64Value(int64(item.LocalPort)),
Proto: types.StringValue(item.Protocol),
}
obj, err := types.ObjectValueFrom(ctx, models.ItemPortForfarding, temp)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenComputePortForwarding struct to obj", err))
}
tempSlice = append(tempSlice, obj)
}
res, err := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.ItemPortForfarding}, tempSlice)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenComputePortForwarding", err))
}
tflog.Info(ctx, "End flattenComputePortForwarding")
return res
}
func flattenUserAccess(ctx context.Context, userList *compute.ListUsers) types.Set {
tflog.Info(ctx, "Start flattenUserAccess")
tempSlice := make([]types.Object, 0)
// Process compute ACL
for _, item := range userList.Data.ComputeACL {
temp := models.UserAccessModel{
Username: types.StringValue(item.UserGroupID),
AccessType: types.StringValue(item.Right),
}
obj, diags := types.ObjectValueFrom(ctx, models.ItemUserAccess, temp)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenUserAccess struct to obj", diags))
continue
}
tempSlice = append(tempSlice, obj)
}
res, diags := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.ItemUserAccess}, tempSlice)
if diags != nil {
tflog.Error(ctx, fmt.Sprint("Error flattenUserAccess", diags))
}
tflog.Info(ctx, "End flattenUserAccess")
return res
}
func flattenPCIDevices(ctx context.Context, pciList *compute.ListPCIDevices) []uint64 {
tflog.Info(ctx, "Start flattenPCI")
res := make([]uint64, 0, len(pciList.Data))
for _, v := range pciList.Data {
res = append(res, v.ID)
}
tflog.Info(ctx, "End flattenPCI")
return res
}
func flattenResourceComputeVGPU(ctx context.Context, vgpuList []compute.VGPUItem) types.List {
tflog.Info(ctx, "Start flattenVGPU")
tempSlice := make([]types.Object, 0, len(vgpuList))
for _, item := range vgpuList {
temp := models.ComputeVGPUModel{
ID: types.Int64Value(int64(item.ID)),
GID: types.Int64Value(int64(item.GID)),
Type: types.StringValue(item.Type),
Mode: types.StringValue(item.Mode),
Status: types.StringValue(item.Status),
ProfileID: types.Int64Value(int64(item.ProfileID)),
RAM: types.Int64Value(int64(item.RAM)),
LastUpdateTime: types.Int64Value(int64(item.LastUpdateTime)),
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
VMID: types.Int64Value(int64(item.VMID)),
PGPUID: types.Int64Value(int64(item.PGPuid)),
ReferenceID: types.StringValue(item.ReferenceID),
AccountID: types.Int64Value(int64(item.AccountID)),
RGID: types.Int64Value(int64(item.RgID)),
LastClaimedBy: types.Int64Value(int64(item.LastClaimedBy)),
PCISlot: types.Int64Value(int64(item.PCISlot)),
BusNumber: types.Int64Value(int64(item.BusNumber)),
GUID: types.Int64Value(int64(item.GUID)),
}
obj, err := types.ObjectValueFrom(ctx, models.ComputeItemVGPU, temp)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error converting VGPU model to object", err))
}
tempSlice = append(tempSlice, obj)
}
res, err := types.ListValueFrom(ctx, types.ObjectType{AttrTypes: models.ComputeItemVGPU}, tempSlice)
if err != nil {
tflog.Error(ctx, fmt.Sprint("Error creating VGPU list value", err))
}
tflog.Info(ctx, "End flattenVGPU")
return res
}

View File

@@ -79,10 +79,14 @@ type RecordComputeModel struct {
UpdatedTime types.Int64 `tfsdk:"updated_time"`
UserManaged types.Bool `tfsdk:"user_managed"`
Userdata types.String `tfsdk:"user_data"`
VGPUs types.List `tfsdk:"vgpus"`
VGPUs []VGPUModel `tfsdk:"vgpus"`
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
VirtualImageName types.String `tfsdk:"virtual_image_name"`
VNCPassword types.String `tfsdk:"vnc_password"`
LoaderType types.String `tfsdk:"loader_type"`
BootType types.String `tfsdk:"boot_type"`
HotResize types.Bool `tfsdk:"hot_resize"`
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
}
type RecordACLModel struct {
@@ -136,7 +140,7 @@ type ItemDiskModel struct {
Passwd types.String `tfsdk:"passwd"`
PCISlot types.Int64 `tfsdk:"pci_slot"`
Pool types.String `tfsdk:"pool"`
PresentTo types.List `tfsdk:"present_to"`
PresentTo types.Map `tfsdk:"present_to"`
PurgeTime types.Int64 `tfsdk:"purge_time"`
ReferenceID types.String `tfsdk:"reference_id"`
RealityDeviceNumber types.Int64 `tfsdk:"reality_device_number"`
@@ -145,6 +149,7 @@ type ItemDiskModel struct {
Role types.String `tfsdk:"role"`
SepID types.Int64 `tfsdk:"sep_id"`
Shareable types.Bool `tfsdk:"shareable"`
SizeAvailable types.Float64 `tfsdk:"size_available"`
SizeMax types.Int64 `tfsdk:"size_max"`
SizeUsed types.Float64 `tfsdk:"size_used"`
Snapshots []ItemSnapshotExtendModel `tfsdk:"snapshots"`
@@ -244,3 +249,25 @@ type ReplicationModel struct {
StorageID types.String `tfsdk:"storage_id"`
VolumeID types.String `tfsdk:"volume_id"`
}
type VGPUModel struct {
ID types.Int64 `tfsdk:"id"`
GID types.Int64 `tfsdk:"gid"`
Type types.String `tfsdk:"type"`
Mode types.String `tfsdk:"mode"`
Status types.String `tfsdk:"status"`
ProfileID types.Int64 `tfsdk:"profile_id"`
RAM types.Int64 `tfsdk:"ram"`
LastUpdateTime types.Int64 `tfsdk:"last_update_time"`
CreatedTime types.Int64 `tfsdk:"created_time"`
DeletedTime types.Int64 `tfsdk:"deleted_time"`
VMID types.Int64 `tfsdk:"vmid"`
PGPUID types.Int64 `tfsdk:"pgpuid"`
ReferenceID types.String `tfsdk:"reference_id"`
AccountID types.Int64 `tfsdk:"account_id"`
RGID types.Int64 `tfsdk:"rg_id"`
LastClaimedBy types.Int64 `tfsdk:"last_claimed_by"`
PCISlot types.Int64 `tfsdk:"pci_slot"`
BusNumber types.Int64 `tfsdk:"bus_number"`
GUID types.Int64 `tfsdk:"guid"`
}

View File

@@ -30,70 +30,74 @@ type ListComputesModel struct {
}
type ItemComputeModel struct {
ACL []ItemACLInListModel `tfsdk:"acl"`
AccountID types.Int64 `tfsdk:"account_id"`
AccountName types.String `tfsdk:"account_name"`
AffinityLabel types.String `tfsdk:"affinity_label"`
AffinityRules []ItemRuleInListModel `tfsdk:"affinity_rules"`
AffinityWeight types.Int64 `tfsdk:"affinity_weight"`
AntiAffinityRules []ItemRuleInListModel `tfsdk:"anti_affinity_rules"`
Architecture types.String `tfsdk:"arch"`
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
BootOrder types.List `tfsdk:"boot_order"`
BootDiskSize types.Int64 `tfsdk:"bootdisk_size"`
CdImageId types.Int64 `tfsdk:"cd_image_id"`
CloneReference types.Int64 `tfsdk:"clone_reference"`
Clones types.List `tfsdk:"clones"`
Chipset types.String `tfsdk:"chipset"`
ComputeCIID types.Int64 `tfsdk:"computeci_id"`
CPU types.Int64 `tfsdk:"cpus"`
CPUPin types.Bool `tfsdk:"cpu_pin"`
CreatedBy types.String `tfsdk:"created_by"`
CreatedTime types.Int64 `tfsdk:"created_time"`
CustomFields types.String `tfsdk:"custom_fields"`
DeletedBy types.String `tfsdk:"deleted_by"`
DeletedTime types.Int64 `tfsdk:"deleted_time"`
Description types.String `tfsdk:"desc"`
Devices types.String `tfsdk:"devices"`
Disks []DiskInListModel `tfsdk:"disks"`
Driver types.String `tfsdk:"driver"`
GID types.Int64 `tfsdk:"gid"`
GUID types.Int64 `tfsdk:"guid"`
HPBacked types.Bool `tfsdk:"hp_backed"`
ComputeId types.Int64 `tfsdk:"compute_id"`
ImageID types.Int64 `tfsdk:"image_id"`
Interfaces []ItemVNFInterfaceInListModel `tfsdk:"interfaces"`
LockStatus types.String `tfsdk:"lock_status"`
ManagerID types.Int64 `tfsdk:"manager_id"`
ManagerType types.String `tfsdk:"manager_type"`
MigrationJob types.Int64 `tfsdk:"migrationjob"`
Milestones types.Int64 `tfsdk:"milestones"`
Name types.String `tfsdk:"name"`
NeedReboot types.Bool `tfsdk:"need_reboot"`
NumaAffinity types.String `tfsdk:"numa_affinity"`
NumaNodeId types.Int64 `tfsdk:"numa_node_id"`
Pinned types.Bool `tfsdk:"pinned"`
PreferredCPU types.List `tfsdk:"preferred_cpu"`
RAM types.Int64 `tfsdk:"ram"`
ReferenceID types.String `tfsdk:"reference_id"`
Registered types.Bool `tfsdk:"registered"`
ResName types.String `tfsdk:"res_name"`
ReservedNodeCpus types.List `tfsdk:"reserved_node_cpus"`
RGID types.Int64 `tfsdk:"rg_id"`
RGName types.String `tfsdk:"rg_name"`
SnapSets []ItemSnapSetInListModel `tfsdk:"snap_sets"`
StatelessSepID types.Int64 `tfsdk:"stateless_sep_id"`
StatelessSepType types.String `tfsdk:"stateless_sep_type"`
Status types.String `tfsdk:"status"`
Tags types.Map `tfsdk:"tags"`
TechStatus types.String `tfsdk:"tech_status"`
TotalDiskSize types.Int64 `tfsdk:"total_disks_size"`
UpdatedBy types.String `tfsdk:"updated_by"`
UpdatedTime types.Int64 `tfsdk:"updated_time"`
UserManaged types.Bool `tfsdk:"user_managed"`
VGPUs types.List `tfsdk:"vgpus"`
VINSConnected types.Int64 `tfsdk:"vins_connected"`
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
ACL []ItemACLInListModel `tfsdk:"acl"`
AccountID types.Int64 `tfsdk:"account_id"`
AccountName types.String `tfsdk:"account_name"`
AffinityLabel types.String `tfsdk:"affinity_label"`
AffinityRules []ItemRuleInListModel `tfsdk:"affinity_rules"`
AffinityWeight types.Int64 `tfsdk:"affinity_weight"`
AntiAffinityRules []ItemRuleInListModel `tfsdk:"anti_affinity_rules"`
Architecture types.String `tfsdk:"arch"`
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
BootOrder types.List `tfsdk:"boot_order"`
BootDiskSize types.Int64 `tfsdk:"bootdisk_size"`
CdImageId types.Int64 `tfsdk:"cd_image_id"`
CloneReference types.Int64 `tfsdk:"clone_reference"`
Clones types.List `tfsdk:"clones"`
Chipset types.String `tfsdk:"chipset"`
ComputeCIID types.Int64 `tfsdk:"computeci_id"`
CPU types.Int64 `tfsdk:"cpus"`
CPUPin types.Bool `tfsdk:"cpu_pin"`
CreatedBy types.String `tfsdk:"created_by"`
CreatedTime types.Int64 `tfsdk:"created_time"`
CustomFields types.String `tfsdk:"custom_fields"`
DeletedBy types.String `tfsdk:"deleted_by"`
DeletedTime types.Int64 `tfsdk:"deleted_time"`
Description types.String `tfsdk:"desc"`
Devices types.String `tfsdk:"devices"`
Disks []DiskInListModel `tfsdk:"disks"`
Driver types.String `tfsdk:"driver"`
GID types.Int64 `tfsdk:"gid"`
GUID types.Int64 `tfsdk:"guid"`
HPBacked types.Bool `tfsdk:"hp_backed"`
ComputeId types.Int64 `tfsdk:"compute_id"`
ImageID types.Int64 `tfsdk:"image_id"`
Interfaces []ItemVNFInterfaceInListModel `tfsdk:"interfaces"`
LockStatus types.String `tfsdk:"lock_status"`
ManagerID types.Int64 `tfsdk:"manager_id"`
ManagerType types.String `tfsdk:"manager_type"`
MigrationJob types.Int64 `tfsdk:"migrationjob"`
Milestones types.Int64 `tfsdk:"milestones"`
Name types.String `tfsdk:"name"`
NeedReboot types.Bool `tfsdk:"need_reboot"`
NumaAffinity types.String `tfsdk:"numa_affinity"`
NumaNodeId types.Int64 `tfsdk:"numa_node_id"`
Pinned types.Bool `tfsdk:"pinned"`
PreferredCPU types.List `tfsdk:"preferred_cpu"`
RAM types.Int64 `tfsdk:"ram"`
ReferenceID types.String `tfsdk:"reference_id"`
Registered types.Bool `tfsdk:"registered"`
ResName types.String `tfsdk:"res_name"`
ReservedNodeCpus types.List `tfsdk:"reserved_node_cpus"`
RGID types.Int64 `tfsdk:"rg_id"`
RGName types.String `tfsdk:"rg_name"`
SnapSets []ItemSnapSetInListModel `tfsdk:"snap_sets"`
StatelessSepID types.Int64 `tfsdk:"stateless_sep_id"`
StatelessSepType types.String `tfsdk:"stateless_sep_type"`
Status types.String `tfsdk:"status"`
Tags types.Map `tfsdk:"tags"`
TechStatus types.String `tfsdk:"tech_status"`
TotalDiskSize types.Int64 `tfsdk:"total_disks_size"`
UpdatedBy types.String `tfsdk:"updated_by"`
UpdatedTime types.Int64 `tfsdk:"updated_time"`
UserManaged types.Bool `tfsdk:"user_managed"`
VGPUs types.List `tfsdk:"vgpus"`
VINSConnected types.Int64 `tfsdk:"vins_connected"`
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
LoaderType types.String `tfsdk:"loader_type"`
BootType types.String `tfsdk:"boot_type"`
HotResize types.Bool `tfsdk:"hot_resize"`
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
}
type ItemACLInListModel struct {

View File

@@ -28,70 +28,74 @@ type ListDeletedComputesModel struct {
}
type ItemListDeletedComputeModel struct {
ACL []ItemACLInListDeletedModel `tfsdk:"acl"`
AccountID types.Int64 `tfsdk:"account_id"`
AccountName types.String `tfsdk:"account_name"`
AffinityLabel types.String `tfsdk:"affinity_label"`
AffinityRules []ItemRuleInListDeletedModel `tfsdk:"affinity_rules"`
AffinityWeight types.Int64 `tfsdk:"affinity_weight"`
AntiAffinityRules []ItemRuleInListDeletedModel `tfsdk:"anti_affinity_rules"`
Architecture types.String `tfsdk:"arch"`
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
BootOrder types.List `tfsdk:"boot_order"`
BootDiskSize types.Int64 `tfsdk:"bootdisk_size"`
CdImageId types.Int64 `tfsdk:"cd_image_id"`
Chipset types.String `tfsdk:"chipset"`
CloneReference types.Int64 `tfsdk:"clone_reference"`
Clones types.List `tfsdk:"clones"`
ComputeCIID types.Int64 `tfsdk:"computeci_id"`
CPU types.Int64 `tfsdk:"cpus"`
CPUPin types.Bool `tfsdk:"cpu_pin"`
CreatedBy types.String `tfsdk:"created_by"`
CreatedTime types.Int64 `tfsdk:"created_time"`
CustomFields types.String `tfsdk:"custom_fields"`
DeletedBy types.String `tfsdk:"deleted_by"`
DeletedTime types.Int64 `tfsdk:"deleted_time"`
Description types.String `tfsdk:"desc"`
Devices types.String `tfsdk:"devices"`
Disks []DiskInListDeletedModel `tfsdk:"disks"`
Driver types.String `tfsdk:"driver"`
GID types.Int64 `tfsdk:"gid"`
GUID types.Int64 `tfsdk:"guid"`
HPBacked types.Bool `tfsdk:"hp_backed"`
ComputeId types.Int64 `tfsdk:"compute_id"`
ImageID types.Int64 `tfsdk:"image_id"`
Interfaces []ItemVNFInterfaceInListDeletedModel `tfsdk:"interfaces"`
LockStatus types.String `tfsdk:"lock_status"`
ManagerID types.Int64 `tfsdk:"manager_id"`
ManagerType types.String `tfsdk:"manager_type"`
MigrationJob types.Int64 `tfsdk:"migrationjob"`
Milestones types.Int64 `tfsdk:"milestones"`
Name types.String `tfsdk:"name"`
NeedReboot types.Bool `tfsdk:"need_reboot"`
NumaAffinity types.String `tfsdk:"numa_affinity"`
NumaNodeId types.Int64 `tfsdk:"numa_node_id"`
Pinned types.Bool `tfsdk:"pinned"`
PreferredCPU types.List `tfsdk:"preferred_cpu"`
RAM types.Int64 `tfsdk:"ram"`
ReferenceID types.String `tfsdk:"reference_id"`
Registered types.Bool `tfsdk:"registered"`
ResName types.String `tfsdk:"res_name"`
ReservedNodeCpus types.List `tfsdk:"reserved_node_cpus"`
RGID types.Int64 `tfsdk:"rg_id"`
RGName types.String `tfsdk:"rg_name"`
SnapSets []ItemSnapSetInListDeletedModel `tfsdk:"snap_sets"`
StatelessSepID types.Int64 `tfsdk:"stateless_sep_id"`
StatelessSepType types.String `tfsdk:"stateless_sep_type"`
Status types.String `tfsdk:"status"`
Tags types.Map `tfsdk:"tags"`
TechStatus types.String `tfsdk:"tech_status"`
TotalDiskSize types.Int64 `tfsdk:"total_disks_size"`
UpdatedBy types.String `tfsdk:"updated_by"`
UpdatedTime types.Int64 `tfsdk:"updated_time"`
UserManaged types.Bool `tfsdk:"user_managed"`
VGPUs types.List `tfsdk:"vgpus"`
VINSConnected types.Int64 `tfsdk:"vins_connected"`
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
ACL []ItemACLInListDeletedModel `tfsdk:"acl"`
AccountID types.Int64 `tfsdk:"account_id"`
AccountName types.String `tfsdk:"account_name"`
AffinityLabel types.String `tfsdk:"affinity_label"`
AffinityRules []ItemRuleInListDeletedModel `tfsdk:"affinity_rules"`
AffinityWeight types.Int64 `tfsdk:"affinity_weight"`
AntiAffinityRules []ItemRuleInListDeletedModel `tfsdk:"anti_affinity_rules"`
Architecture types.String `tfsdk:"arch"`
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
BootOrder types.List `tfsdk:"boot_order"`
BootDiskSize types.Int64 `tfsdk:"bootdisk_size"`
CdImageId types.Int64 `tfsdk:"cd_image_id"`
Chipset types.String `tfsdk:"chipset"`
CloneReference types.Int64 `tfsdk:"clone_reference"`
Clones types.List `tfsdk:"clones"`
ComputeCIID types.Int64 `tfsdk:"computeci_id"`
CPU types.Int64 `tfsdk:"cpus"`
CPUPin types.Bool `tfsdk:"cpu_pin"`
CreatedBy types.String `tfsdk:"created_by"`
CreatedTime types.Int64 `tfsdk:"created_time"`
CustomFields types.String `tfsdk:"custom_fields"`
DeletedBy types.String `tfsdk:"deleted_by"`
DeletedTime types.Int64 `tfsdk:"deleted_time"`
Description types.String `tfsdk:"desc"`
Devices types.String `tfsdk:"devices"`
Disks []DiskInListDeletedModel `tfsdk:"disks"`
Driver types.String `tfsdk:"driver"`
GID types.Int64 `tfsdk:"gid"`
GUID types.Int64 `tfsdk:"guid"`
HPBacked types.Bool `tfsdk:"hp_backed"`
ComputeId types.Int64 `tfsdk:"compute_id"`
ImageID types.Int64 `tfsdk:"image_id"`
Interfaces []ItemVNFInterfaceInListDeletedModel `tfsdk:"interfaces"`
LockStatus types.String `tfsdk:"lock_status"`
ManagerID types.Int64 `tfsdk:"manager_id"`
ManagerType types.String `tfsdk:"manager_type"`
MigrationJob types.Int64 `tfsdk:"migrationjob"`
Milestones types.Int64 `tfsdk:"milestones"`
Name types.String `tfsdk:"name"`
NeedReboot types.Bool `tfsdk:"need_reboot"`
NumaAffinity types.String `tfsdk:"numa_affinity"`
NumaNodeId types.Int64 `tfsdk:"numa_node_id"`
Pinned types.Bool `tfsdk:"pinned"`
PreferredCPU types.List `tfsdk:"preferred_cpu"`
RAM types.Int64 `tfsdk:"ram"`
ReferenceID types.String `tfsdk:"reference_id"`
Registered types.Bool `tfsdk:"registered"`
ResName types.String `tfsdk:"res_name"`
ReservedNodeCpus types.List `tfsdk:"reserved_node_cpus"`
RGID types.Int64 `tfsdk:"rg_id"`
RGName types.String `tfsdk:"rg_name"`
SnapSets []ItemSnapSetInListDeletedModel `tfsdk:"snap_sets"`
StatelessSepID types.Int64 `tfsdk:"stateless_sep_id"`
StatelessSepType types.String `tfsdk:"stateless_sep_type"`
Status types.String `tfsdk:"status"`
Tags types.Map `tfsdk:"tags"`
TechStatus types.String `tfsdk:"tech_status"`
TotalDiskSize types.Int64 `tfsdk:"total_disks_size"`
UpdatedBy types.String `tfsdk:"updated_by"`
UpdatedTime types.Int64 `tfsdk:"updated_time"`
UserManaged types.Bool `tfsdk:"user_managed"`
VGPUs types.List `tfsdk:"vgpus"`
VINSConnected types.Int64 `tfsdk:"vins_connected"`
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
LoaderType types.String `tfsdk:"loader_type"`
BootType types.String `tfsdk:"boot_type"`
HotResize types.Bool `tfsdk:"hot_resize"`
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
}
type ItemACLInListDeletedModel struct {

View File

@@ -16,47 +16,49 @@ type ResourceComputeModel struct {
RAM types.Int64 `tfsdk:"ram"`
//optional fields
ImageID types.Int64 `tfsdk:"image_id"`
WithoutBootDisk types.Bool `tfsdk:"without_boot_disk"`
BootDiskSize types.Int64 `tfsdk:"boot_disk_size"`
AffinityLabel types.String `tfsdk:"affinity_label"`
AffinityRules types.Set `tfsdk:"affinity_rules"`
AntiAffinityRules types.Set `tfsdk:"anti_affinity_rules"`
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
CustomFields types.String `tfsdk:"custom_fields"`
Chipset types.String `tfsdk:"chipset"`
Stateless types.Bool `tfsdk:"stateless"`
SepId types.Int64 `tfsdk:"sep_id"`
Pool types.String `tfsdk:"pool"`
ExtraDisks types.Set `tfsdk:"extra_disks"`
Network types.Set `tfsdk:"network"`
Tags types.Set `tfsdk:"tags"`
PortForwarding types.Set `tfsdk:"port_forwarding"`
UserAccess types.Set `tfsdk:"user_access"`
Snapshot types.Set `tfsdk:"snapshot"`
PCIDevices types.Set `tfsdk:"pci_devices"`
Rollback types.Object `tfsdk:"rollback"`
CD types.Object `tfsdk:"cd"`
PinToStack types.Bool `tfsdk:"pin_to_stack"`
PreferredCPU types.List `tfsdk:"preferred_cpu"`
Description types.String `tfsdk:"description"`
CloudInit types.String `tfsdk:"cloud_init"`
Enabled types.Bool `tfsdk:"enabled"`
Pause types.Bool `tfsdk:"pause"`
Reset types.Bool `tfsdk:"reset"`
Restore types.Bool `tfsdk:"restore"`
AutoStart types.Bool `tfsdk:"auto_start"`
ForceStop types.Bool `tfsdk:"force_stop"`
ForceResize types.Bool `tfsdk:"force_resize"`
DataDisks types.String `tfsdk:"data_disks"`
Started types.Bool `tfsdk:"started"`
DetachDisks types.Bool `tfsdk:"detach_disks"`
Permanently types.Bool `tfsdk:"permanently"`
IS types.String `tfsdk:"is"`
IpaType types.String `tfsdk:"ipa_type"`
NumaAffinity types.String `tfsdk:"numa_affinity"`
CPUPin types.Bool `tfsdk:"cpu_pin"`
HPBacked types.Bool `tfsdk:"hp_backed"`
ImageID types.Int64 `tfsdk:"image_id"`
WithoutBootDisk types.Bool `tfsdk:"without_boot_disk"`
BootDiskSize types.Int64 `tfsdk:"boot_disk_size"`
AffinityLabel types.String `tfsdk:"affinity_label"`
AffinityRules types.Set `tfsdk:"affinity_rules"`
AntiAffinityRules types.Set `tfsdk:"anti_affinity_rules"`
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
CustomFields types.String `tfsdk:"custom_fields"`
Chipset types.String `tfsdk:"chipset"`
SepId types.Int64 `tfsdk:"sep_id"`
Pool types.String `tfsdk:"pool"`
ExtraDisks types.Set `tfsdk:"extra_disks"`
Network types.Set `tfsdk:"network"`
Tags types.Set `tfsdk:"tags"`
PortForwarding types.Set `tfsdk:"port_forwarding"`
UserAccess types.Set `tfsdk:"user_access"`
Snapshot types.Set `tfsdk:"snapshot"`
PCIDevices types.Set `tfsdk:"pci_devices"`
Rollback types.Object `tfsdk:"rollback"`
CDImageID types.Int64 `tfsdk:"cd_image_id"`
PinToStack types.Bool `tfsdk:"pin_to_stack"`
PreferredCPU types.List `tfsdk:"preferred_cpu"`
Description types.String `tfsdk:"description"`
CloudInit types.String `tfsdk:"cloud_init"`
Enabled types.Bool `tfsdk:"enabled"`
Pause types.Bool `tfsdk:"pause"`
Reset types.Bool `tfsdk:"reset"`
Restore types.Bool `tfsdk:"restore"`
ForceStop types.Bool `tfsdk:"force_stop"`
ForceResize types.Bool `tfsdk:"force_resize"`
Started types.Bool `tfsdk:"started"`
DetachDisks types.Bool `tfsdk:"detach_disks"`
Permanently types.Bool `tfsdk:"permanently"`
IS types.String `tfsdk:"is"`
IpaType types.String `tfsdk:"ipa_type"`
NumaAffinity types.String `tfsdk:"numa_affinity"`
CPUPin types.Bool `tfsdk:"cpu_pin"`
HPBacked types.Bool `tfsdk:"hp_backed"`
LoaderType types.String `tfsdk:"loader_type"`
BootType types.String `tfsdk:"boot_type"`
HotResize types.Bool `tfsdk:"hot_resize"`
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
SnapshotDeleteAsync types.Bool `tfsdk:"snapshot_delete_async"`
// response fields
ID types.String `tfsdk:"id"`
@@ -68,7 +70,6 @@ type ResourceComputeModel struct {
BootOrder types.List `tfsdk:"boot_order"`
BootDisk types.Object `tfsdk:"boot_disk"`
BootDiskId types.Int64 `tfsdk:"boot_disk_id"`
CdImageId types.Int64 `tfsdk:"cd_image_id"`
CloneReference types.Int64 `tfsdk:"clone_reference"`
Clones types.List `tfsdk:"clones"`
ComputeCIID types.Int64 `tfsdk:"computeci_id"`
@@ -125,7 +126,6 @@ type RecordResourceACLModel struct {
}
type ItemResourceDiskModel struct {
CKey types.String `tfsdk:"ckey"`
ACL types.String `tfsdk:"acl"`
AccountID types.Int64 `tfsdk:"account_id"`
BootPartition types.Int64 `tfsdk:"boot_partition"`
@@ -151,7 +151,7 @@ type ItemResourceDiskModel struct {
Passwd types.String `tfsdk:"passwd"`
PCISlot types.Int64 `tfsdk:"pci_slot"`
Pool types.String `tfsdk:"pool"`
PresentTo types.List `tfsdk:"present_to"`
PresentTo types.Map `tfsdk:"present_to"`
PurgeTime types.Int64 `tfsdk:"purge_time"`
ReferenceID types.String `tfsdk:"reference_id"`
RealityDeviceNumber types.Int64 `tfsdk:"reality_device_number"`
@@ -218,6 +218,38 @@ type ItemResourceRulesModel struct {
Value types.String `tfsdk:"value"`
}
type ItemTagModel struct {
Key types.String `tfsdk:"key"`
Value types.String `tfsdk:"value"`
}
type UserAccessModel struct {
Username types.String `tfsdk:"username"`
AccessType types.String `tfsdk:"access_type"`
}
type ComputeVGPUModel struct {
ID types.Int64 `tfsdk:"id"`
GID types.Int64 `tfsdk:"gid"`
Type types.String `tfsdk:"type"`
Mode types.String `tfsdk:"mode"`
Status types.String `tfsdk:"status"`
ProfileID types.Int64 `tfsdk:"profile_id"`
RAM types.Int64 `tfsdk:"ram"`
LastUpdateTime types.Int64 `tfsdk:"last_update_time"`
CreatedTime types.Int64 `tfsdk:"created_time"`
DeletedTime types.Int64 `tfsdk:"deleted_time"`
VMID types.Int64 `tfsdk:"vmid"`
PGPUID types.Int64 `tfsdk:"pgpuid"`
ReferenceID types.String `tfsdk:"reference_id"`
AccountID types.Int64 `tfsdk:"account_id"`
RGID types.Int64 `tfsdk:"rg_id"`
LastClaimedBy types.Int64 `tfsdk:"last_claimed_by"`
PCISlot types.Int64 `tfsdk:"pci_slot"`
BusNumber types.Int64 `tfsdk:"bus_number"`
GUID types.Int64 `tfsdk:"guid"`
}
var ItemNetwork = map[string]attr.Type{
"net_type": types.StringType,
"net_id": types.Int64Type,
@@ -228,7 +260,6 @@ var ItemNetwork = map[string]attr.Type{
}
var ItemDisk = map[string]attr.Type{
"ckey": types.StringType,
"acl": types.StringType,
"account_id": types.Int64Type,
"boot_partition": types.Int64Type,
@@ -242,7 +273,7 @@ var ItemDisk = map[string]attr.Type{
"guid": types.Int64Type,
"disk_id": types.Int64Type,
"image_id": types.Int64Type,
"images": types.ListType{ElemType: types.StringType},
"images": types.ListType{ElemType: types.Int64Type},
"iotune": types.ObjectType{AttrTypes: disks.ItemIOTune},
"iqn": types.StringType,
"login": types.StringType,
@@ -254,7 +285,7 @@ var ItemDisk = map[string]attr.Type{
"passwd": types.StringType,
"pci_slot": types.Int64Type,
"pool": types.StringType,
"present_to": types.ListType{ElemType: types.Int64Type},
"present_to": types.MapType{ElemType: types.Int64Type},
"purge_time": types.Int64Type,
"replication": types.ObjectType{AttrTypes: ItemReplication},
"reality_device_number": types.Int64Type,
@@ -361,3 +392,50 @@ var ItemSnapSets = map[string]attr.Type{
"label": types.StringType,
"timestamp": types.Int64Type,
}
var ItemResourceRules = map[string]attr.Type{
"key": types.StringType,
"mode": types.StringType,
"policy": types.StringType,
"topology": types.StringType,
"value": types.StringType,
}
var ItemTag = map[string]attr.Type{
"key": types.StringType,
"value": types.StringType,
}
var ItemPortForfarding = map[string]attr.Type{
"public_port_start": types.Int64Type,
"public_port_end": types.Int64Type,
"local_port": types.Int64Type,
"proto": types.StringType,
}
var ItemUserAccess = map[string]attr.Type{
"username": types.StringType,
"access_type": types.StringType,
}
var ComputeItemVGPU = map[string]attr.Type{
"id": types.Int64Type,
"gid": types.Int64Type,
"type": types.StringType,
"mode": types.StringType,
"status": types.StringType,
"profile_id": types.Int64Type,
"ram": types.Int64Type,
"last_update_time": types.Int64Type,
"created_time": types.Int64Type,
"deleted_time": types.Int64Type,
"vmid": types.Int64Type,
"pgpuid": types.Int64Type,
"reference_id": types.StringType,
"account_id": types.Int64Type,
"rg_id": types.Int64Type,
"last_claimed_by": types.Int64Type,
"pci_slot": types.Int64Type,
"bus_number": types.Int64Type,
"guid": types.Int64Type,
}

View File

@@ -80,7 +80,7 @@ func (r *resourceCompute) Create(ctx context.Context, req resource.CreateRequest
tflog.Info(ctx, "Create resourceCompute: new simple Compute created", map[string]any{"id": ComputeId, "name": plan.Name.ValueString()})
// attach extra disk(s) to new compute
if !plan.ExtraDisks.IsNull() {
if !plan.ExtraDisks.IsNull() && !plan.ExtraDisks.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourceExtraDiskCreate(ctx, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Create resourceCompute: error when attaching extra disk(s) to a new Compute ")
@@ -112,52 +112,52 @@ func (r *resourceCompute) Create(ctx context.Context, req resource.CreateRequest
}
// add affinity_rules if needed, warnings added to resp.Diagnostics in case of failure.
if !plan.AffinityRules.IsNull() {
if !plan.AffinityRules.IsNull() && !plan.AffinityRules.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourceAffinityRules(ctx, &plan, r.client)...)
}
// add anti_affinity_rules if needed, warnings added to resp.Diagnostics in case of failure.
if !plan.AntiAffinityRules.IsNull() {
if !plan.AntiAffinityRules.IsNull() && !plan.AntiAffinityRules.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourceAntiAffinityRules(ctx, &plan, r.client)...)
}
// add tags if needed, warnings added to resp.Diagnostics in case of failure.
if !plan.Tags.IsNull() {
if !plan.Tags.IsNull() && !plan.Tags.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourceTags(ctx, &plan, r.client)...)
}
// add port_forwarding if needed, warnings added to resp.Diagnostics in case of failure.
if !plan.PortForwarding.IsNull() {
if !plan.PortForwarding.IsNull() && !plan.PortForwarding.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourcePortForwarding(ctx, &plan, r.client)...)
}
// add user_access if needed, warnings added to resp.Diagnostics in case of failure.
if !plan.UserAccess.IsNull() {
if !plan.UserAccess.IsNull() && !plan.UserAccess.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourceUserAccess(ctx, &plan, r.client)...)
}
// add snapshot if needed, warnings added to resp.Diagnostics in case of failure.
if !plan.Snapshot.IsNull() {
if !plan.Snapshot.IsNull() && !plan.Snapshot.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourceSnapshot(ctx, &plan, r.client)...)
}
// add cd if needed, warnings added to resp.Diagnostics in case of failure.
if !plan.CD.IsNull() {
if !plan.CDImageID.IsNull() && !plan.CDImageID.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourceCDInsert(ctx, &plan, r.client)...)
}
// attach PCI devices to compute if needed, warnings added to resp.Diagnostics in case of failure.
if !plan.PCIDevices.IsNull() {
if !plan.PCIDevices.IsNull() && !plan.PCIDevices.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourcePCIDevice(ctx, &plan, r.client)...)
}
// set auto start_w_node if pin_to_stack == false
if !plan.PinToStack.ValueBool() && plan.AutoStartWithNode.ValueBool() {
if !plan.PinToStack.ValueBool() && plan.AutoStartWithNode.ValueBool() && !plan.PinToStack.IsUnknown() && !plan.AutoStartWithNode.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourceAutoStartWithNode(ctx, &plan, r.client)...)
}
// pause if needed, warnings added to resp.Diagnostics in case of failure.
if !plan.Pause.IsNull() && plan.Pause.ValueBool() {
if !plan.Pause.IsNull() && plan.Pause.ValueBool() && !plan.Pause.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourcePause(ctx, &plan, r.client)...)
}
@@ -275,7 +275,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
plan.ID = state.ID
// Enable/disable Compute if needed
if !plan.Enabled.Equal(state.Enabled) {
if !plan.Enabled.IsUnknown() && !plan.Enabled.Equal(state.Enabled) {
resp.Diagnostics.Append(utilities.ComputeResourceEnableDisable(ctx, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error enable/disable Compute")
@@ -284,7 +284,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Start/stop Compute if needed
if !plan.Started.Equal(state.Started) {
if !plan.Started.IsUnknown() && !plan.Started.Equal(state.Started) {
resp.Diagnostics.Append(utilities.ComputeResourceStartStop(ctx, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error start/stop Compute")
@@ -302,7 +302,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Resize boot disk size if needed
if !plan.BootDiskSize.Equal(state.BootDiskSize) {
if !plan.BootDiskSize.IsUnknown() && !plan.BootDiskSize.Equal(state.BootDiskSize) {
resp.Diagnostics.Append(utilities.ComputeResourceBootDiskResize(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error resize boot disk")
@@ -311,7 +311,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Extra disk(s) update if needed
if !plan.ExtraDisks.Equal(state.ExtraDisks) {
if !plan.ExtraDisks.IsUnknown() && !plan.ExtraDisks.Equal(state.ExtraDisks) {
resp.Diagnostics.Append(utilities.ComputeResourceExtraDiskUpdate(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update extra disk list")
@@ -320,7 +320,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// PCI device(s) update if needed
if !plan.PCIDevices.Equal(state.PCIDevices) {
if !plan.PCIDevices.IsUnknown() && !plan.PCIDevices.Equal(state.PCIDevices) {
resp.Diagnostics.Append(utilities.ComputeResourcePCIDeviceUpdate(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update PCI device(s) list")
@@ -329,7 +329,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// pin to stack if needed
if !plan.PinToStack.Equal(state.PinToStack) {
if !plan.PinToStack.IsUnknown() && !plan.PinToStack.Equal(state.PinToStack) {
resp.Diagnostics.Append(utilities.ComputeResourcePinToStackUpdate(ctx, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error pin/unpin to stack compute")
@@ -338,9 +338,14 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Compute parameters update if needed
if (!plan.Description.IsUnknown() && !plan.Description.Equal(state.Description)) || !plan.Name.Equal(state.Name) ||
!plan.NumaAffinity.Equal(state.NumaAffinity) || !plan.CPUPin.Equal(state.CPUPin) || !plan.HPBacked.Equal(state.HPBacked) || (!plan.Chipset.IsUnknown() && !plan.Chipset.Equal(state.Chipset)) ||
!plan.AutoStartWithNode.Equal(state.AutoStartWithNode) || (!plan.PreferredCPU.IsUnknown() && !plan.PreferredCPU.Equal(state.Description)) {
if (!plan.Description.IsUnknown() && !plan.Description.Equal(state.Description)) ||
!plan.Name.IsUnknown() && !plan.Name.Equal(state.Name) ||
!plan.NumaAffinity.IsUnknown() && !plan.NumaAffinity.Equal(state.NumaAffinity) ||
!plan.CPUPin.IsUnknown() && !plan.CPUPin.Equal(state.CPUPin) ||
!plan.HPBacked.IsUnknown() && !plan.HPBacked.Equal(state.HPBacked) ||
(!plan.Chipset.IsUnknown() && !plan.Chipset.Equal(state.Chipset)) ||
!plan.AutoStartWithNode.IsUnknown() && !plan.AutoStartWithNode.Equal(state.AutoStartWithNode) ||
(!plan.PreferredCPU.IsUnknown() && !plan.PreferredCPU.Equal(state.Description)) {
resp.Diagnostics.Append(utilities.ComputeResourceComputeUpdate(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update compute parameters")
@@ -358,7 +363,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Affinity label update if needed
if !plan.AffinityLabel.Equal(state.AffinityLabel) && !plan.AffinityLabel.IsUnknown() {
if !plan.AffinityLabel.IsUnknown() && !plan.AffinityLabel.Equal(state.AffinityLabel) {
resp.Diagnostics.Append(utilities.ComputeResourceAffinityLabelUpdate(ctx, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update affinity label")
@@ -367,7 +372,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Affinity rules update if needed
if !plan.AffinityRules.Equal(state.AffinityRules) {
if !plan.AffinityRules.IsUnknown() && !plan.AffinityRules.Equal(state.AffinityRules) {
resp.Diagnostics.Append(utilities.ComputeResourceAffinityRulesUpdate(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update affinity rules")
@@ -376,7 +381,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Anti affinity rules update if needed
if !plan.AntiAffinityRules.Equal(state.AntiAffinityRules) {
if !plan.AntiAffinityRules.IsUnknown() && !plan.AntiAffinityRules.Equal(state.AntiAffinityRules) {
resp.Diagnostics.Append(utilities.ComputeResourceAntiAffinityRulesUpdate(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update anti affinity rules")
@@ -385,7 +390,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Tags update if needed
if !plan.Tags.Equal(state.Tags) {
if !plan.Tags.IsUnknown() && !plan.Tags.Equal(state.Tags) {
resp.Diagnostics.Append(utilities.ComputeResourceTagsUpdate(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update tags")
@@ -394,7 +399,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Port forwarding update if needed
if !plan.PortForwarding.Equal(state.PortForwarding) {
if !plan.PortForwarding.IsUnknown() && !plan.PortForwarding.Equal(state.PortForwarding) {
resp.Diagnostics.Append(utilities.ComputeResourcePortForwardingUpdate(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update port forwarding rules")
@@ -403,7 +408,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// User access update if needed
if !plan.UserAccess.Equal(state.UserAccess) {
if !plan.UserAccess.IsUnknown() && !plan.UserAccess.Equal(state.UserAccess) {
resp.Diagnostics.Append(utilities.ComputeResourceUserAccessUpdate(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update user(s) access rules")
@@ -412,7 +417,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Snapshot update if needed
if !plan.Snapshot.Equal(state.Snapshot) {
if !plan.Snapshot.IsUnknown() && !plan.Snapshot.Equal(state.Snapshot) {
resp.Diagnostics.Append(utilities.ComputeResourceSnapshotUpdate(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update snapshot(s)")
@@ -421,7 +426,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Rollback if needed
if !plan.Rollback.Equal(state.Rollback) && !plan.Rollback.IsNull() {
if !plan.Rollback.Equal(state.Rollback) && !plan.Rollback.IsNull() && !plan.Rollback.IsUnknown() {
resp.Diagnostics.Append(utilities.ComputeResourceRollback(ctx, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error rollback compute")
@@ -430,7 +435,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// Cd update if needed
if !plan.CD.Equal(state.CD) {
if !plan.CDImageID.IsUnknown() && !plan.CDImageID.Equal(state.CDImageID) {
resp.Diagnostics.Append(utilities.ComputeResourceCDUpdate(ctx, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update cd image update")
@@ -448,7 +453,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// reset compute if need
if !plan.Reset.Equal(state.Reset) && plan.Reset.ValueBool() {
if !plan.Reset.IsUnknown() && !plan.Reset.Equal(state.Reset) && plan.Reset.ValueBool() {
resp.Diagnostics.Append(utilities.ComputeResourceResetCompute(ctx, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error reset compute")
@@ -457,7 +462,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// redeploy compute if need
if !plan.ImageID.Equal(state.ImageID) {
if !plan.ImageID.IsUnknown() && !plan.ImageID.Equal(state.ImageID) {
resp.Diagnostics.Append(utilities.ComputeResourceRedeploy(ctx, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error redeploy compute")
@@ -466,7 +471,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// custom fields update if needed
if !plan.CustomFields.Equal(state.CustomFields) && !plan.CustomFields.IsUnknown() {
if !plan.CustomFields.IsUnknown() && !plan.CustomFields.Equal(state.CustomFields) {
resp.Diagnostics.Append(utilities.ComputeResourceCustomFieldUpdate(ctx, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update custom fields")

View File

@@ -170,6 +170,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
Computed: true,
ElementType: types.StringType,
},
"boot_type": schema.StringAttribute{
Computed: true,
},
"bootdisk_size": schema.Int64Attribute{
Computed: true,
},
@@ -337,7 +340,7 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
"pool": schema.StringAttribute{
Computed: true,
},
"present_to": schema.ListAttribute{
"present_to": schema.MapAttribute{
Computed: true,
ElementType: types.Int64Type,
},
@@ -385,6 +388,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
"shareable": schema.BoolAttribute{
Computed: true,
},
"size_available": schema.Float64Attribute{
Computed: true,
},
"size_max": schema.Int64Attribute{
Computed: true,
},
@@ -446,6 +452,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
"hp_backed": schema.BoolAttribute{
Computed: true,
},
"hot_resize": schema.BoolAttribute{
Computed: true,
},
"image_id": schema.Int64Attribute{
Computed: true,
},
@@ -563,6 +572,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
},
},
},
"loader_type": schema.StringAttribute{
Computed: true,
},
"lock_status": schema.StringAttribute{
Computed: true,
},
@@ -581,6 +593,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
"name": schema.StringAttribute{
Computed: true,
},
"network_interface_naming": schema.StringAttribute{
Computed: true,
},
"need_reboot": schema.BoolAttribute{
Computed: true,
},
@@ -705,9 +720,69 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
"user_managed": schema.BoolAttribute{
Computed: true,
},
"vgpus": schema.ListAttribute{
Computed: true,
ElementType: types.Int64Type,
"vgpus": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
Computed: true,
},
"gid": schema.Int64Attribute{
Computed: true,
},
"type": schema.StringAttribute{
Computed: true,
},
"mode": schema.StringAttribute{
Computed: true,
},
"status": schema.StringAttribute{
Computed: true,
},
"profile_id": schema.Int64Attribute{
Computed: true,
},
"ram": schema.Int64Attribute{
Computed: true,
},
"last_update_time": schema.Int64Attribute{
Computed: true,
},
"created_time": schema.Int64Attribute{
Computed: true,
},
"deleted_time": schema.Int64Attribute{
Computed: true,
},
"vmid": schema.Int64Attribute{
Computed: true,
},
"pgpuid": schema.Int64Attribute{
Computed: true,
},
"reference_id": schema.StringAttribute{
Computed: true,
},
"account_id": schema.Int64Attribute{
Computed: true,
},
"rg_id": schema.Int64Attribute{
Computed: true,
},
"last_claimed_by": schema.Int64Attribute{
Computed: true,
},
"pci_slot": schema.Int64Attribute{
Computed: true,
},
"bus_number": schema.Int64Attribute{
Computed: true,
},
"guid": schema.Int64Attribute{
Computed: true,
},
},
},
},
"virtual_image_id": schema.Int64Attribute{
Computed: true,

View File

@@ -176,6 +176,9 @@ func MakeSchemaDataSourceComputeList() map[string]schema.Attribute {
Computed: true,
ElementType: types.StringType,
},
"boot_type": schema.StringAttribute{
Computed: true,
},
"bootdisk_size": schema.Int64Attribute{
Computed: true,
},
@@ -247,6 +250,9 @@ func MakeSchemaDataSourceComputeList() map[string]schema.Attribute {
"hp_backed": schema.BoolAttribute{
Computed: true,
},
"hot_resize": schema.BoolAttribute{
Computed: true,
},
"compute_id": schema.Int64Attribute{
Computed: true,
},
@@ -364,6 +370,9 @@ func MakeSchemaDataSourceComputeList() map[string]schema.Attribute {
"lock_status": schema.StringAttribute{
Computed: true,
},
"loader_type": schema.StringAttribute{
Computed: true,
},
"manager_id": schema.Int64Attribute{
Computed: true,
},
@@ -379,6 +388,9 @@ func MakeSchemaDataSourceComputeList() map[string]schema.Attribute {
"name": schema.StringAttribute{
Computed: true,
},
"network_interface_naming": schema.StringAttribute{
Computed: true,
},
"need_reboot": schema.BoolAttribute{
Computed: true,
},

View File

@@ -168,6 +168,9 @@ func MakeSchemaDataSourceComputeListDeleted() map[string]schema.Attribute {
Computed: true,
ElementType: types.StringType,
},
"boot_type": schema.StringAttribute{
Computed: true,
},
"bootdisk_size": schema.Int64Attribute{
Computed: true,
},
@@ -239,6 +242,9 @@ func MakeSchemaDataSourceComputeListDeleted() map[string]schema.Attribute {
"hp_backed": schema.BoolAttribute{
Computed: true,
},
"hot_resize": schema.BoolAttribute{
Computed: true,
},
"compute_id": schema.Int64Attribute{
Computed: true,
},
@@ -356,6 +362,9 @@ func MakeSchemaDataSourceComputeListDeleted() map[string]schema.Attribute {
"lock_status": schema.StringAttribute{
Computed: true,
},
"loader_type": schema.StringAttribute{
Computed: true,
},
"manager_id": schema.Int64Attribute{
Computed: true,
},
@@ -371,6 +380,9 @@ func MakeSchemaDataSourceComputeListDeleted() map[string]schema.Attribute {
"name": schema.StringAttribute{
Computed: true,
},
"network_interface_naming": schema.StringAttribute{
Computed: true,
},
"need_reboot": schema.BoolAttribute{
Computed: true,
},

View File

@@ -2,7 +2,6 @@ package schemas
import (
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
@@ -53,6 +52,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
// optional attributes
"image_id": schema.Int64Attribute{
Optional: true,
Computed: true,
Description: "ID of the OS image to base this compute instance on.",
},
"without_boot_disk": schema.BoolAttribute{ //default false
@@ -71,6 +71,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
"affinity_rules": schema.SetNestedAttribute{
Optional: true,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"topology": schema.StringAttribute{
@@ -107,6 +108,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
"anti_affinity_rules": schema.SetNestedAttribute{
Optional: true,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"topology": schema.StringAttribute{
@@ -146,10 +148,6 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
Computed: true,
Description: "custom fields for Compute. Must be dict",
},
"stateless": schema.BoolAttribute{ //default false
Optional: true,
Description: "Compute will be stateless (SVA_KVM_X86) if set to True",
},
"sep_id": schema.Int64Attribute{
Optional: true,
Computed: true,
@@ -163,18 +161,12 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
"extra_disks": schema.SetAttribute{
Optional: true,
//Computed: true,
Validators: []validator.Set{
setvalidator.SizeAtMost(constants.MaxExtraDisksPerCompute),
},
ElementType: types.Int64Type,
Description: "Optional list of IDs of extra disks to attach to this compute. You may specify several extra disks.",
},
"network": schema.SetNestedAttribute{
Optional: true,
Computed: true,
Validators: []validator.Set{
setvalidator.SizeBetween(1, constants.MaxNetworksPerCompute),
},
Optional: true,
Computed: true,
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
@@ -195,6 +187,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
Description: "Optional IP address to assign to this connection. This IP should belong to the selected network and free for use.",
},
"mac": schema.StringAttribute{
Optional: true,
Computed: true,
Description: "MAC address associated with this connection. MAC address is assigned automatically.",
},
@@ -216,6 +209,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
"tags": schema.SetNestedAttribute{
Optional: true,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"key": schema.StringAttribute{
@@ -229,6 +223,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
"port_forwarding": schema.SetNestedAttribute{
Optional: true,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"public_port_start": schema.Int64Attribute{
@@ -252,6 +247,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
"user_access": schema.SetNestedAttribute{
Optional: true,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"username": schema.StringAttribute{
@@ -281,13 +277,9 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
},
},
"cd": schema.SingleNestedAttribute{
"cd_image_id": schema.Int64Attribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"cdrom_id": schema.Int64Attribute{
Required: true,
},
},
Computed: true,
},
"pin_to_stack": schema.BoolAttribute{
Optional: true,
@@ -311,6 +303,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
"pause": schema.BoolAttribute{
Optional: true,
Computed: true,
//Default: false,
},
"reset": schema.BoolAttribute{
@@ -323,11 +316,6 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
Default: booldefault.StaticBool(true),
//Default: true,
},
"auto_start": schema.BoolAttribute{
Optional: true,
//Default: false,
Description: "Flag for redeploy compute",
},
"force_stop": schema.BoolAttribute{
Optional: true,
//Default: false,
@@ -338,14 +326,6 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
//Default: false,
Description: "Flag for resize compute",
},
"data_disks": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
stringvalidator.OneOf("KEEP", "DETACH", "DESTROY"),
},
//Default: "DETACH",
Description: "Flag for redeploy compute",
},
"started": schema.BoolAttribute{
Optional: true,
Computed: true,
@@ -372,6 +352,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
"numa_affinity": schema.StringAttribute{
Optional: true,
Computed: true,
Validators: []validator.String{
stringvalidator.OneOf("none", "strict", "loose"),
},
@@ -398,6 +379,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
"pci_devices": schema.SetAttribute{
Optional: true,
Computed: true,
ElementType: types.Int64Type,
Description: "ID of the connected pci devices",
},
@@ -415,6 +397,42 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
Description: "Flag for start compute after node exits from MAINTENANCE state",
Default: booldefault.StaticBool(false),
},
"snapshot_delete_async": schema.BoolAttribute{
Optional: true,
Computed: true,
Description: "Flag for deleting snapshots asynchronously",
Default: booldefault.StaticBool(false),
},
"loader_type": schema.StringAttribute{
Optional: true,
Computed: true,
Description: "Type of VM",
Validators: []validator.String{
stringvalidator.OneOfCaseInsensitive("unknown", "linux", "windows"),
},
},
"boot_type": schema.StringAttribute{
Optional: true,
Computed: true,
Description: "Type of image upload",
Validators: []validator.String{
stringvalidator.OneOfCaseInsensitive("bios", "uefi"),
},
},
"hot_resize": schema.BoolAttribute{
Optional: true,
Computed: true,
Description: "Changing the size of a VM",
},
"network_interface_naming": schema.StringAttribute{
Optional: true,
Computed: true,
Description: "Name of the network interface",
Validators: []validator.String{
stringvalidator.OneOfCaseInsensitive("eth", "ens"),
},
},
// computed attributes
"compute_id": schema.Int64Attribute{
@@ -531,9 +549,6 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
"boot_disk_id": schema.Int64Attribute{
Computed: true,
},
"cd_image_id": schema.Int64Attribute{
Computed: true,
},
"clone_reference": schema.Int64Attribute{
Computed: true,
},
@@ -804,9 +819,69 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
"user_managed": schema.BoolAttribute{
Computed: true,
},
"vgpus": schema.ListAttribute{
Computed: true,
ElementType: types.Int64Type,
"vgpus": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
Computed: true,
},
"gid": schema.Int64Attribute{
Computed: true,
},
"type": schema.StringAttribute{
Computed: true,
},
"mode": schema.StringAttribute{
Computed: true,
},
"status": schema.StringAttribute{
Computed: true,
},
"profile_id": schema.Int64Attribute{
Computed: true,
},
"ram": schema.Int64Attribute{
Computed: true,
},
"last_update_time": schema.Int64Attribute{
Computed: true,
},
"created_time": schema.Int64Attribute{
Computed: true,
},
"deleted_time": schema.Int64Attribute{
Computed: true,
},
"vmid": schema.Int64Attribute{
Computed: true,
},
"pgpuid": schema.Int64Attribute{
Computed: true,
},
"reference_id": schema.StringAttribute{
Computed: true,
},
"account_id": schema.Int64Attribute{
Computed: true,
},
"rg_id": schema.Int64Attribute{
Computed: true,
},
"last_claimed_by": schema.Int64Attribute{
Computed: true,
},
"pci_slot": schema.Int64Attribute{
Computed: true,
},
"bus_number": schema.Int64Attribute{
Computed: true,
},
"guid": schema.Int64Attribute{
Computed: true,
},
},
},
},
"virtual_image_id": schema.Int64Attribute{
Computed: true,
@@ -822,9 +897,6 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
func MakeSchemaResourceComputeDisks() map[string]schema.Attribute {
return map[string]schema.Attribute{
"ckey": schema.StringAttribute{
Computed: true,
},
"acl": schema.StringAttribute{
Computed: true,
},
@@ -866,7 +938,7 @@ func MakeSchemaResourceComputeDisks() map[string]schema.Attribute {
},
"images": schema.ListAttribute{
Computed: true,
ElementType: types.StringType,
ElementType: types.Int64Type,
},
"iotune": schema.SingleNestedAttribute{
Computed: true,
@@ -942,7 +1014,7 @@ func MakeSchemaResourceComputeDisks() map[string]schema.Attribute {
"pool": schema.StringAttribute{
Computed: true,
},
"present_to": schema.ListAttribute{
"present_to": schema.MapAttribute{
Computed: true,
ElementType: types.Int64Type,
},

View File

@@ -37,6 +37,60 @@ func ComputeResourceCheckPresence(ctx context.Context, plan *models.ResourceComp
return computeItem, nil
}
func ResourceComputePCIDevicesListCheckPresence(ctx context.Context, id uint64, c *client.Client) (*compute.ListPCIDevices, error) {
tflog.Info(ctx, "Get PCI devices info")
req := compute.ListPCIDeviceRequest{
ComputeID: id,
}
tflog.Info(ctx, "Check req", map[string]any{"req": req})
pciDevicesList, err := c.CloudAPI().Compute().ListPCIDevice(ctx, req)
if err != nil {
return nil, err
}
tflog.Info(ctx, "Getting PCI devices info, successfully")
return pciDevicesList, nil
}
func ComputeResourceUserAccessGet(ctx context.Context, computeID uint64, c *client.Client) (*compute.ListUsers, error) {
tflog.Info(ctx, "Get compute user access info")
req := compute.UserListRequest{
ComputeID: computeID,
}
tflog.Info(ctx, "Check req", map[string]any{"req": req})
userList, err := c.CloudAPI().Compute().UserList(ctx, req)
if err != nil {
return nil, err
}
tflog.Info(ctx, "Getting compute user access info, successfully")
return userList, nil
}
func ComputeResourcePFWListGet(ctx context.Context, computeID uint64, c *client.Client) (*compute.ListPFWs, error) {
tflog.Info(ctx, "Get compute pfw list info")
req := compute.PFWListRequest{
ComputeID: computeID,
}
tflog.Info(ctx, "Check req", map[string]any{"req": req})
pfwList, err := c.CloudAPI().Compute().PFWList(ctx, req)
if err != nil {
return nil, err
}
tflog.Info(ctx, "Getting compute pfw list info, successfully")
return pfwList, nil
}
func ComputeResourceCheckDetachDisks(state *models.ResourceComputeModel, recordCompute *compute.RecordCompute) bool {
bootDiskId := uint64(state.BootDiskId.ValueInt64())
extraDiskList := state.ExtraDisks.Elements()
@@ -140,6 +194,10 @@ func CreateResourceCompute(ctx context.Context, plan *models.ResourceComputeMode
if ipSet {
reqInterface.IPAddr = ipaddr.(types.String).ValueString()
}
macaddr, macSet := elemMap["mac"]
if macSet {
reqInterface.MAC = macaddr.(types.String).ValueString()
}
interfaces = append(interfaces, reqInterface)
}
@@ -206,6 +264,37 @@ func CreateResourceCompute(ctx context.Context, plan *models.ResourceComputeMode
diags.AddError("CreateResourceCompute: unable to create KVM VP x86", err.Error())
return 0, diags
}
updateReq := compute.UpdateRequest{}
if !plan.LoaderType.IsNull() {
updateReq.LoaderType = plan.LoaderType.ValueString()
}
if !plan.BootType.IsNull() {
updateReq.BootType = plan.BootType.ValueString()
}
if !plan.HotResize.IsNull() {
updateReq.HotResize = plan.HotResize.ValueBool()
}
if !plan.NetworkInterfaceNaming.IsNull() {
updateReq.NetworkInterfaceNaming = plan.NetworkInterfaceNaming.ValueString()
}
if !plan.LoaderType.IsNull() ||
!plan.BootType.IsNull() ||
!plan.HotResize.IsNull() ||
!plan.NetworkInterfaceNaming.IsNull() {
updateReq.ComputeID = id
tflog.Info(ctx, "CreateResourceCompute: creating Compute with LoaderType or BootType or HotResize or NetworkInterfaceNaming")
_, err = c.CloudAPI().Compute().Update(ctx, updateReq)
if err != nil {
diags.AddWarning("CreateResourceCompute: unable to update LoaderType or BootType or HotResize or NetworkInterfaceNaming", err.Error())
}
}
return id, diags
}
@@ -520,8 +609,8 @@ func ComputeResourcePortForwarding(ctx context.Context, plan *models.ResourceCom
PublicPortStart: uint64(itemPortForwarding.PublicPortStart.ValueInt64()),
Proto: strings.ToLower(itemPortForwarding.Proto.ValueString()),
}
if itemPortForwarding.PublicPortStart.ValueInt64() != 0 {
req.PublicPortStart = uint64(itemPortForwarding.PublicPortStart.ValueInt64())
if itemPortForwarding.PublicPortEnd.ValueInt64() != 0 {
req.PublicPortEnd = itemPortForwarding.PublicPortEnd.ValueInt64()
}
if itemPortForwarding.LocalPort.ValueInt64() != 0 {
req.LocalBasePort = uint64(itemPortForwarding.LocalPort.ValueInt64())
@@ -659,7 +748,7 @@ func ComputeResourceCDInsert(ctx context.Context, plan *models.ResourceComputeMo
}
req := compute.CDInsertRequest{ComputeID: computeId}
req.CDROMID = uint64(plan.CD.Attributes()["cdrom_id"].(types.Int64).ValueInt64())
req.CDROMID = uint64(plan.CDImageID.ValueInt64())
tflog.Info(ctx, "ComputeResourceCDInsert: before calling CloudAPI().Compute().CDInsert", map[string]any{"compute_id": computeId, "req": req})
res, err := c.CloudAPI().Compute().CDInsert(ctx, req)
tflog.Info(ctx, "ComputeResourceCDInsert: response from CloudAPI().Compute().CDInsert", map[string]any{"compute_id": computeId, "response": res})

View File

@@ -33,12 +33,13 @@ func differenceSimpleType(oldSet, newSet types.Set) (added, removed []any) {
return
}
func differenceNetwork(oldSet, newSet types.Set) (added, changeIp, removed []map[string]attr.Value) {
func differenceNetwork(oldSet, newSet types.Set) (added, changeIp, changeMac, removed []map[string]attr.Value) {
oldSlice := oldSet.Elements()
newSlice := newSet.Elements()
added = make([]map[string]attr.Value, 0)
changeIp = make([]map[string]attr.Value, 0)
changeMac = make([]map[string]attr.Value, 0)
removed = make([]map[string]attr.Value, 0)
for _, oldNetwork := range oldSlice {
@@ -47,15 +48,19 @@ func differenceNetwork(oldSet, newSet types.Set) (added, changeIp, removed []map
for _, newNetwork := range newSlice {
newMap := newNetwork.(types.Object).Attributes()
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(types.Int64).ValueInt64() == 0) {
if (newMap["net_type"].(types.String).ValueString() == "EXTNET" || newMap["net_type"].(types.String).ValueString() == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(types.String).ValueString() != "") {
found = true
switch {
case (newMap["net_type"].(types.String).ValueString() == "EXTNET" || newMap["net_type"].(types.String).ValueString() == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(types.String).ValueString() != ""):
changeIp = append(changeIp, newMap)
found = true
break
} else if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(types.String).ValueString() != "" {
found = true
break
fallthrough
case newMap["mac"] != oldMap["mac"] && newMap["mac"].(types.String).ValueString() != "":
newMap["old_mac"] = oldMap["mac"]
changeMac = append(changeMac, newMap)
}
}
if found {
break
}
}
if found {
continue
@@ -69,10 +74,8 @@ func differenceNetwork(oldSet, newSet types.Set) (added, changeIp, removed []map
for _, oldNetwork := range oldSlice {
oldMap := oldNetwork.(types.Object).Attributes()
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(types.Int64).ValueInt64() == 0) {
if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(types.String).ValueString() != "" || ((newMap["net_type"].(types.String).ValueString() == "EXTNET" || newMap["net_type"].(types.String).ValueString() == "VINS") && newMap["ip_address"] != oldMap["ip_address"]) {
found = true
break
}
found = true
break
}
}
if found {

View File

@@ -93,7 +93,7 @@ func ComputeResourceBootDiskResize(ctx context.Context, state *models.ResourceCo
}
if state.BootDiskSize.ValueInt64() > plan.BootDiskSize.ValueInt64() {
diags.AddError(fmt.Sprintf("ComputeResourceBootDiskResize: compute ID %d - shrinking boot disk is not allowed", computeId), "")
diags.AddError(fmt.Sprintf("ComputeResourceBootDiskResize: compute ID %d - shrinking boot disk is not allowed, state: %d, plan: %d", computeId, state.BootDiskSize.ValueInt64(), plan.BootDiskSize.ValueInt64()), "")
return diags
}
@@ -159,17 +159,6 @@ func ComputeResourceExtraDiskUpdate(ctx context.Context, state *models.ResourceC
return diags
}
if len(detachSet) > 0 {
tflog.Info(ctx, "ComputeResourceExtraDiskUpdate: stop compute", map[string]any{"compute_id": computeId})
_, err = c.CloudAPI().Compute().Stop(ctx, compute.StopRequest{ComputeID: computeId})
if err != nil {
diags.AddError(
"ComputeResourceExtraDiskUpdate: cannot stop compute", err.Error(),
)
return diags
}
}
for _, disk := range detachSet {
diskId := uint64(disk.(types.Int64).ValueInt64())
tflog.Info(ctx, fmt.Sprintf("ComputeResourceExtraDiskUpdate: Start detach extra disk with ID - %d from compute with ID - %d", diskId, computeId))
@@ -184,10 +173,6 @@ func ComputeResourceExtraDiskUpdate(ctx context.Context, state *models.ResourceC
}
}
if len(detachSet) > 0 && plan.Started.ValueBool() {
diags = ComputeResourceStartStop(ctx, plan, c)
}
if diags.HasError() {
tflog.Error(ctx, "ComputeResourceExtraDiskUpdate: Errors occurred while managing disks")
return diags
@@ -207,7 +192,7 @@ func ComputeResourcePCIDeviceUpdate(ctx context.Context, state *models.ResourceC
return diags
}
attachSet, detachSet := differenceSimpleType(state.ExtraDisks, plan.ExtraDisks)
attachSet, detachSet := differenceSimpleType(state.PCIDevices, plan.PCIDevices)
for _, pciDevice := range detachSet {
pciDeviceId := pciDevice.(types.Int64).ValueInt64()
@@ -256,7 +241,7 @@ func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceCom
return diags
}
attachMap, changeIpMap, detachMap := differenceNetwork(state.Network, plan.Network)
attachMap, changeIpMap, changeMacMap, detachMap := differenceNetwork(state.Network, plan.Network)
tflog.Info(ctx, "ComputeResourceNetworkUpdate: start detach network(s) rules to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
for _, network := range detachMap {
@@ -302,7 +287,7 @@ func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceCom
needStart := false
// need stop to attach first network
if len(detachMap) == len(state.Network.Elements()) || (len(state.Network.Elements()) < 1) && len(attachMap) > 0 {
if len(detachMap) == len(state.Network.Elements()) || (len(state.Network.Elements()) < 1) && len(attachMap) > 0 || hasDPDKnetwork(attachMap) || len(changeMacMap) > 0 {
tflog.Info(ctx, "ComputeResourceNetworkUpdate: stop compute", map[string]any{"compute_id": computeId})
_, err = c.CloudAPI().Compute().Stop(ctx, compute.StopRequest{ComputeID: computeId})
if err != nil {
@@ -316,6 +301,27 @@ func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceCom
}
}
tflog.Info(ctx, "ComputeResourceNetworkUpdate: start change MAC address network(s) to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
for _, network := range changeMacMap {
req := compute.ChangeMACRequest{
ComputeID: computeId,
NewMAC: network["mac"].(types.String).ValueString(),
СurrentMAC: network["old_mac"].(types.String).ValueString(),
}
tflog.Info(ctx, "ComputeResourceNetworkUpdate: before calling CloudAPI().Compute().ChangeMAC", map[string]any{"compute_id": computeId, "req": req})
res, err := c.CloudAPI().Compute().ChangeMAC(ctx, req)
tflog.Info(ctx, "ComputeResourceNetworkUpdate: response from CloudAPI().Compute().ChangeMAC", map[string]any{"compute_id": plan.ID.ValueString(), "response": res})
if err != nil {
diags.AddError(fmt.Sprintf("ComputeResourceNetworkUpdate: failed to change Mac to net ID %d from Compute ID %d",
network["net_id"].(types.Int64).ValueInt64(), computeId), err.Error())
}
}
if diags.HasError() {
return diags
}
sort.Slice(attachMap, func(i, j int) bool {
weightI := attachMap[i]["weight"].(types.Int64).ValueInt64()
weightJ := attachMap[j]["weight"].(types.Int64).ValueInt64()
@@ -341,6 +347,10 @@ func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceCom
if ipSet {
req.IPAddr = ipaddr.(types.String).ValueString()
}
macaddr, macSet := network["mac"]
if macSet {
req.MACAddr = macaddr.(types.String).ValueString()
}
tflog.Info(ctx, "ComputeResourceNetworkUpdate: before calling CloudAPI().Compute().NetAttach", map[string]any{"compute_id": computeId, "req": req})
res, err := c.CloudAPI().Compute().NetAttach(ctx, req)
tflog.Info(ctx, "ComputeResourceNetworkUpdate: response from CloudAPI().Compute().NetAttach", map[string]any{"compute_id": plan.ID.ValueString(), "response": res})
@@ -367,6 +377,15 @@ func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceCom
return nil
}
func hasDPDKnetwork(networkAttachMap []map[string]attr.Value) bool {
for _, elem := range networkAttachMap {
if elem["net_type"].(types.String).ValueString() == "DPDK" {
return true
}
}
return false
}
func ComputeResourceComputeUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceComputeUpdate: start update compute parameters", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -389,13 +408,29 @@ func ComputeResourceComputeUpdate(ctx context.Context, state *models.ResourceCom
req.Description = plan.Description.ValueString()
}
if !plan.NumaAffinity.Equal(state.NumaAffinity) {
if !plan.NumaAffinity.Equal(state.NumaAffinity) && !plan.NumaAffinity.IsUnknown() {
req.NumaAffinity = plan.NumaAffinity.ValueString()
}
req.CPUPin = plan.CPUPin.ValueBool()
req.HPBacked = plan.HPBacked.ValueBool()
req.AutoStart = plan.AutoStartWithNode.ValueBool()
if !plan.CPUPin.Equal(state.CPUPin) && !plan.CPUPin.IsUnknown() {
req.CPUPin = plan.CPUPin.ValueBool()
}
if !plan.HPBacked.Equal(state.HPBacked) && !plan.HPBacked.IsUnknown() {
req.HPBacked = plan.HPBacked.ValueBool()
}
if !plan.LoaderType.Equal(state.LoaderType) && !plan.LoaderType.IsUnknown() {
req.LoaderType = plan.LoaderType.ValueString()
}
if !plan.BootType.Equal(state.BootType) && !plan.BootType.IsUnknown() {
req.BootType = plan.BootType.ValueString()
}
if !plan.HotResize.Equal(state.HotResize) && !plan.HotResize.IsUnknown() {
req.HotResize = plan.HotResize.ValueBool()
}
if !plan.NetworkInterfaceNaming.Equal(state.NetworkInterfaceNaming) && !plan.NetworkInterfaceNaming.IsUnknown() {
req.NetworkInterfaceNaming = plan.NetworkInterfaceNaming.ValueString()
}
if !plan.Chipset.IsUnknown() && !plan.Chipset.Equal(state.Chipset) {
req.Chipset = plan.Chipset.ValueString()
@@ -413,6 +448,10 @@ func ComputeResourceComputeUpdate(ctx context.Context, state *models.ResourceCom
req.PreferredCPU = []int64{-1}
}
if !plan.LoaderType.IsUnknown() && !plan.LoaderType.Equal(state.Description) {
req.Description = plan.Description.ValueString()
}
// Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status.
// If STARTED, we need to stop it before update
@@ -917,19 +956,35 @@ func ComputeResourceSnapshotUpdate(ctx context.Context, state *models.ResourceCo
addedLabel, deleteLabel := differenceSnapshot(state.Snapshot, plan.Snapshot)
for _, label := range deleteLabel {
req := compute.SnapshotDeleteRequest{ComputeID: computeId}
objTag := label.(types.Object)
tagMap := objTag.Attributes()
req.Label = tagMap["label"].(types.String).ValueString()
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: before calling CloudAPI().Compute().SnapshotDelete", map[string]any{"compute_id": computeId, "req": req})
res, err := c.CloudAPI().Compute().SnapshotDelete(ctx, req)
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: response from CloudAPI().Compute().SnapshotDelete", map[string]any{"compute_id": computeId, "response": res})
if err != nil {
diags.AddError(
"ComputeResourceSnapshotUpdate: Unable to delete snapshot for Compute",
err.Error(),
)
reqLabel := tagMap["label"].(types.String).ValueString()
req := compute.SnapshotDeleteRequest{ComputeID: computeId, Label: reqLabel}
if (state.SnapshotDeleteAsync).ValueBool() {
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: before calling CloudAPI().Compute().SnapshotDeleteAsync", map[string]any{"compute_id": computeId, "req": req})
res, err := c.CloudAPI().Compute().SnapshotDeleteAsync(ctx, req)
req.Label = reqLabel
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: response from CloudAPI().Compute().SnapshotDeleteAsync", map[string]any{"compute_id": computeId, "response": res})
if err != nil {
diags.AddError(
"ComputeResourceSnapshotUpdate: Unable to async delete snapshot for Compute",
err.Error(),
)
}
} else {
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: before calling CloudAPI().Compute().SnapshotDelete", map[string]any{"compute_id": computeId, "req": req})
res, err := c.CloudAPI().Compute().SnapshotDelete(ctx, req)
req.Label = reqLabel
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: response from CloudAPI().Compute().SnapshotDelete", map[string]any{"compute_id": computeId, "response": res})
if err != nil {
diags.AddError(
"ComputeResourceSnapshotUpdate: Unable to delete snapshot for Compute",
err.Error(),
)
}
}
}
if diags.HasError() {
@@ -1023,7 +1078,7 @@ func ComputeResourceCDUpdate(ctx context.Context, plan *models.ResourceComputeMo
return diags
}
if plan.CD.IsNull() {
if plan.CDImageID.IsNull() {
tflog.Info(ctx, "ComputeResourceCDUpdate: before calling CloudAPI().Compute().CDEject", map[string]any{"compute_id": computeId})
res, err := c.CloudAPI().Compute().CDEject(ctx, compute.CDEjectRequest{ComputeID: computeId})
tflog.Info(ctx, "ComputeResourceCDUpdate: response from CloudAPI().Compute().CDEject", map[string]any{"compute_id": computeId, "response": res})
@@ -1036,7 +1091,7 @@ func ComputeResourceCDUpdate(ctx context.Context, plan *models.ResourceComputeMo
}
} else {
req := compute.CDInsertRequest{ComputeID: computeId}
req.CDROMID = uint64(plan.CD.Attributes()["cdrom_id"].(types.Int64).ValueInt64())
req.CDROMID = uint64(plan.CDImageID.ValueInt64())
tflog.Info(ctx, "ComputeResourceCDUpdate: before calling CloudAPI().Compute().CDInsert", map[string]any{"compute_id": computeId, "req": req})
res, err := c.CloudAPI().Compute().CDInsert(ctx, req)
tflog.Info(ctx, "ComputeResourceCDUpdate: response from CloudAPI().Compute().CDInsert", map[string]any{"compute_id": computeId, "response": res})
@@ -1188,17 +1243,14 @@ func ComputeResourceRedeploy(ctx context.Context, plan *models.ResourceComputeMo
req := compute.RedeployRequest{
ComputeID: computeId,
ImageID: uint64(plan.ImageID.ValueInt64()),
DataDisks: "detach",
DataDisks: "KEEP",
}
if !plan.BootDiskSize.IsNull() {
req.DiskSize = uint64(plan.BootDiskSize.ValueInt64())
}
if !plan.DataDisks.IsNull() {
req.DataDisks = plan.DataDisks.ValueString()
}
if !plan.AutoStart.IsNull() {
req.AutoStart = plan.AutoStart.ValueBool()
if !plan.Started.IsNull() {
req.AutoStart = plan.Started.ValueBool()
}
if !plan.ForceStop.IsNull() {
req.ForceStop = plan.ForceStop.ValueBool()