launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19372
[Merge] lp:~cjwatson/launchpad/livefsbuild-version into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/livefsbuild-version into lp:launchpad with lp:~cjwatson/launchpad/db-livefsbuild-version as a prerequisite.
Commit message:
Allow overriding the build version in LiveFS.requestBuild.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1496074 in Launchpad itself: "Enable passing version information to livefs builds"
https://bugs.launchpad.net/launchpad/+bug/1496074
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/livefsbuild-version/+merge/271193
Allow overriding the build version in LiveFS.requestBuild. This makes it possible for users (e.g. cloud-image) to set their own serial numbers for builds. The existing LiveFSBuild.version property is informational from LP's point of view, so it shouldn't be a problem to make it user-settable.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/livefsbuild-version into lp:launchpad.
=== modified file 'lib/lp/soyuz/interfaces/livefs.py'
--- lib/lp/soyuz/interfaces/livefs.py 2015-05-07 10:52:10 +0000
+++ lib/lp/soyuz/interfaces/livefs.py 2015-09-15 20:24:14 +0000
@@ -162,12 +162,13 @@
required=False),
metadata_override=Dict(
title=_("A dict of data about the image."),
- key_type=TextLine(), required=False))
+ key_type=TextLine(), required=False),
+ version=TextLine(title=_("A version string for this build.")))
# Really ILiveFSBuild, patched in _schema_circular_imports.py.
@export_factory_operation(Interface, [])
@operation_for_version("devel")
def requestBuild(requester, archive, distro_arch_series, pocket,
- unique_key=None, metadata_override=None):
+ unique_key=None, metadata_override=None, version=None):
"""Request that the live filesystem be built.
:param requester: The person requesting the build.
@@ -179,6 +180,9 @@
:param metadata_override: An optional JSON string with a dict of
data about the image; this will be merged into the metadata dict
for the live filesystem.
+ :param version: A version string for this build; if not set, a
+ version string will be generated from the date and time when the
+ build was requested.
:return: `ILiveFSBuild`.
"""
=== modified file 'lib/lp/soyuz/interfaces/livefsbuild.py'
--- lib/lp/soyuz/interfaces/livefsbuild.py 2014-06-17 11:01:51 +0000
+++ lib/lp/soyuz/interfaces/livefsbuild.py 2015-09-15 20:24:14 +0000
@@ -1,4 +1,4 @@
-# Copyright 2014 Canonical Ltd. This software is licensed under the
+# Copyright 2014-2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Live filesystem build interfaces."""
@@ -97,7 +97,7 @@
title=_("If True, this build is virtualized."), readonly=True)
version = exported(TextLine(
- title=_("A timestamp-based version identifying this build."),
+ title=_("A version string for this build."),
required=True, readonly=True))
score = exported(Int(
@@ -195,5 +195,6 @@
"""Utility for `ILiveFSBuild`."""
def new(requester, livefs, archive, distro_arch_series, pocket,
- unique_key=None, metadata_override=None, date_created=DEFAULT):
+ unique_key=None, metadata_override=None, version=None,
+ date_created=DEFAULT):
"""Create an `ILiveFSBuild`."""
=== modified file 'lib/lp/soyuz/model/livefs.py'
--- lib/lp/soyuz/model/livefs.py 2015-07-20 20:31:20 +0000
+++ lib/lp/soyuz/model/livefs.py 2015-09-15 20:24:14 +0000
@@ -127,7 +127,7 @@
self.date_last_modified = date_created
def requestBuild(self, requester, archive, distro_arch_series, pocket,
- unique_key=None, metadata_override=None):
+ unique_key=None, metadata_override=None, version=None):
"""See `ILiveFS`."""
if not requester.inTeam(self.owner):
raise LiveFSNotOwner(
@@ -152,7 +152,8 @@
build = getUtility(ILiveFSBuildSet).new(
requester, self, archive, distro_arch_series, pocket,
- unique_key=unique_key, metadata_override=metadata_override)
+ unique_key=unique_key, metadata_override=metadata_override,
+ version=version)
build.queueBuild()
return build
=== modified file 'lib/lp/soyuz/model/livefsbuild.py'
--- lib/lp/soyuz/model/livefsbuild.py 2015-07-08 16:05:11 +0000
+++ lib/lp/soyuz/model/livefsbuild.py 2015-09-15 20:24:14 +0000
@@ -1,4 +1,4 @@
-# Copyright 2014 Canonical Ltd. This software is licensed under the
+# Copyright 2014-2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -121,6 +121,8 @@
metadata_override = JSON('json_data_override')
+ _version = Unicode(name='version')
+
date_created = DateTime(
name='date_created', tzinfo=pytz.UTC, allow_none=False)
date_started = DateTime(name='date_started', tzinfo=pytz.UTC)
@@ -145,7 +147,7 @@
def __init__(self, build_farm_job, requester, livefs, archive,
distro_arch_series, pocket, processor, virtualized,
- unique_key, metadata_override, date_created):
+ unique_key, metadata_override, version, date_created):
"""Construct a `LiveFSBuild`."""
if not getFeatureFlag(LIVEFS_FEATURE_FLAG):
raise LiveFSFeatureDisabled
@@ -160,6 +162,7 @@
self.virtualized = virtualized
self.unique_key = unique_key
self.metadata_override = metadata_override
+ self._version = version
self.date_created = date_created
self.status = BuildStatus.NEEDSBUILD
@@ -200,7 +203,10 @@
@property
def version(self):
"""See `ILiveFSBuild`."""
- return self.date_created.strftime("%Y%m%d-%H%M%S")
+ if self._version is not None:
+ return self._version
+ else:
+ return self.date_created.strftime("%Y%m%d-%H%M%S")
@property
def score(self):
@@ -338,7 +344,8 @@
class LiveFSBuildSet(SpecificBuildFarmJobSourceMixin):
def new(self, requester, livefs, archive, distro_arch_series, pocket,
- unique_key=None, metadata_override=None, date_created=DEFAULT):
+ unique_key=None, metadata_override=None, version=None,
+ date_created=DEFAULT):
"""See `ILiveFSBuildSet`."""
store = IMasterStore(LiveFSBuild)
build_farm_job = getUtility(IBuildFarmJobSource).new(
@@ -349,7 +356,7 @@
pocket, distro_arch_series.processor,
not distro_arch_series.processor.supports_nonvirtualized
or livefs.require_virtualized or archive.require_virtualized,
- unique_key, metadata_override, date_created)
+ unique_key, metadata_override, version, date_created)
store.add(livefsbuild)
return livefsbuild
=== modified file 'lib/lp/soyuz/tests/test_livefs.py'
--- lib/lp/soyuz/tests/test_livefs.py 2015-07-20 20:31:20 +0000
+++ lib/lp/soyuz/tests/test_livefs.py 2015-09-15 20:24:14 +0000
@@ -219,6 +219,23 @@
PackagePublishingPocket.RELEASE)
self.assertEqual(build_virt, build.virtualized)
+ def test_requestBuild_version(self):
+ # requestBuild may optionally override the version.
+ livefs = self.factory.makeLiveFS()
+ distroarchseries = self.factory.makeDistroArchSeries(
+ distroseries=livefs.distro_series)
+ build = livefs.requestBuild(
+ livefs.owner, livefs.distro_series.main_archive, distroarchseries,
+ PackagePublishingPocket.RELEASE)
+ self.assertEqual(
+ build.date_created.strftime("%Y%m%d-%H%M%S"), build.version)
+ build.updateStatus(BuildStatus.BUILDING)
+ build.updateStatus(BuildStatus.FULLYBUILT)
+ build = livefs.requestBuild(
+ livefs.owner, livefs.distro_series.main_archive, distroarchseries,
+ PackagePublishingPocket.RELEASE, version=u"20150101")
+ self.assertEqual(u"20150101", build.version)
+
def test_getBuilds(self):
# Test the various getBuilds methods.
livefs = self.factory.makeLiveFS()
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2015-09-09 14:17:46 +0000
+++ lib/lp/testing/factory.py 2015-09-15 20:24:14 +0000
@@ -4472,7 +4472,7 @@
def makeLiveFSBuild(self, requester=None, registrant=None, livefs=None,
archive=None, distroarchseries=None, pocket=None,
- unique_key=None, metadata_override=None,
+ unique_key=None, metadata_override=None, version=None,
date_created=DEFAULT, status=BuildStatus.NEEDSBUILD,
builder=None, duration=None, **kwargs):
"""Make a new LiveFSBuild."""
@@ -4503,7 +4503,7 @@
livefsbuild = getUtility(ILiveFSBuildSet).new(
requester, livefs, archive, distroarchseries, pocket,
unique_key=unique_key, metadata_override=metadata_override,
- date_created=date_created)
+ version=version, date_created=date_created)
if duration is not None:
removeSecurityProxy(livefsbuild).updateStatus(
BuildStatus.BUILDING, builder=builder,
Follow ups