@@ -6,15 +6,16 @@ import (
66 "container/list"
77 "errors"
88 "fmt"
9- log "github.com/hpe-storage/common-host-libs/logger"
10- "github.com/hpe-storage/common-host-libs/util"
119 "os"
1210 "path"
1311 "regexp"
1412 "strconv"
1513 "strings"
1614 "sync"
1715 "time"
16+
17+ log "github.com/hpe-storage/common-host-libs/logger"
18+ "github.com/hpe-storage/common-host-libs/util"
1819)
1920
2021const (
@@ -239,25 +240,21 @@ func addOption(section *Section, option string) {
239240
240241//checks for the section
241242func isSection (line string ) (bool , error ) {
242- line = strings .TrimSpace (line )
243- prefixes := []string {"defaults" , "blacklist" , "blacklist_exceptions" , "devices" , "device" , "multipaths" , "multipath" }
244- for _ , prefix := range prefixes {
245- r , err := regexp .Compile ("^" + prefix + "\\ s*[{]*$" )
246- if err != nil {
247- return false , err
248- }
249-
250- if (r .MatchString (line )) {
251- return true , nil
252- }
253- }
254-
255- return false , nil
256- }
257-
258-
243+ line = strings .TrimSpace (line )
244+ prefixes := []string {"defaults" , "blacklist" , "blacklist_exceptions" , "devices" , "device" , "multipaths" , "multipath" }
245+ for _ , prefix := range prefixes {
246+ r , err := regexp .Compile ("^" + prefix + "\\ s*[{]*$" )
247+ if err != nil {
248+ return false , err
249+ }
259250
251+ if r .MatchString (line ) {
252+ return true , nil
253+ }
254+ }
260255
256+ return false , nil
257+ }
261258
262259// ParseConfig reads and parses give config file into sections
263260func ParseConfig (filePath string ) (config * Configuration , err error ) {
@@ -349,9 +346,9 @@ func SaveConfig(config *Configuration, filePath string) (err error) {
349346 return err
350347}
351348
352- // GetNimbleSection gets nimble device section in /etc/multipath.conf
353- func (config * Configuration ) GetNimbleSection ( ) (section * Section , err error ) {
354- log .Trace ("GetNimbleSection called" )
349+ // GetDeviceSection gets device section in /etc/multipath.conf
350+ func (config * Configuration ) GetDeviceSection ( deviceType string ) (section * Section , err error ) {
351+ log .Trace ("GetDeviceSection called for device: " , deviceType )
355352 config .mutex .RLock ()
356353 defer config .mutex .RUnlock ()
357354
@@ -363,7 +360,7 @@ func (config *Configuration) GetNimbleSection() (section *Section, err error) {
363360 if s .GetChildren ().Len () != 0 {
364361 for e := s .GetChildren ().Front (); e != nil ; e = e .Next () {
365362 childSection := e .Value .(* Section )
366- if childSection .GetName () == "device" && strings .Contains (childSection .properties ["vendor" ], "Nimble" ) {
363+ if childSection .GetName () == "device" && strings .Contains (childSection .properties ["vendor" ], deviceType ) {
367364 return childSection , nil
368365 }
369366 }
0 commit comments