Skip to content

Commit

Permalink
Handle FC PV creation
Browse files Browse the repository at this point in the history
When having FC create the right PV for it.

Signed-off-by: Liran Rotenberg <[email protected]>
  • Loading branch information
liranr23 committed Nov 15, 2023
1 parent 6050771 commit ecf7900
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
28 changes: 20 additions & 8 deletions pkg/controller/plan/adapter/ovirt/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,25 @@ func (r *Builder) LunPersistentVolumes(vmRef ref.Ref) (pvs []core.PersistentVolu
volMode := core.PersistentVolumeBlock
logicalUnit := da.Disk.Lun.LogicalUnits.LogicalUnit[0]

var pvSource core.PersistentVolumeSource
if logicalUnit.Address != "" {
pvSource = core.PersistentVolumeSource{
ISCSI: &core.ISCSIPersistentVolumeSource{
TargetPortal: logicalUnit.Address + ":" + logicalUnit.Port,
IQN: logicalUnit.Target,
Lun: logicalUnit.LunMapping,
ReadOnly: false,
},
}
} else {
pvSource = core.PersistentVolumeSource{
FC: &core.FCVolumeSource{
WWIDs: []string{logicalUnit.LunID},
ReadOnly: false,
},
}
}

pvSpec := core.PersistentVolume{
ObjectMeta: meta.ObjectMeta{
Name: da.Disk.ID,
Expand All @@ -591,14 +610,7 @@ func (r *Builder) LunPersistentVolumes(vmRef ref.Ref) (pvs []core.PersistentVolu
},
},
Spec: core.PersistentVolumeSpec{
PersistentVolumeSource: core.PersistentVolumeSource{
ISCSI: &core.ISCSIPersistentVolumeSource{
TargetPortal: logicalUnit.Address + ":" + logicalUnit.Port,
IQN: logicalUnit.Target,
Lun: logicalUnit.LunMapping,
ReadOnly: false,
},
},
PersistentVolumeSource: pvSource,
Capacity: core.ResourceList{
core.ResourceStorage: *resource.NewQuantity(logicalUnit.Size, resource.BinarySI),
},
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/plan/adapter/ovirt/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (r *Validator) PodNetwork(vmRef ref.Ref) (ok bool, err error) {

// Validate that a VM's disk backing storage has been mapped.
func (r *Validator) StorageMapped(vmRef ref.Ref) (ok bool, err error) {
// TODO validate ovirt version > ovirt-engine-4.5.2.1 (https://github.com/oVirt/ovirt-engine/commit/e7c1f585863a332bcecfc8c3d909c9a3a56eb922)
if r.plan.Referenced.Map.Storage == nil {
return
}
Expand All @@ -110,7 +111,7 @@ func (r *Validator) StorageMapped(vmRef ref.Ref) (ok bool, err error) {
if !r.plan.Referenced.Map.Storage.Status.Refs.Find(ref.Ref{ID: da.Disk.StorageDomain}) {
return
}
} else if len(da.Disk.Lun.LogicalUnits.LogicalUnit) > 0 && da.Disk.Lun.LogicalUnits.LogicalUnit[0].Address == "" {
} else if len(da.Disk.Lun.LogicalUnits.LogicalUnit) > 0 {
// Have LUN disk but without the relevant data. This might happen with older oVirt versions.
return
}
Expand Down

0 comments on commit ecf7900

Please sign in to comment.