Revision d693c864
b/lib/bootstrap.py | ||
---|---|---|
28 | 28 |
import re |
29 | 29 |
import logging |
30 | 30 |
import tempfile |
31 |
import time |
|
31 | 32 |
|
32 | 33 |
from ganeti import rpc |
33 | 34 |
from ganeti import ssh |
... | ... | |
310 | 311 |
master_node_config.name: master_node_config, |
311 | 312 |
} |
312 | 313 |
|
314 |
now = time.time() |
|
313 | 315 |
config_data = objects.ConfigData(version=version, |
314 | 316 |
cluster=cluster_config, |
315 | 317 |
nodes=nodes, |
316 | 318 |
instances={}, |
317 |
serial_no=1) |
|
319 |
serial_no=1, |
|
320 |
ctime=now, mtime=now) |
|
318 | 321 |
utils.WriteFile(cfg_file, |
319 | 322 |
data=serializer.Dump(config_data.ToDict()), |
320 | 323 |
mode=0600) |
b/lib/config.py | ||
---|---|---|
35 | 35 |
import tempfile |
36 | 36 |
import random |
37 | 37 |
import logging |
38 |
import time |
|
38 | 39 |
|
39 | 40 |
from ganeti import errors |
40 | 41 |
from ganeti import locking |
... | ... | |
708 | 709 |
" MAC address '%s' already in use." % (instance.name, nic.mac)) |
709 | 710 |
|
710 | 711 |
instance.serial_no = 1 |
712 |
instance.ctime = instance.mtime = time.time() |
|
711 | 713 |
self._config_data.instances[instance.name] = instance |
712 | 714 |
self._config_data.cluster.serial_no += 1 |
713 | 715 |
self._UnlockedReleaseDRBDMinors(instance.name) |
... | ... | |
729 | 731 |
if instance.admin_up != status: |
730 | 732 |
instance.admin_up = status |
731 | 733 |
instance.serial_no += 1 |
734 |
instance.mtime = time.time() |
|
732 | 735 |
self._WriteConfig() |
733 | 736 |
|
734 | 737 |
@locking.ssynchronized(_config_lock) |
... | ... | |
860 | 863 |
logging.info("Adding node %s to configuration" % node.name) |
861 | 864 |
|
862 | 865 |
node.serial_no = 1 |
866 |
node.ctime = node.mtime = time.time() |
|
863 | 867 |
self._config_data.nodes[node.name] = node |
864 | 868 |
self._config_data.cluster.serial_no += 1 |
865 | 869 |
self._WriteConfig() |
... | ... | |
1031 | 1035 |
|
1032 | 1036 |
""" |
1033 | 1037 |
self._config_data.serial_no += 1 |
1038 |
self._config_data.mtime = time.time() |
|
1034 | 1039 |
|
1035 | 1040 |
def _OpenConfig(self): |
1036 | 1041 |
"""Read the config data from disk. |
... | ... | |
1249 | 1254 |
raise errors.ConfigurationError("Configuration updated since object" |
1250 | 1255 |
" has been read or unknown object") |
1251 | 1256 |
target.serial_no += 1 |
1257 |
target.mtime = now = time.time() |
|
1252 | 1258 |
|
1253 | 1259 |
if update_serial: |
1254 | 1260 |
# for node updates, we need to increase the cluster serial too |
1255 | 1261 |
self._config_data.cluster.serial_no += 1 |
1262 |
self._config_data.cluster.mtime = now |
|
1256 | 1263 |
|
1257 | 1264 |
if isinstance(target, objects.Instance): |
1258 | 1265 |
self._UnlockedReleaseDRBDMinors(target.name) |
b/lib/objects.py | ||
---|---|---|
39 | 39 |
__all__ = ["ConfigObject", "ConfigData", "NIC", "Disk", "Instance", |
40 | 40 |
"OS", "Node", "Cluster", "FillDict"] |
41 | 41 |
|
42 |
_TIMESTAMPS = ["ctime", "mtime"] |
|
42 | 43 |
|
43 | 44 |
def FillDict(defaults_dict, custom_dict): |
44 | 45 |
"""Basic function to apply settings on top a default dict. |
... | ... | |
284 | 285 |
|
285 | 286 |
class ConfigData(ConfigObject): |
286 | 287 |
"""Top-level config object.""" |
287 |
__slots__ = ["version", "cluster", "nodes", "instances", "serial_no"] |
|
288 |
__slots__ = ["version", "cluster", "nodes", "instances", "serial_no"] + \ |
|
289 |
_TIMESTAMPS |
|
288 | 290 |
|
289 | 291 |
def ToDict(self): |
290 | 292 |
"""Custom function for top-level config data. |
... | ... | |
612 | 614 |
"disk_template", |
613 | 615 |
"network_port", |
614 | 616 |
"serial_no", |
615 |
] |
|
617 |
] + _TIMESTAMPS
|
|
616 | 618 |
|
617 | 619 |
def _ComputeSecondaryNodes(self): |
618 | 620 |
"""Compute the list of secondary nodes. |
... | ... | |
769 | 771 |
"master_candidate", |
770 | 772 |
"offline", |
771 | 773 |
"drained", |
772 |
] |
|
774 |
] + _TIMESTAMPS
|
|
773 | 775 |
|
774 | 776 |
|
775 | 777 |
class Cluster(TaggableObject): |
... | ... | |
794 | 796 |
"nicparams", |
795 | 797 |
"candidate_pool_size", |
796 | 798 |
"modify_etc_hosts", |
797 |
] |
|
799 |
] + _TIMESTAMPS
|
|
798 | 800 |
|
799 | 801 |
def UpgradeConfig(self): |
800 | 802 |
"""Fill defaults for missing configuration values. |
Also available in: Unified diff