-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathtotest.py
executable file
·89 lines (71 loc) · 2.91 KB
/
totest.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
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
# -*- coding: utf-8 -*-
#
# (C) 2014 mhrusecky@suse.cz, openSUSE.org
# (C) 2014 tchvatal@suse.cz, openSUSE.org
# (C) 2014 aplanas@suse.de, openSUSE.org
# (C) 2014 coolo@suse.de, openSUSE.org
# (C) 2017 okurz@suse.de, openSUSE.org
# (C) 2018 dheidler@suse.de, openSUSE.org
# Distribute under GPLv2 or GPLv3
import yaml
from osclib.core import attribute_value_load
class ImageProduct(object):
def __init__(self, package, archs):
self.package = package
self.archs = archs
class ToTest(object):
"""Base class to store the basic interface"""
def __init__(self, project, apiurl):
self.name = project
# set the defaults
self.do_not_release = False
self.need_same_build_number = False
self.set_snapshot_number = False
self.snapshot_number_prefix = "Snapshot"
self.take_source_from_product = False
self.same_target_images_repo_for_source_repo = False
self.arch = 'x86_64'
self.openqa_server = None
self.product_repo = 'images'
self.product_arch = 'local'
self.livecd_repo = 'images'
self.totest_container_repo = 'containers'
# Repo for image_products. If not set, uses product_repo.
self.totest_images_repo = None
self.main_products = []
self.ftp_products = []
self.container_products = []
self.containerfile_products = []
self.livecd_products = []
self.image_products = []
self.test_subproject = 'ToTest'
self.base = project.split(':')[0]
self.jobs_num = 42
self.load_config(apiurl)
self.test_project = f'{project}:{self.test_subproject}'
def load_config(self, apiurl):
config = yaml.safe_load(attribute_value_load(apiurl, self.name, 'ToTestManagerConfig'))
for key, value in config.items():
if key == 'products':
self.set_products(value)
else:
setattr(self, key, value)
# Set default for totest_images_repo
if self.totest_images_repo is None:
self.totest_images_repo = self.product_repo
def parse_images(self, products):
parsed = []
for package in products:
# there is only one
for key, value in package.items():
parsed.append(ImageProduct(key, value))
return parsed
def set_products(self, products):
# plain arrays
setattr(self, 'main_products', products.get('main', []))
setattr(self, 'ftp_products', products.get('ftp', []))
# image products
setattr(self, 'livecd_products', self.parse_images(products.get('livecds', [])))
setattr(self, 'image_products', self.parse_images(products.get('images', [])))
setattr(self, 'container_products', self.parse_images(products.get('container', [])))
setattr(self, 'containerfile_products', self.parse_images(products.get('containerfile', [])))