mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
lvmdbusd: Handle missing lv_attr table lookups
If we don't know the meaning we will return the key with default text
instead of raising an exception and taking the daemon out in the
process.
Resolves: rhbz1657950
(cherry picked from commit 51f08efaa7
)
This commit is contained in:
parent
cc59cb1abc
commit
da9b499bc2
@ -10,7 +10,7 @@
|
|||||||
from .automatedproperties import AutomatedProperties
|
from .automatedproperties import AutomatedProperties
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .utils import vg_obj_path_generate
|
from .utils import vg_obj_path_generate, log_error
|
||||||
import dbus
|
import dbus
|
||||||
from . import cmdhandler
|
from . import cmdhandler
|
||||||
from . import cfg
|
from . import cfg
|
||||||
@ -24,6 +24,8 @@ from . import background
|
|||||||
from .utils import round_size, mt_remove_dbus_objects
|
from .utils import round_size, mt_remove_dbus_objects
|
||||||
from .job import JobState
|
from .job import JobState
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
# Try and build a key for a LV, so that we sort the LVs with least dependencies
|
# Try and build a key for a LV, so that we sort the LVs with least dependencies
|
||||||
# first. This may be error prone because of the flexibility LVM
|
# first. This may be error prone because of the flexibility LVM
|
||||||
@ -291,6 +293,22 @@ class LvCommon(AutomatedProperties):
|
|||||||
(lv_uuid, lv_name))
|
(lv_uuid, lv_name))
|
||||||
return dbo
|
return dbo
|
||||||
|
|
||||||
|
def attr_struct(self, index, type_map, default='undisclosed'):
|
||||||
|
try:
|
||||||
|
if self.state.Attr[index] not in type_map:
|
||||||
|
log_error("LV %s %s with lv_attr %s, lv_attr[%d] = "
|
||||||
|
"'%s' is not known" %
|
||||||
|
(self.Uuid, self.Name, self.Attr, index,
|
||||||
|
self.state.Attr[index]))
|
||||||
|
|
||||||
|
return dbus.Struct((self.state.Attr[index],
|
||||||
|
type_map.get(self.state.Attr[index], default)),
|
||||||
|
signature="(ss)")
|
||||||
|
except BaseException:
|
||||||
|
st = traceback.format_exc()
|
||||||
|
log_error("attr_struct: \n%s" % st)
|
||||||
|
return dbus.Struct(('?', 'Unavailable'), signature="(ss)")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def VolumeType(self):
|
def VolumeType(self):
|
||||||
type_map = {'C': 'Cache', 'm': 'mirrored',
|
type_map = {'C': 'Cache', 'm': 'mirrored',
|
||||||
@ -304,16 +322,14 @@ class LvCommon(AutomatedProperties):
|
|||||||
'V': 'thin Volume', 't': 'thin pool', 'T': 'Thin pool data',
|
'V': 'thin Volume', 't': 'thin pool', 'T': 'Thin pool data',
|
||||||
'e': 'raid or pool metadata or pool metadata spare',
|
'e': 'raid or pool metadata or pool metadata spare',
|
||||||
'-': 'Unspecified'}
|
'-': 'Unspecified'}
|
||||||
return dbus.Struct((self.state.Attr[0], type_map[self.state.Attr[0]]),
|
return self.attr_struct(0, type_map)
|
||||||
signature="as")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Permissions(self):
|
def Permissions(self):
|
||||||
type_map = {'w': 'writable', 'r': 'read-only',
|
type_map = {'w': 'writable', 'r': 'read-only',
|
||||||
'R': 'Read-only activation of non-read-only volume',
|
'R': 'Read-only activation of non-read-only volume',
|
||||||
'-': 'Unspecified'}
|
'-': 'Unspecified'}
|
||||||
return dbus.Struct((self.state.Attr[1], type_map[self.state.Attr[1]]),
|
return self.attr_struct(1, type_map)
|
||||||
signature="(ss)")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def AllocationPolicy(self):
|
def AllocationPolicy(self):
|
||||||
@ -322,8 +338,7 @@ class LvCommon(AutomatedProperties):
|
|||||||
'i': 'inherited', 'I': 'inherited locked',
|
'i': 'inherited', 'I': 'inherited locked',
|
||||||
'l': 'cling', 'L': 'cling locked',
|
'l': 'cling', 'L': 'cling locked',
|
||||||
'n': 'normal', 'N': 'normal locked', '-': 'Unspecified'}
|
'n': 'normal', 'N': 'normal locked', '-': 'Unspecified'}
|
||||||
return dbus.Struct((self.state.Attr[2], type_map[self.state.Attr[2]]),
|
return self.attr_struct(2, type_map)
|
||||||
signature="(ss)")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def FixedMinor(self):
|
def FixedMinor(self):
|
||||||
@ -338,8 +353,7 @@ class LvCommon(AutomatedProperties):
|
|||||||
'd': 'mapped device present without tables',
|
'd': 'mapped device present without tables',
|
||||||
'i': 'mapped device present with inactive table',
|
'i': 'mapped device present with inactive table',
|
||||||
'X': 'unknown', '-': 'Unspecified'}
|
'X': 'unknown', '-': 'Unspecified'}
|
||||||
return dbus.Struct((self.state.Attr[4], type_map[self.state.Attr[4]]),
|
return self.attr_struct(4, type_map)
|
||||||
signature="(ss)")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def TargetType(self):
|
def TargetType(self):
|
||||||
@ -358,8 +372,7 @@ class LvCommon(AutomatedProperties):
|
|||||||
type_map = {'p': 'partial', 'r': 'refresh',
|
type_map = {'p': 'partial', 'r': 'refresh',
|
||||||
'm': 'mismatches', 'w': 'writemostly',
|
'm': 'mismatches', 'w': 'writemostly',
|
||||||
'X': 'X unknown', '-': 'Unspecified'}
|
'X': 'X unknown', '-': 'Unspecified'}
|
||||||
return dbus.Struct((self.state.Attr[8], type_map[self.state.Attr[8]]),
|
return self.attr_struct(8, type_map)
|
||||||
signature="(ss)")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def SkipActivation(self):
|
def SkipActivation(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user