prscript: add docker handling support

You can now create the docker image necessary to run a
suricata builbot in docker. To do that you need to have
docker and python-docker installed on the system.

Then you can go to the qa directory.

You need to run once the creattion procedure:
 sudo ./prscript.py  -C -d master  -l
This will create a container named 'suri-buildbot'.

You can start it with:
 sudo ./prscript.py  -s -d master  -l

And stop it with:
 sudo ./prscript.py  -S -d master  -l

To start a test, you can do:
 ./prscript.py -d my_branch -l
pull/1405/head
Eric Leblond 11 years ago committed by Victor Julien
parent dd6f9a6298
commit 1180fc1ac7

@ -22,6 +22,13 @@ except:
import time
import argparse
import sys
import os
GOT_DOCKER = True
try:
from docker import Client
except:
GOT_DOCKER = False
# variables
# - github user
# - buildbot user and password
@ -39,6 +46,10 @@ parser.add_argument('--norebase', action='store_const', const=True, help='do not
parser.add_argument('-r', '--repository', dest='repository', default='suricata', help='name of suricata repository on github')
parser.add_argument('-d', '--docker', action='store_const', const=True, help='use docker based testing', default=False)
parser.add_argument('-l', '--local', action='store_const', const=True, help='local testing before github push', default=False)
if GOT_DOCKER:
parser.add_argument('-C', '--create', action='store_const', const=True, help='create docker container', default=False)
parser.add_argument('-s', '--start', action='store_const', const=True, help='start docker container', default=False)
parser.add_argument('-S', '--stop', action='store_const', const=True, help='stop docker container', default=False)
parser.add_argument('branch', metavar='branch', help='github branch to build')
args = parser.parse_args()
username = args.username
@ -128,10 +139,9 @@ def FindBuild(branch, extension = "", builder_name = None):
def GetBuildStatus(builder, buildid, extension="", builder_name = None):
if builder_name == None:
# https://buildbot.suricata-ids.org/json/builders/build%20deb6/builds/11
request = urllib2.Request(JSON_BUILDERS_URI + username + extension + '/builds/' + str(buildid))
else:
request = urllib2.Request(JSON_BUILDERS_URI + builder_name + '/builds/' + str(buildid))
builder_name = username + extension
# https://buildbot.suricata-ids.org/json/builders/build%20deb6/builds/11
request = urllib2.Request(JSON_BUILDERS_URI + builder_name + '/builds/' + str(buildid))
page = urllib2.urlopen(request)
result = page.read()
if args.verbose:
@ -170,6 +180,43 @@ if not args.local and TestRepoSync(args.branch) == -1:
print "Branch " + args.branch + " is not in sync with inliniac's master branch. Rebase needed."
sys.exit(-1)
def CreateContainer():
if not os.geteuid() == 0:
print "Command must be run as root"
sys.exit(-1)
cli = Client()
# FIXME check if existing
print "Pulling docking image, that will take long"
cli.pull('regit/suri-buildbot')
cli.create_container(name='suri-buildbot', image='regit/suri-buildbot', ports=[8010, 22], volumes=['/data/oisf'])
sys.exit(0)
def StartContainer():
if not os.geteuid() == 0:
print "Command must be run as root"
sys.exit(-1)
cli = Client()
suri_src_dir = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
print "Using base src dir: " + suri_src_dir
cli.start('suri-buildbot', port_bindings={8010:8010, 22:None}, binds={suri_src_dir: { 'bind': '/data/oisf', 'ro': True}} )
sys.exit(0)
def StopContainer():
if not os.geteuid() == 0:
print "Command must be run as root"
sys.exit(-1)
cli = Client()
cli.stop('suri-buildbot')
sys.exit(0)
if GOT_DOCKER:
if args.create:
CreateContainer()
if args.start:
StartContainer()
if args.stop:
StopContainer()
# submit buildbot form to build current branch on the devel builder
if not args.check:
if not args.docker:

Loading…
Cancel
Save