From 13f1af63f2604afe38d136686dace709de60ec01 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Tue, 9 Jun 2009 13:25:34 +0100 Subject: [PATCH] Add nicparams to the NIC object Also populate nicparams with a sensible default for imported instances. Unfortunately we don't know if the bridge set up in old nics is the default one or not, and we don't have access to the config cluster object here to verify, so we'll just copy it without questions. Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/objects.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/objects.py b/lib/objects.py index 64b4418b3..51ef992cf 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -310,7 +310,7 @@ class ConfigData(ConfigObject): class NIC(ConfigObject): """Config object representing a network card.""" - __slots__ = ["mac", "ip", "bridge"] + __slots__ = ["mac", "ip", "bridge", "nicparams"] @classmethod def CheckParameterSyntax(cls, nicparams): @@ -330,6 +330,16 @@ class NIC(ConfigObject): 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 + class Disk(ConfigObject): """Config object representing a block device.""" -- GitLab