+ __slots__ = ["mac", "ip", "bridge", "nicparams"]
+
+ @classmethod
+ def CheckParameterSyntax(cls, nicparams):
+ """Check the given parameters for validity.
+
+ @type nicparams: dict
+ @param nicparams: dictionary with parameter names/value
+ @raise errors.ConfigurationError: when a parameter is not valid
+
+ """
+ if nicparams[constants.NIC_MODE] not in constants.NIC_VALID_MODES:
+ err = "Invalid nic mode: %s" % nicparams[constants.NIC_MODE]
+ raise errors.ConfigurationError(err)
+
+ if (nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED and
+ not nicparams[constants.NIC_LINK]):
+ err = "Missing bridged nic link"
+ raise errors.ConfigurationError(err)
+
+ def UpgradeConfig(self):
+ """Fill defaults for missing configuration values.
+
+ """
+ if self.nicparams is None:
+ self.nicparams = {}
+ if self.bridge is not None:
+ self.nicparams[constants.NIC_MODE] = constants.NIC_MODE_BRIDGED
+ self.nicparams[constants.NIC_LINK] = self.bridge
+ # bridge is no longer used it 2.1. The slot is left there to support
+ # upgrading, but will be removed in 2.2
+ if self.bridge is not None:
+ self.bridge = None