Skip to content

Commit

Permalink
Merge pull request #21 from tardyp/hypersupport
Browse files Browse the repository at this point in the history
Hyper support for buildbot travis
  • Loading branch information
tardyp committed Sep 1, 2016
2 parents 57c0588 + c036a04 commit 9f4fdb6
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 51 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -17,7 +17,6 @@ wheelhouse
dist
slave/
buildbot.tac
cfg.yml
run.sh
*.log
*.pid
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Expand Up @@ -3,10 +3,12 @@ COPY example /usr/src/buildbot_travis/example

RUN \
apk add --no-cache py-cffi py-requests docker-py@testing && \
pip install 'txrequests' 'pyjade' 'txgithub' 'ldap3' 'docker-py>=1.4' && \
pip install 'txrequests' 'pyjade' 'txgithub' 'ldap3' 'docker-py>=1.4' 'hyper-compose' && \
pip install /usr/src/buildbot_travis/example/*.whl && \
rm -r /root/.cache

EXPOSE 8010
EXPOSE 9989
WORKDIR /var/lib/buildbot
VOLUME /var/lib/buildbot
CMD ["/usr/src/buildbot_travis/example/start_buildbot.sh"]
15 changes: 15 additions & 0 deletions README.rst
Expand Up @@ -267,3 +267,18 @@ Deploying
=========

"example" directory is available for easy to use example.


Deploying in hyper
===================

::

IP=<yourFIPaddress>
container=`hyper run -d -e buildbotURL=http://$IP/ -p 0.0.0.0:9989:9989 -p 0.0.0.0:80:8010 tardyp/buildbot_travis:hyper`
hyper fip attach $IP $container
echo go to http://$IP/#/bbtravis/config/workers


And configure your hyper keys in the default hyper worker
You should also configure an authentication plugin in order to protect those keys.
34 changes: 19 additions & 15 deletions buildbot_travis/configurator.py
@@ -1,29 +1,26 @@
import urlparse
import os
import uuid
import traceback
import urlparse
import uuid

from buildbot.config import error as config_error
from twisted.internet import defer
from yaml import safe_load

import buildbot_travis
from buildbot import getVersion
from buildbot.config import error as config_error
# TBD use plugins!
from buildbot.config import BuilderConfig
from buildbot.interfaces import ILatentWorker
from buildbot.plugins import util, worker
from buildbot.process import factory
from buildbot.schedulers.forcesched import StringParameter
from buildbot.schedulers.triggerable import Triggerable
from buildbot.worker import Worker
from buildbot.process import factory
from buildbot.plugins import util
from buildbot.plugins import worker
from buildbot import getVersion
from buildbot.www.authz.endpointmatchers import EndpointMatcherBase, Match
from twisted.internet import defer

from .important import ImportantManager
from .steps import TravisSetupSteps, TravisTrigger
from .vcs import addRepository, getSupportedVCSTypes
from .steps import TravisSetupSteps
from .steps import TravisTrigger
from yaml import safe_load
from buildbot.interfaces import ILatentWorker

import buildbot_travis


class TravisEndpointMatcher(EndpointMatcherBase):
Expand Down Expand Up @@ -228,6 +225,13 @@ def createWorkerConfigDockerWorker(self, config, name):
docker_host=config['docker_host'], image=config['image'],
followStartupLogs=True)

def createWorkerConfigHyperWorker(self, config, name):
return worker.HyperLatentWorker(
name, str(uuid.uuid4()),
hyper_host=config['hyper_host'], image=config['image'],
hyper_accesskey=config['hyper_accesskey'], hyper_secretkey=config['hyper_secretkey'],
masterFQDN=config.get('masterFQDN'), hyper_size=config.get('size'))

def createWorkerConfig(self):
self.config.setdefault('workers', [])
if 'workers' not in self.cfgdict:
Expand Down
46 changes: 36 additions & 10 deletions buildbot_travis/ui/src/app/configEditors/workers_config.tpl.jade
Expand Up @@ -17,33 +17,59 @@ config-page
.pull-right.btn.btn-danger(ng-click="worker_remove(worker)")
| delete worker
.form-group
label.col-sm-2.control-label number of workers:
label.col-sm-2.control-label Number of workers:
.col-sm-10
input.form-control(type="number", ng-model="worker.number")

.form-group(ng-if="worker.type=='Worker'")
label.col-sm-2.control-label password for the workers:
label.col-sm-2.control-label Password for the workers:
.col-sm-10
input.form-control(type="text", ng-model="worker.password", ng-init="change_me")

.form-group(ng-if="worker.type=='DockerWorker'")
label.col-sm-2.control-label image name:
.col-sm-10
input.form-control(type="text", ng-model="worker.image", placeholder = "buildbot/worker-%{prop:language}")
.alert.alert-info(ng-if="worker.type=='DockerWorker'")
b Note:&nbsp;
| image name is interpolated with buildrequest properties
div(ng-if="worker.type=='HyperWorker'")
.form-group
label.col-sm-2.control-label Hyper Host Url:
.col-sm-10
input.form-control(type="text", ng-model="worker.hyper_host", placeholder = "tcp://us-west-1.hyper.sh:443")
.form-group
label.col-sm-2.control-label MasterFQDN:
.col-sm-10
input.form-control(type="text", ng-model="worker.masterFQDN", placeholder = "IP or dns of the master, leave empty for autodetection")
.form-group
label.col-sm-2.control-label Accesskey:
.col-sm-10
input.form-control(type="text", ng-model="worker.hyper_accesskey")
.form-group
label.col-sm-2.control-label Secretkey:
.col-sm-10
input.form-control(type="text", ng-model="worker.hyper_secretkey")
.form-group
label.col-sm-2.control-label
a(href='https://www.hyper.sh/pricing.html') Worker Size
| &nbsp;:
.col-sm-2
select.form-control(ng-model="worker.size")
option(value="{{s}}" ng-repeat="s in 's1 s2 s3 s4 m1 m2 m3 l1 l2 l3'.split(' ')") {{s}}
div(ng-if="worker.type=='DockerWorker' || worker.type=='HyperWorker'")
.form-group
label.col-sm-2.control-label image name:
.col-sm-10
input.form-control(type="text", ng-model="worker.image", placeholder = "buildbot/worker-%{prop:language}")
.alert.alert-info
b Note:&nbsp;
| image name is interpolated with buildrequest properties

.form-group(ng-if="worker.type=='DockerWorker'")
label.col-sm-2.control-label Docker Host Url:
.col-sm-10
input.form-control(type="text", ng-model="worker.docker_host", placeholder = "tcp://dockerhost:2375")

.row
.col-sm-12
.input-group.filelist
select.form-control(ng-model="new_worker.type")
option(value="LocalWorker") LocalWorker (a worker running on the master host)
option(value="Worker") Worker (a worker running on another host)
option(value="DockerWorker") DockerWorker (a worker spawn on demand on a docker host)
option(value="HyperWorker") HyperWorker (a worker spawn on demand on a hyper caas)
.input-group-btn
.btn.btn-default(ng-click="worker_add()") +
41 changes: 20 additions & 21 deletions example/cfg.yml
@@ -1,22 +1,21 @@
not_important_files:
- CHANGES
- CHANGES.rst
- CHANGES.txt
- HISTORY.txt
- HISTORY
- version.txt
- .badger.yml

env:
CI: 'true'

env: {}
not_important_files: []
projects:
- name: buildbot_travis
repository: git://github.com/tardyp/buildbot_travis
vcs_type: git+poller

stages:
- Commit
- Acceptance
- Staging
- Production
- branches:
- master
name: buildbot
repository: https://github.com/tardyp/buildbot
stages: []
tags: []
vcs_type: github
stages: []
workers:
- hyper_accesskey: fillme
hyper_host: tcp://us-west-1.hyper.sh:443
hyper_secretkey: fillme
id: 3386175858
image: buildbot/buildbot-worker:master
name: hyperworker
number: 5
size: xxs
type: HyperWorker
2 changes: 1 addition & 1 deletion example/master.cfg
@@ -1,3 +1,3 @@
from buildbot_travis import TravisConfigurator
c = BuildmasterConfig = {}
TravisConfigurator(BuildmasterConfig, basedir).fromDb() # or .fromYaml('cfg.yml')
TravisConfigurator(BuildmasterConfig, basedir).fromYaml('cfg.yml')
5 changes: 3 additions & 2 deletions example/start_buildbot.sh
Expand Up @@ -2,9 +2,10 @@
B=`pwd`
if [ ! -f $B/buildbot.tac ]
then
buildbot create-master --db="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres/$POSTGRES_DB" $B
mv /usr/src/buildbot_travis/example/master.cfg $B/master.cfg
buildbot create-master $B
cp /usr/src/buildbot_travis/example/master.cfg $B/master.cfg
cp /usr/src/buildbot_travis/example/buildbot.tac $B
cp /usr/src/buildbot_travis/example/cfg.yml $B

echo
echo buildbot is now setup on the docker host in /var/lib/buildbot
Expand Down

0 comments on commit 9f4fdb6

Please sign in to comment.