bitbake: toaster: use OneToOneField instead of ForeignKey

Used OneToOneField to reference BuildRequest in BRBitbake model.

Fixed django warning:
WARNINGS: Setting unique=True on a ForeignKey has the same effect
          as using a OneToOneField.

(Bitbake rev: aaa4319ebbb06facb77b4ba936cf3aa2068ff238)

Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ed Bartosh 2015-12-09 19:56:38 -08:00 committed by Richard Purdie
parent c464f34d5b
commit 84daa40bc7
5 changed files with 13 additions and 14 deletions

View File

@ -141,10 +141,10 @@ class BuildEnvironmentController(object):
raise Exception("FIXME: Must override in order to actually start the BB server")
def setLayers(self, bbs, ls):
def setLayers(self, bitbake, ls):
""" Checks-out bitbake executor and layers from git repositories.
Sets the layer variables in the config file, after validating local layer paths.
The bitbakes must be a 1-length list of BRBitbake
bitbake must be a single BRBitbake instance
The layer paths must be in a list of BRLayer object
a word of attention: by convention, the first layer for any build will be poky!

View File

@ -115,18 +115,17 @@ class LocalhostBEController(BuildEnvironmentController):
return local_checkout_path
def setLayers(self, bitbakes, layers, targets):
def setLayers(self, bitbake, layers, targets):
""" a word of attention: by convention, the first layer for any build will be poky! """
assert self.be.sourcedir is not None
assert len(bitbakes) == 1
# set layers in the layersource
# 1. get a list of repos with branches, and map dirpaths for each layer
gitrepos = {}
gitrepos[(bitbakes[0].giturl, bitbakes[0].commit)] = []
gitrepos[(bitbakes[0].giturl, bitbakes[0].commit)].append( ("bitbake", bitbakes[0].dirpath) )
gitrepos[(bitbake.giturl, bitbake.commit)] = []
gitrepos[(bitbake.giturl, bitbake.commit)].append( ("bitbake", bitbake.dirpath) )
for layer in layers:
# we don't process local URLs
@ -198,7 +197,7 @@ class LocalhostBEController(BuildEnvironmentController):
# make sure we have a working bitbake
if not os.path.exists(os.path.join(self.pokydirname, 'bitbake')):
logger.debug("localhostbecontroller: checking bitbake into the poky dirname %s " % self.pokydirname)
self._shellcmd("git clone -b \"%s\" \"%s\" \"%s\" " % (bitbakes[0].commit, bitbakes[0].giturl, os.path.join(self.pokydirname, 'bitbake')))
self._shellcmd("git clone -b \"%s\" \"%s\" \"%s\" " % (bitbake.commit, bitbake.giturl, os.path.join(self.pokydirname, 'bitbake')))
# verify our repositories
for name, dirpath in gitrepos[(giturl, commit)]:
@ -224,7 +223,7 @@ class LocalhostBEController(BuildEnvironmentController):
for target in targets:
try:
customrecipe = CustomImageRecipe.objects.get(name=target.target,
project=bitbakes[0].req.project)
project=bitbake.req.project)
except CustomImageRecipe.DoesNotExist:
continue # not a custom recipe, skip
@ -278,7 +277,7 @@ class LocalhostBEController(BuildEnvironmentController):
def triggerBuild(self, bitbake, layers, variables, targets):
# set up the buid environment with the needed layers
# set up the build environment with the needed layers
self.setLayers(bitbake, layers, targets)
# get the bb server running with the build req id and build env id

View File

@ -57,7 +57,7 @@ class Command(NoArgsCommand):
br.save()
# this triggers an async build
bec.triggerBuild(br.brbitbake_set.all(), br.brlayer_set.all(), br.brvariable_set.all(), br.brtarget_set.all())
bec.triggerBuild(br.brbitbake, br.brlayer_set.all(), br.brvariable_set.all(), br.brtarget_set.all())
except Exception as e:
logger.error("runbuilds: Error launching build %s" % e)

View File

@ -106,7 +106,7 @@ class BRLayer(models.Model):
layer_version = models.ForeignKey(Layer_Version, null=True)
class BRBitbake(models.Model):
req = models.ForeignKey(BuildRequest, unique = True) # only one bitbake for a request
req = models.OneToOneField(BuildRequest) # only one bitbake for a request
giturl = models.CharField(max_length =254)
commit = models.CharField(max_length = 254)
dirpath = models.CharField(max_length = 254)

View File

@ -18,7 +18,7 @@ import subprocess
import os
# standard poky data hardcoded for testing
BITBAKE_LAYERS = [type('bitbake_info', (object,), { "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "", "commit": "HEAD"})]
BITBAKE_LAYER = type('bitbake_info', (object,), { "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "", "commit": "HEAD"})
POKY_LAYERS = [
type('poky_info', (object,), { "name": "meta", "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "meta", "commit": "HEAD"}),
type('poky_info', (object,), { "name": "meta-yocto", "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "meta-yocto", "commit": "HEAD"}),
@ -53,7 +53,7 @@ class BEControllerTests(object):
bc = self._getBEController(obe)
try:
# setting layers, skip any layer info
bc.setLayers(BITBAKE_LAYERS, POKY_LAYERS)
bc.setLayers(BITBAKE_LAYER, POKY_LAYERS)
except NotImplementedException, e:
print "Test skipped due to command not implemented yet"
return True
@ -80,7 +80,7 @@ class BEControllerTests(object):
layerSet = False
try:
# setting layers, skip any layer info
layerSet = bc.setLayers(BITBAKE_LAYERS, POKY_LAYERS)
layerSet = bc.setLayers(BITBAKE_LAYER, POKY_LAYERS)
except NotImplementedException:
print "Test skipped due to command not implemented yet"
return True