Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Set node name to be hostname #114

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions calyptos/chefmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -199,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