Revision 288f240f tools/cluster-merge
b/tools/cluster-merge | ||
---|---|---|
162 | 162 |
|
163 | 163 |
self.merger_data.append(MergerData(cluster, key_path, nodes, instances)) |
164 | 164 |
|
165 |
def _PrepareAuthorizedKeys(self): |
|
166 |
"""Prepare the authorized_keys on every merging node.
|
|
165 |
def _PrepareAuthorizedKeys(self, merge_data, node):
|
|
166 |
"""Prepare the authorized_keys on merging nodes.
|
|
167 | 167 |
|
168 | 168 |
This method add our public key to remotes authorized_key for further |
169 | 169 |
communication. |
... | ... | |
172 | 172 |
(_, pub_key_file, auth_keys) = ssh.GetUserFiles("root") |
173 | 173 |
pub_key = utils.ReadFile(pub_key_file) |
174 | 174 |
|
175 |
for data in self.merger_data: |
|
176 |
for node in data.nodes: |
|
177 |
result = self._RunCmd(node, ("cat >> %s << '!EOF.'\n%s!EOF.\n" % |
|
178 |
(auth_keys, pub_key)), |
|
179 |
private_key=data.key_path) |
|
175 |
result = self._RunCmd(node, ("cat >> %s << '!EOF.'\n%s!EOF.\n" % |
|
176 |
(auth_keys, pub_key)), |
|
177 |
private_key=merge_data.key_path) |
|
180 | 178 |
|
181 |
if result.failed:
|
|
182 |
raise errors.RemoteError("Unable to add our public key to %s in %s."
|
|
183 |
" Fail reason: %s; output: %s" %
|
|
184 |
(node, data.cluster, result.fail_reason,
|
|
185 |
result.output))
|
|
179 |
if result.failed: |
|
180 |
raise errors.RemoteError("Unable to add our public key to %s in %s." |
|
181 |
" Fail reason: %s; output: %s" % |
|
182 |
(node, data.cluster, result.fail_reason, |
|
183 |
result.output)) |
|
186 | 184 |
|
187 | 185 |
def _RunCmd(self, hostname, command, user="root", use_cluster_key=False, |
188 | 186 |
strict_host_check=False, private_key=None, batch=True, |
... | ... | |
284 | 282 |
|
285 | 283 |
for node in other_config.GetNodeList(): |
286 | 284 |
node_info = other_config.GetNodeInfo(node) |
287 |
my_config.AddNode(node_info, _CLUSTERMERGE_ECID + str(fake_ec_id)) |
|
285 |
if not node_info.offline: |
|
286 |
self._PrepareAuthorizedKeys(data, node_info.name) |
|
287 |
my_config.AddNode(node_info, _CLUSTERMERGE_ECID + str(fake_ec_id)) |
|
288 | 288 |
fake_ec_id += 1 |
289 | 289 |
|
290 | 290 |
for instance in other_config.GetInstanceList(): |
... | ... | |
450 | 450 |
logging.info("Pre cluster verification") |
451 | 451 |
self._VerifyCluster() |
452 | 452 |
|
453 |
logging.info("Prepare authorized_keys") |
|
454 |
rbsteps.append("Remove our key from authorized_keys on nodes:" |
|
455 |
" %(nodes)s") |
|
456 |
self._PrepareAuthorizedKeys() |
|
457 |
|
|
458 | 453 |
rbsteps.append("Start all instances again on the merging" |
459 | 454 |
" clusters: %(clusters)s") |
460 | 455 |
logging.info("Stopping merging instances (takes a while)") |
Also available in: Unified diff