Skip to content

Commit 08ef585

Browse files
authored
Merge pull request #131 from eric-ch/s8-oxt-796
STABLE-8: OXT-796: xenmgr: Match multi-strings in dmi chassis type.
2 parents db93ba3 + ab58e71 commit 08ef585

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

xenmgr/XenMgr/Host.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,14 @@ hostCheckFreeStorage = do
386386
haveSystemAmtPt :: Rpc Bool
387387
haveSystemAmtPt = dbReadWithDefault False "system-amt-pt-active"
388388

389-
-- Check if this is laptop by testing the chassis type string
390-
isLaptop :: IO Bool
391-
isLaptop =
392-
do hi <- readHostInfo
393-
let chassis = map toLower . strip $ hostChassisType hi
394-
return (chassis == "laptop" || chassis == "notebook" || chassis == "portable")
389+
-- Check if this is laptop by testing the chassis type string against list of
390+
-- known keywords.
391+
isLaptopStr :: String -> Bool
392+
isLaptopStr chassisTypeStr =
393+
let keywords = [ "laptop", "notebook", "portable" ]
394+
chassisStrs = lines $ strip $ map toLower chassisTypeStr
395+
in
396+
foldl (||) False $ map (`elem` keywords) chassisStrs
395397

396398
-- Check if host contains PCI devices required to turn AMT on
397399
isAMTCapable :: IO Bool
@@ -457,9 +459,7 @@ readHostInfo = do
457459
eth0Addr <- future $ maybe "" id <$> eth0Mac
458460
wifiAddr <- future $ maybe "" id <$> wlan0Mac
459461
amt_cap <- future $ isAMTCapable
460-
chassisType <- getHostChassisType
461-
let chassis = map toLower . strip $ chassisType
462-
is_laptop = (chassis == "laptop" || chassis == "notebook" || chassis == "portable")
462+
chassisType <- getHostChassisType
463463
force $ HostInfo <$>
464464
vendor
465465
<*> model
@@ -472,7 +472,7 @@ readHostInfo = do
472472
<*> wifiAddr
473473
<*> wifiModel
474474
<*> pure chassisType
475-
<*> pure is_laptop
475+
<*> pure (isLaptopStr chassisType)
476476
<*> amt_cap
477477
where
478478
fetch s regex = case s `matchG` regex of [] -> ""

0 commit comments

Comments
 (0)