Skip to content

Commit 4f6652b

Browse files
committed
feat: add reserved memory field
Signed-off-by: PoAn Yang <poan.yang@suse.com>
1 parent 637dbb9 commit 4f6652b

File tree

4 files changed

+60
-32
lines changed

4 files changed

+60
-32
lines changed

rancher2/schema_machine_config_v2_harvester.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ func machineConfigV2HarvesterFields() map[string]*schema.Schema {
3030
Default: "4",
3131
Description: "Memory size (in GiB)",
3232
},
33+
"reserved_memory_size": {
34+
Type: schema.TypeString,
35+
Optional: true,
36+
Description: "Reserved memory size (in MiB)",
37+
},
3338
"disk_size": {
3439
Type: schema.TypeString,
3540
Optional: true,

rancher2/schema_node_template_harvester.go

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,22 @@ const (
2222
//Types
2323

2424
type harvesterConfig struct {
25-
VMNamespace string `json:"vmNamespace,omitempty" yaml:"vmNamespace,omitempty"`
26-
VMAffinity string `json:"vmAffinity,omitempty" yaml:"vmAffinity,omitempty"`
27-
CPUCount string `json:"cpuCount,omitempty" yaml:"cpuCount,omitempty"`
28-
MemorySize string `json:"memorySize,omitempty" yaml:"memorySize,omitempty"`
29-
DiskSize string `json:"diskSize,omitempty" yaml:"diskSize,omitempty"`
30-
DiskBus string `json:"diskBus,omitempty" yaml:"diskBus,omitempty"`
31-
ImageName string `json:"imageName,omitempty" yaml:"imageName,omitempty"`
32-
DiskInfo string `json:"diskInfo,omitempty" yaml:"diskInfo,omitempty"`
33-
SSHUser string `json:"sshUser,omitempty" yaml:"sshUser,omitempty"`
34-
SSHPassword string `json:"sshPassword,omitempty" yaml:"sshPassword,omitempty"`
35-
NetworkName string `json:"networkName,omitempty" yaml:"networkName,omitempty"`
36-
NetworkModel string `json:"networkModel,omitempty" yaml:"networkModel,omitempty"`
37-
NetworkInfo string `json:"networkInfo,omitempty" yaml:"networkInfo,omitempty"`
38-
UserData string `json:"userData,omitempty" yaml:"userData,omitempty"`
39-
NetworkData string `json:"networkData,omitempty" yaml:"networkData,omitempty"`
25+
VMNamespace string `json:"vmNamespace,omitempty" yaml:"vmNamespace,omitempty"`
26+
VMAffinity string `json:"vmAffinity,omitempty" yaml:"vmAffinity,omitempty"`
27+
CPUCount string `json:"cpuCount,omitempty" yaml:"cpuCount,omitempty"`
28+
MemorySize string `json:"memorySize,omitempty" yaml:"memorySize,omitempty"`
29+
ReservedMemorySize string `json:"reservedMemorySize,omitempty" yaml:"reservedMemorySize,omitempty"`
30+
DiskSize string `json:"diskSize,omitempty" yaml:"diskSize,omitempty"`
31+
DiskBus string `json:"diskBus,omitempty" yaml:"diskBus,omitempty"`
32+
ImageName string `json:"imageName,omitempty" yaml:"imageName,omitempty"`
33+
DiskInfo string `json:"diskInfo,omitempty" yaml:"diskInfo,omitempty"`
34+
SSHUser string `json:"sshUser,omitempty" yaml:"sshUser,omitempty"`
35+
SSHPassword string `json:"sshPassword,omitempty" yaml:"sshPassword,omitempty"`
36+
NetworkName string `json:"networkName,omitempty" yaml:"networkName,omitempty"`
37+
NetworkModel string `json:"networkModel,omitempty" yaml:"networkModel,omitempty"`
38+
NetworkInfo string `json:"networkInfo,omitempty" yaml:"networkInfo,omitempty"`
39+
UserData string `json:"userData,omitempty" yaml:"userData,omitempty"`
40+
NetworkData string `json:"networkData,omitempty" yaml:"networkData,omitempty"`
4041
}
4142

4243
//Schemas
@@ -65,6 +66,11 @@ func harvesterConfigFields() map[string]*schema.Schema {
6566
Default: "4",
6667
Description: "Memory size (in GiB)",
6768
},
69+
"reserved_memory_size": {
70+
Type: schema.TypeString,
71+
Optional: true,
72+
Description: "Reserved memory size (in MiB)",
73+
},
6874
"disk_size": {
6975
Type: schema.TypeString,
7076
Optional: true,

rancher2/structure_machine_config_v2_harvester.go

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,24 @@ const (
1515
//Types
1616

1717
type machineConfigV2Harvester struct {
18-
metav1.TypeMeta `json:",inline"`
19-
metav1.ObjectMeta `json:"metadata,omitempty"`
20-
VMNamespace string `json:"vmNamespace,omitempty" yaml:"vmNamespace,omitempty"`
21-
VMAffinity string `json:"vmAffinity,omitempty" yaml:"vmAffinity,omitempty"`
22-
CPUCount string `json:"cpuCount,omitempty" yaml:"cpuCount,omitempty"`
23-
MemorySize string `json:"memorySize,omitempty" yaml:"memorySize,omitempty"`
24-
DiskSize string `json:"diskSize,omitempty" yaml:"diskSize,omitempty"`
25-
DiskBus string `json:"diskBus,omitempty" yaml:"diskBus,omitempty"`
26-
ImageName string `json:"imageName,omitempty" yaml:"imageName,omitempty"`
27-
DiskInfo string `json:"diskInfo,omitempty" yaml:"diskInfo,omitempty"`
28-
SSHUser string `json:"sshUser,omitempty" yaml:"sshUser,omitempty"`
29-
SSHPassword string `json:"sshPassword,omitempty" yaml:"sshPassword,omitempty"`
30-
NetworkName string `json:"networkName,omitempty" yaml:"networkName,omitempty"`
31-
NetworkModel string `json:"networkModel,omitempty" yaml:"networkModel,omitempty"`
32-
NetworkInfo string `json:"networkInfo,omitempty" yaml:"networkInfo,omitempty"`
33-
UserData string `json:"userData,omitempty" yaml:"userData,omitempty"`
34-
NetworkData string `json:"networkData,omitempty" yaml:"networkData,omitempty"`
18+
metav1.TypeMeta `json:",inline"`
19+
metav1.ObjectMeta `json:"metadata,omitempty"`
20+
VMNamespace string `json:"vmNamespace,omitempty" yaml:"vmNamespace,omitempty"`
21+
VMAffinity string `json:"vmAffinity,omitempty" yaml:"vmAffinity,omitempty"`
22+
CPUCount string `json:"cpuCount,omitempty" yaml:"cpuCount,omitempty"`
23+
MemorySize string `json:"memorySize,omitempty" yaml:"memorySize,omitempty"`
24+
ReservedMemorySize string `json:"reservedMemorySize,omitempty" yaml:"reservedMemorySize,omitempty"`
25+
DiskSize string `json:"diskSize,omitempty" yaml:"diskSize,omitempty"`
26+
DiskBus string `json:"diskBus,omitempty" yaml:"diskBus,omitempty"`
27+
ImageName string `json:"imageName,omitempty" yaml:"imageName,omitempty"`
28+
DiskInfo string `json:"diskInfo,omitempty" yaml:"diskInfo,omitempty"`
29+
SSHUser string `json:"sshUser,omitempty" yaml:"sshUser,omitempty"`
30+
SSHPassword string `json:"sshPassword,omitempty" yaml:"sshPassword,omitempty"`
31+
NetworkName string `json:"networkName,omitempty" yaml:"networkName,omitempty"`
32+
NetworkModel string `json:"networkModel,omitempty" yaml:"networkModel,omitempty"`
33+
NetworkInfo string `json:"networkInfo,omitempty" yaml:"networkInfo,omitempty"`
34+
UserData string `json:"userData,omitempty" yaml:"userData,omitempty"`
35+
NetworkData string `json:"networkData,omitempty" yaml:"networkData,omitempty"`
3536
}
3637

3738
type MachineConfigV2Harvester struct {
@@ -64,6 +65,10 @@ func flattenMachineConfigV2Harvester(in *MachineConfigV2Harvester) []interface{}
6465
obj["memory_size"] = in.MemorySize
6566
}
6667

68+
if len(in.ReservedMemorySize) > 0 {
69+
obj["reserved_memory_size"] = in.ReservedMemorySize
70+
}
71+
6772
if len(in.DiskSize) > 0 {
6873
obj["disk_size"] = in.DiskSize
6974
}
@@ -145,6 +150,10 @@ func expandMachineConfigV2Harvester(p []interface{}, source *MachineConfigV2) *M
145150
obj.MemorySize = v
146151
}
147152

153+
if v, ok := in["reserved_memory_size"].(string); ok && len(v) > 0 {
154+
obj.ReservedMemorySize = v
155+
}
156+
148157
if v, ok := in["disk_size"].(string); ok && len(v) > 0 {
149158
obj.DiskSize = v
150159
}

rancher2/structure_node_template_harvester.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ func flattenHarvesterConfig(in *harvesterConfig) []interface{} {
2424
obj["memory_size"] = in.MemorySize
2525
}
2626

27+
if len(in.ReservedMemorySize) > 0 {
28+
obj["reserved_memory_size"] = in.ReservedMemorySize
29+
}
30+
2731
if len(in.DiskSize) > 0 {
2832
obj["disk_size"] = in.DiskSize
2933
}
@@ -96,6 +100,10 @@ func expandHarvestercloudConfig(p []interface{}) *harvesterConfig {
96100
obj.MemorySize = v
97101
}
98102

103+
if v, ok := in["reserved_memory_size"].(string); ok && len(v) > 0 {
104+
obj.ReservedMemorySize = v
105+
}
106+
99107
if v, ok := in["disk_size"].(string); ok && len(v) > 0 {
100108
obj.DiskSize = v
101109
}

0 commit comments

Comments
 (0)