Resolves: rhbz#1081982
If this patch resolves this bug, the bug should be reassigned to avoid process nightmares.
# if it contains '.', vlan id should follow (eg 'ens7.171', 'mydev.171')
split_name = retval.interfacename.split(".", 1)
if len(split_name) > 1:
# 'vlan' can't be followed by a '.'
if split_name[0] == "vlan":
raise KickstartValueError(formatErrorMsg(self.lineno,
msg=_("for network --interfacename 'vlan' can't be followed by a '.'")))
I don't really understand this error message. Could it be made more clear?
try:
vlan_id = int(split_name[1])
except ValueError:
raise KickstartValueError(formatErrorMsg(self.lineno,
msg=_("if network --interfacename contains a '.', valid vlan id should follow")))
# if it starts with 'vlan', vlan id should follow ('vlan171')
if retval.interfacename.startswith("vlan"):
try:
vlan_id = int(retval.interfacename.strip("vlan"))
except ValueError:
raise KickstartValueError(formatErrorMsg(self.lineno,
msg=_("if network --interfacename starts with 'vlan', valid vlan id should follow")))
I'd like these two error messages to look more like sentences - capitalize the If, put a period at the end.
# check if the vlan id is in range
if vlan_id is not None:
if not(min_vlan_id <= vlan_id <= max_vlan_id):
raise KickstartValueError(formatErrorMsg(self.lineno,
msg=_("vlan id out of range")))
return retval
It'd help the user if you said what the valid range is.
Also this should probably all be in its own method. That way if some later version of the network command needs to override the parse method, it doesn't also need to duplicate all the work you've done here.
- Chris