aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-09-02 22:28:34 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-09-02 22:28:34 +0530
commit3c5a0f5de49a5971b2824b454d86f9dd0f6c542c (patch)
tree50c94e804c10f517de9a6f3cf283e0e2caa0104e
parentsetup-master.py now does db initialization (diff)
downloadautotua-3c5a0f5de49a5971b2824b454d86f9dd0f6c542c.tar.gz
autotua-3c5a0f5de49a5971b2824b454d86f9dd0f6c542c.tar.bz2
autotua-3c5a0f5de49a5971b2824b454d86f9dd0f6c542c.zip
Setup a sample job while syncing db
- master/custom/sample_data.py -- data for job intialisation - master/setup-master.py -- Implement sample job initialisation after syncdb - Fix a few bugs in models.py regarding self._get_deplist - Move master/autotua/process/const.py to master/autotua/const.py after removing stuff that's in the DB now
-rw-r--r--master/autotua/const.py11
-rw-r--r--master/autotua/models.py6
-rw-r--r--master/autotua/process/__init__.py3
-rw-r--r--master/autotua/process/const.py36
-rw-r--r--master/custom/db_defaults.py2
-rw-r--r--master/custom/sample_data.py19
-rwxr-xr-xmaster/setup-master.py31
7 files changed, 63 insertions, 45 deletions
diff --git a/master/autotua/const.py b/master/autotua/const.py
new file mode 100644
index 0000000..e96d94c
--- /dev/null
+++ b/master/autotua/const.py
@@ -0,0 +1,11 @@
+# vim: set sw=4 sts=4 et :
+# Copyright: 2008 Gentoo Foundation
+# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+# License: GPL-2
+#
+# Immortal lh!
+#
+
+# FIXME: insecure tmpdir.
+TMPDIR = '/tmp/master'
+JOBTAGE = 'git://git.overlays.gentoo.org/proj/jobtage.git'
diff --git a/master/autotua/models.py b/master/autotua/models.py
index a2d93cc..ea39dd7 100644
--- a/master/autotua/models.py
+++ b/master/autotua/models.py
@@ -10,6 +10,7 @@ from django.db import models
from django.forms import ModelForm, ModelChoiceField
from django.contrib.auth.models import User
from autotua import jobuild, sync
+import const, random
####################
### Models begin ###
@@ -113,18 +114,17 @@ class Job(models.Model):
atoms = models.TextField()
class Meta:
- unique_together = [("name", "maintainer")]
+ unique_together = ['name', 'maintainer']
def __unicode__(self):
return '%s/%s' % (self.maintainer, self.name)
def save(self):
atoms = self._get_deplist(self.atoms.split(), self.jobtagerev)
- print atoms
self.atoms = '\n'.join(atoms)
super(Job, self).save()
- def _get_deplist(atoms, rev):
+ def _get_deplist(self, atoms, rev):
"""
Use autotua-slave to get the deplist
from the root jobuild atom
diff --git a/master/autotua/process/__init__.py b/master/autotua/process/__init__.py
index e118d54..88e9bb3 100644
--- a/master/autotua/process/__init__.py
+++ b/master/autotua/process/__init__.py
@@ -10,8 +10,9 @@ import random
from ..models import Mirror
def generate_stage_url(job):
- mirror = random.choice(Mirror.objects.list(owner=job.provider))
+ mirror = random.choice(Mirror.objects.filter(owner=job.provider))
url = mirror.server+mirror.prefix+mirror.structure
+ data = {}
data['owner'] = mirror.owner.name
data['stage'] = job.stage.name
data['arch'] = job.arch.specific
diff --git a/master/autotua/process/const.py b/master/autotua/process/const.py
deleted file mode 100644
index 9df0f5b..0000000
--- a/master/autotua/process/const.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# vim: set sw=4 sts=4 et :
-# Copyright: 2008 Gentoo Foundation
-# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
-# License: GPL-2
-#
-# Immortal lh!
-#
-
-# FIXME: insecure tmpdir.
-TMPDIR = '/tmp/master'
-JOBTAGE = '/home/nirbheek/projects/jobtage.git'
-
-# No 'arm' in here because the dir structure is weird
-# and it hasn't been updated in forever anyway.
-# Use a custom stage url if you want to use arm
-#
-# 'Mirror dir': (<archs that reside there>)
-ARCHS = { 'x86': ('i686', 'x86',),
- 'amd64': ('amd64',),
- 'ppc': ('970-32ul', '970-64ul', 'g4', 'power5', 'ppc', 'ppc64',),
- 'sparc': ('sparc64',),
- 'alpha': ('alpha',),
- 'ia64': ('ia64',),
- 'hppa': ('hppa1.1', 'hppa2.0',),
- 'mips': ('cobalt', 'mips3', 'mips4', 'n32',),
- 'sh': ('sh4',),
- 's390': ('s390', 's390x',) }
-
-# How do we get this list? Keep updating it regularly?
-# Do we associate mirrors with the slave's geo location?
-MIRRORS = { 'gentoo': ('http://gentoo.osuosl.org',) }
-# Example:
-# http://gentoo.osuosl.org/releases/hppa/2008.0/stages/stage3-hppa2.0-2008.0.tar.bz2
-STAGES = ('stage1', 'stage2', 'stage3', 'stage4',)
-STAGE_URI = '%(mirror)s/releases/%(gen_arch)s/%(release)s/stages/%(stage)s-%(arch)s-%(release)s.tar.bz2'
-#stage_types = ('', 'hardened', 'hardened+nomultilib')
diff --git a/master/custom/db_defaults.py b/master/custom/db_defaults.py
index f49826d..a58696d 100644
--- a/master/custom/db_defaults.py
+++ b/master/custom/db_defaults.py
@@ -39,7 +39,7 @@ releases = {'gentoo': ('2007.0', '2008.0'),
mirrors = { 'gentoo': {'servers': (('http://gentoo.osuosl.org/', 'releases/'),
('http://ftp.jaist.ac.jp/', 'pub/Linux/Gentoo/releases/'),),
- 'structure': '%(mirror)s/releases/%(gen_arch)s/%(release)s/stages/%(stage)s-%(arch)s-%(release)s.tar.bz2',},
+ 'structure': '%(gen_arch)s/%(release)s/stages/%(stage)s-%(arch)s-%(release)s.tar.bz2',},
'funtoo': {'servers': ('http://www.funtoo.org/', 'linux/'),
'structure': '%(arch)s/%(owner)s-%(arch)s-%(release)/%(stage)s-%(arch)s-%(release)s.tar.bz2'} }
diff --git a/master/custom/sample_data.py b/master/custom/sample_data.py
new file mode 100644
index 0000000..1f53981
--- /dev/null
+++ b/master/custom/sample_data.py
@@ -0,0 +1,19 @@
+# vim: set sw=4 sts=4 et :
+# Copyright: 2008 Gentoo Foundation
+# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+# License: GPL-2
+#
+# Immortal lh!
+#
+
+sample_job = {
+ 'name': 'Sample AutotuA job',
+ 'maintainer': ('test_user', 'test_user_email@test.com', None),
+ 'provider': 'gentoo',
+ 'stage': 'stage3',
+ 'arch': 'i686',
+ 'release': '2008.0',
+ 'jobtagerev': '',
+ 'atoms': 'bheekling/test-brasero',
+}
+
diff --git a/master/setup-master.py b/master/setup-master.py
index 896f680..3b2f3b1 100755
--- a/master/setup-master.py
+++ b/master/setup-master.py
@@ -66,11 +66,7 @@ def install_master():
def syncdb_master():
"""Initialize the database"""
- import settings
- from django.core.management import setup_environ
- setup_environ(settings)
from db_defaults import providers, archs, stages, releases, mirrors
- from master.models import StageProvider, Arch, Stage, Release, Mirror
import copy
management.call_command('syncdb')
@@ -111,6 +107,26 @@ def syncdb_master():
serverobj.prefix = server[1]
serverobj.save()
+def setup_sample_job():
+ from sample_data import sample_job
+ job = Job()
+ for i in ['name', 'jobtagerev', 'atoms']:
+ setattr(job, i, sample_job[i])
+ maintainers = User.objects.filter(username=sample_job['maintainer'][0])
+ if maintainers:
+ job.maintainer = maintainers[0]
+ else:
+ job.maintainer = User.objects.create_user(*sample_job['maintainer'])
+ job.provider = StageProvider.objects.get(name=sample_job['provider'])
+ job.stage = Stage.objects.get(name=sample_job['stage'],
+ provider=job.provider)
+ job.arch = Arch.objects.get(specific=sample_job['arch'],
+ provider=job.provider)
+ job.release = Release.objects.get(name=sample_job['release'],
+ provider=job.provider)
+ print job.atoms
+ job.save()
+
if len(sys.argv) < 3:
print_help()
sys.exit(1)
@@ -134,7 +150,14 @@ if sys.argv[1] == 'install':
Now you need to edit the database settings in %(dest)s/settings.py
and run `./setup-master.py syncdb %(dest)s`""" % { 'dest': os.path.join(sys.argv[2], DESTDIR) }
elif sys.argv[1] == 'syncdb':
+ # Import stuff
+ import settings
+ from django.core.management import setup_environ
+ setup_environ(settings)
+ from master.models import User, StageProvider, Arch, Stage, Release, Mirror, Job
+ # Start stuff
syncdb_master()
+ setup_sample_job()
print "All done! Now you can start the master with `python manage.py runserver`"
else:
print_help()