virtinst: device: Remove set_addrstr()

There's only one user now, in cli.py. Open code it there

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson
2020-01-25 13:40:24 -05:00
parent 2367e70efa
commit b3ea89f218
2 changed files with 11 additions and 16 deletions

View File

@@ -3498,7 +3498,17 @@ class ParserController(VirtCLIParser):
###################
def set_address_cb(self, inst, val, virtarg):
inst.address.set_addrstr(val)
addrstr = val
if addrstr.count(":") in [1, 2] and "." in addrstr:
inst.address.type = inst.address.ADDRESS_TYPE_PCI
addrstr, inst.address.function = addrstr.split(".", 1)
addrstr, inst.address.slot = addrstr.rsplit(":", 1)
inst.address.domain = "0"
if ":" in addrstr:
inst.address.domain, inst.address.bus = addrstr.split(":", 1)
return
raise ValueError(
_("Expected PCI format string for '%s'") % addrstr)
@classmethod
def _init_class(cls, **kwargs):

View File

@@ -58,21 +58,6 @@ class DeviceAddress(XMLBuilder):
_XML_PROP_ORDER = ["type", "domain", "controller", "bus", "slot",
"function", "target", "unit", "multifunction"]
def set_addrstr(self, addrstr):
if addrstr is None:
return
if addrstr.count(":") in [1, 2] and "." in addrstr:
self.type = self.ADDRESS_TYPE_PCI
addrstr, self.function = addrstr.split(".", 1)
addrstr, self.slot = addrstr.rsplit(":", 1)
self.domain = "0"
if ":" in addrstr:
self.domain, self.bus = addrstr.split(":", 1)
else:
raise ValueError(_("Could not determine or unsupported "
"format of '%s'") % addrstr)
def pretty_desc(self):
pretty_desc = None
if self.type == self.ADDRESS_TYPE_DRIVE: