From 1738f3ac186741f0afd33b8a376bfe898c0e7280 Mon Sep 17 00:00:00 2001 From: Matt Clark Date: Wed, 20 Jul 2016 22:14:33 -0700 Subject: [PATCH 1/2] Set node name to be hostname --- calyptos/chefmanager.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/calyptos/chefmanager.py b/calyptos/chefmanager.py index 4b98c5f..ff3048f 100644 --- a/calyptos/chefmanager.py +++ b/calyptos/chefmanager.py @@ -186,10 +186,12 @@ def clear_node_info(self): with hide('running'): return run('knife node bulk delete -z -E {0} -y ".*"'.format(self.environment_name)) - def run_chef_client(self, chef_command="chef-client -z"): + def run_chef_client(self, chef_command="chef-client -z", hide_opts=None): with cd(self.remote_folder_path + 'chef-repo'): - with hide('running'): - return run(chef_command + " -E " + self.environment_name + " -l info") + hide_opts = hide_opts or [] + with hide(*hide_opts): + return run("{0} -E {1} -N $(hostname) -l info".format(chef_command, + self.environment_name)) def push_deployment_data(self): with hide(*self.hidden_outputs): From 53f96c355b3efde7c609df71652fffc8c6cc9570 Mon Sep 17 00:00:00 2001 From: Matt Clark Date: Wed, 20 Jul 2016 22:21:52 -0700 Subject: [PATCH 2/2] Use hostname to pull node info --- calyptos/chefmanager.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/calyptos/chefmanager.py b/calyptos/chefmanager.py index ff3048f..00571fe 100644 --- a/calyptos/chefmanager.py +++ b/calyptos/chefmanager.py @@ -201,8 +201,14 @@ def push_deployment_data(self): ssh_opts=self.ssh_opts, delete=True) def pull_node_info(self): - local_path = 'chef-repo/nodes/' + run('hostname') + '.json' + hostname = run('hostname') + local_path = 'chef-repo/nodes/' + str(hostname) + '.json' remote_path = self.remote_folder_path + local_path - if self.local_hostname != run('hostname'): - get(remote_path=remote_path, local_path=local_path) - self.read_node_hash(local_path) + try: + if self.local_hostname != hostname: + get(remote_path=remote_path, local_path=local_path) + self.read_node_hash(local_path) + except Exception as E: + print red('Failed to download node info. Localpath:{0}, remotepath:{1}' + .format(local_path, remote_path)) + raise E