From b3ea89f218ba345c26701fd802d6d36aed0566a6 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sat, 25 Jan 2020 13:40:24 -0500 Subject: [PATCH] virtinst: device: Remove set_addrstr() There's only one user now, in cli.py. Open code it there Signed-off-by: Cole Robinson --- virtinst/cli.py | 12 +++++++++++- virtinst/devices/device.py | 15 --------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/virtinst/cli.py b/virtinst/cli.py index a43338e8e..a7b1257bc 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -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): diff --git a/virtinst/devices/device.py b/virtinst/devices/device.py index c3676da55..1946572d1 100644 --- a/virtinst/devices/device.py +++ b/virtinst/devices/device.py @@ -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: