Skip to content

Commit

Permalink
Use BlockDev's DM plugin for DM map existence testing
Browse files Browse the repository at this point in the history
So that we move a step closer to putting pyblock into retirement.
  • Loading branch information
vpodzime committed Feb 19, 2015
1 parent c30eeb8 commit f077d2e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions blivet/devices/dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import os
from gi.repository import BlockDev as blockdev
import block
from gi.repository import GLib

from .. import errors
from .. import util
Expand Down Expand Up @@ -96,9 +96,13 @@ def mapName(self):

@property
def status(self):
match = next((m for m in block.dm.maps() if m.name == self.mapName),
None)
return (match.live_table and not match.suspended) if match else False
try:
return blockdev.dm_map_exists(self.mapName, True, True)
except GLib.GError as e:
if "Not running as root" in e.message:
return False
else:
raise

#def getTargetType(self):
# return dm.getDmTarget(name=self.name)
Expand Down

0 comments on commit f077d2e

Please sign in to comment.