Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
clusterexec: Update for secret models
Browse files Browse the repository at this point in the history
  • Loading branch information
ashcrow authored and mbarnes committed May 25, 2017
1 parent 2ca7fdd commit d84b652
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/commissaire_service/clusterexec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from commissaire import constants as C
from commissaire.models import (
ClusterDeploy, ClusterUpgrade, ClusterRestart)
ClusterDeploy, ClusterUpgrade, ClusterRestart, HostCreds)
from commissaire.storage.client import StorageClient
from commissaire.util.date import formatted_dt
from commissaire.util.ssh import TemporarySSHKey
Expand Down Expand Up @@ -124,8 +124,9 @@ def _execute(self, message, model_instance, command_args,
self.logger.warn('No hosts in cluster "{}"'.format(cluster_name))

for address in cluster.hostset:
# Get initial data
host = self.storage.get_host(address)

host_creds = self.storage.get(HostCreds.new(address=host.address))
oscmd = get_oscmd(host.os)

# os_command is only used for logging
Expand All @@ -136,9 +137,9 @@ def _execute(self, message, model_instance, command_args,
model_instance.in_process.append(host.address)
self.storage.save(model_instance)

with TemporarySSHKey(host, self.logger) as key:
with TemporarySSHKey(host_creds, self.logger) as key:
try:
transport = ansibleapi.Transport(host.remote_user)
transport = ansibleapi.Transport(host_creds.remote_user)
method = getattr(transport, command_name)
method(host.address, key.path, oscmd, command_args)
except Exception as error:
Expand Down

0 comments on commit d84b652

Please sign in to comment.