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
|
# Copyright (C) 2018 Linaro Limited
#
# Author: Neil Williams <neil.williams@linaro.org>
#
# This file is part of LAVA.
#
# LAVA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LAVA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along
# with this program; if not, see <http://www.gnu.org/licenses>.
from lava_dispatcher.action import Pipeline
from lava_dispatcher.connections.serial import ConnectDevice
from lava_dispatcher.actions.deploy.download import DownloaderAction, CopyToLxcAction
from lava_dispatcher.actions.deploy import DeployAction
from lava_dispatcher.logical import Deployment
class RecoveryModeAction(DeployAction):
name = "deploy-recovery-mode"
description = "deploy firmware by switching to recovery mode"
summary = "deploy firmware in recovery mode"
def populate(self, parameters):
super().populate(parameters)
self.internal_pipeline = Pipeline(parent=self, job=self.job, parameters=parameters)
recovery = self.job.device['actions']['deploy']['methods']['recovery']
recovery_dir = self.mkdtemp()
image_keys = sorted(parameters['images'].keys())
for image in image_keys:
if image != 'yaml_line':
self.internal_pipeline.add_action(DownloaderAction(image, recovery_dir))
self.internal_pipeline.add_action(CopyToLxcAction())
tags = []
if 'tags' in recovery:
tags = recovery['tags']
if 'serial' in tags:
# might not be a usable shell here, just power on.
# FIXME: if used, FastbootAction must not try to reconnect
self.internal_pipeline.add_action(ConnectDevice())
class RecoveryMode(Deployment):
compatibility = 4
name = 'recovery-mode'
def __init__(self, parent, parameters):
super().__init__(parent)
self.action = RecoveryModeAction()
self.action.section = self.action_type
self.action.job = self.job
parent.add_action(self.action, parameters)
@classmethod
def accepts(cls, device, parameters):
if 'recovery' not in device['actions']['deploy']['methods']:
return False, "'recovery' not in the device configuration deploy methods"
if parameters['to'] != 'recovery':
return False, '"to" parameter is not "recovery"'
if 'images' not in parameters:
return False, '"images" is not in the deployment parameters'
return True, 'accepted'
|