mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Support OpenStack+ESXi Volumes in GetDevicePath
GetDevicePath was currently coded to only support Nova+KVM style device paths, update so we also support Nova+ESXi and leave the code such that new pattern additions are easy.
This commit is contained in:
parent
3eae250c58
commit
4942a57db6
@ -169,16 +169,25 @@ func (os *OpenStack) CreateVolume(name string, size int, vtype, availability str
|
|||||||
|
|
||||||
// GetDevicePath returns the path of an attached block storage volume, specified by its id.
|
// GetDevicePath returns the path of an attached block storage volume, specified by its id.
|
||||||
func (os *OpenStack) GetDevicePath(diskId string) string {
|
func (os *OpenStack) GetDevicePath(diskId string) string {
|
||||||
|
// Build a list of candidate device paths
|
||||||
|
candidateDeviceNodes := []string{
|
||||||
|
// KVM
|
||||||
|
fmt.Sprintf("virtio-%s", diskId[:20]),
|
||||||
|
// ESXi
|
||||||
|
fmt.Sprintf("wwn-0x%s", strings.Replace(diskId, "-", "", -1)),
|
||||||
|
}
|
||||||
|
|
||||||
files, _ := ioutil.ReadDir("/dev/disk/by-id/")
|
files, _ := ioutil.ReadDir("/dev/disk/by-id/")
|
||||||
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
if strings.Contains(f.Name(), "virtio-") {
|
for _, c := range candidateDeviceNodes {
|
||||||
devid_prefix := f.Name()[len("virtio-"):len(f.Name())]
|
if c == f.Name() {
|
||||||
if strings.Contains(diskId, devid_prefix) {
|
|
||||||
glog.V(4).Infof("Found disk attached as %q; full devicepath: %s\n", f.Name(), path.Join("/dev/disk/by-id/", f.Name()))
|
glog.V(4).Infof("Found disk attached as %q; full devicepath: %s\n", f.Name(), path.Join("/dev/disk/by-id/", f.Name()))
|
||||||
return path.Join("/dev/disk/by-id/", f.Name())
|
return path.Join("/dev/disk/by-id/", f.Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Warningf("Failed to find device for the diskid: %q\n", diskId)
|
glog.Warningf("Failed to find device for the diskid: %q\n", diskId)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user