From 0c40c03ff2c8919d24ccaf068af94ddf68b84635 Mon Sep 17 00:00:00 2001 From: beierlm Date: Tue, 30 Jun 2020 13:36:26 -0400 Subject: [PATCH] Update Artifactory URL Updates the artifactory URL to point to the new Artifactory server. Change-Id: I3d6b67861037364da32e571a5d61cc2aa83af978 Signed-off-by: beierlm (cherry picked from commit ff4016f59de7e49c2747db4e5982a09469c20a47) --- tools/cleanupBuilds.py | 41 ++++++++++++++++++++++------------------- tools/cleanupRepo.py | 2 +- tools/getbuild.py | 10 +++++----- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/tools/cleanupBuilds.py b/tools/cleanupBuilds.py index 2c44ae23..4e6dfbcb 100755 --- a/tools/cleanupBuilds.py +++ b/tools/cleanupBuilds.py @@ -25,12 +25,12 @@ from dateutil.tz import tzutc from datetime import datetime import time -arg_parser=argparse.ArgumentParser(description="Tool to retrieve the latest build from the artifactory server") +arg_parser = argparse.ArgumentParser(description="Tool to retrieve the latest build from the artifactory server") arg_parser.add_argument('branch') -arg_parser.add_argument('--project',default='osm-stage_3') -arg_parser.add_argument('--url',default='http://osm1.etsi.org:8081/') -arg_parser.add_argument('--keep',default=5) -arg_parser.add_argument('--password',default='') +arg_parser.add_argument('--project', default='osm-stage_3') +arg_parser.add_argument('--url', default='https://artifactory-osm.etsi.org/') +arg_parser.add_argument('--keep', default=5) +arg_parser.add_argument('--password', default='') args = arg_parser.parse_args() url = args.url + 'artifactory/api/build/' + args.project + " :: " + args.branch @@ -42,7 +42,7 @@ if 'buildsNumbers' not in jsonData: exit(1) # first entry is the latest build -buildlist = sorted(jsonData['buildsNumbers'], key=lambda x: int(x['uri'][1:]),reverse=True) +buildlist = sorted(jsonData['buildsNumbers'], key=lambda x: int(x['uri'][1:]), reverse=True) print("total builds is {}".format(len(buildlist))) pprint.pprint(buildlist) @@ -50,15 +50,17 @@ if len(buildlist) < args.keep: print("nothing to cleanup") exit(0) + def convert_to_ms(datetime): - #get the millisecond from the date/time - ms=datetime.split('.')[1].split('+')[0] - parser_out=parser.parse(datetime) - timeval=parser_out - tuple=int(time.mktime(timeval.timetuple())) - return (tuple*1000+int(ms)-(time.timezone*1000)) + # get the millisecond from the date/time + ms = datetime.split('.')[1].split('+')[0] + parser_out = parser.parse(datetime) + timeval = parser_out + tuple = int(time.mktime(timeval.timetuple())) + return (tuple * 1000 + int(ms) - (time.timezone * 1000)) + -def buildPost(dateInMS,buildNumber): +def buildPost(dateInMS, buildNumber): build = {} data = {} build['buildName'] = args.project + " :: " + args.branch @@ -68,14 +70,15 @@ def buildPost(dateInMS,buildNumber): data['buildsCoordinates'] = list() data['buildsCoordinates'].append(build) return data - + + delete_url = args.url + 'artifactory/ui/builds/buildsDelete' headers = {'Content-Type': 'application/json'} for entry in buildlist[int(args.keep):]: - ms = convert_to_ms(entry['started']) - buildNumber = entry['uri'].split('/')[1] - print("deleting build {} ms {}".format(args.project + " :: " + args.branch + '/' + buildNumber,ms)) - postData = buildPost(ms,entry['uri'].split('/')[1]) + ms = convert_to_ms(entry['started']) + buildNumber = entry['uri'].split('/')[1] + print("deleting build {} ms {}".format(args.project + " :: " + args.branch + '/' + buildNumber, ms)) + postData = buildPost(ms, entry['uri'].split('/')[1]) - requests.post(delete_url,data=json.dumps(postData),headers=headers,auth=('admin',args.password)) + requests.post(delete_url, data=json.dumps(postData), headers=headers, auth=('admin', args.password)) diff --git a/tools/cleanupRepo.py b/tools/cleanupRepo.py index d25b5c55..997d6bf1 100755 --- a/tools/cleanupRepo.py +++ b/tools/cleanupRepo.py @@ -28,7 +28,7 @@ import time arg_parser=argparse.ArgumentParser(description="Tool to retrieve the latest build from the artifactory server") arg_parser.add_argument('--branch',default=None) arg_parser.add_argument('repo') -arg_parser.add_argument('--url',default='http://osm1.etsi.org:8081/') +arg_parser.add_argument('--url',default='https://artifactory-osm.etsi.org/) arg_parser.add_argument('--keep',default=5) arg_parser.add_argument('--password',default='') arg_parser.add_argument('--debug',default=None) diff --git a/tools/getbuild.py b/tools/getbuild.py index de4dcdff..7a54ba05 100755 --- a/tools/getbuild.py +++ b/tools/getbuild.py @@ -20,10 +20,10 @@ import json import pprint import argparse -parser=argparse.ArgumentParser(description="Tool to retrieve the latest build from the artifactory server") +parser = argparse.ArgumentParser(description="Tool to retrieve the latest build from the artifactory server") parser.add_argument('branch') -parser.add_argument('--project',default='osm-stage_3') -parser.add_argument('--url',default='http://osm1.etsi.org:8081/artifactory/api/build/') +parser.add_argument('--project', default='osm-stage_3') +parser.add_argument('--url', default='https://artifactory-osm.etsi.org/artifactory/api/build/') args = parser.parse_args() url = args.url + args.project + " :: " + args.branch @@ -36,6 +36,6 @@ if 'buildsNumbers' not in jsonData: exit(1) # first entry is the latest build -build = sorted(jsonData['buildsNumbers'], key=lambda x: int(x['uri'][1:]),reverse=True)[0] +build = sorted(jsonData['buildsNumbers'], key=lambda x: int(x['uri'][1:]), reverse=True)[0] -print "{} :: {}{}".format(args.project,args.branch,build['uri']) +print "{} :: {}{}".format(args.project, args.branch, build['uri']) -- 2.25.1