Skip to content

Commit

Permalink
Merge pull request #9 from wznoinsk/RHOSINFRA-2945
Browse files Browse the repository at this point in the history
offline the slave after it's been set up
  • Loading branch information
mpryc authored Jan 30, 2020
2 parents ac0068b + 97dc702 commit 12f7124
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion devnest/lib/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,27 @@ def create_update_node_from_xml(self, xml_path, directory=False):
baseurl = '%s/computer/%s' % (self.jenkins.baseurl, slave_name)

config_str = ElementTree.tostring(slave_xml.getroot())
offlineMessage = 'devnest_making_slave_offline_after_setup'

LOG.info('Node config: %s using file: %s' % (slave_name, s_xml_path))

try:
self.jenkins.requester.post_and_confirm_status("%s/config.xml"
% baseurl,
data=config_str)

except JenkinsAPIException:
LOG.debug('Node %s not found, adding new' % slave_name)
self.jenkins.create_node(slave_name, labels='provisioning_node')
self.jenkins.create_node(slave_name, labels='devnest_creating_a_new_slave')
self.jenkins.requester.post_and_confirm_status("%s/config.xml"
% baseurl,
data=config_str)

finally:
LOG.info("Take the slave offline after it's been set up")
self.jenkins.requester.post_and_confirm_status("%s/toggleOffline"
% baseurl, data={'offlineMessage': offlineMessage})

LOG.info('Node %s updated' % slave_name)

def get_jenkins_username(self):
Expand Down

0 comments on commit 12f7124

Please sign in to comment.