Skip to content

Commit

Permalink
Remove volumeName from disks
Browse files Browse the repository at this point in the history
Disks and Volumes now need to have matching names, similar to Interfaces
and Networks.
  • Loading branch information
rmohr authored and davidvossel committed Jan 14, 2019
1 parent c9f0c50 commit 2d2b502
Show file tree
Hide file tree
Showing 29 changed files with 230 additions and 369 deletions.
7 changes: 1 addition & 6 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4245,8 +4245,7 @@
},
"v1.Disk": {
"required": [
"name",
"volumeName"
"name"
],
"properties": {
"bootOrder": {
Expand Down Expand Up @@ -4285,10 +4284,6 @@
"serial": {
"description": "Serial provides the ability to specify a serial number for the disk device.\n+optional",
"type": "string"
},
"volumeName": {
"description": "Name of the volume which is referenced.\nMust match the Name of a Volume.",
"type": "string"
}
}
},
Expand Down
6 changes: 2 additions & 4 deletions cluster/examples/vm-alpine-multipvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@ spec:
- disk:
bus: virtio
name: pvcdisk1
volumeName: pvcvolume1
- disk:
bus: virtio
name: pvcdisk2
volumeName: pvcvolume2
machine:
type: ""
resources:
requests:
memory: 64M
terminationGracePeriodSeconds: 0
volumes:
- name: pvcvolume1
- name: pvcdisk1
persistentVolumeClaim:
claimName: disk-alpine
- name: pvcvolume2
- name: pvcdisk2
persistentVolumeClaim:
claimName: disk-custom
8 changes: 3 additions & 5 deletions cluster/examples/vm-template-fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ objects:
disks:
- disk:
bus: virtio
name: containerdisk
volumeName: registryvolume
name: registrydisk
- disk:
bus: virtio
name: cloudinitdisk
volumeName: cloudinitvolume
machine:
type: ""
resources:
Expand All @@ -50,13 +48,13 @@ objects:
volumes:
- containerDisk:
image: registry:5000/kubevirt/fedora-cloud-container-disk-demo:devel
name: registryvolume
name: registrydisk
- cloudInitNoCloud:
userData: |-
#cloud-config
password: fedora
chpasswd: { expire: False }
name: cloudinitvolume
name: cloudinitdisk
status: {}
parameters:
- description: Name for the new VM
Expand Down
3 changes: 1 addition & 2 deletions cluster/examples/vm-template-rhel7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ objects:
- disk:
bus: virtio
name: disk0
volumeName: disk0-pvc
machine:
type: ""
resources:
requests:
memory: ${MEMORY}
terminationGracePeriodSeconds: 0
volumes:
- name: disk0-pvc
- name: disk0
persistentVolumeClaim:
claimName: linux-vm-pvc-${NAME}
status: {}
Expand Down
6 changes: 2 additions & 4 deletions cluster/examples/vm-template-windows2012r2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ objects:
- disk:
bus: sata
name: pvcdisk
volumeName: pvcvolume
- disk:
bus: virtio
name: disk0
volumeName: disk0-pvc
interfaces:
- bridge: {}
model: e1000
Expand All @@ -75,10 +73,10 @@ objects:
pod: {}
terminationGracePeriodSeconds: 0
volumes:
- name: pvcvolume
- name: pvcdisk
persistentVolumeClaim:
claimName: disk-windows
- name: disk0-pvc
- name: disk0
persistentVolumeClaim:
claimName: windows-vm-pvc-${NAME}
status: {}
Expand Down
3 changes: 1 addition & 2 deletions cluster/examples/vmi-block-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ spec:
- disk:
bus: virtio
name: blockpvcdisk
volumeName: blockpvcvolume
machine:
type: ""
resources:
requests:
memory: 64M
terminationGracePeriodSeconds: 0
volumes:
- name: blockpvcvolume
- name: blockpvcdisk
persistentVolumeClaim:
claimName: local-block-storage-cirros
3 changes: 1 addition & 2 deletions cluster/examples/vmi-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ spec:
- disk:
bus: virtio
name: pvcdisk
volumeName: pvcvolume
machine:
type: ""
resources:
requests:
memory: 64M
terminationGracePeriodSeconds: 0
volumes:
- name: pvcvolume
- name: pvcdisk
persistentVolumeClaim:
claimName: disk-alpine
3 changes: 1 addition & 2 deletions cluster/examples/vmi-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ spec:
- disk:
bus: sata
name: pvcdisk
volumeName: pvcvolume
interfaces:
- bridge: {}
model: e1000
Expand All @@ -49,6 +48,6 @@ spec:
pod: {}
terminationGracePeriodSeconds: 0
volumes:
- name: pvcvolume
- name: pvcdisk
persistentVolumeClaim:
claimName: disk-windows
9 changes: 1 addition & 8 deletions pkg/api/v1/openapi_generated.go

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

3 changes: 0 additions & 3 deletions pkg/api/v1/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ type Devices struct {
type Disk struct {
// Name is the device name
Name string `json:"name"`
// Name of the volume which is referenced.
// Must match the Name of a Volume.
VolumeName string `json:"volumeName"`
// DiskDevice specifies as which device the disk should be added to the guest.
// Defaults to Disk.
DiskDevice `json:",inline"`
Expand Down
1 change: 0 additions & 1 deletion pkg/api/v1/schema_swagger_generated.go

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

33 changes: 11 additions & 22 deletions pkg/api/v1/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,13 @@ var exampleJSON = `{
"disks": [
{
"name": "disk0",
"volumeName": "volume0",
"disk": {
"bus": "virtio"
},
"dedicatedIOThread": true
},
{
"name": "cdrom0",
"volumeName": "volume1",
"cdrom": {
"bus": "virtio",
"readonly": true,
Expand All @@ -142,23 +140,20 @@ var exampleJSON = `{
},
{
"name": "floppy0",
"volumeName": "volume2",
"floppy": {
"readonly": true,
"tray": "open"
}
},
{
"name": "lun0",
"volumeName": "volume3",
"lun": {
"bus": "virtio",
"readonly": true
}
},
{
"name": "disk1",
"volumeName": "volume4",
"disk": {
"bus": "virtio"
},
Expand All @@ -181,19 +176,18 @@ var exampleJSON = `{
"name": "volume0",
"containerDisk": {
"image": "test/image",
"path": "/disk.img"
}
},
{
"name": "volume1",
"name": "cdrom0",
"cloudInitNoCloud": {
"secretRef": {
"name": "testsecret"
}
}
},
{
"name": "volume2",
"name": "floppy0",
"persistentVolumeClaim": {
"claimName": "testclaim"
}
Expand All @@ -218,8 +212,7 @@ var _ = Describe("Schema", func() {

exampleVMI.Spec.Domain.Devices.Disks = []Disk{
{
Name: "disk0",
VolumeName: "volume0",
Name: "disk0",
DiskDevice: DiskDevice{
Disk: &DiskTarget{
Bus: "virtio",
Expand All @@ -229,8 +222,7 @@ var _ = Describe("Schema", func() {
DedicatedIOThread: _true,
},
{
Name: "cdrom0",
VolumeName: "volume1",
Name: "cdrom0",
DiskDevice: DiskDevice{
CDRom: &CDRomTarget{
Bus: "virtio",
Expand All @@ -240,8 +232,7 @@ var _ = Describe("Schema", func() {
},
},
{
Name: "floppy0",
VolumeName: "volume2",
Name: "floppy0",
DiskDevice: DiskDevice{
Floppy: &FloppyTarget{
ReadOnly: true,
Expand All @@ -250,8 +241,7 @@ var _ = Describe("Schema", func() {
},
},
{
Name: "lun0",
VolumeName: "volume3",
Name: "lun0",
DiskDevice: DiskDevice{
LUN: &LunTarget{
Bus: "virtio",
Expand All @@ -260,9 +250,8 @@ var _ = Describe("Schema", func() {
},
},
{
Name: "disk1",
VolumeName: "volume4",
Serial: "sn-11223344",
Name: "disk1",
Serial: "sn-11223344",
DiskDevice: DiskDevice{
Disk: &DiskTarget{
Bus: "virtio",
Expand All @@ -277,7 +266,7 @@ var _ = Describe("Schema", func() {

exampleVMI.Spec.Volumes = []Volume{
{
Name: "volume0",
Name: "disk0",
VolumeSource: VolumeSource{
ContainerDisk: &ContainerDiskSource{
Image: "test/image",
Expand All @@ -286,7 +275,7 @@ var _ = Describe("Schema", func() {
},
},
{
Name: "volume1",
Name: "cdrom0",
VolumeSource: VolumeSource{
CloudInitNoCloud: &CloudInitNoCloudSource{
UserDataSecretRef: &v1.LocalObjectReference{
Expand All @@ -296,7 +285,7 @@ var _ = Describe("Schema", func() {
},
},
{
Name: "volume2",
Name: "floppy0",
VolumeSource: VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: "testclaim",
Expand Down
Loading

0 comments on commit 2d2b502

Please sign in to comment.