seaweedfs/weed/storage/types/volume_disk_type.go

34 lines
485 B
Go
Raw Normal View History

2021-02-16 10:47:02 +00:00
package types
2020-12-13 08:58:58 +00:00
2021-02-13 21:50:14 +00:00
import (
"strings"
)
2020-12-13 08:58:58 +00:00
2020-12-13 19:59:32 +00:00
type DiskType string
2020-12-13 08:58:58 +00:00
const (
2021-02-16 11:03:00 +00:00
HardDriveType DiskType = "hdd"
2020-12-16 17:14:05 +00:00
SsdType = "ssd"
2020-12-13 08:58:58 +00:00
)
2021-02-13 21:50:14 +00:00
func ToDiskType(vt string) (diskType DiskType) {
vt = strings.ToLower(vt)
2020-12-13 19:59:32 +00:00
diskType = HardDriveType
2020-12-13 08:58:58 +00:00
switch vt {
case "", "hdd":
2020-12-13 19:59:32 +00:00
diskType = HardDriveType
2020-12-13 08:58:58 +00:00
case "ssd":
2020-12-13 19:59:32 +00:00
diskType = SsdType
2020-12-13 08:58:58 +00:00
default:
2021-02-13 21:50:14 +00:00
diskType = DiskType(vt)
2020-12-13 08:58:58 +00:00
}
return
}
2021-02-13 23:42:42 +00:00
func (diskType DiskType) String() string{
if diskType == "" {
return "hdd"
}
return string(diskType)
}