Merge "stx tool: repomgr: Add the support of repomgr module"

This commit is contained in:
Zuul 2021-09-24 14:22:42 +00:00 committed by Gerrit Code Review
commit 32ffad761c
2 changed files with 55 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import logging
from stx import command # pylint: disable=E0611
from stx import stx_configparser # pylint: disable=E0611
from stx import stx_control # pylint: disable=E0611
from stx import stx_repomgr # pylint: disable=E0611
from stx import utils # pylint: disable=E0611
logger = logging.getLogger('STX')
@ -88,6 +89,16 @@ settings.\t\teg: [ --show|--get|--add|--unset|--remove-section ]')
required=False)
config_subparser.set_defaults(handle=self.handleconfig.handleConfig)
repo_subparser = subparsers.add_parser('repomgr',
help='Manage source|binary \
packages.\t\teg: [ list|download|sync|mirror|clean|remove_repo|upload_pkg|\
delete_pkg ]')
repo_subparser.add_argument('repomgr_task',
help='[ list|download|sync|mirror|clean|\
remove_repo|upload_pkg|delete_pkg ]: \
Execute the management task.\n\n')
repo_subparser.set_defaults(handle=stx_repomgr.handleRepomgr)
parser.add_argument('-d', '--debug',
help='Enable debug output\n\n',
action='store_const', const=logging.DEBUG,

View File

@ -0,0 +1,44 @@
# Copyright (c) 2021 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from stx import command # pylint: disable=E0611
from stx import utils # pylint: disable=E0611
import subprocess
logger = logging.getLogger('STX-Repomgr')
utils.set_logger(logger)
def handleRepomgr(args):
'''Sync the repo '''
logger.setLevel(args.loglevel)
logger.debug('Execute the repomgr command: [%s]', args.repomgr_task)
podname = command.get_pod_name('builder')
if not podname:
logger.error('The builder container does not exist, so please \
consider to use the control module')
prefix_cmd = command.generatePrefixCommand(podname, '', 1)
cmd = prefix_cmd + '"repo_manage.py ' + args.repomgr_task + '"\''
logger.debug('Manage the repo with the command [%s]', cmd)
try:
subprocess.check_call(cmd, shell=True)
except subprocess.CalledProcessError as exc:
raise Exception('Failed to manage the repo with the command [%s].\n \
Returncode: %s' % (cmd, exc.returncode))