postgres.grantRead('trac', 'amptrac') with settings(user=self.serviceUser): run('/bin/ln -nsf {}/start {}/start'.format(self.configDir, self.binDir)) self.update() cron.install(self.serviceUser, '{}/crontab'.format(self.configDir)) def update(self): """ Update config. """ with settings(user=self.serviceUser): run('mkdir -p ' + self.configDir) put( os.path.dirname(__file__) + '/*', self.configDir, mirror_local_mode=True) self.venv.install_twisted() self.venv.install('git+https://github.com/twisted-infra/amptrac.git') self.venv.install('git+https://github.com/twisted-infra/amptrac-server') def task_update(self): """ Update config and restart. """ self.update() self.task_restart() addTasks(globals(), AmpTrac('amptrac').getTasks())
""" self.setUser() name = "twtest" # A tap device without protocol information sudo('ip tuntap add dev tap-{} mode tap user buildslave'.format(name)) sudo('ip link set up dev tap-{}'.format(name)) sudo('ip addr add 172.16.0.1/24 dev tap-{}'.format(name)) sudo('ip neigh add 172.16.0.2 lladdr de:ad:be:ef:ca:fe dev tap-{}'.format(name)) sudo('iptables -I INPUT --dest 172.16.0.1 -j ACCEPT') # A tap device with protocol information sudo('ip tuntap add dev tap-{}-pi mode tap user buildslave'.format(name)) sudo('ip link set up dev tap-{}-pi'.format(name)) sudo('ip addr add 172.16.1.1/24 dev tap-{}-pi'.format(name)) sudo('ip neigh add 172.16.1.2 lladdr de:ad:ca:fe:be:ef dev tap-{}-pi'.format(name)) sudo('iptables -I INPUT --dest 172.16.1.1 -j ACCEPT') # A tun device without protocol information sudo('ip tuntap add dev tun-{} mode tun user buildslave'.format(name)) sudo('ip link set up dev tun-{}'.format(name)) # A tun device with protocol information sudo('ip tuntap add dev tun-{}-pi mode tun user buildslave'.format(name)) sudo('ip link set up dev tun-{}-pi'.format(name)) from braid.tasks import addTasks addTasks(globals(), Buildslave('buildslave').getTasks())
""" Dump non-versioned resources. """ with settings(user=self.serviceUser): archive.dump({ 'data': 'data', }, dump) def task_restore(self, dump): """ Resotre non-versioned resources. """ msg = 'All non-versioned web resources will be replaced with the backup.' if confirm(msg): with settings(user=self.serviceUser): archive.restore({ 'data': 'data', }, dump) def task_startMaintenanceSite(self): """ Start maintenance site. """ with settings(user=self.serviceUser): run('{}/start-maintenance'.format(self.binDir)) addTasks(globals(), TwistedWeb('t-web').getTasks())
""" debconf.setDebconfValue('mailman', 'mailman/site_languages', 'multiselect', 'en') debconf.setDebconfValue('mailman', 'mailman/create_site_list', 'note', '') package.install(['mailman']) put(sibpath(__file__, 'mm_cfg.py'), '/etc/mailman/mm_cfg.py', use_sudo=True) sudo('/usr/sbin/usermod -a -G service --home /var/lib/mailman {}'.format(self.serviceUser)) def task_start(self): """ Start mailman. """ service.start('mailman') def task_stop(self): """ Stop mailman. """ service.stop('mailman') def task_restart(self): """ Restart mailman. """ service.restart('mailman') tasks.addTasks(globals(), Service().getTasks())
with settings(user=self.serviceUser): self.update() # Move the old attachments directory out of the way, but keep it # around. run("/bin/mv ~/attachments ~/attachments.old") # Update the symlink within the git repository that was previously # pointing at ~/attachments to point at ~/attachments.old. Dump # and restore work on ~/attachments. run("/bin/ln -nsf ~/attachments.old {}/trac-env/attachments".format(self.configDir)) # Create a new directory at the old attachment location, and point # trac 1.0.1's new attachment storage directory at it. run("/bin/mkdir ~/attachments") run("/bin/mkdir {}/trac-env/files".format(self.configDir)) # Trac 1.0 moved attachments from trac-env/attachments to # trac-env/files/attachments. run("/bin/ln -nsf ~/attachments {}/trac-env/files/attachments".format( self.configDir)) # The file format for attachments also changed to be hashed and # sharded, so trac-env upgrade is going to look in # ~/trac-env/attachments (attachments.old). run(".local/bin/trac-admin {}/trac-env upgrade".format(self.configDir)) # Wiki pages have attachments too, so upgrade any metadata # associated with those. run(".local/bin/trac-admin {}/trac-env wiki upgrade".format(self.configDir)) addTasks(globals(), Trac('trac').getTasks())
def task_dump(self, localfile): """ Create a tarball containing all information not currently stored in version control and download it to the given C{localfile}. """ with settings(user=self.serviceUser): archive.dump({ 'data': 'data', }, localfile, exclude=[ 'http.log*', ]) def task_restore(self, localfile): """ Restore all information not stored in version control from a tarball on the invoking users machine. """ msg = 'The whole data directory will be replaced with the backup.' if confirm(msg): with settings(user=self.serviceUser): archive.restore({ 'data': 'data', }, localfile) addTasks(globals(), Buildbot('bb-master').getTasks(role='buildbot'))
def task_dump(self, localfile): """ Create a tarball containing all information not currently stored in version control and download it to the given C{localfile}. """ with settings(user=self.serviceUser): archive.dump({ 'data': 'data', }, localfile, exclude=[ 'http.log*', ]) def task_restore(self, localfile): """ Restore all information not stored in version control from a tarball on the invoking users machine. """ msg = 'The whole data directory will be replaced with the backup.' if confirm(msg): with settings(user=self.serviceUser): archive.restore({ 'data': 'data', }, localfile) addTasks(globals(), Buildbot('bb-master').getTasks())
self.update() self.task_restart() def task_dump(self, localfile): """ Dump codespeed database and download it to the given C{localfile}. """ with settings(user=self.serviceUser): with utils.tempfile() as temp: run('/usr/bin/sqlite3 ~/data/codespeed.db .dump >{}'.format(temp)) archive.dump({ 'db.dump': temp, }, localfile) def task_restore(self, localfile): """ Restore codespeed database from the given C{localfile}. """ msg = 'The whole database will be replaced with the backup.' if utils.confirm(msg): with settings(user=self.serviceUser): with utils.tempfile() as temp: archive.restore({ 'db.dump': temp, }, localfile) run('/bin/rm -f ~/data/codespeed.db') run('/usr/bin/sqlite3 ~/data/codespeed.db ".read {}"'.format(temp)) addTasks(globals(), Codespeed('codespeed').getTasks())
package.install(['diffstat']) with settings(user=self.serviceUser): run('/bin/ln -nsf {}/start {}/start'.format(self.configDir, self.binDir)) self.update() cron.install(self.serviceUser, '{}/crontab'.format(self.configDir)) run('PYTHONPATH=~/divmod/Combinator COMBINATOR_PROJECTS=~/Projects ~/divmod/Combinator/bin/chbranch Twisted trunk svn://svn.twistedmatrix.com/svn/Twisted/trunk') def update(self): """ Update config. """ with settings(user=self.serviceUser): git.branch('https://github.com/twisted-infra/diffresource', self.configDir) bazaar.branch('lp:divmod.org', '~/divmod') # We aren't using combinator for its path munging, so stop it from doing that. run('/bin/rm -f ~/divmod/Combinator/sitecustomize.py*') def task_update(self): """ Update config and restart. """ self.update() self.task_restart() addTasks(globals(), DiffResource('diffresource').getTasks())
archive.restore(files, localfile) if restoreDb: postgres.restoreFromPath('trac', temp) def task_installTestData(self): """ Create an empty trac database for testing. """ if env.get('environment') == 'production': abort("Don't use installTestData in production.") if postgres.tableExists('trac', 'system'): abort("Existing Trac tables found.") with settings(user=self.serviceUser): # Run trac initenv to create the postgresql database tables, but use # a throwaway trac-env directory because that comes from # https://github.com/twisted-infra/trac-config/tree/master/trac-env try: run('~/virtualenv/bin/trac-admin ' '/tmp/trac-init initenv TempTrac postgres://@/trac git ""') finally: run("rm -rf /tmp/trac-init") # Run an upgrade to add plugin specific database tables and columns. run('~/virtualenv/bin/trac-admin config/trac-env upgrade --no-backup' ) addTasks(globals(), Trac('trac').getTasks())
""" Collection of utilities to automate the administration of Twisted's infrastructure. Use this utility to install, update and start/stop/restart services running on twistedmatrix.com. """ from braid import base, users, postgres, config, pypy __all__ = ['base', 'config', 'users', 'postgres', 'pypy'] from braid.utils import loadServices from braid.tasks import addTasks addTasks(globals(), loadServices(__file__))
debconf.setDebconfValue('mailman', 'mailman/create_site_list', 'note', '') package.update() package.install(['mailman']) put(sibpath(__file__, 'mm_cfg.py'), '/etc/mailman/mm_cfg.py', use_sudo=True) sudo('/usr/sbin/usermod -a -G service --home /var/lib/mailman {}'. format(self.serviceUser)) def task_start(self): """ Start mailman. """ service.start('mailman') def task_stop(self): """ Stop mailman. """ service.stop('mailman') def task_restart(self): """ Restart mailman. """ service.restart('mailman') tasks.addTasks(globals(), Service().getTasks())
""" self.bootstrap() with settings(user=self.serviceUser): self.venv.install('buildbot-slave') put( os.path.join(self.serviceLocalDir, 'start'), self.binDir, mirror_local_mode=True) execute(self.update) def update(self, _installDeps=False): """ Update configuration. """ with settings(user=self.serviceUser): put( os.path.join(self.serviceLocalDir, 'buildbot.tac'), self.configDir) put(os.path.join(self.serviceLocalDir, 'info'), self.configDir) def task_update(self): """ Update config and restart. """ self.update() self.task_restart() addTasks(globals(), Buildslave('bb-slave').getTasks())