| Line | |
|---|
| 1 | #!/usr/bin/python |
|---|
| 2 | #--------------------------------------------------------------- |
|---|
| 3 | # Project : pxemngr |
|---|
| 4 | # File : syncbootnames |
|---|
| 5 | # Copyright : 2009 Splitted-Desktop Systems |
|---|
| 6 | # Author : Frederic Lepied |
|---|
| 7 | # Created On : Sun Feb 1 19:17:33 2009 |
|---|
| 8 | # Purpose : read the pxe directory containing the profiles |
|---|
| 9 | # and add them to the database as available. |
|---|
| 10 | #--------------------------------------------------------------- |
|---|
| 11 | |
|---|
| 12 | import os |
|---|
| 13 | import settings |
|---|
| 14 | from pxe.models import * |
|---|
| 15 | from pxe.common import * |
|---|
| 16 | |
|---|
| 17 | l = len(settings.PXE_SUFFIX) |
|---|
| 18 | list = [] |
|---|
| 19 | for f in os.listdir(settings.PXE_ROOT + '/' + settings.PXE_PROFILES): |
|---|
| 20 | if f[-l:] == settings.PXE_SUFFIX: |
|---|
| 21 | list.append(f[:-l]) |
|---|
| 22 | |
|---|
| 23 | if 'local' not in list: |
|---|
| 24 | print 'error local profile not present. Add it with a content like this:' |
|---|
| 25 | print |
|---|
| 26 | print '''prompt 0 |
|---|
| 27 | timeout 0 |
|---|
| 28 | default 0 |
|---|
| 29 | |
|---|
| 30 | label 0 |
|---|
| 31 | LOCALBOOT 0 |
|---|
| 32 | ''' |
|---|
| 33 | |
|---|
| 34 | for b in BootName.objects.all(): |
|---|
| 35 | if b.available: |
|---|
| 36 | b.available = False |
|---|
| 37 | b.save() |
|---|
| 38 | |
|---|
| 39 | for n in list: |
|---|
| 40 | try: |
|---|
| 41 | boot_name = BootName.objects.get(name=n) |
|---|
| 42 | boot_name.available = True |
|---|
| 43 | except BootName.DoesNotExist: |
|---|
| 44 | boot_name = BootName(name=n, available=True) |
|---|
| 45 | print 'registering', boot_name.name |
|---|
| 46 | boot_name.save() |
|---|
| 47 | |
|---|
| 48 | # syncbootnames ends here |
|---|