From 8f1ee2a1b98340f1d92642f9202debb666f58c85 Mon Sep 17 00:00:00 2001 From: e Date: Wed, 28 Dec 2022 09:56:02 +0800 Subject: [PATCH 01/16] =?UTF-8?q?start=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javcra/application/majun/__init__.py | 153 +++++++++++++++++ .../javcra/application/majun/majun_start.py | 155 ++++++++++++++++++ .../javcra/cli/commands/majun_start.py | 73 +++++++++ release-assistant/javcra/common/constant.py | 8 + release-assistant/javcra/libs/read_excel.py | 1 + 5 files changed, 390 insertions(+) create mode 100644 release-assistant/javcra/application/majun/__init__.py create mode 100644 release-assistant/javcra/application/majun/majun_start.py create mode 100644 release-assistant/javcra/cli/commands/majun_start.py diff --git a/release-assistant/javcra/application/majun/__init__.py b/release-assistant/javcra/application/majun/__init__.py new file mode 100644 index 0000000..6626d80 --- /dev/null +++ b/release-assistant/javcra/application/majun/__init__.py @@ -0,0 +1,153 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ + + +import datetime +import json +import os +import re +from enum import Enum, unique +from functools import wraps +import requests +from javcra.common.constant import MAJUN_CALLBACK_URL, BRANCH_LIST +from javcra.libs.log import logger + + +@unique +class MessageCode(Enum): + SUCCESS_MESSAGE = "Operation succeeded" + FAILURE_MESSAGE = "Operation failed" + SUCCESS_CODE = "200" + FAILED_CODE = "400" + + +def combine_content(content, majun_id, multip_start): + """ + jenkins run result + Args: + content: jenkins run result + majun_id: majun id + multip_start: Whether to enable the multi-version start function + Returns: + content_dic: Send a combination of Majun's data + """ + content_dic = {"data": content, "id": majun_id} + if any([content, multip_start]): + content_dic.update({"code": MessageCode.SUCCESS_CODE.value, "msg": MessageCode.SUCCESS_MESSAGE.value}) + else: + content_dic.update({"code": MessageCode.FAILED_CODE.value, "msg": MessageCode.FAILURE_MESSAGE.value}) + return content_dic + + +def send_content_majun(content, majun_id, multip_start=False): + """ + jenkins result sent to majun + Args: + content: Data sent to majun + majun_id: majun id + multip_start: Whether to enable the multi-version start function + Returns: + Sending data Results + """ + new_content = combine_content(content, majun_id, multip_start) + heard = {"access_token": os.getenv("majun_access_token")} + try: + resp = requests.post( + url=MAJUN_CALLBACK_URL, data=json.dumps(new_content), headers=heard + ) + except requests.RequestException as error: + logger.error(f"Failed to send data, because {error}") + return False + if resp.status_code == requests.codes.ok: + logger.info(f"The {new_content} data sent to majun was successful") + return True + return False + + +def get_product_version(task_title): + """ + Parse the key information in the task name + Args: + task_title: Task Name + + Returns: + branch_name: git branch name + release_date: Version schedule date + multi_content: Multiple versions of the specific information + + """ + base_re_str = r"^(.+)_([a-zA-Z]+)(\d+)" + + if "Multi" in task_title: + re_content = re.compile(f"{base_re_str}_(.+)", re.MULTILINE).search( + task_title + ) + branch_name, release_date, multi_content = ( + re_content.group(1), + re_content.group(3), + re_content.group(4), + ) + else: + re_content = re.compile(base_re_str, re.MULTILINE).search(task_title) + branch_name, release_date = ( + re_content.group(1), + re_content.group(3), + ) + multi_content = None + if branch_name not in BRANCH_LIST: + raise ValueError(f"This branch {branch_name} is not supported yet") + if release_date.isdigit(): + freeze_date = ( + datetime.datetime.strptime(release_date, "%Y%m%d") + + datetime.timedelta(days=2) + ).strftime("%Y%m%d") + + else: + re_release_date = re.compile(r"(\d+)(\D+)", re.MULTILINE).search(release_date) + new_update_time, temporary_str = re_content.group(1), re_release_date.group(2) + freeze_date = (datetime.datetime.strptime(new_update_time, "%Y%m%d") + + datetime.timedelta(days=2)).strftime( + "%Y%m%d") + temporary_str + return branch_name, freeze_date, multi_content + + +def catch_majun_error(func): + """ + Exception capture decorator + """ + + @wraps(func) + def inner(*args, **kwargs): + """ + capture decorator + """ + _, params = args + try: + if not os.getenv("majun_access_token"): + raise ValueError( + "Failed to obtain the majun access token value." + "Please check the Settings of jenkins engineering environment variables" + ) + return func(*args, **kwargs) + except ( + ValueError, + AttributeError, + KeyError, + TypeError, + FileNotFoundError, + IndexError + ) as err: + logger.error(f"repo {err}") + return send_content_majun(False, params.id) + + return inner diff --git a/release-assistant/javcra/application/majun/majun_start.py b/release-assistant/javcra/application/majun/majun_start.py new file mode 100644 index 0000000..3091db0 --- /dev/null +++ b/release-assistant/javcra/application/majun/majun_start.py @@ -0,0 +1,155 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ + +import datetime +import requests +from pytz import timezone +from retrying import retry +from javcra.libs.log import logger +from javcra.libs.read_excel import download_file +from javcra.application.checkpart.check_requires.shell_api_tool import ShellCmdApi +from javcra.application.majun import ( + send_content_majun, + get_product_version, + catch_majun_error, +) +from javcra.common.constant import WAIT_NUMBER, WAIT_TIME, CVE_MANAGE_URL + + +class MaJunStart: + """ + cve-manage archiving is triggered to read archived data and send it to majun platform + """ + + def __init__(self) -> None: + self.headers = {"Content-Type": "application/json; charset=utf8"} + + @staticmethod + def cve_list_recombine(cve_list): + """ + cve list Data regroup + Args: + cve_list: cve list + + Returns: + The combined data + """ + new_cve_list = list() + for cve in cve_list[:]: + if "abi是否变化" in cve.keys(): + cve.update({"abiChange": cve.pop("abi是否变化")}) + if "仓库" in cve.keys(): + cve.update({"software": cve.pop("仓库")}) + new_cve_list.append(cve) + return new_cve_list + + def trigger_cve_archive(self, user_email): + """ + cve-manage archiving is triggered + Args: + user_email: user email + + Returns: + cve-manage archiving is triggered + """ + # Take cve within three months + start_time = ( + datetime.datetime.now(tz=timezone("Asia/Shanghai")) + + datetime.timedelta(days=-90) + ).strftime("%Y-%m-%d") + try: + email_name = user_email.split("@")[0] + except AttributeError as error: + logger.error("The CVE List file fails to be archived because %s " % error) + return False + parameter = {"startTime": start_time, "typeName": email_name} + try: + response = requests.get(CVE_MANAGE_URL, headers=self.headers, params=parameter) + except requests.RequestException as error: + logger.error("The CVE List file fails to be archived because %s " % error) + return False + if response.status_code == 200 and "a task being processed" in response.text: + logger.info( + "The CVE-Manager is triggered to generate the CVE list and archive the CVE list" + ) + return True + logger.error( + "The CVE List file fails to be archived," + "The response status code is %s," + "the response body is %s" % (response.status_code, response.text) + ) + return False + + @retry( + stop_max_attempt_number=WAIT_NUMBER, + wait_incrementing_start=WAIT_TIME, + wait_incrementing_increment=WAIT_TIME, + ) + def get_cve_list(self, branch_name, obs_ak, obs_sk): + """ + Obtain CVE-related information provided by the CVE-Manager. + Returns: + cve_list: Data in Excel in dictionary form + """ + now_time = datetime.datetime.now(tz=timezone("Asia/Shanghai")).strftime( + "%Y-%m-%d" + ) + cve_list = download_file( + now_time, "{}_updateinfo.xlsx".format(branch_name), obs_ak, obs_sk + ) + if not cve_list: + logger.error("Failed to obtain CVE data") + raise ValueError("Failed to obtain CVE data") + return cve_list + + @catch_majun_error + def send_cve_list_to_majun(self, params): + """ + start function general entry + Args: + params: Command line argument + Returns: + Data sent to majun results + """ + # Gets the branch and the date + user_email, obs_ak, obs_sk, task_title, majun_id = ( + params.useremail, + params.ak, + params.sk, + params.task_title, + params.id, + ) + # openEuler-20.03-LTS-SP1_update20221013. + branch_name, _, multi_content = get_product_version(task_title) + if not branch_name: + logger.error("Failed to obtain branch") + return send_content_majun([], majun_id) + # trigger cve_manger to archive + resp = self.trigger_cve_archive(user_email) + if not resp: + raise ValueError("trigger cve-manege archive failure") + cve_list = self.get_cve_list(branch_name, obs_ak, obs_sk) + new_cves = self.cve_list_recombine(cve_list) + if multi_content: + obs_project = f"{branch_name.replace('-', ':')}:{multi_content}" + all_multi_packages = ShellCmdApi.call_subprocess( + ["osc", "ls", obs_project] + ).splitlines() + new_cves = [ + new_cve + for new_cve in new_cves[:] + if new_cve.get("software") in all_multi_packages + ] + return send_content_majun(new_cves, majun_id, multip_start=True) + else: + return send_content_majun(new_cves, majun_id) diff --git a/release-assistant/javcra/cli/commands/majun_start.py b/release-assistant/javcra/cli/commands/majun_start.py new file mode 100644 index 0000000..c3a8961 --- /dev/null +++ b/release-assistant/javcra/cli/commands/majun_start.py @@ -0,0 +1,73 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +""" +Description:majun start method's entrance for custom commands +Class:StartMajunCommand +""" +from javcra.cli.base import BaseCommand +from javcra.application.majun.majun_start import MaJunStart + + +class StartMajunCommand(BaseCommand): + """ + Description: start the release assistant + Attributes: + sub_parse: Subcommand parameters + params: Command line parameters + """ + + def __init__(self): + """ + Description: Instance initialization + """ + super(StartMajunCommand, self).__init__() + self.sub_parse = BaseCommand.subparsers.add_parser( + "majunstart", help="majun start" + ) + self.add_obs_ak_arg() + self.add_obs_sk_arg() + self.sub_parse.add_argument( + "--useremail", + type=str, + help="the user's email address", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--task_title", + type=str, + help="task title eg.openEuler-20.03-LTS-SP1_update20221013", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--id", + type=str, + help="uuid", + action="store", + required=True, + ) + + def do_command(self, params): + """ + Description: Executing command + Args: + params: Command line parameters + Returns: + + Raises: + + """ + majunstart = MaJunStart() + majunstart.send_cve_list_to_majun(params) + diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index ca30fd6..22f8204 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -163,3 +163,11 @@ LABEL_DICT = {"start": "check-pkg", "requires": "check-requires", "release": "re MULTI_VERSION_BRANCHS = ["sp2", "sp3", "SP2", "SP3"] CHECK_PART_LIST = ["status", "requires", "test", "cve_bugfix"] +# Number of retries +WAIT_NUMBER = 7 +# Interval waiting times +WAIT_TIME = 90000 +# majun callback url +MAJUN_CALLBACK_URL = "https://majun-beta.osinfra.cn/api/ci-backend/ci-portal/ci-admin/saveJenkinsCallbackResult" +# CVE MANAGE URL +CVE_MANAGE_URL = "https://api.openeuler.org/cve-manager/v1/download/excel/triggerCveData" diff --git a/release-assistant/javcra/libs/read_excel.py b/release-assistant/javcra/libs/read_excel.py index cd01528..afad8ad 100644 --- a/release-assistant/javcra/libs/read_excel.py +++ b/release-assistant/javcra/libs/read_excel.py @@ -77,6 +77,7 @@ def download_file(now_time, file_name, obs_ak, obs_sk): obs_client = ObsCloud(obs_ak, obs_sk, CVE_MANAGE_SERVER, CVE_MANAGE_BUCKET_NAME) # Determine whether the file to be downloaded is in the object of the bucket files = obs_client.bucket_list("{}/{}".format(CVE_UPDATE_INFO, now_time)) + logger.info(f"The current files on the cloud are {files}") file_object = "" for file in files: if "{CVE_UPDATE_INFO}/{date}/{title}".format( -- Gitee From c43c47278913de75342dec24ef353808cfb11953 Mon Sep 17 00:00:00 2001 From: jiangpengjuj Date: Wed, 28 Dec 2022 11:41:12 +0800 Subject: [PATCH 02/16] =?UTF-8?q?release-tools=20update=20=E7=89=88?= =?UTF-8?q?=E6=9C=AC=20check=20version=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javcra/application/majun/__init__.py | 1 + .../application/majun/package_version.py | 252 ++++++++++++++++++ release-assistant/javcra/common/constant.py | 22 +- 3 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 release-assistant/javcra/application/majun/package_version.py diff --git a/release-assistant/javcra/application/majun/__init__.py b/release-assistant/javcra/application/majun/__init__.py index 6626d80..cf304b6 100644 --- a/release-assistant/javcra/application/majun/__init__.py +++ b/release-assistant/javcra/application/majun/__init__.py @@ -151,3 +151,4 @@ def catch_majun_error(func): return send_content_majun(False, params.id) return inner + diff --git a/release-assistant/javcra/application/majun/package_version.py b/release-assistant/javcra/application/majun/package_version.py new file mode 100644 index 0000000..5539df0 --- /dev/null +++ b/release-assistant/javcra/application/majun/package_version.py @@ -0,0 +1,252 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ + +import re +import collections +import requests +from pyrpm.spec import Spec, replace_macros +from requests import RequestException +from javcra.application.checkpart.check_requires.shell_api_tool import ShellCmdApi +from javcra.application.majun import get_product_version, send_content_majun +from javcra.common.constant import BRANCH_MAP, OBS_PROJECT_MULTI_VERSION_MAP +from javcra.libs.log import logger + + +class PackageVersion: + def __init__(self) -> None: + self.pkglist = None + self.majun_id = None + self.branch_map = collections.OrderedDict(BRANCH_MAP) + self.task_title = None + self.repo_arch_map = {"arm": "aarch64", "x86": "x86_64"} + self.headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0", + } + + @staticmethod + def osc_ls_binaries_list(proj, pkg, arch): + """ + Get the binary files archived on OBS + Args: + proj: project name + pkg: package name + arch: arch or x86 + + Returns: + Binary package list + """ + cmd = "osc ls -b {proj} {pkg} {repo} {arch}".format( + proj=proj, pkg=pkg, repo=f"standard_{arch}", arch=arch + ) + stout = ShellCmdApi.call_subprocess(cmd.split()) + return stout + + def parse_spec_version(self, spec_format_url): + """ + Parse spec content + Args: + spec_format_url: repo spec url + + Returns: + version: Package Version + release: package release + """ + version, release = "", "" + try: + response = requests.get(spec_format_url, headers=self.headers) + except RequestException as error: + logger.error(f"An error occurred parsing spec contents {error}") + return version, release + if response.status_code != requests.codes.ok or not response.text: + return version, release + try: + spec = Spec.from_string(response.text) + except AttributeError as error: + logger.error(f"An error occurred parsing spec contents {error}") + return version, release + version = replace_macros(spec.version, spec) + release = replace_macros(spec.release, spec) + return version, release + + def git_package_version(self, packagename, branch_name): + """ + Get the contents in the spec on the git repository + Args: + packagename: package name + branch_name: branch name + + Returns: + package_versions: eg{"22.03":"CUnit-5.3.0"} + """ + package_versions = {} + spec_format_url = f"https://gitee.com/src-openeuler/{packagename}/raw/{branch_name}/{packagename}.spec" + version, release = self.parse_spec_version(spec_format_url) + version, release = (version, release) if version else ("unknow", "unknow") + package_versions[packagename] = {branch_name: f"{version}-{release}"} + return package_versions + + def gitee_package_version(self, branch_name): + """ + gitee repo package name + Args: + branch_name: branch name + + Returns: + packages_version + """ + packages_version = dict() + for packagename in self.pkglist: + packages_version.update(self.git_package_version(packagename, branch_name)) + return packages_version + + def get_osc_pkg_version(self, pkg_name, project, arch): + """ + + Args: + pkg_name: package name + project: project name + arch: Compile structure + + Returns: + version: package version + release: package release + """ + version, release = "", "" + stdout = self.osc_ls_binaries_list(project, pkg_name, arch) + if not stdout: + return version, release + for line in stdout.splitlines(): + if line.strip().endswith(".src.rpm"): + nvr = line.strip().rsplit(".", 2)[0] + nvr_list = nvr.rsplit("-", 2) + version = nvr_list[1] if len(nvr_list) > 1 else "" + release = ( + re.split("\.oe\d+", nvr_list[2])[0] if len(nvr_list) > 2 else "" + ) + return version, release + + def branch_package_version(self, pkg_name, obs_branch): + """ + Software package information of multiple architectures + Args: + pkg_name: pcakage name + obs_branch: obs project name + + Returns: + version: version + release: release + """ + version, release = "", "" + for arch in self.repo_arch_map.values(): + version, release = self.get_osc_pkg_version(pkg_name, obs_branch, arch) + if version: + return version, release + return version, release + + def arch_package_version(self, pkg_name, branch_name): + """ + Obtain the binary package of the software package on OBS, + and obtain the version and release information of the source code package + Args: + pkg_name: package name + branch_name: branch name + + Returns: + package_versions: package name version release + """ + package_versions = {} + obs_branchs = self.branch_map.get(branch_name) + main_package_version, main_package_release = self.branch_package_version( + pkg_name, obs_branchs[0] + ) + if main_package_version: + package_versions[pkg_name] = {branch_name: f"{main_package_version}-{main_package_release}"} + + else: + epol_package_version, epols_package_release = self.branch_package_version( + pkg_name, obs_branchs[1] + ) + package_versions[pkg_name] = {branch_name: f"{epol_package_version}-{epols_package_release}"} + return package_versions + + def obs_package_version(self, branch_name): + """ + obs package version + Args: + branch_name: branch name + + Returns: + packages_version: package version + """ + packages_version = dict() + for pkg_name in self.pkglist: + packages_version.update(self.arch_package_version(pkg_name, branch_name)) + return packages_version + + def mutil_obs_package(self, obs_project, branch_name): + """ + Multi-version software package information + Args: + obs_project: obs project + branch_name: branch name + + Returns: + mutil packages version release + """ + mutil_packages_version = dict() + for pkg_name in self.pkglist: + package_versions = {} + package_version, package_release = self.branch_package_version( + pkg_name, obs_project + ) + package_versions[pkg_name] = {branch_name: f"{package_version}-{package_release}"} + mutil_packages_version.update(package_versions) + return mutil_packages_version + + def run(self, params): + """ + Check the software package version + Args: + params: params + + Returns: + send data to majun + """ + self.majun_id, self.pkglist, self.task_title = ( + params.id, + params.pkglist, + params.task_title, + ) + branch_name, _, multi_content = get_product_version(self.task_title) + if branch_name not in self.branch_map.keys(): + raise ValueError(f"[ERROR]: This branch {branch_name} is not supported") + if multi_content: + obs_project = f"{branch_name.replace('-', ':')}:{multi_content}" + branch_name = OBS_PROJECT_MULTI_VERSION_MAP.get(obs_project) + if not branch_name: + raise ValueError(f"[ERROR]: This branch {obs_project} is not supported") + obs_packages = self.mutil_obs_package(obs_project, branch_name) + else: + obs_packages = self.obs_package_version(branch_name) + gitee_packages = self.gitee_package_version(branch_name) + _package_dict = dict([(pkg, []) for pkg in self.pkglist]) + for _package, branch_and_version in gitee_packages.items(): + _gitee_package_version = branch_and_version.get(branch_name) + _obs_package_version = obs_packages.get(_package, {}).get(branch_name) + if "unknow" not in _gitee_package_version and _gitee_package_version == _obs_package_version: + compare_result = "same" + else: + compare_result = "unknow" + _package_dict[_package] = compare_result + + return send_content_majun(_package_dict, self.majun_id) diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index 22f8204..7f56e78 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -73,7 +73,8 @@ AARCH_FRAME = "aarch64" X86_FRAME = "x86_64" # branch list for standard epol list -BRANCH_LIST = ["openEuler-20.03-LTS-SP1", "openEuler-20.03-LTS-SP2", "openEuler-20.03-LTS-SP3", "openEuler-20.03-LTS", "openEuler-22.03-LTS"] +BRANCH_LIST = ["openEuler-20.03-LTS-SP1", "openEuler-20.03-LTS-SP2", "openEuler-20.03-LTS-SP3", "openEuler-20.03-LTS", + "openEuler-22.03-LTS"] # lts branch LTS_BRANCH = "openEuler-20.03-LTS" @@ -163,6 +164,7 @@ LABEL_DICT = {"start": "check-pkg", "requires": "check-requires", "release": "re MULTI_VERSION_BRANCHS = ["sp2", "sp3", "SP2", "SP3"] CHECK_PART_LIST = ["status", "requires", "test", "cve_bugfix"] + # Number of retries WAIT_NUMBER = 7 # Interval waiting times @@ -171,3 +173,21 @@ WAIT_TIME = 90000 MAJUN_CALLBACK_URL = "https://majun-beta.osinfra.cn/api/ci-backend/ci-portal/ci-admin/saveJenkinsCallbackResult" # CVE MANAGE URL CVE_MANAGE_URL = "https://api.openeuler.org/cve-manager/v1/download/excel/triggerCveData" + +BRANCH_MAP = { + "openEuler-20.03-LTS-SP1": [ + "openEuler:20.03:LTS:SP1", + "openEuler:20.03:LTS:SP1:Epol", + ], + "openEuler-20.03-LTS-SP3": [ + "openEuler:20.03:LTS:SP3", + "openEuler:20.03:LTS:SP3:Epol", + ], + "openEuler-22.03-LTS": ["openEuler:22.03:LTS", "openEuler:22.03:LTS:Epol"], +} + +OBS_PROJECT_MULTI_VERSION_MAP = { + "openEuler:22.03:LTS:Epol:Multi-Version:OpenStack:Train": "Multi-Version_OpenStack-Train_openEuler-22.03-LTS", + "openEuler:22.03:LTS:Epol:Multi-Version:OpenStack:Wallaby": "Multi-Version_OpenStack-Wallaby_openEuler-22.03-LTS", + "openEuler:22.03:LTS:Epol:Multi-Version:obs-server:2.10.11": "Multi-Version_obs-server-2.10.11_openEuler-22.03-LTS", +} -- Gitee From 93b6ad2a3c917e9ab3736df054a1e1c4c584ded9 Mon Sep 17 00:00:00 2001 From: jiangpengjuj Date: Wed, 28 Dec 2022 16:08:36 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E6=93=8D=E4=BD=9C=20repo,=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=95=B0=E6=8D=AE=E7=BB=99=E6=B5=8B=E8=AF=95=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0,cvrf=E5=92=8Cupdate=20info=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javcra/application/majun/majun_operate.py | 406 ++++++++++++++++++ release-assistant/javcra/common/constant.py | 11 +- 2 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 release-assistant/javcra/application/majun/majun_operate.py diff --git a/release-assistant/javcra/application/majun/majun_operate.py b/release-assistant/javcra/application/majun/majun_operate.py new file mode 100644 index 0000000..bd60c6f --- /dev/null +++ b/release-assistant/javcra/application/majun/majun_operate.py @@ -0,0 +1,406 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +import copy +import json +from concurrent.futures import ThreadPoolExecutor, as_completed +import requests +from javcra.api.gitee_api import Issue +from javcra.common.constant import ( + CVE_UPDATE_INFO_JOB_NAME, + CVRF_JOB_NAME, + EPOL_DICT, + MAX_PARAL_NUM, + MULTI_VERSION_BRANCHS, + OBS_PROJECT_MULTI_VERSION_MAP, + REPO_BASE_URL, + TEST_MILESTONE_URL, +) +from javcra.application.majun import ( + catch_majun_error, + get_product_version, + send_content_majun, +) +from javcra.api.jenkins_api import JenkinsJob +from javcra.common import constant +from javcra.libs.log import logger + + +class MajunOperate: + """ + Operation jenkins sends data to majun + """ + + def __init__(self) -> None: + self.task_title = None + self.pkglist = None + self.jenkins_server_obj = None + self.headers = { + "Content-Type": "application/json; charset=utf8", + "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0", + } + + @staticmethod + def get_repo(branch_name, release_date, pkglist): + """ + get repo according to branch 、date and epol + Args: + branch_name: branch name + release_date: Release date + pkglist: package names + + Returns: + repos: Addresses of all generated repo + standard_list: standard package names + epol_list: epol package names + """ + standard_list, epol_list = Issue.get_standard_epol_list(branch_name, pkglist) + base_url = REPO_BASE_URL + branch_name + repos = [{"repo_type": "standard", "url": f"{base_url}/update_{release_date}/"}] + if epol_list: + repo_dict = dict() + repo_dict["repo_type"] = "epol" + if any(mul_branch in branch_name for mul_branch in MULTI_VERSION_BRANCHS): + repo_dict["url"] = f"{base_url}/EPOL/update_{release_date}/main/" + else: + repo_dict["url"] = f"{base_url}/EPOL/update_{release_date}/" + repos.append(repo_dict) + return repos, standard_list, epol_list + + @staticmethod + def judge_result(transfer_res): + """ + Determine jenkins running results + Args: + transfer_res: jenkins results + + Returns: + Return true on success and false on failure + """ + return ( + True + if transfer_res and transfer_res[0].get("status") == "SUCCESS" + else False + ) + + @staticmethod + def jenkins_server( + params, + paral_num=MAX_PARAL_NUM, + release_date="", + branch_name="", + ): + """ + Description: to get the jenkins server + Args: + params: Command line parameters + paral_num: paral num of jenkins job + branch_name: branch name of release issue + release_date: date of release + + Returns: + jenkins server object + """ + jenkins_server = JenkinsJob( + constant.JENKINS_BASE_URL, + params.jenkinsuser, + params.jenkinskey, + paral_num, + branch_name, + release_date, + ) + return jenkins_server + + def send_data_test_platform(self, update_data, majun_id): + """ + Send data to the test platform and get milestones + Args: + update_data: Data sent to the test platform + majun_id: majub id + + Returns: + The result of sending the data to majun + """ + + try: + resp = requests.post( + TEST_MILESTONE_URL, data=json.dumps(update_data), headers=self.headers + ) + except requests.RequestException as error: + raise ValueError(f"Request test failed, {error}") from error + try: + res_text = json.loads(resp.text) + except json.JSONDecodeError as error: + raise ValueError(f"JSONDecodeError,because {error}") from error + if not resp or resp.status_code != 200 or res_text.get("error_code") != "2000": + raise ValueError(f"Request test failed,{resp.status_code} and {resp.text}") + else: + logger.info("Successful milestone acquisition") + return send_content_majun( + res_text.get("data", {}).get("milestone_name"), majun_id + ) + + @catch_majun_error + def send_repo_info(self, params): + """ + to send repo info + Args: + params: Command line argument + Returns: + True or False + """ + majun_id, self.pkglist, self.task_title = ( + params.id, + params.pkglist, + params.task_title, + ) + branch_name, release_date, multi_content = get_product_version(self.task_title) + product_version = branch_name.split("-", 1) + update_data = { + "product": product_version[0], + "version": product_version[1], + "pkgs": self.pkglist, + } + if not multi_content: + # The normal version sends data + repo_list, _, _ = self.get_repo(branch_name, release_date, self.pkglist) + # branch demo: openEuler-20.03-LTS-SP1 + for repo_info in repo_list: + if repo_info.get("repo_type") == "standard": + update_data["base_update_url"] = repo_info.get("url") + else: + update_data["epol_update_url"] = repo_info.get("url") + else: + # Multiple versions send data + multi_contents = multi_content.rsplit(":", 2) + folder_name = f"{multi_contents[-1]}/{multi_contents[-2]}" + + update_data[ + "base_update_url" + ] = f"{REPO_BASE_URL}{branch_name}/update_{release_date}/" + update_data[ + "epol_update_url" + ] = f"{REPO_BASE_URL}{branch_name}/EPOL/update_{release_date}/multi_version/{folder_name}/" + return self.send_data_test_platform(update_data, majun_id) + + def transfer_pkg_rpm(self, *args, pkgs=None): + """ + transfer the rpm package to the server, and comment on the Jenkins + job result on the release issue + """ + obs_project, pkg_family, obs_action, release_date = args + obs_job_params = { + "ScanOSSAPIURL": constant.JENKINS_API_URL, + "ScanOSSResultRepo": constant.JENKINS_SERVER_REPO, + "action": obs_action, + "obs_project": obs_project, + "update_dir": "update_" + release_date, + "package_family": pkg_family, + } + if pkgs: + obs_job_params.update({"pkgnamelist": ",".join(pkgs)}) + jenkins_obs_res = self.jenkins_server_obj.get_specific_job_comment( + obs_job_params, constant.OBS_RELEASE_JOB + ) + return jenkins_obs_res + + @catch_majun_error + def operate_repo(self, params): + """ + Manipulate the main entry to the repo source + Args: + params: Command line argument + + Returns: + result to majun + """ + self.task_title = params.task_title + branch_name, release_date, multi_content = get_product_version(self.task_title) + if multi_content: + obs_project = f"{branch_name.replace('-', ':')}:{multi_content}" + multi_contents = multi_content.rsplit(":", 2) + folder_name = f"{multi_contents[-1]}/{multi_contents[-2]}" + else: + obs_project = branch_name.replace("-", ":") + folder_name = None + # get jenkins_server object + self.jenkins_server_obj = self.jenkins_server( + params, MAX_PARAL_NUM, branch_name, release_date + ) + if params.action in ["create", "del_pkg_rpm", "update"]: + # The create del_pkg_rpm update action is mandatory according to pkglist + if not multi_content: + # Daily version operation + return self._normal_repo(branch_name, release_date, obs_project, params) + else: + # Multiversion operation + return self._multi_repo( + branch_name, release_date, obs_project, params, folder_name + ) + else: + # del_update_dir + stand_transfer_res = self.transfer_pkg_rpm( + obs_project, params.package_family, params.action, release_date + ) + return send_content_majun(self.judge_result(stand_transfer_res), params.id) + + @catch_majun_error + def synchronous_info(self, params): + """ + Call cvrf synchronization and updateinfo to synchronize the jenkins project + Args: + params: Incoming parameter + + Returns: + jenkins runs the result back to majun + """ + self.jenkins_server_obj = self.jenkins_server(params) + jenkins_params = dict( + server=params.server, bucketname=params.bucketname, ipaddr=params.ipaddr + ) + sync_func_map = {"cvrf": "single", "updateinfo": "single", "all": "all"} + return getattr(self, "_{}_sync".format(sync_func_map.get(params.choice)))( + params, jenkins_params + ) + + def _all_sync(self, params, jenkins_params): + """ + Call both the cvrf and update info tasks + Args: + params: Incoming parameter + jenkins_params: jenkins task parameter + + Returns: + Send data to majun + """ + new_params = copy.deepcopy(jenkins_params) + jenkins_params.update({"filename": params.cvrffilename}) + new_params.update({"filename": params.updatefilename}) + with ThreadPoolExecutor(max_workers=2) as pool: + cvrf_future = pool.submit( + self.jenkins_server_obj.get_specific_job_comment, + jenkins_params, + CVRF_JOB_NAME, + ) + updateinfo_future = pool.submit( + self.jenkins_server_obj.get_specific_job_comment, + new_params, + CVE_UPDATE_INFO_JOB_NAME, + ) + jenkins_result = all( + [ + self.judge_result(future.result()) + for future in as_completed([cvrf_future, updateinfo_future]) + ] + ) + # Send data to majun + return send_content_majun(jenkins_result, params.id) + + def _normal_repo(self, branch_name, release_date, obs_project, params): + """ + Daily operation repo + Args: + branch_name: branch name + release_date: release data + obs_project: obs project name + params: Command line argument + + Returns: + Send data to majun result + """ + repos, standard_packages, epol_packages = self.get_repo( + branch_name, release_date, params.pkglist + ) + stand_transfer_res = self.transfer_pkg_rpm( + obs_project, "standard", params.action, release_date, pkgs=standard_packages + ) + if not self.judge_result(stand_transfer_res): + return send_content_majun(False, params.id) + if epol_packages: + pkg_family = EPOL_DICT.get(branch_name) + if not pkg_family: + raise ValueError( + f"failed to get epol name of jenkins job for {branch_name}" + ) + obs_project = obs_project + ":" + "Epol" + epol_transfer_res = self.transfer_pkg_rpm( + obs_project, pkg_family, epol_packages, params.action, release_date + ) + if not self.judge_result(epol_transfer_res): + return send_content_majun(False, params.id) + if params.action == "create": + data = {repo.get("repo_type"): repo.get("url") for repo in repos} + elif params.action == "del_pkg_rpm": + data = ",".join(params.pkglist) + else: + data = True + return send_content_majun(data, params.id) + + def _multi_repo(self, *args): + """ + Multi-version operation repo + Args: + branch_name: branch name + release_date: release data + obs_project: obs project name + params: Command line argument + folder_name: folder name + + Returns: + Send data to majun + """ + branch_name, release_date, obs_project, params, folder_name = args + if obs_project not in OBS_PROJECT_MULTI_VERSION_MAP.keys(): + raise ValueError( + "If the package has multiple versions, package_family must have a value" + ) + package_family = "EPOL-multi_version" + _transfer_res = self.transfer_pkg_rpm( + obs_project, + package_family, + params.action, + release_date, + pkgs=params.pkglist, + ) + if not self.judge_result(_transfer_res): + return send_content_majun(False, params.id) + if params.action == "create": + data = { + "epol": f"{REPO_BASE_URL}{branch_name}/EPOL/update_{release_date}/multi_version/{folder_name}" + } + elif params.action == "del_pkg_rpm": + data = ",".join(params.pkglist) + else: + data = True + return send_content_majun(data, params.id) + + def _single_sync(self, params, jenkins_params): + """ + cvrf or update info jenkins job + Args: + params: incoming params + jenkins_params: jenkins params + + Returns: + send data to majun + """ + if params.choice == "cvrf": + jenkins_params.update({"filename": params.cvrffilename}) + else: + jenkins_params.update({"filename": params.updatefilename}) + jenkins_job = ( + CVRF_JOB_NAME if params.choice == "cvrf" else CVE_UPDATE_INFO_JOB_NAME + ) + jenkins_obs_res = self.jenkins_server_obj.get_specific_job_comment( + jenkins_params, jenkins_job + ) + return send_content_majun(self.judge_result(jenkins_obs_res), params.id) diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index 7f56e78..34b400c 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -161,7 +161,7 @@ COMMENT_DICT = {"cve": "/cve-ok", "bugfix": "/bugfix-ok", "test": "/test-ok"} # label dict LABEL_DICT = {"start": "check-pkg", "requires": "check-requires", "release": "release-check"} -MULTI_VERSION_BRANCHS = ["sp2", "sp3", "SP2", "SP3"] +MULTI_VERSION_BRANCHS = ["sp2", "sp3", "SP2", "SP3", "22.03-LTS"] CHECK_PART_LIST = ["status", "requires", "test", "cve_bugfix"] @@ -191,3 +191,12 @@ OBS_PROJECT_MULTI_VERSION_MAP = { "openEuler:22.03:LTS:Epol:Multi-Version:OpenStack:Wallaby": "Multi-Version_OpenStack-Wallaby_openEuler-22.03-LTS", "openEuler:22.03:LTS:Epol:Multi-Version:obs-server:2.10.11": "Multi-Version_obs-server-2.10.11_openEuler-22.03-LTS", } + +# jenkins cvrf name +CVRF_JOB_NAME = "obs/update_cve_xml_file_automatic" + +# jenkins update info name +CVE_UPDATE_INFO_JOB_NAME = "function-item/update_repodata_by_updateinfo_automatic" + +# Test milestone routing +TEST_MILESTONE_URL = "http://radiatest.openeuler.org/api/v1/openeuler/update-release/validate" \ No newline at end of file -- Gitee From f4b98a26f61ece9efeb70351a598289485d61206 Mon Sep 17 00:00:00 2001 From: jiangpengjuj Date: Wed, 28 Dec 2022 16:27:56 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E8=A7=84=E5=88=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javcra/application/majun/majun_operate.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/release-assistant/javcra/application/majun/majun_operate.py b/release-assistant/javcra/application/majun/majun_operate.py index bd60c6f..2a001ff 100644 --- a/release-assistant/javcra/application/majun/majun_operate.py +++ b/release-assistant/javcra/application/majun/majun_operate.py @@ -86,12 +86,8 @@ class MajunOperate: Returns: Return true on success and false on failure """ - return ( - True - if transfer_res and transfer_res[0].get("status") == "SUCCESS" - else False - ) - + return True if transfer_res and transfer_res[0].get("status") == "SUCCESS" else False + @staticmethod def jenkins_server( params, -- Gitee From 2f90b96f5da0c7f6fed3f0ddfa640462baf166fc Mon Sep 17 00:00:00 2001 From: jiangpengjuj Date: Thu, 29 Dec 2022 17:23:18 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javcra/application/majun/majun_operate.py | 8 ++++---- release-assistant/javcra/common/constant.py | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/release-assistant/javcra/application/majun/majun_operate.py b/release-assistant/javcra/application/majun/majun_operate.py index 2a001ff..1191a82 100644 --- a/release-assistant/javcra/application/majun/majun_operate.py +++ b/release-assistant/javcra/application/majun/majun_operate.py @@ -20,6 +20,7 @@ from javcra.common.constant import ( CVRF_JOB_NAME, EPOL_DICT, MAX_PARAL_NUM, + MILESTONE_SUCCESS_CODE, MULTI_VERSION_BRANCHS, OBS_PROJECT_MULTI_VERSION_MAP, REPO_BASE_URL, @@ -137,7 +138,7 @@ class MajunOperate: res_text = json.loads(resp.text) except json.JSONDecodeError as error: raise ValueError(f"JSONDecodeError,because {error}") from error - if not resp or resp.status_code != 200 or res_text.get("error_code") != "2000": + if not resp or resp.status_code != 200 or res_text.get("error_code") != MILESTONE_SUCCESS_CODE: raise ValueError(f"Request test failed,{resp.status_code} and {resp.text}") else: logger.info("Successful milestone acquisition") @@ -391,11 +392,10 @@ class MajunOperate: """ if params.choice == "cvrf": jenkins_params.update({"filename": params.cvrffilename}) + jenkins_job = CVRF_JOB_NAME else: jenkins_params.update({"filename": params.updatefilename}) - jenkins_job = ( - CVRF_JOB_NAME if params.choice == "cvrf" else CVE_UPDATE_INFO_JOB_NAME - ) + jenkins_job = CVE_UPDATE_INFO_JOB_NAME jenkins_obs_res = self.jenkins_server_obj.get_specific_job_comment( jenkins_params, jenkins_job ) diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index 34b400c..69f80f2 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -199,4 +199,6 @@ CVRF_JOB_NAME = "obs/update_cve_xml_file_automatic" CVE_UPDATE_INFO_JOB_NAME = "function-item/update_repodata_by_updateinfo_automatic" # Test milestone routing -TEST_MILESTONE_URL = "http://radiatest.openeuler.org/api/v1/openeuler/update-release/validate" \ No newline at end of file +TEST_MILESTONE_URL = "http://radiatest.openeuler.org/api/v1/openeuler/update-release/validate" + +MILESTONE_SUCCESS_CODE = "2000" \ No newline at end of file -- Gitee From ab61ce404cfa4c7e6e2f4033c300c4b06293ce4a Mon Sep 17 00:00:00 2001 From: jiangpengjuj Date: Fri, 30 Dec 2022 16:20:43 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E5=8D=8F=E5=8A=A9=E8=8E=B7=E5=8F=96at?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release-assistant/javcra/api/jenkins_api.py | 54 ++++++ .../javcra/application/majun/__init__.py | 49 ++++-- .../javcra/application/majun/majun_at.py | 162 ++++++++++++++++++ release-assistant/javcra/common/constant.py | 41 ++++- 4 files changed, 288 insertions(+), 18 deletions(-) create mode 100644 release-assistant/javcra/application/majun/majun_at.py diff --git a/release-assistant/javcra/api/jenkins_api.py b/release-assistant/javcra/api/jenkins_api.py index 9e697b8..b4c8f65 100644 --- a/release-assistant/javcra/api/jenkins_api.py +++ b/release-assistant/javcra/api/jenkins_api.py @@ -34,6 +34,8 @@ from javcra.common.constant import TRIGGER_TM_JOB from javcra.common.constant import AARCH64_TM_JOB from javcra.common.constant import X86_TM_JOB from javcra.common.constant import ACTUATOR_DICT +from javcra.common.constant import ISO_BUILD_WAIT_NUMBER +from javcra.common.constant import MIN_JENKINS_BUILD_WAIT_TIME def catch_jenkins_error(func): @@ -570,3 +572,55 @@ class JenkinsJob(object): } job_status_list.append(job_name_status_dict) return job_status_list + + + @catch_jenkins_error + def get_jenkins_job_build_result(self, params, job_name, wait_time=MIN_JENKINS_BUILD_WAIT_TIME): + """ + get job status of jenkins job according to job name + Args: + params: params to build jenkins job + job_name: job name + wait_time: The amount of time it takes to get jenkins' result + Returns: + job_status_dict: jenkins build result + """ + build_id = self.build_specific_job(job_name, params) + + if build_id: + job_status = self.wait_job_result_status(job_name, build_id, wait_time) + job_status_dict = { + "name": job_name, + "status": job_status, + "output": self.get_output_hyperlink(job_name, build_id), + } + return [job_status_dict] + + return [] + + @catch_jenkins_error + def wait_job_result_status(self, job_name, job_id, wait_time): + """ + get jenkins job result status + Args: + job_name: job name + job_id: jenkins job build id + wait_time: The amount of time it takes to get jenkins' result + Returns: + build_res: SUCCESS, FAILURE, ABORTED, None(means the job is under building) + """ + get_status_results = 0 + while True: + time.sleep(wait_time) + build_res = self.server.get_build_info(job_name, job_id)["result"] + get_status_results += 1 + if build_res: + break + if get_status_results > ISO_BUILD_WAIT_NUMBER: + build_res = "BUILD" + break + logger.info( + "%s %s build finished. The result status is %s" + % (job_name, job_id, build_res) + ) + return build_res \ No newline at end of file diff --git a/release-assistant/javcra/application/majun/__init__.py b/release-assistant/javcra/application/majun/__init__.py index cf304b6..397c988 100644 --- a/release-assistant/javcra/application/majun/__init__.py +++ b/release-assistant/javcra/application/majun/__init__.py @@ -31,6 +31,13 @@ class MessageCode(Enum): FAILED_CODE = "400" +@unique +class ConstantNumber(Enum): + CON_NUMBER_ZERO = 0 + CON_NUMBER_ONE = 1 + CON_NUMBER_TWO = 2 + + def combine_content(content, majun_id, multip_start): """ jenkins run result @@ -43,9 +50,19 @@ def combine_content(content, majun_id, multip_start): """ content_dic = {"data": content, "id": majun_id} if any([content, multip_start]): - content_dic.update({"code": MessageCode.SUCCESS_CODE.value, "msg": MessageCode.SUCCESS_MESSAGE.value}) + content_dic.update( + { + "code": MessageCode.SUCCESS_CODE.value, + "msg": MessageCode.SUCCESS_MESSAGE.value, + } + ) else: - content_dic.update({"code": MessageCode.FAILED_CODE.value, "msg": MessageCode.FAILURE_MESSAGE.value}) + content_dic.update( + { + "code": MessageCode.FAILED_CODE.value, + "msg": MessageCode.FAILURE_MESSAGE.value, + } + ) return content_dic @@ -89,9 +106,7 @@ def get_product_version(task_title): base_re_str = r"^(.+)_([a-zA-Z]+)(\d+)" if "Multi" in task_title: - re_content = re.compile(f"{base_re_str}_(.+)", re.MULTILINE).search( - task_title - ) + re_content = re.compile(f"{base_re_str}_(.+)", re.MULTILINE).search(task_title) branch_name, release_date, multi_content = ( re_content.group(1), re_content.group(3), @@ -108,16 +123,17 @@ def get_product_version(task_title): raise ValueError(f"This branch {branch_name} is not supported yet") if release_date.isdigit(): freeze_date = ( - datetime.datetime.strptime(release_date, "%Y%m%d") - + datetime.timedelta(days=2) + datetime.datetime.strptime(release_date, "%Y%m%d") + + datetime.timedelta(days=2) ).strftime("%Y%m%d") else: re_release_date = re.compile(r"(\d+)(\D+)", re.MULTILINE).search(release_date) new_update_time, temporary_str = re_content.group(1), re_release_date.group(2) - freeze_date = (datetime.datetime.strptime(new_update_time, "%Y%m%d") + - datetime.timedelta(days=2)).strftime( - "%Y%m%d") + temporary_str + freeze_date = ( + datetime.datetime.strptime(new_update_time, "%Y%m%d") + + datetime.timedelta(days=2) + ).strftime("%Y%m%d") + temporary_str return branch_name, freeze_date, multi_content @@ -140,15 +156,14 @@ def catch_majun_error(func): ) return func(*args, **kwargs) except ( - ValueError, - AttributeError, - KeyError, - TypeError, - FileNotFoundError, - IndexError + ValueError, + AttributeError, + KeyError, + TypeError, + FileNotFoundError, + IndexError, ) as err: logger.error(f"repo {err}") return send_content_majun(False, params.id) return inner - diff --git a/release-assistant/javcra/application/majun/majun_at.py b/release-assistant/javcra/application/majun/majun_at.py new file mode 100644 index 0000000..fa67d66 --- /dev/null +++ b/release-assistant/javcra/application/majun/majun_at.py @@ -0,0 +1,162 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +""" +at use-case results assist in obtaining +""" +import re +import datetime +import requests +from javcra.common.constant import ( + DAYLIBUILD_URL, + ISO_ARCH_MAP, + MAX_PARAL_NUM, + OBS_KEY_NAMES, + OBS_VALUES_NAMES, + VM_IP_MAP, + MAX_ISO_BUILD_WAIT_TIME, +) +from javcra.application.majun import ( + ConstantNumber, + catch_majun_error, + get_product_version, + send_content_majun, +) +from javcra.application.majun.majun_operate import MajunOperate + + +class MaJunAt: + def __init__(self) -> None: + self.task_title = None + self.iso_build_first_info = None + self.iso_build_last_info = None + self.jenkins_server_obj = None + self.iso_build_url = None + self.headers = { + "Content-Type": "application/json; charset=utf8", + "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0", + } + + @staticmethod + def get_iso_single_build_time(branch_name, arch_url): + """ + The iso address of the single arch + Args: + branch_name: branch name + arch_url: arch name url + + Returns: + iso_build_url: iso build url + + """ + try: + resp = requests.get(f"{DAYLIBUILD_URL}{branch_name}/{arch_url}/release_iso") + except requests.RequestException as error: + raise ValueError( + f"An error occurred at the parse iso build time, because {error}" + ) from error + if not resp or resp.status_code != requests.codes.ok: + raise ValueError("Failed to obtain the iso compile time. Procedure") + iso_build_url = resp.text.rstrip() + base_re = r"^(.+)(openeuler-)([\d|-]+)(.+)" + openeuler_build_time = re.compile(base_re).search(iso_build_url) + iso_build_time = datetime.datetime.strptime( + openeuler_build_time.group(3), + "%Y-%m-%d-%H-%M-%S", + ) + return iso_build_url, iso_build_time + + @staticmethod + def jenkins_param(branch_name): + """ + Compose jenkins task parameters + Args: + branch_name: branch name + + Returns: + base_param: jenkins parameters after composition + """ + base_param = { + "set_release_dir": ConstantNumber.CON_NUMBER_ONE.value, + "update_release_info": ConstantNumber.CON_NUMBER_ZERO.value, + "make_iso": ConstantNumber.CON_NUMBER_ONE.value, + "make_docker_image": ConstantNumber.CON_NUMBER_ONE.value, + "make_iso_everything": ConstantNumber.CON_NUMBER_ONE.value, + "make_iso_everysrc": ConstantNumber.CON_NUMBER_ONE.value, + "make_debug_everything": ConstantNumber.CON_NUMBER_ONE.value, + "make_hmi": ConstantNumber.CON_NUMBER_ONE.value, + "make_netinst_iso": ConstantNumber.CON_NUMBER_ONE.value, + "make_raspi_image": ConstantNumber.CON_NUMBER_ONE.value, + } + base_param.update(dict(vm_ip=VM_IP_MAP.get(branch_name))) + base_param.update(dict(zip(OBS_KEY_NAMES, OBS_VALUES_NAMES.get(branch_name)))) + return base_param + + def all_iso_time(self, branch_name): + """ + Get the iso urls for the different arch + Args: + branch_name: branch name + + Returns: + all_iso_info: iso addresses for different architectures + """ + all_iso_info = dict() + for arch_name, arch_url in ISO_ARCH_MAP.items(): + iso_build_url, iso_build_time = self.get_iso_single_build_time( + branch_name, arch_url + ) + all_iso_info[arch_name] = dict( + iso_build_url=iso_build_url, iso_build_time=iso_build_time + ) + return all_iso_info + + @catch_majun_error + def run(self, params): + """ + Function main entry + Args: + params: Parameter from the command line + + Returns: + Send the results to majun + """ + self.task_title = params.task_title + branch_name, freeze_date, _ = get_product_version(self.task_title) + # Gets the first build time of the iso build. + self.iso_build_first_info = self.all_iso_time(branch_name) + self.jenkins_server_obj = MajunOperate.jenkins_server( + params, MAX_PARAL_NUM, branch_name, freeze_date + ) + jenkins_params = self.jenkins_param(branch_name) + jenkins_job = f"openEuler-OS-build/Main-{branch_name}-build" + res = self.jenkins_server_obj.get_jenkins_job_build_result( + jenkins_params, jenkins_job, MAX_ISO_BUILD_WAIT_TIME + ) + if not res or res[0].get("status") != "SUCCESS": + raise ValueError( + "The iso construction fails. Check the cause of the failure" + ) + # Gets the last build time of the iso build. + self.iso_build_last_info = self.all_iso_time(branch_name) + iso_urls = list() + for arch_name, iso_info in self.iso_build_last_info.items(): + if ( + iso_info.get("iso_build_time") + - self.iso_build_first_info.get(arch_name).get("iso_build_time") + ).seconds <= 0: + raise ValueError( + "The iso url is not updated. Check the cause manually" + ) + else: + iso_urls.append(iso_info.get("iso_build_url")) + return send_content_majun(";".join(iso_urls), params.id) diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index 69f80f2..96d1dd6 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -201,4 +201,43 @@ CVE_UPDATE_INFO_JOB_NAME = "function-item/update_repodata_by_updateinfo_automati # Test milestone routing TEST_MILESTONE_URL = "http://radiatest.openeuler.org/api/v1/openeuler/update-release/validate" -MILESTONE_SUCCESS_CODE = "2000" \ No newline at end of file +MILESTONE_SUCCESS_CODE = "2000" +DAYLIBUILD_URL = "http://121.36.84.172/dailybuild/" + +ISO_ARCH_MAP = {"ARM64": "openeuler_ARM64", "X86": "openeuler_X86"} + +OBS_KEY_NAMES = ["obs_standard_prj", "obs_epol_prj", "obs_extras_prj"] + +OBS_VALUES_NAMES = { + "openEuler-22.09": [ + "openEuler:22.09", + "openEuler:22.09:Epol", + "openEuler:22.09:Extras", + ], + "openEuler-20.03-LTS-SP1": [ + "openEuler:20.03:LTS:SP1", + "openEuler:20.03:LTS:SP1:Epol", + "openEuler:20.03:LTS:SP1:Extras", + ], + "openEuler-20.03-LTS-SP3": [ + "openEuler:20.03:LTS:SP3", + "openEuler:20.03:LTS:SP3:Epol", + "openEuler:20.03:LTS:SP3:Extras", + ], + "openEuler-22.03-LTS": [ + "openEuler:22.03:LTS", + "openEuler:22.03:LTS:Epol", + "openEuler:22.03:LTS:Epol:Extras", + ], +} + +VM_IP_MAP = { + "openEuler-22.09": "172.16.1.155", + "openEuler-20.03-LTS-SP1": "172.16.1.32", + "openEuler-20.03-LTS-SP3": "172.16.1.32", + "openEuler-22.03-LTS": "172.16.1.32", +} + +MIN_JENKINS_BUILD_WAIT_TIME = 5 +MAX_ISO_BUILD_WAIT_TIME = 1200 +ISO_BUILD_WAIT_NUMBER = 6 -- Gitee From af5d09d55304a94cac562bf08a2f8c9f158904e1 Mon Sep 17 00:00:00 2001 From: jiangpengjuj Date: Thu, 5 Jan 2023 19:09:33 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=20=E5=8D=8F=E5=8A=A9=E8=8E=B7=E5=8F=96at?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E7=BB=93=E6=9E=9C,=20=E6=94=AF=E6=8C=8122.03?= =?UTF-8?q?-sp1=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javcra/application/majun/majun_at.py | 5 +- .../application/majun/package_version.py | 11 +- release-assistant/javcra/cli/cmd.py | 18 ++- .../javcra/cli/commands/majun_at.py | 77 ++++++++++++ .../cli/commands/majun_check_version.py | 68 +++++++++++ .../javcra/cli/commands/majun_operate_repo.py | 97 +++++++++++++++ .../javcra/cli/commands/majun_send_test.py | 68 +++++++++++ .../javcra/cli/commands/majun_synchronous.py | 110 ++++++++++++++++++ release-assistant/javcra/common/constant.py | 41 ++++--- .../check_requires/support_branch.yaml | 2 + .../yum.repo/openEuler-22.03-LTS-SP1.repo | 86 ++++++++++++++ 11 files changed, 564 insertions(+), 19 deletions(-) create mode 100644 release-assistant/javcra/cli/commands/majun_at.py create mode 100644 release-assistant/javcra/cli/commands/majun_check_version.py create mode 100644 release-assistant/javcra/cli/commands/majun_operate_repo.py create mode 100644 release-assistant/javcra/cli/commands/majun_send_test.py create mode 100644 release-assistant/javcra/cli/commands/majun_synchronous.py create mode 100644 release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-22.03-LTS-SP1.repo diff --git a/release-assistant/javcra/application/majun/majun_at.py b/release-assistant/javcra/application/majun/majun_at.py index fa67d66..31c3768 100644 --- a/release-assistant/javcra/application/majun/majun_at.py +++ b/release-assistant/javcra/application/majun/majun_at.py @@ -24,6 +24,7 @@ from javcra.common.constant import ( OBS_VALUES_NAMES, VM_IP_MAP, MAX_ISO_BUILD_WAIT_TIME, + ISO_BUILD_JOB_MAP ) from javcra.application.majun import ( ConstantNumber, @@ -85,6 +86,8 @@ class MaJunAt: Returns: base_param: jenkins parameters after composition """ + # jenkins parameter combination with multiple constants of the numbers 1 and 0, + # which are obtained using the enumeration class base_param = { "set_release_dir": ConstantNumber.CON_NUMBER_ONE.value, "update_release_info": ConstantNumber.CON_NUMBER_ZERO.value, @@ -138,7 +141,7 @@ class MaJunAt: params, MAX_PARAL_NUM, branch_name, freeze_date ) jenkins_params = self.jenkins_param(branch_name) - jenkins_job = f"openEuler-OS-build/Main-{branch_name}-build" + jenkins_job = ISO_BUILD_JOB_MAP.get(branch_name) res = self.jenkins_server_obj.get_jenkins_job_build_result( jenkins_params, jenkins_job, MAX_ISO_BUILD_WAIT_TIME ) diff --git a/release-assistant/javcra/application/majun/package_version.py b/release-assistant/javcra/application/majun/package_version.py index 5539df0..12431d7 100644 --- a/release-assistant/javcra/application/majun/package_version.py +++ b/release-assistant/javcra/application/majun/package_version.py @@ -17,7 +17,7 @@ import requests from pyrpm.spec import Spec, replace_macros from requests import RequestException from javcra.application.checkpart.check_requires.shell_api_tool import ShellCmdApi -from javcra.application.majun import get_product_version, send_content_majun +from javcra.application.majun import catch_majun_error, get_product_version, send_content_majun from javcra.common.constant import BRANCH_MAP, OBS_PROJECT_MULTI_VERSION_MAP from javcra.libs.log import logger @@ -74,8 +74,12 @@ class PackageVersion: except AttributeError as error: logger.error(f"An error occurred parsing spec contents {error}") return version, release - version = replace_macros(spec.version, spec) - release = replace_macros(spec.release, spec) + try: + version = replace_macros(spec.version, spec) + release = replace_macros(spec.release, spec) + except TypeError as error: + logger.error(f"An error occurred parsing spec contents {error}") + return version, release return version, release def git_package_version(self, packagename, branch_name): @@ -213,6 +217,7 @@ class PackageVersion: mutil_packages_version.update(package_versions) return mutil_packages_version + @catch_majun_error def run(self, params): """ Check the software package version diff --git a/release-assistant/javcra/cli/cmd.py b/release-assistant/javcra/cli/cmd.py index e3d6ccd..0ee9188 100644 --- a/release-assistant/javcra/cli/cmd.py +++ b/release-assistant/javcra/cli/cmd.py @@ -22,6 +22,22 @@ from javcra.cli.commands.startpart import StartCommand # pylint: disable=unused from javcra.cli.commands.releasepart import ReleaseCommand # pylint: disable=unused-import from javcra.cli.commands.modifypart import ModifyCommand # pylint: disable=unused-import from javcra.cli.commands.checkpart import CheckCommand # pylint: disable=unused-import +from javcra.cli.commands.majun_start import ( + StartMajunCommand, +) # pylint: disable=unused-import +from javcra.cli.commands.majun_send_test import ( + MajunSendCommand, +) # pylint: disable=unused-import +from javcra.cli.commands.majun_operate_repo import ( + MajunOperateRepoCommand, +) # pylint: disable=unused-import +from javcra.cli.commands.majun_synchronous import ( + MajunSynchronousCommand, +) # pylint: disable=unused-import +from javcra.cli.commands.majun_check_version import ( + CheckVersionMajunCommand, +) # pylint: disable=unused-import +from javcra.cli.commands.majun_at import AtMajunCommand # pylint: disable=unused-import def main(): @@ -38,5 +54,5 @@ def main(): # add all arguments' attribution into instance BaseCommand().args_parser() except Error: - print('Command execution error please try again') + print("Command execution error please try again") print(Error) diff --git a/release-assistant/javcra/cli/commands/majun_at.py b/release-assistant/javcra/cli/commands/majun_at.py new file mode 100644 index 0000000..2229369 --- /dev/null +++ b/release-assistant/javcra/cli/commands/majun_at.py @@ -0,0 +1,77 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +""" +Description: majun at method's entrance for custom commands +Class:AtMajunCommand +""" +from javcra.cli.base import BaseCommand +from javcra.application.majun.majun_at import MaJunAt + + +class AtMajunCommand(BaseCommand): + """ + Description: start the release assistant + Attributes: + sub_parse: Subcommand parameters + params: Command line parameters + """ + + def __init__(self): + """ + Description: Instance initialization + """ + super(AtMajunCommand, self).__init__() + self.sub_parse = BaseCommand.subparsers.add_parser( + "majunat", help="assist majun at result" + ) + self.sub_parse.add_argument( + "--id", + type=str, + help="majun uuid", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--task_title", + type=str, + help="Software release tasks e.g openEuler-20.03-LTS-SP1_update20221013", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--jenkinsuser", + type=str, + help="provide your jenkinsuser", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--jenkinskey", + type=str, + help="provide your jenkins key", + action="store", + required=True, + ) + + def do_command(self, params): + """ + Description: Executing command + Args: + params: Command line parameters + Returns: + + Raises: + + """ + majunat = MaJunAt() + majunat.run(params) diff --git a/release-assistant/javcra/cli/commands/majun_check_version.py b/release-assistant/javcra/cli/commands/majun_check_version.py new file mode 100644 index 0000000..4141b7c --- /dev/null +++ b/release-assistant/javcra/cli/commands/majun_check_version.py @@ -0,0 +1,68 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +""" +Description: majun method's entrance for custom commands +Class:CheckVersionMajunCommand +""" + +from javcra.cli.base import BaseCommand + +from javcra.application.majun.package_version import PackageVersion + + +class CheckVersionMajunCommand(BaseCommand): + """ + Description: start the release assistant + Attributes: + sub_parse: Subcommand parameters + params: Command line parameters + """ + + def __init__(self): + """ + Description: Instance initialization + """ + super(CheckVersionMajunCommand, self).__init__() + self.sub_parse = BaseCommand.subparsers.add_parser( + "majuncheck", help="majun check package version" + ) + self.sub_parse.add_argument( + "--pkglist", required=True, nargs="+", help="package names" + ) + self.sub_parse.add_argument( + "--id", + type=str, + help="uuid", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--task_title", + type=str, + help="Software release tasks e.g openEuler-20.03-LTS-SP1_update20221013", + action="store", + required=True, + ) + + def do_command(self, params): + """ + Description: Executing command + Args: + params: Command line parameters + Returns: + + Raises: + + """ + package_version = PackageVersion() + package_version.run(params) diff --git a/release-assistant/javcra/cli/commands/majun_operate_repo.py b/release-assistant/javcra/cli/commands/majun_operate_repo.py new file mode 100644 index 0000000..088e39e --- /dev/null +++ b/release-assistant/javcra/cli/commands/majun_operate_repo.py @@ -0,0 +1,97 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +""" +Description: majun method's entrance for custom commands +Class:MajunOperateRepoCommand +""" +from javcra.cli.base import BaseCommand +from javcra.application.majun.majun_operate import MajunOperate + + +class MajunOperateRepoCommand(BaseCommand): + """ + Description: start the release assistant + Attributes: + sub_parse: Subcommand parameters + params: Command line parameters + """ + + def __init__(self): + """ + Description: Instance initialization + """ + super(MajunOperateRepoCommand, self).__init__() + self.sub_parse = BaseCommand.subparsers.add_parser( + "majunrepo", help="majun operate repo" + ) + self.sub_parse.add_argument( + "--task_title", + type=str, + help="task title eg.openEuler-20.03-LTS-SP1_update20221013", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--pkglist", required=False, nargs="+", help="package names" + ) + self.sub_parse.add_argument( + "--id", + type=str, + help="uuid", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--jenkinsuser", + type=str, + help="provide your jenkinsuser", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--jenkinskey", + type=str, + help="provide your jenkins key", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--action", + type=str, + help="the action of the repo operation", + action="store", + required=True, + choices=["create", "del_pkg_rpm", "update", "del_update_dir"], + ) + self.sub_parse.add_argument( + "--package_family", + type=str, + help="owning group of the software package", + action="store", + required=False, + choices=["standard", "EPOL", "EPOL-main", "EPOL-multi_version"], + ) + + def do_command(self, params): + """ + Description: Executing command + Args: + params: Command line parameters + Returns: + + Raises: + + """ + + checkmajun = MajunOperate() + checkmajun.operate_repo(params) diff --git a/release-assistant/javcra/cli/commands/majun_send_test.py b/release-assistant/javcra/cli/commands/majun_send_test.py new file mode 100644 index 0000000..322c713 --- /dev/null +++ b/release-assistant/javcra/cli/commands/majun_send_test.py @@ -0,0 +1,68 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +""" +Description:majun method's entrance for custom commands +Class:MajunSendCommand +""" + +from javcra.cli.base import BaseCommand +from javcra.application.majun.majun_operate import MajunOperate + + +class MajunSendCommand(BaseCommand): + """ + Description: start the release assistant + Attributes: + sub_parse: Subcommand parameters + params: Command line parameters + """ + + def __init__(self): + """ + Description: Instance initialization + """ + super(MajunSendCommand, self).__init__() + self.sub_parse = BaseCommand.subparsers.add_parser( + "majunsend", help="majun send data to raidatest" + ) + self.sub_parse.add_argument( + "--task_title", + type=str, + help="task title eg.openEuler-20.03-LTS-SP1_update20221013", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--pkglist", required=True, nargs="+", help="package names" + ) + self.sub_parse.add_argument( + "--id", + type=str, + help="majun id", + action="store", + required=True, + ) + + def do_command(self, params): + """ + Description: Executing command + Args: + params: Command line parameters + Returns: + + Raises: + + """ + + checkmajun = MajunOperate() + checkmajun.send_repo_info(params) diff --git a/release-assistant/javcra/cli/commands/majun_synchronous.py b/release-assistant/javcra/cli/commands/majun_synchronous.py new file mode 100644 index 0000000..3b1a72a --- /dev/null +++ b/release-assistant/javcra/cli/commands/majun_synchronous.py @@ -0,0 +1,110 @@ +#!/usr/bin/python3 +# ****************************************************************************** +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +# PURPOSE. +# See the Mulan PSL v2 for more details. +# ******************************************************************************/ +from javcra.cli.base import BaseCommand +from javcra.application.majun.majun_operate import MajunOperate + + +class MajunSynchronousCommand(BaseCommand): + """ + Description: start the release assistant + Attributes: + sub_parse: Subcommand parameters + params: Command line parameters + """ + + def __init__(self): + """ + Description: Instance initialization + """ + super(MajunSynchronousCommand, self).__init__() + self.sub_parse = BaseCommand.subparsers.add_parser( + "majunsync", help="updateinfo synchronization and cvrf synchronization" + ) + self.sub_parse.add_argument( + "--choice", + type=str, + help="synchronous data platform", + action="store", + required=True, + choices=["cvrf", "updateinfo", "all"], + ) + self.sub_parse.add_argument( + "--jenkinsuser", + type=str, + help="provide your jenkinsuser", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--jenkinskey", + type=str, + help="provide your jenkins key", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--server", + type=str, + help="The distribution store background background", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--bucketname", + type=str, + help="name of the bucket where the object is stored", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--cvrffilename", + type=str, + help="directory file name", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--updatefilename", + type=str, + help="directory file name", + action="store", + required=True, + ) + self.sub_parse.add_argument( + "--ipaddr", + type=str, + help="IP address of the publishing machine", + action="store", + required=False, + ) + self.sub_parse.add_argument( + "--id", + type=str, + help="uuid", + action="store", + required=True, + ) + + def do_command(self, params): + """ + Description: Executing command + Args: + params: Command line parameters + Returns: + + Raises: + + """ + + check_majun = MajunOperate() + check_majun.synchronous_info(params) diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index 96d1dd6..783a95f 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -74,7 +74,7 @@ X86_FRAME = "x86_64" # branch list for standard epol list BRANCH_LIST = ["openEuler-20.03-LTS-SP1", "openEuler-20.03-LTS-SP2", "openEuler-20.03-LTS-SP3", "openEuler-20.03-LTS", - "openEuler-22.03-LTS"] + "openEuler-22.03-LTS", "openEuler-22.03-LTS-SP1"] # lts branch LTS_BRANCH = "openEuler-20.03-LTS" @@ -105,7 +105,8 @@ ACTUATOR_DICT = { "openEuler-20.03-LTS-SP2": "openeuler-20.03-lts-sp2", "openEuler-20.03-LTS-SP3": "openeuler-20.03-lts-sp3", "openEuler-20.03-LTS": "openeuler-20.03-lts", - "openEuler-22.03-LTS": "openeuler-22.03-lts" + "openEuler-22.03-LTS": "openeuler-22.03-lts", + "openEuler-22.03-LTS-SP1": "openeuler-22.03-lts-sp1", } # git warehouse address for release issue @@ -120,9 +121,6 @@ JENKINS_SERVER_REPO = "121.36.53.23" # install jenkins job prefix INSTALL_JOB_PREFIX = "function-item/release-manager/update_template_jobs/install_" -# job for upload package rpm to server -OBS_RELEASE_JOB = "obs/update_release_pkg_rpm" - # jenkins base url JENKINS_BASE_URL = 'https://jenkins.openeuler.org' @@ -152,7 +150,8 @@ EPOL_DICT = { "openEuler-20.03-LTS-SP1": "EPOL", "openEuler-20.03-LTS-SP2": "EPOL-main", "openEuler-20.03-LTS-SP3": "EPOL-main", - "openEuler-22.03-LTS": "EPOL-main" + "openEuler-22.03-LTS": "EPOL-main", + "openEuler-22.03-LTS-SP1": "EPOL-main" } # comment dict @@ -161,7 +160,7 @@ COMMENT_DICT = {"cve": "/cve-ok", "bugfix": "/bugfix-ok", "test": "/test-ok"} # label dict LABEL_DICT = {"start": "check-pkg", "requires": "check-requires", "release": "release-check"} -MULTI_VERSION_BRANCHS = ["sp2", "sp3", "SP2", "SP3", "22.03-LTS"] +MULTI_VERSION_BRANCHS = ["sp2", "sp3", "SP2", "SP3", "22.03-LTS", "22.03-LTS-SP1"] CHECK_PART_LIST = ["status", "requires", "test", "cve_bugfix"] @@ -184,6 +183,10 @@ BRANCH_MAP = { "openEuler:20.03:LTS:SP3:Epol", ], "openEuler-22.03-LTS": ["openEuler:22.03:LTS", "openEuler:22.03:LTS:Epol"], + "openEuler-22.03-LTS-SP1": [ + "openEuler:22.03:LTS:SP1", + "openEuler:22.03:LTS:SP1:Epol", + ], } OBS_PROJECT_MULTI_VERSION_MAP = { @@ -198,6 +201,9 @@ CVRF_JOB_NAME = "obs/update_cve_xml_file_automatic" # jenkins update info name CVE_UPDATE_INFO_JOB_NAME = "function-item/update_repodata_by_updateinfo_automatic" +# job for upload package rpm to server +OBS_RELEASE_JOB = "obs/update_release_pkg_rpm" + # Test milestone routing TEST_MILESTONE_URL = "http://radiatest.openeuler.org/api/v1/openeuler/update-release/validate" @@ -209,11 +215,6 @@ ISO_ARCH_MAP = {"ARM64": "openeuler_ARM64", "X86": "openeuler_X86"} OBS_KEY_NAMES = ["obs_standard_prj", "obs_epol_prj", "obs_extras_prj"] OBS_VALUES_NAMES = { - "openEuler-22.09": [ - "openEuler:22.09", - "openEuler:22.09:Epol", - "openEuler:22.09:Extras", - ], "openEuler-20.03-LTS-SP1": [ "openEuler:20.03:LTS:SP1", "openEuler:20.03:LTS:SP1:Epol", @@ -227,15 +228,27 @@ OBS_VALUES_NAMES = { "openEuler-22.03-LTS": [ "openEuler:22.03:LTS", "openEuler:22.03:LTS:Epol", - "openEuler:22.03:LTS:Epol:Extras", + "openEuler:22.03:LTS:Extras", + ], + "openEuler-22.03-LTS-SP1": [ + "openEuler:22.03:LTS:SP1", + "openEuler:22.03:LTS:SP1:Epol", + "openEuler:22.03:LTS:SP1:Extras", ], } VM_IP_MAP = { - "openEuler-22.09": "172.16.1.155", "openEuler-20.03-LTS-SP1": "172.16.1.32", "openEuler-20.03-LTS-SP3": "172.16.1.32", "openEuler-22.03-LTS": "172.16.1.32", + "openEuler-22.03-LTS-SP1": "172.16.1.95", +} + +ISO_BUILD_JOB_MAP = { + "openEuler-20.03-LTS-SP1": "openEuler-OS-build/Main-openEuler-20.03-LTS-SP1-build", + "openEuler-20.03-LTS-SP3": "openEuler-OS-build/Main-openEuler-20.03-LTS-SP3-build", + "openEuler-22.03-LTS": "openEuler-OS-build/Main-openEuler-22.03-LTS-build", + "openEuler-22.03-LTS-SP1": "openEuler-OS-build/Main-openEuler-22.03-LTS-SP1-build", } MIN_JENKINS_BUILD_WAIT_TIME = 5 diff --git a/release-assistant/javcra/libs/config/checkpart/check_requires/support_branch.yaml b/release-assistant/javcra/libs/config/checkpart/check_requires/support_branch.yaml index 8ba4925..574761d 100644 --- a/release-assistant/javcra/libs/config/checkpart/check_requires/support_branch.yaml +++ b/release-assistant/javcra/libs/config/checkpart/check_requires/support_branch.yaml @@ -9,3 +9,5 @@ openEuler : obs_alias: "openEuler:20.03:LTS:SP3" openEuler-22.03-LTS: obs_alias: "openEuler:22.03:LTS" + openEuler-22.03-LTS-SP1: + obs_alias: "openEuler:22.03:LTS:SP1" diff --git a/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-22.03-LTS-SP1.repo b/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-22.03-LTS-SP1.repo new file mode 100644 index 0000000..c0f0ac8 --- /dev/null +++ b/release-assistant/javcra/libs/config/checkpart/check_requires/yum.repo/openEuler-22.03-LTS-SP1.repo @@ -0,0 +1,86 @@ +#generic-repos is licensed under the Mulan PSL v2. +#You can use this software according to the terms and conditions of the Mulan PSL v2. +#You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +#THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR +#IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR +#PURPOSE. +#See the Mulan PSL v2 for more details. + +#binary repo + +[published-everything] +name=published-everything +baseurl=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/everything/$basearch/ +enabled=1 +gpgcheck=0 +priority=2 +gpgkey=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/everything/$basearch/RPM-GPG-KEY-openEuler + +[published-update] +name=published-update +baseurl=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/update/$basearch/ +enabled=1 +gpgcheck=0 +priority=1 +gpgkey=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/update/$basearch/RPM-GPG-KEY-openEuler + +[published-debuginfo] +name=published-debuginfo +baseurl=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/debuginfo/$basearch/ +enabled=0 +gpgcheck=0 +gpgkey=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/debuginfo/$basearch/RPM-GPG-KEY-openEuler + +[devel-obs] +name=devel-obs +baseurl=http://119.3.219.20:82/openEuler:/22.03:/LTS/standard_$basearch/ +enabled=1 +gpgcheck=0 +priority=3 + +#source repo + +[published-everything-src] +name=published-everything-src +baseurl=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/source +enabled=0 +gpgcheck=0 +gpgkey=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/source/$basearch/RPM-GPG-KEY-openEuler + +[published-update-src] +name=published-update-src +baseurl=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/update/source +enabled=0 +gpgcheck=0 +gpgkey=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/update/source/RPM-GPG-KEY-openEuler + +#EPOL binary repo + +[published-EPOL] +name=published-EPOL +baseurl=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/EPOL/$basearch/ +enabled=0 +gpgcheck=0 +gpgkey=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/OS/$basearch/RPM-GPG-KEY-openEuler + +[published-Epol-src] +name=published-Epol-src +baseurl=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/EPOL/main/source/ +enabled=0 +gpgcheck=0 +gpgkey=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/EPOL/main/source/RPM-GPG-KEY-openEuler + +[published-Epol-update-src] +name=published-Epol-update-src +baseurl=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/EPOL/update/main/source +enabled=0 +gpgcheck=0 +gpgkey=https://repo.openeuler.org/openEuler-22.03-LTS-SP1/EPOL/update/main/source/RPM-GPG-KEY-openEuler + +[devel-obs] +name=devel-obs +baseurl=http://119.3.219.20:82/openEuler:/22.03:/LTS:/SP1:/Epol/standard_$basearch/ +enabled=1 +gpgcheck=0 +priority=3 -- Gitee From 8796e4da77ba5396e3bb64d78734eef8ad84464a Mon Sep 17 00:00:00 2001 From: muyuying Date: Tue, 21 Feb 2023 11:54:44 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9majun=20=E5=9B=9E?= =?UTF-8?q?=E8=AA=BF=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改majun回調地址 --- release-assistant/javcra/common/constant.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index 783a95f..b332c40 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -169,7 +169,8 @@ WAIT_NUMBER = 7 # Interval waiting times WAIT_TIME = 90000 # majun callback url -MAJUN_CALLBACK_URL = "https://majun-beta.osinfra.cn/api/ci-backend/ci-portal/ci-admin/saveJenkinsCallbackResult" +MAJUN_CALLBACK_URL = \ + "https://majun-beta.osinfra.cn/api/http/majun-platform-release/publish/jenkins/saveJenkinsCallbackResult" # CVE MANAGE URL CVE_MANAGE_URL = "https://api.openeuler.org/cve-manager/v1/download/excel/triggerCveData" @@ -207,7 +208,7 @@ OBS_RELEASE_JOB = "obs/update_release_pkg_rpm" # Test milestone routing TEST_MILESTONE_URL = "http://radiatest.openeuler.org/api/v1/openeuler/update-release/validate" -MILESTONE_SUCCESS_CODE = "2000" +MILESTONE_SUCCESS_CODE = "2000" DAYLIBUILD_URL = "http://121.36.84.172/dailybuild/" ISO_ARCH_MAP = {"ARM64": "openeuler_ARM64", "X86": "openeuler_X86"} -- Gitee From 9aee781ad77370a78c090b065eaefd500d21ec25 Mon Sep 17 00:00:00 2001 From: muyuying Date: Sat, 6 May 2023 10:51:23 +0800 Subject: [PATCH 09/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9JENKINS=5FBASE=5FURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release-assistant/javcra/common/constant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index b332c40..3dd7fb8 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -122,7 +122,7 @@ JENKINS_SERVER_REPO = "121.36.53.23" INSTALL_JOB_PREFIX = "function-item/release-manager/update_template_jobs/install_" # jenkins base url -JENKINS_BASE_URL = 'https://jenkins.openeuler.org' +JENKINS_BASE_URL = 'https://openeulerjenkins.osinfra.cn' REALSE_TOOLS_BUCKET_NAME = "release-tools" -- Gitee From b302c561e53579a5f4b5410de9ae804b4bcaca7f Mon Sep 17 00:00:00 2001 From: muyuying Date: Mon, 13 Nov 2023 11:05:02 +0800 Subject: [PATCH 10/16] add print --- release-assistant/javcra/application/majun/majun_at.py | 1 + 1 file changed, 1 insertion(+) diff --git a/release-assistant/javcra/application/majun/majun_at.py b/release-assistant/javcra/application/majun/majun_at.py index 31c3768..6065f3e 100644 --- a/release-assistant/javcra/application/majun/majun_at.py +++ b/release-assistant/javcra/application/majun/majun_at.py @@ -61,6 +61,7 @@ class MaJunAt: """ try: resp = requests.get(f"{DAYLIBUILD_URL}{branch_name}/{arch_url}/release_iso") + print(f"{DAYLIBUILD_URL}{branch_name}/{arch_url}/release_iso") except requests.RequestException as error: raise ValueError( f"An error occurred at the parse iso build time, because {error}" -- Gitee From 6aec5844c96248176bf098192518a11ed6087d60 Mon Sep 17 00:00:00 2001 From: muyuying Date: Mon, 13 Nov 2023 14:46:05 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E6=94=B9branch=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release-assistant/javcra/application/majun/majun_at.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release-assistant/javcra/application/majun/majun_at.py b/release-assistant/javcra/application/majun/majun_at.py index 6065f3e..657c157 100644 --- a/release-assistant/javcra/application/majun/majun_at.py +++ b/release-assistant/javcra/application/majun/majun_at.py @@ -59,6 +59,8 @@ class MaJunAt: iso_build_url: iso build url """ + if branch_name in ['openEuler-22.03-LTS-SP1','openEuler-22.03-LTS-SP2','openEuler-22.03-LTS-SP3','openEuler-20.03-LTS-SP4']: + branch_name = "EBS-" + branch_name try: resp = requests.get(f"{DAYLIBUILD_URL}{branch_name}/{arch_url}/release_iso") print(f"{DAYLIBUILD_URL}{branch_name}/{arch_url}/release_iso") -- Gitee From 08e5cdebe2b1ba8a92d49b70c34c7a854e684497 Mon Sep 17 00:00:00 2001 From: muyuying Date: Mon, 13 Nov 2023 16:38:50 +0800 Subject: [PATCH 12/16] add log --- release-assistant/javcra/api/jenkins_api.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/release-assistant/javcra/api/jenkins_api.py b/release-assistant/javcra/api/jenkins_api.py index b4c8f65..02a61e4 100644 --- a/release-assistant/javcra/api/jenkins_api.py +++ b/release-assistant/javcra/api/jenkins_api.py @@ -196,7 +196,7 @@ class JenkinsJob(object): """ try: queue_item = self.server.build_job(job_name, params) - + logger.info("failed to build the job: %s ,params: %s" % (job_name, params)) # If the task of build jenkins job fails, then retry count = 0 while not queue_item and count < retry: @@ -573,7 +573,6 @@ class JenkinsJob(object): job_status_list.append(job_name_status_dict) return job_status_list - @catch_jenkins_error def get_jenkins_job_build_result(self, params, job_name, wait_time=MIN_JENKINS_BUILD_WAIT_TIME): """ @@ -623,4 +622,4 @@ class JenkinsJob(object): "%s %s build finished. The result status is %s" % (job_name, job_id, build_res) ) - return build_res \ No newline at end of file + return build_res -- Gitee From 59b583dda99ba9d60841394fcacf35a8e2fb6383 Mon Sep 17 00:00:00 2001 From: muyuying Date: Mon, 13 Nov 2023 16:56:23 +0800 Subject: [PATCH 13/16] add log --- release-assistant/javcra/api/jenkins_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/release-assistant/javcra/api/jenkins_api.py b/release-assistant/javcra/api/jenkins_api.py index 02a61e4..6a8bab6 100644 --- a/release-assistant/javcra/api/jenkins_api.py +++ b/release-assistant/javcra/api/jenkins_api.py @@ -194,6 +194,7 @@ class JenkinsJob(object): queue_item: a queue item number """ + logger.info("failed to build the job: %s ,params: %s" % (job_name, params)) try: queue_item = self.server.build_job(job_name, params) logger.info("failed to build the job: %s ,params: %s" % (job_name, params)) -- Gitee From bff906e8a3889afec0c519159e630ca31a230130 Mon Sep 17 00:00:00 2001 From: muyuying Date: Mon, 13 Nov 2023 19:43:00 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9job=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release-assistant/javcra/common/constant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index 658bc2f..b001e20 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -260,7 +260,7 @@ ISO_BUILD_JOB_MAP = { "openEuler-20.03-LTS-SP1": "openEuler-OS-build/Main-openEuler-20.03-LTS-SP1-build", "openEuler-20.03-LTS-SP3": "openEuler-OS-build/Main-openEuler-20.03-LTS-SP3-build", "openEuler-22.03-LTS": "openEuler-OS-build/Main-openEuler-22.03-LTS-build", - "openEuler-22.03-LTS-SP1": "openEuler-OS-build/Main-openEuler-22.03-LTS-SP1-build", + "openEuler-22.03-LTS-SP1": "EBS-OS-build/Main-openEuler-22.03-LTS-SP1-EBS", } MIN_JENKINS_BUILD_WAIT_TIME = 5 -- Gitee From 94b2462bf2c62adfc98d5ab5bdeb15df1a39b0f1 Mon Sep 17 00:00:00 2001 From: muyuying Date: Tue, 14 Nov 2023 11:53:32 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E6=B7=BB=E5=8A=A02203=20sp2=E5=88=86?= =?UTF-8?q?=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release-assistant/javcra/api/jenkins_api.py | 2 -- .../javcra/application/majun/majun_at.py | 1 - release-assistant/javcra/common/constant.py | 21 ++++++++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/release-assistant/javcra/api/jenkins_api.py b/release-assistant/javcra/api/jenkins_api.py index 6a8bab6..5e4d0e7 100644 --- a/release-assistant/javcra/api/jenkins_api.py +++ b/release-assistant/javcra/api/jenkins_api.py @@ -194,10 +194,8 @@ class JenkinsJob(object): queue_item: a queue item number """ - logger.info("failed to build the job: %s ,params: %s" % (job_name, params)) try: queue_item = self.server.build_job(job_name, params) - logger.info("failed to build the job: %s ,params: %s" % (job_name, params)) # If the task of build jenkins job fails, then retry count = 0 while not queue_item and count < retry: diff --git a/release-assistant/javcra/application/majun/majun_at.py b/release-assistant/javcra/application/majun/majun_at.py index 657c157..130b0f8 100644 --- a/release-assistant/javcra/application/majun/majun_at.py +++ b/release-assistant/javcra/application/majun/majun_at.py @@ -63,7 +63,6 @@ class MaJunAt: branch_name = "EBS-" + branch_name try: resp = requests.get(f"{DAYLIBUILD_URL}{branch_name}/{arch_url}/release_iso") - print(f"{DAYLIBUILD_URL}{branch_name}/{arch_url}/release_iso") except requests.RequestException as error: raise ValueError( f"An error occurred at the parse iso build time, because {error}" diff --git a/release-assistant/javcra/common/constant.py b/release-assistant/javcra/common/constant.py index b001e20..f8c88d8 100644 --- a/release-assistant/javcra/common/constant.py +++ b/release-assistant/javcra/common/constant.py @@ -167,7 +167,7 @@ COMMENT_DICT = {"cve": "/cve-ok", "bugfix": "/bugfix-ok", "test": "/test-ok"} # label dict LABEL_DICT = {"start": "check-pkg", "requires": "check-requires", "release": "release-check"} -MULTI_VERSION_BRANCHS = ["sp2", "sp3", "SP2", "SP3", "22.03-LTS", "22.03-LTS-SP1"] +MULTI_VERSION_BRANCHS = ["sp2", "sp3", "SP2", "SP3", "22.03-LTS", "22.03-LTS-SP1", "22.03-LTS-SP2"] CHECK_PART_LIST = ["status", "requires", "test", "cve_bugfix", "versions"] @@ -199,6 +199,10 @@ BRANCH_MAP = { "openEuler:22.03:LTS:SP1", "openEuler:22.03:LTS:SP1:Epol", ], + "openEuler-22.03-LTS-SP2": [ + "openEuler:22.03:LTS:SP2", + "openEuler:22.03:LTS:SP2:Epol", + ] } OBS_PROJECT_MULTI_VERSION_MAP = { @@ -247,6 +251,11 @@ OBS_VALUES_NAMES = { "openEuler:22.03:LTS:SP1:Epol", "openEuler:22.03:LTS:SP1:Extras", ], + "openEuler-22.03-LTS-SP2": [ + "openEuler:22.03:LTS:SP2", + "openEuler:22.03:LTS:SP2:Epol", + "openEuler:22.03:LTS:SP2:Extras", + ] } VM_IP_MAP = { @@ -254,6 +263,7 @@ VM_IP_MAP = { "openEuler-20.03-LTS-SP3": "172.16.1.32", "openEuler-22.03-LTS": "172.16.1.32", "openEuler-22.03-LTS-SP1": "172.16.1.95", + "openEuler-22.03-LTS-SP2": "172.16.1.155" } ISO_BUILD_JOB_MAP = { @@ -261,21 +271,22 @@ ISO_BUILD_JOB_MAP = { "openEuler-20.03-LTS-SP3": "openEuler-OS-build/Main-openEuler-20.03-LTS-SP3-build", "openEuler-22.03-LTS": "openEuler-OS-build/Main-openEuler-22.03-LTS-build", "openEuler-22.03-LTS-SP1": "EBS-OS-build/Main-openEuler-22.03-LTS-SP1-EBS", + "openEuler-22.03-LTS-SP2": "EBS-OS-build/Main-openEuler-22.03-LTS-SP2-EBS" } MIN_JENKINS_BUILD_WAIT_TIME = 5 MAX_ISO_BUILD_WAIT_TIME = 1200 ISO_BUILD_WAIT_NUMBER = 6 -#staff +# staff VERSION_MANAGER = "@gitee-cmd @zhangtao2020" DEVELOPER = "@gitee-cmd @zhangtao2020 @caodongxia @yaoxin" SECURITY_COMMITTEE = "@yanxiaobing2020 @gitee-cmd @zhangtao2020" TESTER = "@gitee-cmd @zhangtao2020 @disnight" -#check cvrf and package's configuration +# check cvrf and package's configuration VERSION_LIST = ["openEuler-22.03-LTS", "openEuler-22.03-LTS-SP1", "openEuler-20.03-LTS-SP1", "openEuler-20.03-LTS-SP3", - "openEuler-22.03-LTS/EPOL", "openEuler-22.03-LTS-SP1/EPOL", "openEuler-20.03-LTS-SP1/EPOL", - "openEuler-20.03-LTS-SP3/EPOL"] + "openEuler-22.03-LTS-SP2", "openEuler-22.03-LTS/EPOL", "openEuler-22.03-LTS-SP1/EPOL", + "openEuler-20.03-LTS-SP1/EPOL", "openEuler-20.03-LTS-SP3/EPOL", "openEuler-22.03-LTS-SP2/EPOL"] ARCH_LIST = ["aarch64", "source", "x86_64", "noarch"] # openEuler test repo url -- Gitee From 700ba91483a7e175eb03e7f6cfc7cd008bf246b7 Mon Sep 17 00:00:00 2001 From: muyuying Date: Tue, 14 Nov 2023 14:31:48 +0800 Subject: [PATCH 16/16] clean code --- release-assistant/javcra/application/majun/majun_at.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/release-assistant/javcra/application/majun/majun_at.py b/release-assistant/javcra/application/majun/majun_at.py index 130b0f8..addc9e2 100644 --- a/release-assistant/javcra/application/majun/majun_at.py +++ b/release-assistant/javcra/application/majun/majun_at.py @@ -59,7 +59,8 @@ class MaJunAt: iso_build_url: iso build url """ - if branch_name in ['openEuler-22.03-LTS-SP1','openEuler-22.03-LTS-SP2','openEuler-22.03-LTS-SP3','openEuler-20.03-LTS-SP4']: + if branch_name in ['openEuler-22.03-LTS-SP1', 'openEuler-22.03-LTS-SP2', 'openEuler-22.03-LTS-SP3', + 'openEuler-20.03-LTS-SP4']: branch_name = "EBS-" + branch_name try: resp = requests.get(f"{DAYLIBUILD_URL}{branch_name}/{arch_url}/release_iso") @@ -156,8 +157,8 @@ class MaJunAt: iso_urls = list() for arch_name, iso_info in self.iso_build_last_info.items(): if ( - iso_info.get("iso_build_time") - - self.iso_build_first_info.get(arch_name).get("iso_build_time") + iso_info.get("iso_build_time") + - self.iso_build_first_info.get(arch_name).get("iso_build_time") ).seconds <= 0: raise ValueError( "The iso url is not updated. Check the cause manually" -- Gitee