From 3b790e635dfd0136fd8798c0581c9db35e2dbb88 Mon Sep 17 00:00:00 2001 From: Waldemar Znoinski Date: Thu, 30 Jan 2020 11:30:09 +0000 Subject: [PATCH 1/2] offline the slave after it's been set up RHOSINFRA-2945 --- devnest/lib/jenkins.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/devnest/lib/jenkins.py b/devnest/lib/jenkins.py index 6b8f554..03addd9 100644 --- a/devnest/lib/jenkins.py +++ b/devnest/lib/jenkins.py @@ -177,6 +177,7 @@ 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)) @@ -184,13 +185,22 @@ def create_update_node_from_xml(self, xml_path, directory=False): self.jenkins.requester.post_and_confirm_status("%s/config.xml" % baseurl, data=config_str) + + LOG.info("Take the slave offline after it's been set up") + self.jenkins.requester.post_and_confirm_status("%s/doDisconnect" + % baseurl, data={'offlineMessage': offlineMessage}) + 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) + LOG.info("Take the slave offline after it's been set up") + self.jenkins.requester.post_and_confirm_status("%s/doDisconnect" + % baseurl, data={'offlineMessage': offlineMessage}) + LOG.info('Node %s updated' % slave_name) def get_jenkins_username(self): From 97dc702642eba0ea3d9a43ea4d2a4cb7b23be4a7 Mon Sep 17 00:00:00 2001 From: Waldemar Znoinski Date: Thu, 30 Jan 2020 11:30:09 +0000 Subject: [PATCH 2/2] offline the slave after it's been set up RHOSINFRA-2945 --- devnest/lib/jenkins.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/devnest/lib/jenkins.py b/devnest/lib/jenkins.py index 03addd9..898c5e4 100644 --- a/devnest/lib/jenkins.py +++ b/devnest/lib/jenkins.py @@ -186,10 +186,6 @@ def create_update_node_from_xml(self, xml_path, directory=False): % baseurl, data=config_str) - LOG.info("Take the slave offline after it's been set up") - self.jenkins.requester.post_and_confirm_status("%s/doDisconnect" - % baseurl, data={'offlineMessage': offlineMessage}) - except JenkinsAPIException: LOG.debug('Node %s not found, adding new' % slave_name) self.jenkins.create_node(slave_name, labels='devnest_creating_a_new_slave') @@ -197,8 +193,9 @@ def create_update_node_from_xml(self, xml_path, directory=False): % 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/doDisconnect" + self.jenkins.requester.post_and_confirm_status("%s/toggleOffline" % baseurl, data={'offlineMessage': offlineMessage}) LOG.info('Node %s updated' % slave_name)