1
# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
8
"IPlainPackageCopyJob",
9
"IPlainPackageCopyJobSource",
13
from lazr.enum import (
17
from lazr.restful.fields import Reference
18
from zope.interface import (
22
from zope.schema import (
29
from canonical.launchpad import _
30
from lp.registry.interfaces.distroseries import IDistroSeries
31
from lp.services.job.interfaces.job import (
36
from lp.soyuz.interfaces.archive import IArchive
39
class IPackageCopyJob(Interface):
40
"""A job that copies packages between `IArchive`s."""
43
title=_('DB ID'), required=True, readonly=True,
44
description=_("The tracking number for this job."))
46
source_archive_id = Int(
47
title=_('Source Archive ID'),
48
required=True, readonly=True)
50
source_archive = Reference(
51
schema=IArchive, title=_('Source Archive'),
52
required=True, readonly=True)
54
target_archive_id = Int(
55
title=_('Target Archive ID'),
56
required=True, readonly=True)
58
target_archive = Reference(
59
schema=IArchive, title=_('Target Archive'),
60
required=True, readonly=True)
62
target_distroseries = Reference(
63
schema=IDistroSeries, title=_('Target DistroSeries.'),
64
required=True, readonly=True)
67
schema=IJob, title=_('The common Job attributes'),
68
required=True, readonly=True)
70
metadata = Attribute('A dict of data about the job.')
73
class PackageCopyJobType(DBEnumeratedType):
76
Copy packages between archives.
78
This job copies one or more packages, optionally including binaries.
82
class IPlainPackageCopyJobSource(IJobSource):
83
"""An interface for acquiring `IPackageCopyJobs`."""
85
def create(cls, source_packages, source_archive,
86
target_archive, target_distroseries, target_pocket,
87
include_binaries=False):
88
"""Create a new `IPackageCopyJob`.
90
:param source_packages: An iterable of `(source_package_name,
91
version)` tuples, where both `source_package_name` and `version`
93
:param source_archive: The `IArchive` in which `source_packages` are
95
:param target_archive: The `IArchive` to which to copy the packages.
96
:param target_distroseries: The `IDistroSeries` to which to copy the
98
:param target_pocket: The pocket into which to copy the packages. Must
99
be a member of `PackagePublishingPocket`.
100
:param include_binaries: See `do_copy`.
103
def getActiveJobs(target_archive):
104
"""Retrieve all active sync jobs for an archive."""
106
def getPendingJobsPerPackage(target_series):
107
"""Find pending jobs for each package in `target_series`.
109
This is meant for finding jobs that will resolve specific
110
`DistroSeriesDifference`s, so see also `specify_dsd_package`.
112
:param target_series: Target `DistroSeries`; this corresponds to
113
`DistroSeriesDifference.derived_series`.
114
:return: A dict containing as keys the (name, version) tuples for
115
each `DistroSeriesDifference` that has a resolving
116
`PlainPackageCopyJob` pending. Each of these DSDs maps to its
117
oldest pending job. The `version` corresponds to
118
`DistroSeriesDifference.parent_source_version`.
122
class IPlainPackageCopyJob(IRunnableJob):
123
"""A no-frills job to copy packages between `IArchive`s."""
125
source_packages = List(
126
title=_("Source Packages"),
127
value_type=Tuple(min_length=3, max_length=3),
128
required=True, readonly=True)
131
title=_("Target package publishing pocket"), required=True,
134
include_binaries = Bool(
135
title=_("Copy binaries"),
136
required=False, readonly=True)