diff options
| author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2013-10-11 13:46:23 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-10-18 11:13:49 +0100 |
| commit | 164ab730ccb504b823f43b48de282de702ccf71b (patch) | |
| tree | 3f8331f10df8fadab7b761f2a90416aa08507697 /bitbake/lib/toaster/orm | |
| parent | d0072fc1391eda890268a91d692075b876f85914 (diff) | |
| download | poky-164ab730ccb504b823f43b48de282de702ccf71b.tar.gz | |
bitbake: toaster: add toaster code to bitbake
This patch adds the Toaster component to Bitbake.
Toaster is a module designed to record the progress of a
Bitbake build, and data about the resultant artifacts.
It contains a web-based interface and a REST API allowing
post-facto inspection of the build process and artifacts.
Features present in this build:
* toaster start script
* relational data model
* Django boilerplate code
* the REST API
* the Simple UI web interface
This patch has all the development history squashed together.
Code portions contributed by Calin Dragomir <calindragomir@gmail.com>.
(Bitbake rev: d24334a5e83d09b3ab227af485971bb768bf5412)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm')
| -rw-r--r-- | bitbake/lib/toaster/orm/__init__.py | 0 | ||||
| -rw-r--r-- | bitbake/lib/toaster/orm/models.py | 258 |
2 files changed, 258 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/orm/__init__.py b/bitbake/lib/toaster/orm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/bitbake/lib/toaster/orm/__init__.py | |||
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py new file mode 100644 index 0000000000..cb6581c9e1 --- /dev/null +++ b/bitbake/lib/toaster/orm/models.py | |||
| @@ -0,0 +1,258 @@ | |||
| 1 | # | ||
| 2 | # BitBake Toaster Implementation | ||
| 3 | # | ||
| 4 | # Copyright (C) 2013 Intel Corporation | ||
| 5 | # | ||
| 6 | # This program is free software; you can redistribute it and/or modify | ||
| 7 | # it under the terms of the GNU General Public License version 2 as | ||
| 8 | # published by the Free Software Foundation. | ||
| 9 | # | ||
| 10 | # This program is distributed in the hope that it will be useful, | ||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | # GNU General Public License for more details. | ||
| 14 | # | ||
| 15 | # You should have received a copy of the GNU General Public License along | ||
| 16 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 18 | |||
| 19 | from django.db import models | ||
| 20 | from django.utils.encoding import python_2_unicode_compatible | ||
| 21 | |||
| 22 | |||
| 23 | class Build(models.Model): | ||
| 24 | SUCCEEDED = 0 | ||
| 25 | FAILED = 1 | ||
| 26 | IN_PROGRESS = 2 | ||
| 27 | |||
| 28 | BUILD_OUTCOME = ( | ||
| 29 | (SUCCEEDED, 'Succeeded'), | ||
| 30 | (FAILED, 'Failed'), | ||
| 31 | (IN_PROGRESS, 'In Progress'), | ||
| 32 | ) | ||
| 33 | |||
| 34 | search_allowed_fields = ['machine', | ||
| 35 | 'cooker_log_path'] | ||
| 36 | |||
| 37 | machine = models.CharField(max_length=100) | ||
| 38 | image_fstypes = models.CharField(max_length=100) | ||
| 39 | distro = models.CharField(max_length=100) | ||
| 40 | distro_version = models.CharField(max_length=100) | ||
| 41 | started_on = models.DateTimeField() | ||
| 42 | completed_on = models.DateTimeField() | ||
| 43 | outcome = models.IntegerField(choices=BUILD_OUTCOME, default=IN_PROGRESS) | ||
| 44 | errors_no = models.IntegerField(default=0) | ||
| 45 | warnings_no = models.IntegerField(default=0) | ||
| 46 | cooker_log_path = models.CharField(max_length=500) | ||
| 47 | build_name = models.CharField(max_length=100) | ||
| 48 | bitbake_version = models.CharField(max_length=50) | ||
| 49 | |||
| 50 | @python_2_unicode_compatible | ||
| 51 | class Target(models.Model): | ||
| 52 | search_allowed_fields = ['target', 'image_fstypes', 'file_name'] | ||
| 53 | build = models.ForeignKey(Build) | ||
| 54 | target = models.CharField(max_length=100) | ||
| 55 | is_image = models.BooleanField(default = False) | ||
| 56 | file_name = models.CharField(max_length=100) | ||
| 57 | file_size = models.IntegerField() | ||
| 58 | |||
| 59 | def __str__(self): | ||
| 60 | return self.target | ||
| 61 | |||
| 62 | |||
| 63 | class Task(models.Model): | ||
| 64 | |||
| 65 | SSTATE_NA = 0 | ||
| 66 | SSTATE_MISS = 1 | ||
| 67 | SSTATE_FAILED = 2 | ||
| 68 | SSTATE_RESTORED = 3 | ||
| 69 | |||
| 70 | SSTATE_RESULT = ( | ||
| 71 | (SSTATE_NA, 'Not Applicable'), # For rest of tasks, but they still need checking. | ||
| 72 | (SSTATE_MISS, 'Missing'), # it is a miss | ||
| 73 | (SSTATE_FAILED, 'Failed'), # there was a pkg, but the script failed | ||
| 74 | (SSTATE_RESTORED, 'Restored'), # succesfully restored | ||
| 75 | ) | ||
| 76 | |||
| 77 | CODING_PYTHON = 0 | ||
| 78 | CODING_SHELL = 1 | ||
| 79 | |||
| 80 | TASK_CODING = ( | ||
| 81 | (CODING_PYTHON, 'Python'), | ||
| 82 | (CODING_SHELL, 'Shell'), | ||
| 83 | ) | ||
| 84 | |||
| 85 | OUTCOME_SUCCESS = 0 | ||
| 86 | OUTCOME_COVERED = 1 | ||
| 87 | OUTCOME_SSTATE = 2 | ||
| 88 | OUTCOME_EXISTING = 3 | ||
| 89 | OUTCOME_FAILED = 4 | ||
| 90 | OUTCOME_NA = 5 | ||
| 91 | |||
| 92 | TASK_OUTCOME = ( | ||
| 93 | (OUTCOME_SUCCESS, 'Succeeded'), | ||
| 94 | (OUTCOME_COVERED, 'Covered'), | ||
| 95 | (OUTCOME_SSTATE, 'Sstate'), | ||
| 96 | (OUTCOME_EXISTING, 'Existing'), | ||
| 97 | (OUTCOME_FAILED, 'Failed'), | ||
| 98 | (OUTCOME_NA, 'Not Available'), | ||
| 99 | ) | ||
| 100 | |||
| 101 | build = models.ForeignKey(Build, related_name='task_build') | ||
| 102 | order = models.IntegerField(null=True) | ||
| 103 | task_executed = models.BooleanField(default=False) # True means Executed, False means Prebuilt | ||
| 104 | outcome = models.IntegerField(choices=TASK_OUTCOME, default=OUTCOME_NA) | ||
| 105 | sstate_checksum = models.CharField(max_length=100, blank=True) | ||
| 106 | path_to_sstate_obj = models.FilePathField(max_length=500, blank=True) | ||
| 107 | recipe = models.ForeignKey('Recipe', related_name='build_recipe') | ||
| 108 | task_name = models.CharField(max_length=100) | ||
| 109 | source_url = models.FilePathField(max_length=255, blank=True) | ||
| 110 | work_directory = models.FilePathField(max_length=255, blank=True) | ||
| 111 | script_type = models.IntegerField(choices=TASK_CODING, default=CODING_PYTHON) | ||
| 112 | line_number = models.IntegerField(default=0) | ||
| 113 | disk_io = models.IntegerField(null=True) | ||
| 114 | cpu_usage = models.DecimalField(max_digits=6, decimal_places=2, null=True) | ||
| 115 | elapsed_time = models.CharField(max_length=50, default=0) | ||
| 116 | sstate_result = models.IntegerField(choices=SSTATE_RESULT, default=SSTATE_NA) | ||
| 117 | message = models.CharField(max_length=240) | ||
| 118 | logfile = models.FilePathField(max_length=255, blank=True) | ||
| 119 | |||
| 120 | class Meta: | ||
| 121 | ordering = ('order', 'recipe' ,) | ||
| 122 | |||
| 123 | |||
| 124 | class Task_Dependency(models.Model): | ||
| 125 | task = models.ForeignKey(Task, related_name='task_dependencies_task') | ||
| 126 | depends_on = models.ForeignKey(Task, related_name='task_dependencies_depends') | ||
| 127 | |||
| 128 | |||
| 129 | class Build_Package(models.Model): | ||
| 130 | build = models.ForeignKey('Build') | ||
| 131 | recipe = models.ForeignKey('Recipe', null=True) | ||
| 132 | name = models.CharField(max_length=100) | ||
| 133 | version = models.CharField(max_length=100, blank=True) | ||
| 134 | revision = models.CharField(max_length=32, blank=True) | ||
| 135 | summary = models.CharField(max_length=200, blank=True) | ||
| 136 | description = models.CharField(max_length=200, blank=True) | ||
| 137 | size = models.IntegerField(default=0) | ||
| 138 | section = models.CharField(max_length=80, blank=True) | ||
| 139 | license = models.CharField(max_length=80, blank=True) | ||
| 140 | |||
| 141 | class Build_Package_Dependency(models.Model): | ||
| 142 | TYPE_RDEPENDS = 0 | ||
| 143 | TYPE_RPROVIDES = 1 | ||
| 144 | TYPE_RRECOMMENDS = 2 | ||
| 145 | TYPE_RSUGGESTS = 3 | ||
| 146 | TYPE_RREPLACES = 4 | ||
| 147 | TYPE_RCONFLICTS = 5 | ||
| 148 | DEPENDS_TYPE = ( | ||
| 149 | (TYPE_RDEPENDS, "rdepends"), | ||
| 150 | (TYPE_RPROVIDES, "rprovides"), | ||
| 151 | (TYPE_RRECOMMENDS, "rrecommends"), | ||
| 152 | (TYPE_RSUGGESTS, "rsuggests"), | ||
| 153 | (TYPE_RREPLACES, "rreplaces"), | ||
| 154 | (TYPE_RCONFLICTS, "rconflicts"), | ||
| 155 | ) | ||
| 156 | package = models.ForeignKey(Build_Package, related_name='bpackage_dependencies_package') | ||
| 157 | depends_on = models.CharField(max_length=100) # soft dependency | ||
| 158 | dep_type = models.IntegerField(choices=DEPENDS_TYPE) | ||
| 159 | |||
| 160 | |||
| 161 | class Target_Package(models.Model): | ||
| 162 | target = models.ForeignKey('Target') | ||
| 163 | recipe = models.ForeignKey('Recipe', null=True) | ||
| 164 | name = models.CharField(max_length=100) | ||
| 165 | version = models.CharField(max_length=100, blank=True) | ||
| 166 | size = models.IntegerField() | ||
| 167 | |||
| 168 | |||
| 169 | class Target_Package_Dependency(models.Model): | ||
| 170 | TYPE_DEPENDS = 0 | ||
| 171 | TYPE_RDEPENDS = 1 | ||
| 172 | TYPE_RECOMMENDS = 2 | ||
| 173 | |||
| 174 | DEPENDS_TYPE = ( | ||
| 175 | (TYPE_DEPENDS, "depends"), | ||
| 176 | (TYPE_RDEPENDS, "rdepends"), | ||
| 177 | (TYPE_RECOMMENDS, "recommends"), | ||
| 178 | ) | ||
| 179 | package = models.ForeignKey(Target_Package, related_name='tpackage_dependencies_package') | ||
| 180 | depends_on = models.ForeignKey(Target_Package, related_name='tpackage_dependencies_depends') | ||
| 181 | dep_type = models.IntegerField(choices=DEPENDS_TYPE) | ||
| 182 | |||
| 183 | |||
| 184 | class Build_File(models.Model): | ||
| 185 | bpackage = models.ForeignKey(Build_Package, related_name='filelist_bpackage') | ||
| 186 | path = models.FilePathField(max_length=255, blank=True) | ||
| 187 | size = models.IntegerField() | ||
| 188 | |||
| 189 | class Target_File(models.Model): | ||
| 190 | tpackage = models.ForeignKey(Target_Package, related_name='filelist_tpackage') | ||
| 191 | path = models.FilePathField(max_length=255, blank=True) | ||
| 192 | size = models.IntegerField() | ||
| 193 | |||
| 194 | |||
| 195 | class Recipe(models.Model): | ||
| 196 | name = models.CharField(max_length=100, blank=True) | ||
| 197 | version = models.CharField(max_length=100, blank=True) | ||
| 198 | layer_version = models.ForeignKey('Layer_Version', related_name='recipe_layer_version') | ||
| 199 | summary = models.CharField(max_length=100, blank=True) | ||
| 200 | description = models.CharField(max_length=100, blank=True) | ||
| 201 | section = models.CharField(max_length=100, blank=True) | ||
| 202 | license = models.CharField(max_length=200, blank=True) | ||
| 203 | licensing_info = models.TextField(blank=True) | ||
| 204 | homepage = models.URLField(blank=True) | ||
| 205 | bugtracker = models.URLField(blank=True) | ||
| 206 | author = models.CharField(max_length=100, blank=True) | ||
| 207 | file_path = models.FilePathField(max_length=255) | ||
| 208 | |||
| 209 | |||
| 210 | class Recipe_Dependency(models.Model): | ||
| 211 | TYPE_DEPENDS = 0 | ||
| 212 | TYPE_RDEPENDS = 1 | ||
| 213 | |||
| 214 | DEPENDS_TYPE = ( | ||
| 215 | (TYPE_DEPENDS, "depends"), | ||
| 216 | (TYPE_RDEPENDS, "rdepends"), | ||
| 217 | ) | ||
| 218 | recipe = models.ForeignKey(Recipe, related_name='r_dependencies_recipe') | ||
| 219 | depends_on = models.ForeignKey(Recipe, related_name='r_dependencies_depends') | ||
| 220 | dep_type = models.IntegerField(choices=DEPENDS_TYPE) | ||
| 221 | |||
| 222 | class Layer(models.Model): | ||
| 223 | name = models.CharField(max_length=100) | ||
| 224 | local_path = models.FilePathField(max_length=255) | ||
| 225 | layer_index_url = models.URLField() | ||
| 226 | |||
| 227 | |||
| 228 | class Layer_Version(models.Model): | ||
| 229 | layer = models.ForeignKey(Layer, related_name='layer_version_layer') | ||
| 230 | branch = models.CharField(max_length=50) | ||
| 231 | commit = models.CharField(max_length=100) | ||
| 232 | priority = models.IntegerField() | ||
| 233 | |||
| 234 | |||
| 235 | class Variable(models.Model): | ||
| 236 | build = models.ForeignKey(Build, related_name='variable_build') | ||
| 237 | variable_name = models.CharField(max_length=100) | ||
| 238 | variable_value = models.TextField(blank=True) | ||
| 239 | file = models.FilePathField(max_length=255) | ||
| 240 | changed = models.BooleanField(default=False) | ||
| 241 | human_readable_name = models.CharField(max_length=200) | ||
| 242 | description = models.TextField(blank=True) | ||
| 243 | |||
| 244 | |||
| 245 | class LogMessage(models.Model): | ||
| 246 | INFO = 0 | ||
| 247 | WARNING = 1 | ||
| 248 | ERROR = 2 | ||
| 249 | |||
| 250 | LOG_LEVEL = ( (INFO, "info"), | ||
| 251 | (WARNING, "warn"), | ||
| 252 | (ERROR, "error") ) | ||
| 253 | |||
| 254 | build = models.ForeignKey(Build) | ||
| 255 | level = models.IntegerField(choices=LOG_LEVEL, default=INFO) | ||
| 256 | message=models.CharField(max_length=240) | ||
| 257 | pathname = models.FilePathField(max_length=255, blank=True) | ||
| 258 | lineno = models.IntegerField(null=True) | ||
