-
Notifications
You must be signed in to change notification settings - Fork 6
/
check_robot.py
executable file
·51 lines (39 loc) · 1.67 KB
/
check_robot.py
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
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2018 The Linux Foundation and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
##############################################################################
"""Ensures that we are only ever using one robot system.
Due to the way the Jenkins OpenStack Cloud plugin works we can only limit
max parallel robot systems by the VM. So having multiple VM types makes it
very difficult for us to properly limit the amount of parallel robot runs.
"""
__author__ = "Thanh Ha"
import fnmatch
import os
import re
import sys
def get_robot_systems(filename):
"""Scan for robot vms.
Returns a list of Robot systems found in file.
"""
robots = set()
with open(filename, "r") as _file:
for num, line in enumerate(_file, 1):
if re.search("centos[78]-robot", line):
robots.add(line.rsplit(maxsplit=1)[1])
return robots
if __name__ == "__main__":
robots = []
for root, dirnames, filenames in os.walk("jjb"):
for filename in fnmatch.filter(filenames, "*.yaml"):
robots += get_robot_systems(os.path.join(root, filename))
if len(robots) > 1:
print("ERROR: More than one robot system type definition detected.")
print("Please ensure that ALL templates use the same robot nodes.")
print("Infra does not support more than 1 robot node type in use.")
sys.exit(1)