diff --git a/lib/config.py b/lib/config.py index ee9747c3caaf4f3e1199c2455a04c2ab5ac6d547..1e8741809f6c3a3a97897250322f7150a9b37292 100644 --- a/lib/config.py +++ b/lib/config.py @@ -164,8 +164,21 @@ class ConfigWriter: self._my_hostname = netutils.Hostname.GetSysName() self._last_cluster_serial = -1 self._cfg_id = None + self._context = None self._OpenConfig(accept_foreign) + def _GetRpc(self, address_list): + """Returns RPC runner for configuration. + + """ + return rpc.ConfigRunner(self._context, address_list) + + def SetContext(self, context): + """Sets Ganeti context. + + """ + self._context = context + # this method needs to be static, so that we can call it on the class @staticmethod def IsCluster(): @@ -1749,7 +1762,7 @@ class ConfigWriter: # TODO: Use dedicated resolver talking to config writer for name resolution result = \ - rpc.ConfigRunner(addr_list).call_upload_file(node_list, self._cfg_file) + self._GetRpc(addr_list).call_upload_file(node_list, self._cfg_file) for to_node, to_result in result.items(): msg = to_result.fail_msg if msg: @@ -1808,7 +1821,7 @@ class ConfigWriter: # Write ssconf files on all nodes (including locally) if self._last_cluster_serial < self._config_data.cluster.serial_no: if not self._offline: - result = rpc.ConfigRunner(None).call_write_ssconf_files( + result = self._GetRpc(None).call_write_ssconf_files( self._UnlockedGetOnlineNodeList(), self._UnlockedGetSsconfValues()) diff --git a/lib/rpc.py b/lib/rpc.py index ca48478013a77f3ef16eed9661aa2c04fc88a536..9626501c058ac25db0be69eb1e8fade2a3f6b054 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -723,15 +723,21 @@ class ConfigRunner(_RpcClientBase, _generated_rpc.RpcClientConfig): """RPC wrappers for L{config}. """ - def __init__(self, address_list): + def __init__(self, context, address_list): """Initializes this class. """ + if context: + lock_monitor_cb = context.glm.AddToLockMonitor + else: + lock_monitor_cb = None + if address_list is None: resolver = _SsconfResolver else: # Caller provided an address list resolver = _StaticResolver(address_list) - _RpcClientBase.__init__(self, resolver, _ENCODERS.get) + _RpcClientBase.__init__(self, resolver, _ENCODERS.get, + lock_monitor_cb=lock_monitor_cb) _generated_rpc.RpcClientConfig.__init__(self) diff --git a/lib/server/masterd.py b/lib/server/masterd.py index 59563322da01be97d8b41101031ef70ce8bd20b7..a91c9d46279ada18ab661489d70686b10ecf9f00 100644 --- a/lib/server/masterd.py +++ b/lib/server/masterd.py @@ -401,6 +401,8 @@ class GanetiContext(object): self.cfg.GetNodeGroupList(), self.cfg.GetInstanceList()) + self.cfg.SetContext(self) + # Job queue self.jobqueue = jqueue.JobQueue(self)