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