Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/core/go.sum

This file was deleted.

17 changes: 10 additions & 7 deletions pkg/domain/entities/logicalvolume/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func ValidateRAIDCreation(
}

// Check if there are unavailable drives
unavailableDrives := unavailablesDrives(pds)
unavailableDrives := unavailableDrives(pds)

// If there are unavailable drives, return an error
if len(unavailableDrives) > 0 {
Expand All @@ -148,8 +148,8 @@ func ValidateRAIDCreation(
return nil
}

// unavailablesDrives returns the IDs of the unavailable physical drives.
func unavailablesDrives(pds []*physicaldrive.PhysicalDrive) []string {
// unavailableDrives returns the IDs of the unavailable physical drives.
func unavailableDrives(pds []*physicaldrive.PhysicalDrive) []string {
var unavailableDrives []string

for _, pd := range pds {
Expand Down Expand Up @@ -203,14 +203,17 @@ func findMostFrequentSize(pds []*physicaldrive.PhysicalDrive) uint64 {

// RAIDLevelMap maps the RAID level string to the RAID level type.
func RAIDLevelMap(str string) RAIDLevel {
// Remove the "RAID" prefix from the string if it exists
raidLevelString := strings.TrimPrefix(str, "RAID")

// raidLevelMap maps the RAID level string to the RAID level type.
raidLevelMap := map[string]RAIDLevel{
"RAID0": RAIDLevel0,
"RAID1": RAIDLevel1,
"RAID10": RAIDLevel10,
"0": RAIDLevel0,
"1": RAIDLevel1,
"10": RAIDLevel10,
}

if raidLevel, ok := raidLevelMap[strings.ToUpper(str)]; ok {
if raidLevel, ok := raidLevelMap[raidLevelString]; ok {
return raidLevel
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/domain/entities/physicaldrive/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const (
DiskTypeHDD
DiskTypeSSD
DiskTypeNVMe
)

const (
PDStatusUnknown PDStatus = iota
PDStatusUsed
PDStatusUnassignedGood
Expand Down
39 changes: 38 additions & 1 deletion pkg/domain/entities/physicaldrive/types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//nolint:lll // Structures with tags are too long for you, lll.
//nolint:lll,cyclop,gocognit // Structures with tags are too long for you, lll.
package physicaldrive

import (
Expand Down Expand Up @@ -74,6 +74,43 @@ func (s *Slot) String() string {
return str
}

func (s *Slot) Format() string {
if s == nil {
return nilSlot
}

// Handle empty cases for all fields
if s.Port == "" && s.Enclosure == "" && s.Bay == "" {
return emptySlot
}

if s.Port == "" {
// Handle when only Port is empty
if s.Enclosure == "" {
return s.Bay
}

if s.Bay == "" {
return s.Enclosure
}

return s.Enclosure + ":" + s.Bay
}

// Handle when Port exists but other fields might be empty
result := s.Port

if s.Enclosure != "" || s.Bay != "" {
result += ":" + s.Enclosure
}
Comment thread
TeddyAndrieux marked this conversation as resolved.
Outdated

if s.Bay != "" {
result += ":" + s.Bay
}

return result
Comment thread
TeddyAndrieux marked this conversation as resolved.
Outdated
}

// Available checks if the PhysicalDrive Status is PDStatusUnassignedGood.
func (pd *PhysicalDrive) IsAvailable() bool {
return pd.Status == PDStatusUnassignedGood
Expand Down
6 changes: 6 additions & 0 deletions pkg/domain/ports/raidcontroller.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package ports

import (
"github.com/pkg/errors"

"github.com/scality/raidmgmt/pkg/domain/entities/logicalvolume"
"github.com/scality/raidmgmt/pkg/domain/entities/physicaldrive"
"github.com/scality/raidmgmt/pkg/domain/entities/raidcontroller"
)

const functionNotSupportedByImplementation = "function not supported by implementation"

var ErrFunctionNotSupportedByImplementation = errors.New(functionNotSupportedByImplementation)

type (
ControllersGetter interface {
// Controllers returns a list of RAID controllers
Expand Down
62 changes: 62 additions & 0 deletions pkg/implementation/blinker/ssacli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package blinker

import (
"strconv"

"github.com/pkg/errors"

"github.com/scality/raidmgmt/pkg/domain/entities/physicaldrive"
"github.com/scality/raidmgmt/pkg/domain/ports"
"github.com/scality/raidmgmt/pkg/implementation/commandrunner"
)

type SSACLI struct {
commandrunner.CommandRunner
}

var _ ports.Blinker = &SSACLI{}

func NewSSACLI() *SSACLI {
return &SSACLI{}
}

// StartBlink starts blinking a physical drive.
func (s *SSACLI) StartBlink(metadata *physicaldrive.Metadata) error {
err := s.blink(metadata, "on")
if err != nil {
return errors.Wrap(err, "failed to start blinking physical drive")
}

return nil
}

// StopBlink stops blinking a physical drive.
func (s *SSACLI) StopBlink(metadata *physicaldrive.Metadata) error {
err := s.blink(metadata, "off")
if err != nil {
return errors.Wrap(err, "failed to stop blinking physical drive")
}

return nil
}

// blink makes a physical drive blink.
func (s *SSACLI) blink(metadata *physicaldrive.Metadata, action string) error {
slot := metadata.Slot.Format()

args := []string{
"controller",
"slot=" + strconv.Itoa(metadata.CtrlMetadata.ID),
"physicaldrive",
slot,
"modify",
"led=" + action,
}

_, err := s.CommandRunner.Run(args)
if err != nil {
return errors.Wrapf(err, "failed to blink physical drive %s", slot)
}

return nil
}
3 changes: 3 additions & 0 deletions pkg/implementation/controllergetter/controller/show/all.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

HPE Smart Array P816i-a SR Gen10 in Slot 0 (Embedded) (sn: PWXLA0CRHF10FM)

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

HPE Smart Array P816i-a SR Gen10 in Slot 0 (Embedded)
Bus Interface: PCI
Slot: 0
Serial Number: PWXLA0CRHF10FM
RAID 6 Status: Enabled
Controller Status: OK
Hardware Revision: A
Firmware Version: 5.00
Firmware Supports Online Firmware Activation: False
Rebuild Priority: High
Expand Priority: Medium
Surface Scan Delay: 3 secs
Surface Scan Mode: Idle
Parallel Surface Scan Supported: Yes
Current Parallel Surface Scan Count: 1
Max Parallel Surface Scan Count: 16
Queue Depth: Automatic
Monitor and Performance Delay: 60 min
Elevator Sort: Enabled
Degraded Performance Optimization: Disabled
Inconsistency Repair Policy: Disabled
Write Cache Bypass Threshold Size: 1040 KiB
Wait for Cache Room: Disabled
Surface Analysis Inconsistency Notification: Disabled
Post Prompt Timeout: 15 secs
Cache Board Present: True
Cache Status: OK
Cache Ratio: 10% Read / 90% Write
Configured Drive Write Cache Policy: Disable
Unconfigured Drive Write Cache Policy: Default
Total Cache Size: 4.0
Total Cache Memory Available: 3.8
Battery Backed Cache Size: 3.8
No-Battery Write Cache: Disabled
SSD Caching RAID5 WriteBack Enabled: True
SSD Caching Version: 2
Cache Backup Power Source: Batteries
Battery/Capacitor Count: 1
Battery/Capacitor Status: OK
SATA NCQ Supported: True
Spare Activation Mode: Activate on physical drive failure (default)
Spare Spindown Policy Supported: False
Controller Temperature (C): 64
Capacitor Temperature (C): 50
Number of Ports: 4 Internal only
Encryption: Not Set
Express Local Encryption: False
SED Based Encryption Supported: False
Driver Name: smartpqi
Driver Version: Linux 2.1.24-046
WWN Port: 51402EC0167C85E0
PCI Address (Domain:Bus:Device.Function): 0000:5C:00.0
Negotiated PCIe Data Rate: PCIe 3.0 x8 (7880 MB/s)
Controller Mode: Mixed
Port Max Phy Rate Limiting Supported: False
Latency Scheduler Setting: Disabled
Current Power Mode: MaxPerformance
Survival Mode: Enabled
Host Serial Number: 2M21210201
Sanitize Erase Supported: True
Sanitize Lock: None
Sensor ID: 0
Location: Capacitor
Current Value (C): 50
Max Value Since Power On: 52
Sensor ID: 1
Location: ASIC
Current Value (C): 64
Max Value Since Power On: 67
Sensor ID: 2
Location: Unknown
Current Value (C): 50
Max Value Since Power On: 52
Primary Boot Volume: None
Secondary Boot Volume: None
SPDM Supports Get Slot Certificate Chain: no
SPDM Supports Get Controller Info : no
SPDM Supports Get Slot Info : no
SPDM Supports Set Import Certificate : no
SPDM Supports Set Invalidate Slot : no
Surface Scan Completion Supported: False
Persistent Event Log Policy Change Supported: False
UEFI Health Reporting Mode Supported: False
Firmware Supports NVMe Log Pages: False
Firmware Supports NAND Field: False
Firmware Supports NOR Field: False


112 changes: 112 additions & 0 deletions pkg/implementation/controllergetter/controller/show/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@

HPE Smart Array P816i-a SR Gen10 in Slot 0 (Embedded) (sn: PWXLA0CRHF10FM)



Internal Drive Cage at Port 1I, Box 1 (Index 0), OK



Internal Drive Cage at Port 2I, Box 2 (Index 1), OK



Internal Drive Cage at Port 3I, Box 3 (Index 2), OK



Internal Drive Cage at Port 4I, Box 6 (Index 3), OK


Port Name: 1I (Mixed)

Port Name: 2I (Mixed)

Port Name: 3I (Mixed)

Port Name: 4I (Mixed)

Array A (Solid State SAS, Unused Space: 0 MB)

logicaldrive 1 (745.18 GB, RAID 1, OK)

physicaldrive 4I:6:1 (port 4I:box 6:bay 1, SAS SSD, 800 GB, OK)
physicaldrive 4I:6:2 (port 4I:box 6:bay 2, SAS SSD, 800 GB, OK)


Array B (SAS, Unused Space: 0 MB)

logicaldrive 2 (5.46 TB, RAID 0, OK)

physicaldrive 1I:1:3 (port 1I:box 1:bay 3, SAS HDD, 6 TB, OK)


Array C (SAS, Unused Space: 0 MB)

logicaldrive 3 (5.46 TB, RAID 0, OK)

physicaldrive 1I:1:4 (port 1I:box 1:bay 4, SAS HDD, 6 TB, OK)


Array D (SAS, Unused Space: 0 MB)

logicaldrive 4 (5.46 TB, RAID 0, OK)

physicaldrive 2I:2:1 (port 2I:box 2:bay 1, SAS HDD, 6 TB, OK)


Array E (SAS, Unused Space: 0 MB)

logicaldrive 5 (5.46 TB, RAID 0, OK)

physicaldrive 2I:2:2 (port 2I:box 2:bay 2, SAS HDD, 6 TB, OK)


Array F (SAS, Unused Space: 0 MB)

logicaldrive 6 (5.46 TB, RAID 0, OK)

physicaldrive 2I:2:3 (port 2I:box 2:bay 3, SAS HDD, 6 TB, OK)


Array G (SAS, Unused Space: 0 MB)

logicaldrive 7 (5.46 TB, RAID 0, OK)

physicaldrive 2I:2:4 (port 2I:box 2:bay 4, SAS HDD, 6 TB, OK)


Array H (SAS, Unused Space: 0 MB)

logicaldrive 8 (5.46 TB, RAID 0, OK)

physicaldrive 3I:3:1 (port 3I:box 3:bay 1, SAS HDD, 6 TB, OK)


Array I (SAS, Unused Space: 0 MB)

logicaldrive 9 (5.46 TB, RAID 0, OK)

physicaldrive 3I:3:2 (port 3I:box 3:bay 2, SAS HDD, 6 TB, OK)


Array J (SAS, Unused Space: 0 MB)

logicaldrive 10 (5.46 TB, RAID 0, OK)

physicaldrive 3I:3:3 (port 3I:box 3:bay 3, SAS HDD, 6 TB, OK)


Array K (SAS, Unused Space: 0 MB)

logicaldrive 11 (5.46 TB, RAID 0, OK)

physicaldrive 3I:3:4 (port 3I:box 3:bay 4, SAS HDD, 6 TB, OK)

Unassigned

physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS HDD, 2 TB, OK)
physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SAS HDD, 2 TB, OK)

SEP (Vendor ID HPE, Model Smart Adapter) 379 (WWID: 51402EC0167C85F0)

Loading