diff options
author | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2009-01-18 18:50:27 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2009-01-18 18:56:03 +0530 |
commit | de1bccc9959a3724ab0e07ad66cc0a488c0ad2ab (patch) | |
tree | cda2390bccd353c2e78be261432671577616c33c | |
parent | Add autotua.crypt to setup.py (diff) | |
download | autotua-de1bccc9959a3724ab0e07ad66cc0a488c0ad2ab.tar.gz autotua-de1bccc9959a3724ab0e07ad66cc0a488c0ad2ab.tar.bz2 autotua-de1bccc9959a3724ab0e07ad66cc0a488c0ad2ab.zip |
Reorganise setup-master.py
- Add support for sample slave on the same test machine
* With slave gpg home (with .gitignore for it)
- Add user and slave groups as well
* Need to have proper Permission() stuff (added to TODO)
- Reduce default sub key length to 1024
- Enable symlinking by default
- Probably should have separate interactive setup (added to TODO)
-rw-r--r-- | master/TODO | 3 | ||||
-rw-r--r-- | master/custom/sample_data.py | 32 | ||||
-rw-r--r-- | master/master/.gitignore | 1 | ||||
-rwxr-xr-x | master/setup-master.py | 44 |
4 files changed, 63 insertions, 17 deletions
diff --git a/master/TODO b/master/TODO index 2b930dc..6e187fb 100644 --- a/master/TODO +++ b/master/TODO @@ -1,9 +1,12 @@ TODO: + * Proper Permission() stuff + - See django.contrib.auth.models * Implement input via the webinterface (manual via command line atm) * Better jobuild dependency resolution for atom list (basic right now) * Job status tracking and management (skeleton right now) setup-master.py: + * Separate auto-setup and interactive setup * Should prompt for database super-user Low-priority TODO: diff --git a/master/custom/sample_data.py b/master/custom/sample_data.py index 0e91871..cb13f18 100644 --- a/master/custom/sample_data.py +++ b/master/custom/sample_data.py @@ -6,9 +6,38 @@ # Immortal lh! # +sample_maintainer = { + 'username': 'test_user', + 'email': 'test_user_email@test.com', + 'password': 'password', + 'group': 'dev', +} + +sample_master_gpg_data = { + 'name': 'AutotuA Master (Sample)', + 'email': 'autotua_master@localhost', + 'expire': '1m', + 'length': '1024', # small length because it's a sample anyway +} + +sample_slave = { + 'name': 'Sample AutotuA slave', + 'gpg_fp': '', + 'owner': sample_maintainer, + 'users': (sample_maintainer['group'],), +} + +sample_slave_gpg_data = { + 'name': sample_slave['name'], + 'email': 'autotua_slave@localhost', + 'expire': '1m', + 'length': '1024', # small length because it's a sample anyway +} + sample_job = { 'name': 'Sample AutotuA job', - 'maintainer': ('test_user', 'test_user_email@test.com', 'password'), + 'maintainer': sample_maintainer, + 'slave': sample_slave['name'], 'provider': 'gentoo', # If stage is unspecified, defaults to stage3 #'stage': 'stage3', @@ -17,4 +46,3 @@ sample_job = { 'jobtagerev': '', 'atoms': 'bheekling/test-brasero', } - diff --git a/master/master/.gitignore b/master/master/.gitignore index c6bc574..a632697 100644 --- a/master/master/.gitignore +++ b/master/master/.gitignore @@ -1 +1,2 @@ gnupg/ +sample_slave_gpghome/ diff --git a/master/setup-master.py b/master/setup-master.py index f10454f..1ea51c7 100755 --- a/master/setup-master.py +++ b/master/setup-master.py @@ -21,7 +21,7 @@ if os.environ.has_key('PYTHONPATH'): sys.path.insert(0, os.environ['PYTHONPATH']) DESTDIR = 'autotua_master' -SYMLINKS = False +SYMLINKS = True def print_help(): print \ @@ -113,33 +113,44 @@ def syncdb_master(): serverobj.prefix = server[1] serverobj.save() -def setup_gpg(): +def setup_gpg(data, gpghome): from autotua import crypt from master import const - if not os.path.isdir(const.GPGHOME): - os.mkdir(const.GPGHOME, 0700) - data = {'name': 'AutotuA Master', - 'email': 'autotua@localhost', - 'expire': '1m'} + if not os.path.isdir(gpghome): + os.mkdir(gpghome, 0700) print 'Creating a "sample" gpg key (expires in 1 month)' - crypt.Crypto(gpghome=const.GPGHOME).init_gpghome(**data) + crypt.Crypto(gpghome).init_gpghome(**data) + +def setup_sample_slave(): + from sample_data import sample_slave + from master import const + slave = Slave() + slave.name = sample_slave['name'] + try: + slave.owner = User.objects.get(username=sample_slave['owner']['username']) + except User.DoesNotExist: + slave.owner = User.objects.create_user(*[sample_slave['owner'][key] + for key in ('username', 'email', 'password')]) + slave.owner.groups.add(Group.objects.get(name=sample_slave['owner']['group'])) + slave.save() + slave.users = [Group.objects.get(name=group) for group in sample_slave['users']] + slave.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.maintainer = User.objects.get(username=sample_job['maintainer']['username']) job.release = Release.objects.get(name=sample_job['release'], provider=Provider.objects.get(name=sample_job['provider'])) job.arch = job.release.archs.get(specific=sample_job['arch']) # If stage is not set, defaults to stage3 job.save() + job.slaves.add(Slave.objects.get(name=sample_job['slave'])) + job.save() +### Start Work ### if len(sys.argv) < 3: print_help() sys.exit(1) @@ -172,12 +183,15 @@ elif sys.argv[1] == 'syncdb': from django.core.management import setup_environ setup_environ(settings) from master.models import User, Group, Provider, Arch, Release, Mirror, Job, Slave + from master import const + from sample_data import sample_master_gpg_data, sample_slave_gpg_data # Start stuff syncdb_master() + setup_gpg(sample_master_gpg_data, const.GPGHOME) + setup_sample_slave() # Should be done before job; inits User if DNE + setup_gpg(sample_slave_gpg_data, const.MASTER_DIR+'/sample_slave_gpghome') setup_sample_job() - setup_gpg() print "All done! Now you can start the master with `python manage.py runserver`" else: print_help() sys.exit(1) - |