push-two-week-atomic.py fixes/refactor #101
1 changed files with 50 additions and 26 deletions
|
|
@ -60,8 +60,8 @@ ATOMIC_EMAIL_RECIPIENTS = [
|
|||
# Full path will be:
|
||||
# /pub/alt/stage/$VERSION-$DATE/$IMAGE_TYPE/x86_64/[Images|os]/
|
||||
# http://dl.fedoraproject.org/pub/alt/atomic/stable/
|
||||
ATOMIC_TESTING_BASEDIR = "/pub/alt/atomic/testing/"
|
||||
ATOMIC_STABLE_DESTINATION = "/pub/alt/atomic/stable/"
|
||||
ATOMIC_LINKDEST = "/pub/alt/atomic/testing/"
|
||||
ATOMIC_STABLE_BASEDIR = "/pub/alt/atomic/stable/"
|
||||
|
||||
# the modname gets used to construct the fully qualified topic, like
|
||||
# 'org.fedoraproject.prod.releng.blahblahblah'
|
||||
|
|
@ -116,9 +116,13 @@ def construct_url(msg):
|
|||
|
||||
Takes an autocloud fedmsg message and returns the image name and final url.
|
||||
"""
|
||||
dest_dir = ATOMIC_STABLE_DESTINATION + 'CloudImages/x86_64/images/'
|
||||
dest_dir = os.path.join(
|
||||
ATOMIC_STABLE_BASEDIR,
|
||||
msg[u'msg'][u'compose_id'],
|
||||
'CloudImages/x86_64/images/'
|
||||
)
|
||||
image_name = msg[u'msg'][u'compose_url'].split('/')[-1]
|
||||
image_url = dest_dir + image_name
|
||||
image_url = os.path.join(dest_dir, image_name)
|
||||
return image_name, image_url
|
||||
|
||||
|
||||
|
|
@ -390,6 +394,9 @@ Images can be found here:
|
|||
Respective signed CHECKSUM files can be found here:
|
||||
{}
|
||||
|
||||
For direct download, the "latest" target is always available here:
|
||||
https://download.fedoraproject.org/pub/alt/atomic/stable/latest/
|
||||
|
||||
Thank you,
|
||||
Fedora Release Engineering
|
||||
""".format(
|
||||
|
|
@ -409,12 +416,11 @@ Fedora Release Engineering
|
|||
except smtplib.SMTPException, e:
|
||||
print "ERROR: Unable to send email:\n{}\n".format(e)
|
||||
|
||||
|
||||
def stage_atomic_release(
|
||||
compose_id,
|
||||
compose_basedir=COMPOSE_BASEDIR,
|
||||
testing_basedir=ATOMIC_TESTING_BASEDIR,
|
||||
dest_dir=ATOMIC_STABLE_DESTINATION):
|
||||
dest_base_dir=ATOMIC_STABLE_BASEDIR,
|
||||
link_dest=ATOMIC_LINKDEST):
|
||||
"""
|
||||
stage_atomic_release
|
||||
|
||||
|
|
@ -424,6 +430,7 @@ def stage_atomic_release(
|
|||
"""
|
||||
|
||||
source_loc = os.path.join(compose_basedir, compose_id, "compose")
|
||||
dest_dir = os.path.join(dest_base_dir, compose_id)
|
||||
|
||||
# FIXME - need sudo until pungi perms are fixed
|
||||
rsync_cmd = [
|
||||
|
|
@ -431,7 +438,7 @@ def stage_atomic_release(
|
|||
'rsync -avhHP --delete-after',
|
||||
'--link-dest={}'.format(
|
||||
os.path.join(
|
||||
testing_basedir,
|
||||
link_dest,
|
||||
compose_id.split('-')[-1]
|
||||
)
|
||||
),
|
||||
|
|
@ -447,7 +454,6 @@ def stage_atomic_release(
|
|||
)
|
||||
exit(3)
|
||||
|
||||
|
||||
def sign_checksum_files(
|
||||
key,
|
||||
artifact_path,
|
||||
|
|
@ -567,30 +573,47 @@ def fedmsg_publish(topic, msg):
|
|||
pass
|
||||
|
||||
|
||||
def prune_old_testing_composes(
|
||||
prune_limit=ATOMIC_COMPOSE_PERSIST_LIMIT,
|
||||
prune_base_dir=ATOMIC_TESTING_BASEDIR):
|
||||
def prune_old_composes(prune_base_dir, prune_limit):
|
||||
"""
|
||||
prune_old_testing_composes
|
||||
prune_old_composes
|
||||
|
||||
Clean up old testing composes from /pub/alt/
|
||||
|
||||
:param prune_base_dir: str, path to base diretory needing pruning
|
||||
:param prune_limit: int, the number of composes that should be kept,
|
||||
pruning all others.
|
||||
"""
|
||||
|
||||
prune_candidate_dirs = os.listdir(prune_base_dir)
|
||||
|
||||
for testing_dir in prune_candidate_dirs[prune_limit:]:
|
||||
try:
|
||||
shutil.rmtree(
|
||||
os.path.join(prune_base_dir, testing_dir)
|
||||
)
|
||||
except OSError, e:
|
||||
log.error(
|
||||
"Error trying to remove directory: {}\n{}".format(
|
||||
testing_dir,
|
||||
e
|
||||
)
|
||||
)
|
||||
# Sort then reverse so we can slice the list from [0:prune_limit]
|
||||
prune_candidate_dirs.sort()
|
||||
prune_candidate_dirs.reverse()
|
||||
|
||||
for candidate_dir in prune_candidate_dirs[0:prune_limit]:
|
||||
#try:
|
||||
# shutil.rmtree(
|
||||
# os.path.join(prune_base_dir, candidate_dir)
|
||||
# )
|
||||
#except OSError, e:
|
||||
# log.error(
|
||||
# "Error trying to remove directory: {}\n{}".format(
|
||||
# candidate_dir,
|
||||
# e
|
||||
# )
|
||||
# )
|
||||
|
||||
#FIXME - need to do this with sudo until pungi perms are fixed
|
||||
prune_cmd = "sudo rm -fr {}".format(
|
||||
os.path.join(
|
||||
prune_base_dir,
|
||||
candidate_dir
|
||||
)
|
||||
)
|
||||
if subprocess.call(prune_cmd.split()):
|
||||
log.error(
|
||||
"prune_old_composes: command failed: {}".format(prune_cmd)
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
|
@ -641,7 +664,7 @@ if __name__ == '__main__':
|
|||
log.info("Extracting compose_id from tested autocloud data")
|
||||
compose_id = tested_autocloud_info['atomic_qcow2']['compose_id']
|
||||
|
||||
log.info("Signing image metadata")
|
||||
log.info("Signing image metadata - compose")
|
||||
sign_checksum_files(
|
||||
pargs.key,
|
||||
os.path.join(COMPOSE_BASEDIR, compose_id),
|
||||
|
|
@ -659,7 +682,8 @@ if __name__ == '__main__':
|
|||
log.info("Sending Two Week Atomic announcement email")
|
||||
# Find all the Atomic images and CHECKSUM files to include in the email
|
||||
email_filelist = []
|
||||
for full_dir_path, _, short_names in os.walk(ATOMIC_STABLE_DESTINATION):
|
||||
for full_dir_path, _, short_names in \
|
||||
os.walk(os.join(ATOMIC_STABLE_BASEDIR, compose_id)):
|
||||
for sname in fnmatch.filter(short_names, '*Atomic*'):
|
||||
email_filelist.append(
|
||||
os.path.join(
|
||||
|
|
@ -673,7 +697,7 @@ if __name__ == '__main__':
|
|||
send_atomic_announce_email(set(email_filelist))
|
||||
|
||||
log.info("Pruning old Atomic test composes")
|
||||
prune_old_testing_composes()
|
||||
prune_old_composes(ATOMIC_STABLE_BASEDIR, 2)
|
||||
|
||||
log.info("Two Week Atomic Release Complete!")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue