Skip to content

Commit 2d72746

Browse files
committed
F-558: Add missing paramters in OS section of VM template
This commit adds support for missing OS section in VM template. It aligns the OS section with the Documentation: https://docs.opennebula.io/6.10/management_and_operations/references/template.html?highlight=firmware#os-and-boot-options-section A correct fix consist in updating GOCA OSVec structure to reflec the Documentation A dedicated issue has bee openned in the Goca Repo: OpenNebula/one#6782 Closes: F-558
1 parent 60707b6 commit 2d72746

File tree

2 files changed

+145
-2
lines changed

2 files changed

+145
-2
lines changed

opennebula/resource_opennebula_virtual_machine_test.go

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,51 @@ func TestAccVirtualMachine(t *testing.T) {
6666
}),
6767
),
6868
},
69+
{
70+
Config: testAccVirtualMachineTemplateConfigOs,
71+
Check: resource.ComposeTestCheckFunc(
72+
testAccSetDSdummy(),
73+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "name", "test-virtual_machine"),
74+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "permissions", "642"),
75+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "memory", "128"),
76+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "cpu", "0.1"),
77+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "context.%", "3"),
78+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "context.NETWORK", "YES"),
79+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "context.TESTVAR", "TEST"),
80+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "graphics.#", "1"),
81+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "graphics.0.keymap", "en-us"),
82+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "graphics.0.listen", "0.0.0.0"),
83+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "graphics.0.type", "VNC"),
84+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "os.#", "1"),
85+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "os.0.arch", "x86_64"),
86+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "os.0.boot", ""),
87+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "os.0.machine", "q35"),
88+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "os.0.firmware", ""),
89+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "os.0.firmware_secure", "false"),
90+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "disk.#", "0"),
91+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "tags.%", "2"),
92+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "tags.env", "prod"),
93+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "tags.customer", "test"),
94+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "description", "VM created for provider acceptance tests"),
95+
resource.TestCheckResourceAttr("opennebula_virtual_machine.testos", "timeout", "5"),
96+
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.testos", "uid"),
97+
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.testos", "gid"),
98+
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.testos", "uname"),
99+
resource.TestCheckResourceAttrSet("opennebula_virtual_machine.testos", "gname"),
100+
testAccCheckVirtualMachinePermissions(&shared.Permissions{
101+
OwnerU: 1,
102+
OwnerM: 1,
103+
GroupU: 1,
104+
OtherM: 1,
105+
}),
106+
resource.TestCheckTypeSetElemNestedAttrs("opennebula_virtual_machine.testos", "template_section.*", map[string]string{
107+
"name": "test_vec_key",
108+
"elements.%": "2",
109+
"elements.testkey1": "testvalue1",
110+
"elements.testkey2": "testvalue2",
111+
}),
112+
),
113+
},
69114
{
70115
Config: testAccVirtualMachineConfigUpdate,
71116
Check: resource.ComposeTestCheckFunc(
@@ -635,7 +680,7 @@ resource "opennebula_virtual_machine" "test" {
635680
os {
636681
arch = "x86_64"
637682
boot = ""
638-
}
683+
}
639684
640685
tags = {
641686
env = "prod"
@@ -656,6 +701,52 @@ resource "opennebula_virtual_machine" "test" {
656701
}
657702
`
658703

704+
var testAccVirtualMachineTemplateConfigOs = `
705+
resource "opennebula_virtual_machine" "testos" {
706+
name = "test-virtual_machine"
707+
group = "oneadmin"
708+
permissions = "642"
709+
memory = 128
710+
cpu = 0.1
711+
description = "VM created for provider acceptance tests"
712+
713+
context = {
714+
TESTVAR = "TEST"
715+
NETWORK = "YES"
716+
SET_HOSTNAME = "$NAME"
717+
}
718+
719+
graphics {
720+
type = "VNC"
721+
listen = "0.0.0.0"
722+
keymap = "en-us"
723+
}
724+
725+
os {
726+
arch = "x86_64"
727+
boot = ""
728+
machine = "q35"
729+
firmware = ""
730+
firmware_secure = false
731+
}
732+
733+
tags = {
734+
env = "prod"
735+
customer = "test"
736+
}
737+
738+
template_section {
739+
name = "test_vec_key"
740+
elements = {
741+
testkey1 = "testvalue1"
742+
testkey2 = "testvalue2"
743+
}
744+
}
745+
746+
timeout = 5
747+
}
748+
`
749+
659750
var testAccVirtualMachineTemplateConfigCPUModel = `
660751
resource "opennebula_virtual_machine" "test" {
661752
name = "test-virtual_machine-renamed"

opennebula/shared_schemas.go

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ func osSchema() *schema.Schema {
414414
Type: schema.TypeList,
415415
Optional: true,
416416
MaxItems: 1,
417-
Description: "Definition of OS boot and type for the Virtual Machine",
417+
Description: "Definition of OS parameters for the Virtual Machine",
418418
Elem: &schema.Resource{
419419
Schema: map[string]*schema.Schema{
420420
"arch": {
@@ -425,6 +425,58 @@ func osSchema() *schema.Schema {
425425
Type: schema.TypeString,
426426
Required: true,
427427
},
428+
"machine": {
429+
Type: schema.TypeString,
430+
Optional: true,
431+
},
432+
"kernel": {
433+
Type: schema.TypeString,
434+
Optional: true,
435+
ConflictsWith: []string{"os.0.kernel_ds"},
436+
},
437+
"kernel_ds": {
438+
Type: schema.TypeString,
439+
Optional: true,
440+
ConflictsWith: []string{"os.0.kernel"},
441+
},
442+
"initrd": {
443+
Type: schema.TypeString,
444+
Optional: true,
445+
ConflictsWith: []string{"os.0.initrd_ds"},
446+
},
447+
"initrd_ds": {
448+
Type: schema.TypeString,
449+
Optional: true,
450+
ConflictsWith: []string{"os.0.initrd"},
451+
},
452+
"root": {
453+
Type: schema.TypeString,
454+
Optional: true,
455+
},
456+
"kernel_cmd": {
457+
Type: schema.TypeString,
458+
Optional: true,
459+
},
460+
"bootloader": {
461+
Type: schema.TypeString,
462+
Optional: true,
463+
},
464+
"sd_disk_bus": {
465+
Type: schema.TypeString,
466+
Optional: true,
467+
},
468+
"uuid": {
469+
Type: schema.TypeString,
470+
Optional: true,
471+
},
472+
"firmware": {
473+
Type: schema.TypeString,
474+
Optional: true,
475+
},
476+
"firmware_secure": {
477+
Type: schema.TypeBool,
478+
Optional: true,
479+
},
428480
},
429481
},
430482
}

0 commit comments

Comments
 (0)