getInstanceByName :: ConfigData -> String -> ErrorResult Instance
getInstanceByName cfg name =
  let instances = M.elems . fromContainer . configInstances $ cfg
      matching = F.find (maybe False (== name) . instName) instances
  in case matching of
      Just inst -> Ok inst
      Nothing   -> Bad $ OpPrereqError
                   ("Instance name " ++ name ++ " not found")
                   ECodeNoEnt

-- | Looks up a disk by uuid.
getInstanceByName :: ConfigData -> String -> ErrorResult Instance
getInstanceByName cfg name =
  let instances = M.elems . fromContainer . configInstances $ cfg
      matching = F.find (maybe False (== name) . instName) instances
  in case matching of
      Just inst -> Ok inst
      Nothing   -> Bad $ OpPrereqError
                   ("Instance name " ++ name ++ " not found")
                   ECodeNoEnt

-- | Looks up a disk by uuid.
getInstanceByName cfg name =
  let instances = M.elems . fromContainer . configInstances $ cfg
      matching = F.find (maybe False (== name) . instName) instances
  in case matching of
      Just inst -> Ok inst
      Nothing   -> Bad $ OpPrereqError
                   ("Instance name " ++ name ++ " not found")
                   ECodeNoEnt

-- | Looks up a disk by uuid.