1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# Copyright 2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
__all__ = [
"InitialiseDistroSeriesJob",
]
from zope.interface import (
classProvides,
implements,
)
from canonical.launchpad.interfaces.lpstorm import (
IMasterStore,
IStore,
)
from lp.registry.model.distroseries import DistroSeries
from lp.soyuz.interfaces.distributionjob import (
DistributionJobType,
IInitialiseDistroSeriesJob,
IInitialiseDistroSeriesJobSource,
)
from lp.soyuz.model.distributionjob import (
DistributionJob,
DistributionJobDerived,
)
from lp.soyuz.scripts.initialise_distroseries import InitialiseDistroSeries
from lp.services.job.model.job import Job
class InitialiseDistroSeriesJob(DistributionJobDerived):
implements(IInitialiseDistroSeriesJob)
class_job_type = DistributionJobType.INITIALISE_SERIES
classProvides(IInitialiseDistroSeriesJobSource)
@classmethod
def create(cls, parent, child, arches=(), packagesets=(), rebuild=False):
"""See `IInitialiseDistroSeriesJob`."""
metadata = {
'parent': parent.id,
'arches': arches,
'packagesets': packagesets,
'rebuild': rebuild,
}
job = DistributionJob(
child.distribution, child, cls.class_job_type,
metadata)
IMasterStore(DistributionJob).add(job)
return cls(job)
@classmethod
def getPendingJobsForDistroseries(cls, distroseries):
"""See `IInitialiseDistroSeriesJob`."""
return IStore(DistributionJob).find(
DistributionJob,
DistributionJob.job_id == Job.id,
DistributionJob.job_type ==
DistributionJobType.INITIALISE_SERIES,
DistributionJob.distroseries_id == distroseries.id,
Job._status.is_in(Job.PENDING_STATUSES))
@property
def parent(self):
return IStore(DistroSeries).get(
DistroSeries, self.metadata["parent"])
@property
def arches(self):
return tuple(self.metadata['arches'])
@property
def packagesets(self):
return tuple(self.metadata['packagesets'])
@property
def rebuild(self):
return self.metadata['rebuild']
def run(self):
"""See `IRunnableJob`."""
ids = InitialiseDistroSeries(
self.parent, self.distroseries, self.arches,
self.packagesets, self.rebuild)
ids.check()
ids.initialise()
def getOopsVars(self):
"""See `IRunnableJob`."""
vars = super(InitialiseDistroSeriesJob, self).getOopsVars()
vars.append(('parent_distroseries_id', self.metadata.get("parent")))
return vars
|