Skip to content

Commit

Permalink
Added feature to specify Chassis info for domain
Browse files Browse the repository at this point in the history
  • Loading branch information
vatsalparekh committed Aug 12, 2019
1 parent 811aecb commit 0c674d3
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 1 deletion.
24 changes: 24 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4164,6 +4164,26 @@
}
}
},
"v1.Chassis": {
"description": "Chassis specifies the chassins info passed to the domain.",
"properties": {
"asset": {
"type": "string"
},
"manufacturer": {
"type": "string"
},
"serial": {
"type": "string"
},
"sku": {
"type": "string"
},
"version": {
"type": "string"
}
}
},
"v1.Clock": {
"description": "Represents the clock and timers of a vmi.",
"required": [
Expand Down Expand Up @@ -4498,6 +4518,10 @@
"devices"
],
"properties": {
"chassis": {
"description": "Chassis specifies the chassins info passed to the domain.\n+optional",
"$ref": "#/definitions/v1.Chassis"
},
"clock": {
"description": "Clock sets the clock and timers of the vmi.\n+optional",
"$ref": "#/definitions/v1.Clock"
Expand Down
2 changes: 2 additions & 0 deletions examples/vm-cirros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ spec:
resources:
requests:
memory: 64M
chassis:
asset: 123456
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
Expand Down
2 changes: 2 additions & 0 deletions examples/vmi-fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ spec:
resources:
requests:
memory: 1024M
chassis:
asset: 123456
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
Expand Down
25 changes: 25 additions & 0 deletions pkg/virt-launcher/virtwrap/api/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,31 @@ func Convert_v1_VirtualMachine_To_api_Domain(vmi *v1.VirtualMachineInstance, dom
}
}

if vmi.Spec.Domain.Chassis != nil {
domain.Spec.SysInfo.Chassis = []Entry{
{
Name: "manufacturer",
Value: string(vmi.Spec.Domain.Chassis.Manufacturer),
},
{
Name: "version",
Value: string(vmi.Spec.Domain.Chassis.Version),
},
{
Name: "serial",
Value: string(vmi.Spec.Domain.Chassis.Serial),
},
{
Name: "asset",
Value: string(vmi.Spec.Domain.Chassis.Asset),
},
{
Name: "sku",
Value: string(vmi.Spec.Domain.Chassis.Sku),
},
}
}

if domain.Spec.Memory, err = QuantityToByte(*getVirtualMemory(vmi)); err != nil {
return err
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/virt-launcher/virtwrap/api/deepcopy_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/virt-launcher/virtwrap/api/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ type SysInfo struct {
System []Entry `xml:"system>entry"`
BIOS []Entry `xml:"bios>entry"`
BaseBoard []Entry `xml:"baseBoard>entry"`
Chassis []Entry `xml:"chassis>entry"`
}

type Entry struct {
Expand Down
25 changes: 25 additions & 0 deletions staging/src/kubevirt.io/client-go/api/v1/deepcopy_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 51 additions & 1 deletion staging/src/kubevirt.io/client-go/api/v1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions staging/src/kubevirt.io/client-go/api/v1/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ type DomainSpec struct {
// One of: shared, auto
// +optional
IOThreadsPolicy *IOThreadsPolicy `json:"ioThreadsPolicy,omitempty"`
// Chassis specifies the chassins info passed to the domain.
// +optional
Chassis *Chassis `json:"chassis,omitempty"`
}

// Chassis specifies the chassins info passed to the domain.
// ---
// +k8s:openapi-gen=true
type Chassis struct {
Manufacturer string `json:"manufacturer,omitempty"`
Version string `json:"version,omitempty"`
Serial string `json:"serial,omitempty"`
Asset string `json:"asset,omitempty"`
Sku string `json:"sku,omitempty"`
}

// Represents the firmware blob used to assist in the domain creation process.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions tests/vmi_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1857,4 +1857,27 @@ var _ = Describe("Configurations", func() {
})
})
})

Context("Check Chassis value", func() {
var vmi *v1.VirtualMachineInstance

BeforeEach(func() {
vmi = tests.NewRandomVMI()
})

It("Test Chassis value in a newly created VM", func() {
vmi.Spec.Domain.Chassis = &v1.Chassis{
Asset: "Test-123",
}

By("Starting a VirtualMachineInstance")
vmi, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmi)
Expect(err).ToNot(HaveOccurred())
tests.WaitForSuccessfulVMIStart(vmi)

domXml, err := tests.GetRunningVirtualMachineInstanceDomainXML(virtClient, vmi)
Expect(err).ToNot(HaveOccurred())
Expect(domXml).To(ContainSubstring("<entry name='asset'>Test-123</entry>"))
})
})
})

0 comments on commit 0c674d3

Please sign in to comment.