check udev data directly when processing match: specs
also allow matching on ID_VENDOR
This commit is contained in:
parent
a8b9a42c21
commit
ac6c84a78b
|
@ -1378,16 +1378,22 @@ class FilesystemModel(object):
|
|||
def _make_matchers(self, match):
|
||||
matchers = []
|
||||
|
||||
def _udev_val(disk, key):
|
||||
return self._probe_data['blockdev'].get(disk.path, {}).get(key, '')
|
||||
|
||||
def match_serial(disk):
|
||||
if disk.serial is not None:
|
||||
return fnmatch.fnmatchcase(disk.serial, match['serial'])
|
||||
return fnmatch.fnmatchcase(
|
||||
_udev_val(disk, "ID_SERIAL"), match['serial'])
|
||||
|
||||
def match_model(disk):
|
||||
if disk.model is not None:
|
||||
return fnmatch.fnmatchcase(disk.model, match['model'])
|
||||
return fnmatch.fnmatchcase(
|
||||
_udev_val(disk, "ID_MODEL"), match['model'])
|
||||
|
||||
def match_vendor(disk):
|
||||
return fnmatch.fnmatchcase(
|
||||
_udev_val(disk, "ID_VENDOR"), match['vendor'])
|
||||
|
||||
def match_path(disk):
|
||||
if disk.path is not None:
|
||||
return fnmatch.fnmatchcase(disk.path, match['path'])
|
||||
|
||||
def match_ssd(disk):
|
||||
|
@ -1398,6 +1404,8 @@ class FilesystemModel(object):
|
|||
matchers.append(match_serial)
|
||||
if 'model' in match:
|
||||
matchers.append(match_model)
|
||||
if 'vendor' in match:
|
||||
matchers.append(match_vendor)
|
||||
if 'path' in match:
|
||||
matchers.append(match_path)
|
||||
if 'ssd' in match:
|
||||
|
|
|
@ -145,7 +145,7 @@ def make_disk(fs_model, **kw):
|
|||
if 'serial' not in kw:
|
||||
kw['serial'] = 'serial%s' % len(fs_model._actions)
|
||||
if 'path' not in kw:
|
||||
kw['path'] = '/dev/thing'
|
||||
kw['path'] = '/dev/thing%s' % len(fs_model._actions)
|
||||
if 'ptable' not in kw:
|
||||
kw['ptable'] = 'gpt'
|
||||
size = kw.pop('size', 100*(2**30))
|
||||
|
@ -856,6 +856,8 @@ def fake_up_blockdata(model):
|
|||
for disk in model.all_disks():
|
||||
bd[disk.path] = {
|
||||
'DEVTYPE': 'disk',
|
||||
'ID_SERIAL': disk.serial,
|
||||
'ID_MODEL': disk.model,
|
||||
'attrs': {
|
||||
'size': disk.size,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue