devices: Add DeviceSeclabel
Hoist it out of DeviceDisk, so we can eventually share it with CharSource as well
This commit is contained in:
parent
dc945dc4b9
commit
569533b187
|
@ -2474,6 +2474,22 @@ def _add_device_boot_order_arg(cls):
|
|||
cls.add_arg("boot.order", "boot.order", cb=cls.set_boot_order_cb)
|
||||
|
||||
|
||||
def _add_device_seclabel_args(cls, list_propname):
|
||||
def seclabel_find_inst_cb(c, *args, **kwargs):
|
||||
# pylint: disable=protected-access
|
||||
cliarg = "seclabel" # seclabel[0-9]*
|
||||
cb = c._make_find_inst_cb(cliarg, list_propname)
|
||||
return cb(*args, **kwargs)
|
||||
|
||||
# DeviceDisk.seclabels properties
|
||||
cls.add_arg("source.seclabel[0-9]*.model", "model",
|
||||
find_inst_cb=seclabel_find_inst_cb)
|
||||
cls.add_arg("source.seclabel[0-9]*.relabel", "relabel", is_onoff=True,
|
||||
find_inst_cb=seclabel_find_inst_cb)
|
||||
cls.add_arg("source.seclabel[0-9]*.label", "label", can_comma=True,
|
||||
find_inst_cb=seclabel_find_inst_cb)
|
||||
|
||||
|
||||
def _add_char_source_args(cls, prefix=""):
|
||||
"""
|
||||
Add arguments that represent the CharSource object, which is shared
|
||||
|
@ -2689,12 +2705,6 @@ class ParserDisk(VirtCLIParser):
|
|||
# Option handling #
|
||||
###################
|
||||
|
||||
def seclabel_find_inst_cb(self, *args, **kwargs):
|
||||
cliarg = "seclabel" # seclabel[0-9]*
|
||||
list_propname = "seclabels" # disk.seclabels
|
||||
cb = self._make_find_inst_cb(cliarg, list_propname)
|
||||
return cb(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def _init_class(cls, **kwargs):
|
||||
VirtCLIParser._init_class(**kwargs)
|
||||
|
@ -2721,12 +2731,7 @@ class ParserDisk(VirtCLIParser):
|
|||
cls.add_arg("source.host.socket", "source_host_socket")
|
||||
cls.add_arg("source.host.transport", "source_host_transport")
|
||||
cls.add_arg("source.startupPolicy", "startup_policy")
|
||||
cls.add_arg("source.seclabel[0-9]*.model", "model",
|
||||
find_inst_cb=cls.seclabel_find_inst_cb)
|
||||
cls.add_arg("source.seclabel[0-9]*.relabel", "relabel", is_onoff=True,
|
||||
find_inst_cb=cls.seclabel_find_inst_cb)
|
||||
cls.add_arg("source.seclabel[0-9]*.label", "label", can_comma=True,
|
||||
find_inst_cb=cls.seclabel_find_inst_cb)
|
||||
_add_device_seclabel_args(cls, "seclabels")
|
||||
|
||||
cls.add_arg("path", "path")
|
||||
cls.add_arg("device", "device")
|
||||
|
|
|
@ -9,6 +9,16 @@
|
|||
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
|
||||
|
||||
|
||||
class DeviceSeclabel(XMLBuilder):
|
||||
"""
|
||||
Minimal seclabel that's used for device sources.
|
||||
"""
|
||||
XML_NAME = "seclabel"
|
||||
model = XMLProperty("./@model")
|
||||
relabel = XMLProperty("./@relabel", is_yesno=True)
|
||||
label = XMLProperty("./label")
|
||||
|
||||
|
||||
class DeviceAlias(XMLBuilder):
|
||||
XML_NAME = "alias"
|
||||
name = XMLProperty("./@name")
|
||||
|
|
|
@ -10,7 +10,7 @@ import logging
|
|||
|
||||
from .. import diskbackend
|
||||
from .. import util
|
||||
from .device import Device
|
||||
from .device import Device, DeviceSeclabel
|
||||
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
|
||||
|
||||
|
||||
|
@ -35,17 +35,6 @@ class _Host(XMLBuilder):
|
|||
port = XMLProperty("./@port", is_int=True)
|
||||
|
||||
|
||||
class _DiskSeclabel(XMLBuilder):
|
||||
"""
|
||||
This is for disk source <seclabel>. It's similar to a domain
|
||||
<seclabel> but has fewer options
|
||||
"""
|
||||
XML_NAME = "seclabel"
|
||||
model = XMLProperty("./@model")
|
||||
relabel = XMLProperty("./@relabel", is_yesno=True)
|
||||
label = XMLProperty("./label")
|
||||
|
||||
|
||||
class DeviceDisk(Device):
|
||||
XML_NAME = "disk"
|
||||
|
||||
|
@ -677,7 +666,7 @@ class DeviceDisk(Device):
|
|||
iotune_wbs = XMLProperty("./iotune/write_bytes_sec", is_int=True)
|
||||
iotune_wis = XMLProperty("./iotune/write_iops_sec", is_int=True)
|
||||
|
||||
seclabels = XMLChildProperty(_DiskSeclabel, relative_xpath="./source")
|
||||
seclabels = XMLChildProperty(DeviceSeclabel, relative_xpath="./source")
|
||||
|
||||
geometry_cyls = XMLProperty("./geometry/@cyls", is_int=True)
|
||||
geometry_heads = XMLProperty("./geometry/@heads", is_int=True)
|
||||
|
|
Loading…
Reference in New Issue