2019-03-26 07:51:53 +01:00
|
|
|
#!/usr/bin/python2
|
|
|
|
# -*- 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
|
|
|
|
|
|
|
|
from __future__ import print_function
|
2019-03-26 08:21:47 +01:00
|
|
|
import yaml
|
2019-03-26 16:37:12 +01:00
|
|
|
from osclib.core import attribute_value_load
|
2019-03-26 07:51:53 +01:00
|
|
|
|
|
|
|
class ImageProduct(object):
|
|
|
|
def __init__(self, package, archs):
|
|
|
|
self.package = package
|
|
|
|
self.archs = archs
|
|
|
|
|
|
|
|
class ToTest(object):
|
|
|
|
|
|
|
|
"""Base class to store the basic interface"""
|
|
|
|
|
2019-03-26 16:37:12 +01:00
|
|
|
def __init__(self, project, apiurl):
|
2019-03-26 07:51:53 +01:00
|
|
|
self.name = project
|
|
|
|
|
|
|
|
# set the defaults
|
|
|
|
self.do_not_release = False
|
|
|
|
self.need_same_build_number = False
|
|
|
|
self.set_snapshot_number = False
|
2019-03-26 08:21:47 +01:00
|
|
|
self.take_source_from_product = False
|
|
|
|
self.arch = 'x86_64'
|
|
|
|
self.openqa_server = None
|
2019-03-26 07:51:53 +01:00
|
|
|
|
|
|
|
self.product_repo = 'images'
|
|
|
|
self.product_arch = 'local'
|
|
|
|
self.livecd_repo = 'images'
|
|
|
|
self.totest_container_repo = 'containers'
|
|
|
|
|
|
|
|
self.main_products = []
|
|
|
|
self.ftp_products = []
|
|
|
|
self.container_products = []
|
|
|
|
self.livecd_products = []
|
|
|
|
self.image_products = []
|
|
|
|
|
|
|
|
self.test_subproject = 'ToTest'
|
2019-03-26 08:21:47 +01:00
|
|
|
self.base = project.split(':')[0]
|
2019-03-26 07:51:53 +01:00
|
|
|
|
2019-03-26 08:21:47 +01:00
|
|
|
self.jobs_num = 42
|
2019-03-26 16:37:12 +01:00
|
|
|
self.load_config(apiurl)
|
2019-03-26 08:21:47 +01:00
|
|
|
self.test_project = '%s:%s' % (project, self.test_subproject)
|
2019-03-26 11:25:38 +01:00
|
|
|
self.is_image_product = not len(self.main_products)
|
2019-03-26 07:51:53 +01:00
|
|
|
|
2019-03-26 16:37:12 +01:00
|
|
|
def load_config(self, apiurl):
|
|
|
|
config = yaml.safe_load(attribute_value_load(apiurl, self.name, 'ToTestManagerConfig'))
|
2019-03-26 08:21:47 +01:00
|
|
|
for key, value in config.items():
|
|
|
|
if key == 'products':
|
|
|
|
self.set_products(value)
|
|
|
|
else:
|
|
|
|
setattr(self, key, value)
|
|
|
|
|
|
|
|
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
|
2019-03-26 11:25:38 +01:00
|
|
|
setattr(self, 'main_products', products.get('main', []))
|
|
|
|
setattr(self, 'ftp_products', products.get('ftp', []))
|
2019-03-26 08:21:47 +01:00
|
|
|
|
|
|
|
# image products
|
2019-03-26 11:25:38 +01:00
|
|
|
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', [])))
|