File: validate_devices.py

package info (click to toggle)
lava-server 2016.12-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 28,728 kB
  • sloc: python: 34,417; sh: 902; makefile: 298; xml: 154
file content (71 lines) | stat: -rwxr-xr-x 2,194 bytes parent folder | download | duplicates (3)
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
#! /usr/bin/python

"""
This script is to check the combination of the Jinja2 device-type templates
and the instance-specific device dictionary configuration, to ensure that the
device configuration is valid for each pipeline device on a specified instance.

(This script is part of the lava-dev binary package.)

"""

# Copyright 2016 Linaro Limited
# Author: Neil Williams <neil.williams@linaro.org>
#
# This file is part of LAVA Dispatcher.
#
# LAVA Dispatcher 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 Dispatcher 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>.

# pylint gets confused: commands have no shebang, but the file is not a module.
# pylint: disable=invalid-name


import argparse
import sys
if sys.version > '3':
    import xmlrpc.client as xmlrpclib
else:
    import xmlrpclib


def main():
    parser = argparse.ArgumentParser(description='LAVA Dispatcher template helper')
    parser.add_argument(
        '--instance',
        type=str,
        required=True,
        help='Name of the instance to check')
    parser.add_argument(
        '--hostname',
        default=None,
        type=str,
        help='Device to check (all pipeline devices if not used)')
    parser.add_argument(
        '--https',
        action='store_true',
        help='Use https instead of http')
    args = parser.parse_args()

    protocol = 'https' if args.https else 'http'

    connection = xmlrpclib.ServerProxy("%s://%s//RPC2" % (protocol, args.instance))
    if args.hostname:
        print(connection.scheduler.validate_pipeline_devices(args.hostname))
    else:
        print(connection.scheduler.validate_pipeline_devices())


if __name__ == '__main__':
    main()