Revision 0debfb35
b/daemons/ganeti-masterd | ||
---|---|---|
365 | 365 |
assert self.__class__._instance is None, "Attempt to modify Ganeti Context" |
366 | 366 |
object.__setattr__(self, name, value) |
367 | 367 |
|
368 |
def AddNode(self, node): |
|
368 |
def AddNode(self, node, ec_id):
|
|
369 | 369 |
"""Adds a node to the configuration and lock manager. |
370 | 370 |
|
371 | 371 |
""" |
372 | 372 |
# Add it to the configuration |
373 |
self.cfg.AddNode(node) |
|
373 |
self.cfg.AddNode(node, ec_id)
|
|
374 | 374 |
|
375 | 375 |
# If preseeding fails it'll not be added |
376 | 376 |
self.jobqueue.AddNode(node) |
b/lib/cmdlib.py | ||
---|---|---|
3037 | 3037 |
" candidate status: %s" % msg) |
3038 | 3038 |
else: |
3039 | 3039 |
_RedistributeAncillaryFiles(self, additional_nodes=[node]) |
3040 |
self.context.AddNode(new_node) |
|
3040 |
self.context.AddNode(new_node, self.proc.GetECId())
|
|
3041 | 3041 |
|
3042 | 3042 |
|
3043 | 3043 |
class LUSetNodeParams(LogicalUnit): |
... | ... | |
6097 | 6097 |
|
6098 | 6098 |
feedback_fn("adding instance %s to cluster config" % instance) |
6099 | 6099 |
|
6100 |
self.cfg.AddInstance(iobj) |
|
6100 |
self.cfg.AddInstance(iobj, self.proc.GetECId()) |
|
6101 |
|
|
6101 | 6102 |
# Declare that we don't want to remove the instance lock anymore, as we've |
6102 | 6103 |
# added the instance to the config |
6103 | 6104 |
del self.remove_locks[locking.LEVEL_INSTANCE] |
b/lib/config.py | ||
---|---|---|
724 | 724 |
return self._config_data.cluster.rsahostkeypub |
725 | 725 |
|
726 | 726 |
@locking.ssynchronized(_config_lock) |
727 |
def AddInstance(self, instance): |
|
727 |
def AddInstance(self, instance, ec_id):
|
|
728 | 728 |
"""Add an instance to the config. |
729 | 729 |
|
730 | 730 |
This should be used after creating a new instance. |
... | ... | |
747 | 747 |
" MAC address '%s' already in use." % |
748 | 748 |
(instance.name, nic.mac)) |
749 | 749 |
|
750 |
self._EnsureUUID(instance) |
|
750 |
self._EnsureUUID(instance, ec_id)
|
|
751 | 751 |
|
752 | 752 |
instance.serial_no = 1 |
753 | 753 |
instance.ctime = instance.mtime = time.time() |
... | ... | |
758 | 758 |
self._temporary_macs.discard(nic.mac) |
759 | 759 |
self._WriteConfig() |
760 | 760 |
|
761 |
def _EnsureUUID(self, item): |
|
761 |
def _EnsureUUID(self, item, ec_id):
|
|
762 | 762 |
"""Ensures a given object has a valid UUID. |
763 | 763 |
|
764 | 764 |
@param item: the instance or node to be checked |
765 |
@param ec_id: the execution context id for the uuid reservation |
|
765 | 766 |
|
766 | 767 |
""" |
767 | 768 |
if not item.uuid: |
... | ... | |
907 | 908 |
return my_dict |
908 | 909 |
|
909 | 910 |
@locking.ssynchronized(_config_lock) |
910 |
def AddNode(self, node): |
|
911 |
def AddNode(self, node, ec_id):
|
|
911 | 912 |
"""Add a node to the configuration. |
912 | 913 |
|
913 | 914 |
@type node: L{objects.Node} |
... | ... | |
916 | 917 |
""" |
917 | 918 |
logging.info("Adding node %s to configuration", node.name) |
918 | 919 |
|
919 |
self._EnsureUUID(node) |
|
920 |
self._EnsureUUID(node, ec_id)
|
|
920 | 921 |
|
921 | 922 |
node.serial_no = 1 |
922 | 923 |
node.ctime = node.mtime = time.time() |
b/test/ganeti.config_unittest.py | ||
---|---|---|
148 | 148 |
self.failUnlessRaises(errors.ConfigurationError, cfg.Update, fake_instance, |
149 | 149 |
None) |
150 | 150 |
|
151 |
cfg.AddInstance(inst) |
|
151 |
cfg.AddInstance(inst, "my-job")
|
|
152 | 152 |
instance = cfg.GetInstanceInfo(cfg.GetInstanceList()[0]) |
153 | 153 |
# first pass, must not fail |
154 | 154 |
cfg.Update(instance, None) |
Also available in: Unified diff