~dpigott/lava-dispatcher/increase-timeout

« back to all changes in this revision

Viewing changes to lava_dispatcher/actions/deploy.py

  • Committer: Michael Hudson-Doyle
  • Date: 2012-03-13 03:47:38 UTC
  • mfrom: (240.3.10 more-validation)
  • Revision ID: michael.hudson@linaro.org-20120313034738-c2wmuw7dw8s0kzv8
make the validation of the job file that happens before a job starts much more rigorous

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
 
23
23
class cmd_deploy_linaro_image(BaseAction):
24
 
    def run(self, hwpack=None, rootfs=None, image=None, kernel_matrix=None, use_cache=True, rootfstype='ext3'):
 
24
 
 
25
    # This is how the schema for parameters should look, but there are bugs in
 
26
    # json_schema_validation that means it doesn't work (see
 
27
    # https://github.com/zyga/json-schema-validator/pull/6).
 
28
 
 
29
    ## parameters_schema = {
 
30
    ##     'type': [
 
31
    ##         {
 
32
    ##             'type': 'object',
 
33
    ##             'properties': {
 
34
    ##                 'image': {'type': 'string'},
 
35
    ##                 },
 
36
    ##             'additionalProperties': False,
 
37
    ##             },
 
38
    ##         {
 
39
    ##             'type': 'object',
 
40
    ##             'properties': {
 
41
    ##                 'hwpack': {'type': 'string'},
 
42
    ##                 'rootfs': {'type': 'string'},
 
43
    ##                 'kernel_matrix': {'type': 'string', 'optional': True},
 
44
    ##                 'use_cache': {'type': 'bool', 'optional': True, 'default': True},
 
45
    ##                 'rootfstype': {'type': 'string', 'optional': True, 'default': 'ext3'},
 
46
    ##                 },
 
47
    ##             'additionalProperties': False,
 
48
    ##             },
 
49
    ##         ],
 
50
    ##     }
 
51
 
 
52
    parameters_schema = {
 
53
        'type': 'object',
 
54
        'properties': {
 
55
            'hwpack': {'type': 'string', 'optional': True},
 
56
            'rootfs': {'type': 'string', 'optional': True},
 
57
            'image': {'type': 'string', 'optional': True},
 
58
            'kernel_matrix': {'type': 'string', 'optional': True},
 
59
            'use_cache': {'type': 'bool', 'optional': True},
 
60
            'rootfstype': {'type': 'string', 'optional': True},
 
61
            },
 
62
        'additionalProperties': False,
 
63
        }
 
64
 
 
65
    @classmethod
 
66
    def validate_parameters(cls, parameters):
 
67
        super(cmd_deploy_linaro_image, cls).validate_parameters(parameters)
 
68
        if 'hwpack' in parameters:
 
69
            if 'rootfs' not in parameters:
 
70
                raise ValueError('must specify rootfs when specifying hwpack')
 
71
            if 'image' in parameters:
 
72
                raise ValueError('cannot specify image and hwpack')
 
73
        elif 'image' not in parameters:
 
74
            raise ValueError('must specify image if not specifying a hwpack')
 
75
        elif 'kernel_matrix' in parameters:
 
76
            raise ValueError('cannot specify kernel_matrix with an image')
 
77
 
 
78
    def run(self, hwpack=None, rootfs=None, image=None, kernel_matrix=None,
 
79
            use_cache=True, rootfstype='ext3'):
25
80
        self.client.deploy_linaro(
26
 
            hwpack=hwpack, rootfs=rootfs, image=image, kernel_matrix=kernel_matrix, use_cache=use_cache, rootfstype=rootfstype)
 
81
            hwpack=hwpack, rootfs=rootfs, image=image,
 
82
            kernel_matrix=kernel_matrix, use_cache=use_cache,
 
83
            rootfstype=rootfstype)