From ca519248ff6285da678228c3af6f671f1a560d0e Mon Sep 17 00:00:00 2001 From: Dimitris Aragiorgis Date: Wed, 5 Dec 2012 16:08:10 +0200 Subject: [PATCH] Use new util function for mac_prefix validation Use new NormalizeAndValidateThreeOctetMacPrefix() util function in LUNetworkAdd/LUNetworkSetParams to validate network's MAC prefix. Additionally, move the check in CheckArguments() in the case of LUNetworkAdd. Signed-off-by: Dimitris Aragiorgis Reviewed-by: Michael Hanselmann --- lib/cmdlib.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index b36cab3..b7f997b 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -15662,6 +15662,11 @@ class LUNetworkAdd(LogicalUnit): mn = self.cfg.GetMasterNode() return ([mn], [mn]) + def CheckArguments(self): + if self.op.mac_prefix: + self.op.mac_prefix = \ + utils.NormalizeAndValidateThreeOctetMacPrefix(self.op.mac_prefix) + def ExpandNames(self): self.network_uuid = self.cfg.GenerateUniqueID(self.proc.GetECId()) @@ -15676,12 +15681,6 @@ class LUNetworkAdd(LogicalUnit): self.add_locks[locking.LEVEL_NETWORK] = self.network_uuid def CheckPrereq(self): - """Check prerequisites. - - This checks that the given group name is not an existing node group - already. - - """ if self.op.network is None: raise errors.OpPrereqError("Network must be given", errors.ECODE_INVAL) @@ -15692,9 +15691,6 @@ class LUNetworkAdd(LogicalUnit): raise errors.OpPrereqError("Network '%s' already defined" % self.op.network, errors.ECODE_EXISTS) - if self.op.mac_prefix: - utils.NormalizeAndValidateMac(self.op.mac_prefix + ":00:00:00") - # Check tag validity for tag in self.op.tags: objects.TaggableObject.ValidateTag(tag) @@ -15896,8 +15892,8 @@ class LUNetworkSetParams(LogicalUnit): if self.op.mac_prefix == constants.VALUE_NONE: self.mac_prefix = None else: - utils.NormalizeAndValidateMac(self.op.mac_prefix + ":00:00:00") - self.mac_prefix = self.op.mac_prefix + self.mac_prefix = \ + utils.NormalizeAndValidateThreeOctetMacPrefix(self.op.mac_prefix) if self.op.gateway6: if self.op.gateway6 == constants.VALUE_NONE: -- 1.7.10.4