Revision 41ea331e lib/config.py
b/lib/config.py | ||
---|---|---|
195 | 195 |
self._all_rms = [self._temporary_ids, self._temporary_macs, |
196 | 196 |
self._temporary_secrets, self._temporary_lvs, |
197 | 197 |
self._temporary_ips] |
198 |
# Note: in order to prevent errors when resolving our name in
|
|
199 |
# _DistributeConfig, we compute it here once and reuse it; it's
|
|
198 |
# Note: in order to prevent errors when resolving our name later,
|
|
199 |
# we compute it here once and reuse it; it's |
|
200 | 200 |
# better to raise an error before starting to modify the config |
201 | 201 |
# file than after it was modified |
202 | 202 |
self._my_hostname = netutils.Hostname.GetSysName() |
... | ... | |
2457 | 2457 |
(utils.CommaJoin(config_errors))) |
2458 | 2458 |
logging.critical(errmsg) |
2459 | 2459 |
|
2460 |
def _DistributeConfig(self, feedback_fn): |
|
2461 |
"""Distribute the configuration to the other nodes. |
|
2462 |
|
|
2463 |
Currently, this only copies the configuration file. In the future, |
|
2464 |
it could be used to encapsulate the 2/3-phase update mechanism. |
|
2465 |
|
|
2466 |
""" |
|
2467 |
if self._offline: |
|
2468 |
return True |
|
2469 |
|
|
2470 |
bad = False |
|
2471 |
|
|
2472 |
node_list = [] |
|
2473 |
addr_list = [] |
|
2474 |
myhostname = self._my_hostname |
|
2475 |
# we can skip checking whether _UnlockedGetNodeInfo returns None |
|
2476 |
# since the node list comes from _UnlocketGetNodeList, and we are |
|
2477 |
# called with the lock held, so no modifications should take place |
|
2478 |
# in between |
|
2479 |
for node_uuid in self._UnlockedGetNodeList(): |
|
2480 |
node_info = self._UnlockedGetNodeInfo(node_uuid) |
|
2481 |
if node_info.name == myhostname or not node_info.master_candidate: |
|
2482 |
continue |
|
2483 |
node_list.append(node_info.name) |
|
2484 |
addr_list.append(node_info.primary_ip) |
|
2485 |
|
|
2486 |
# TODO: Use dedicated resolver talking to config writer for name resolution |
|
2487 |
result = \ |
|
2488 |
self._GetRpc(addr_list).call_upload_file(node_list, self._cfg_file) |
|
2489 |
for to_node, to_result in result.items(): |
|
2490 |
msg = to_result.fail_msg |
|
2491 |
if msg: |
|
2492 |
msg = ("Copy of file %s to node %s failed: %s" % |
|
2493 |
(self._cfg_file, to_node, msg)) |
|
2494 |
logging.error(msg) |
|
2495 |
|
|
2496 |
if feedback_fn: |
|
2497 |
feedback_fn(msg) |
|
2498 |
|
|
2499 |
bad = True |
|
2500 |
|
|
2501 |
return not bad |
|
2502 |
|
|
2503 | 2460 |
def _WriteConfig(self, destination=None, feedback_fn=None): |
2504 | 2461 |
"""Write the configuration data to persistent storage. |
2505 | 2462 |
|
... | ... | |
2552 | 2509 |
|
2553 | 2510 |
self.write_count += 1 |
2554 | 2511 |
|
2555 |
# and redistribute the config file to master candidates |
|
2556 |
self._DistributeConfig(feedback_fn) |
|
2557 |
|
|
2558 | 2512 |
# Write ssconf files on all nodes (including locally) |
2559 | 2513 |
if self._last_cluster_serial < self._config_data.cluster.serial_no: |
2560 | 2514 |
if not self._offline: |
Also available in: Unified diff