diff --git a/daemons/ganeti-masterd b/daemons/ganeti-masterd index 46e857e51d480ac90e5cd5b0e9b9222dcf61bae1..9b0851fe1b43223606e5ae1d80d0404bd781058a 100755 --- a/daemons/ganeti-masterd +++ b/daemons/ganeti-masterd @@ -365,12 +365,12 @@ class GanetiContext(object): assert self.__class__._instance is None, "Attempt to modify Ganeti Context" object.__setattr__(self, name, value) - def AddNode(self, node): + def AddNode(self, node, ec_id): """Adds a node to the configuration and lock manager. """ # Add it to the configuration - self.cfg.AddNode(node) + self.cfg.AddNode(node, ec_id) # If preseeding fails it'll not be added self.jobqueue.AddNode(node) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index c1a52ffeb06f0f1cbbd16703317dc219d007059f..abf9e70aaab31a31d252461bacc9a83b44c700bc 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -3037,7 +3037,7 @@ class LUAddNode(LogicalUnit): " candidate status: %s" % msg) else: _RedistributeAncillaryFiles(self, additional_nodes=[node]) - self.context.AddNode(new_node) + self.context.AddNode(new_node, self.proc.GetECId()) class LUSetNodeParams(LogicalUnit): @@ -6097,7 +6097,8 @@ class LUCreateInstance(LogicalUnit): feedback_fn("adding instance %s to cluster config" % instance) - self.cfg.AddInstance(iobj) + self.cfg.AddInstance(iobj, self.proc.GetECId()) + # Declare that we don't want to remove the instance lock anymore, as we've # added the instance to the config del self.remove_locks[locking.LEVEL_INSTANCE] diff --git a/lib/config.py b/lib/config.py index 665c15cb1a2632593d8a1830e858fb3a3fb12414..338c3216e3dded1c6816f1336bc08cc130436604 100644 --- a/lib/config.py +++ b/lib/config.py @@ -724,7 +724,7 @@ class ConfigWriter: return self._config_data.cluster.rsahostkeypub @locking.ssynchronized(_config_lock) - def AddInstance(self, instance): + def AddInstance(self, instance, ec_id): """Add an instance to the config. This should be used after creating a new instance. @@ -747,7 +747,7 @@ class ConfigWriter: " MAC address '%s' already in use." % (instance.name, nic.mac)) - self._EnsureUUID(instance) + self._EnsureUUID(instance, ec_id) instance.serial_no = 1 instance.ctime = instance.mtime = time.time() @@ -758,10 +758,11 @@ class ConfigWriter: self._temporary_macs.discard(nic.mac) self._WriteConfig() - def _EnsureUUID(self, item): + def _EnsureUUID(self, item, ec_id): """Ensures a given object has a valid UUID. @param item: the instance or node to be checked + @param ec_id: the execution context id for the uuid reservation """ if not item.uuid: @@ -907,7 +908,7 @@ class ConfigWriter: return my_dict @locking.ssynchronized(_config_lock) - def AddNode(self, node): + def AddNode(self, node, ec_id): """Add a node to the configuration. @type node: L{objects.Node} @@ -916,7 +917,7 @@ class ConfigWriter: """ logging.info("Adding node %s to configuration", node.name) - self._EnsureUUID(node) + self._EnsureUUID(node, ec_id) node.serial_no = 1 node.ctime = node.mtime = time.time() diff --git a/test/ganeti.config_unittest.py b/test/ganeti.config_unittest.py index 77d7f395c2d33afe3218d1f1712df05216ae5ba0..25fa7eda040b22bfbd2404645f2241af723cecb4 100755 --- a/test/ganeti.config_unittest.py +++ b/test/ganeti.config_unittest.py @@ -148,7 +148,7 @@ class TestConfigRunner(unittest.TestCase): self.failUnlessRaises(errors.ConfigurationError, cfg.Update, fake_instance, None) - cfg.AddInstance(inst) + cfg.AddInstance(inst, "my-job") instance = cfg.GetInstanceInfo(cfg.GetInstanceList()[0]) # first pass, must not fail cfg.Update(instance, None)