devices: interface: Convert setup() to validate()

That's all it's doing. Fold in mac validation while we are here
This commit is contained in:
Cole Robinson 2018-09-03 16:44:18 -04:00
parent 43f40950eb
commit c27cdc67de
2 changed files with 5 additions and 7 deletions

View File

@ -369,6 +369,8 @@ class vmmNetworkList(vmmGObjectUI):
net.virtualport.typeid = vport_typeid or None
net.virtualport.typeidversion = vport_idver or None
net.virtualport.instanceid = vport_instid or None
net.validate()
except Exception as e:
return self.err.val_err(_("Error with network parameters."), e)

View File

@ -204,10 +204,6 @@ class DeviceInterface(Device):
# XML helpers #
###############
def _validate_mac(self, val):
util.validate_macaddr(val)
return val
def _get_source(self):
"""
Convenience function, try to return the relevant <source> value
@ -257,7 +253,7 @@ class DeviceInterface(Device):
type = XMLProperty("./@type")
trustGuestRxFilters = XMLProperty("./@trustGuestRxFilters", is_yesno=True)
macaddr = XMLProperty("./mac/@address", set_converter=_validate_mac)
macaddr = XMLProperty("./mac/@address")
source_type = XMLProperty("./source/@type")
source_path = XMLProperty("./source/@path")
@ -281,11 +277,11 @@ class DeviceInterface(Device):
# Build API #
#############
def setup(self, meter=None):
ignore = meter
def validate(self):
if not self.macaddr:
return
util.validate_macaddr(self.macaddr)
ret, msg = self.is_conflict_net(self.conn, self.macaddr)
if msg is None:
return