[Fuego] [PATCH] ftc: merge node creation and removal

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Fri Mar 24 07:47:53 UTC 2017


Node creation and removal were in separate scripts on
Toshiba's fork. Merge that functionality using the
python-jenkins library.

Although Jessie has a python-jenkins package, it was a bit
to old so I installed a newer version with pip.

Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
---
 Dockerfile                               |  3 +-
 README                                   |  2 +-
 fuego-ro/scripts/nodes/fuego-create-node | 56 --------------------------------
 fuego-ro/scripts/nodes/fuego-delete-node | 36 --------------------
 4 files changed, 3 insertions(+), 94 deletions(-)
 delete mode 100755 fuego-ro/scripts/nodes/fuego-create-node
 delete mode 100755 fuego-ro/scripts/nodes/fuego-delete-node

diff --git a/Dockerfile b/Dockerfile
index a807cae..f0827ca 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -28,7 +28,8 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -yV install \
 	libtool xmlstarlet autoconf automake rsync openjdk-7-jre openjdk-7-jdk iperf \
 	netperf netpipe-tcp sshpass wget git diffstat sudo net-tools vim curl \
 	inotify-tools g++ bzip2 bc libaio-dev gettext pkg-config libglib2.0-dev \
-	time
+	time python-pip
+RUN pip install python-jenkins==0.4.14
 RUN /bin/bash -c 'echo "dash dash/sh boolean false" | debconf-set-selections ; DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash'
 RUN if [ -n "$HTTP_PROXY" ]; then echo "use_proxy = on" >> /etc/wgetrc; fi
 
diff --git a/README b/README
index da89e7c..329da20 100644
--- a/README
+++ b/README
@@ -79,7 +79,7 @@ Initial test
 You can use the docker container as a fuego target in order to confirm that
 the installation was successful.
 
-# fuego-create-node --board docker
+# sudo -u jenkins ftc add-nodes docker
 # fuego-create-jobs --board docker --testplan testplan_docker --distrib nosyslogd.dist
 
 Build the job "docker.testplan_docker.batch", it will trigger the rest of
diff --git a/fuego-ro/scripts/nodes/fuego-create-node b/fuego-ro/scripts/nodes/fuego-create-node
deleted file mode 100755
index 6ca26c6..0000000
--- a/fuego-ro/scripts/nodes/fuego-create-node
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/python
-#
-# fuego-create-node - a tool to create a jenkins node
-#
-# Copyright 2016 TOSHIBA Corporation
-#
-#   This program is free software; you can redistribute it and/or modify
-#   it under the terms of version 2 of the GNU General Public License as
-#   published by the Free Software Foundation.  The GNU General Public
-#   License is available online at: http://www.gnu.org/copyleft/gpl.html
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-# Author: Daniel Sangorrin <daniel.sangorrin (at) toshiba.co.jp>
-#
-import subprocess
-import sys
-import argparse
-
-def create_node(board):
-    tmp = "/tmp/fuego_tmp_node"
-    fd = open(tmp, "w+")
-    fd.write("""<?xml version='1.0' encoding='UTF-8'?>
-<slave>
-    <name>{board}</name>
-    <description></description>
-    <remoteFS>/tmp/dev-slave1</remoteFS>
-    <numExecutors>1</numExecutors>
-    <mode>NORMAL</mode>
-    <retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
-    <launcher class="hudson.slaves.CommandLauncher">
-    <agentCommand>java -jar /fuego-core/engine/slave.jar</agentCommand>
-    </launcher>
-    <label></label>
-    <nodeProperties/>
-</slave>
-""".format(board=board))
-    fd.close()
-
-    print("Creating node " + board)
-    try:
-        subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/fuego create-node ' + board + ' < ' + tmp, shell=True)
-        subprocess.call('rm -f ' + tmp, shell=True)
-    except Exception as e:
-        print("Node already exists")
-        print(e)
-        sys.exit(1)
-
-if __name__=="__main__":
-    parser = argparse.ArgumentParser(description='Create a jenkins node')
-    parser.add_argument('-b', '--board', type=str, help='board name (e.g.: bbb for bbb.board)', required=True)
-    args = parser.parse_args()
-    create_node(args.board)
diff --git a/fuego-ro/scripts/nodes/fuego-delete-node b/fuego-ro/scripts/nodes/fuego-delete-node
deleted file mode 100755
index a4bd7a0..0000000
--- a/fuego-ro/scripts/nodes/fuego-delete-node
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/python
-#
-# fuego-delete-node - a tool to delete a jenkins node
-#
-# Copyright 2016 TOSHIBA Corporation
-#
-#   This program is free software; you can redistribute it and/or modify
-#   it under the terms of version 2 of the GNU General Public License as
-#   published by the Free Software Foundation.  The GNU General Public
-#   License is available online at: http://www.gnu.org/copyleft/gpl.html
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#   GNU General Public License for more details.
-#
-# Author: Daniel Sangorrin <daniel.sangorrin (at) toshiba.co.jp>
-#
-import subprocess
-import sys
-import argparse
-
-def delete_node(board):
-    print("Deleting node " + board)
-    try:
-        subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/fuego delete-node ' + board, shell=True)
-    except Exception as e:
-        print("Node didn't exist")
-        print(e)
-        sys.exit(1)
-
-if __name__=="__main__":
-    parser = argparse.ArgumentParser(description='Delete a jenkins node')
-    parser.add_argument('-b', '--board', type=str, help='board name (e.g.: bbb for bbb.board)', required=True)
-    args = parser.parse_args()
-    delete_node(args.board)
-- 
2.7.4




More information about the Fuego mailing list