Skip to content

Commit

Permalink
In the mirror script first connect with the S3 API
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt committed Dec 11, 2023
1 parent 7c82146 commit a03949f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions openstack_image_manager/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,33 @@ def main(
logger.remove()
logger.add(sys.stderr, format=log_fmt, level=level, colorize=True)

client = Minio(
minio_server,
access_key=minio_access_key,
secret_key=minio_secret_key,
)

result = client.bucket_exists(minio_bucket)
if not result:
logger.error(f"Create bucket '{minio_bucket}' first")
if not dry_run:
sys.exit(1)

onlyfiles = []
for f in listdir(images):
if isfile(join(images, f)):
logger.debug(f"Adding {f} to the list of files")
onlyfiles.append(f)

all_images = []
for file in onlyfiles:
for file in [x for x in onlyfiles if x.endswith(".yml")]:
logger.info(f"Processing file {file}")
with open(join(images, file)) as fp:
data = yaml.load(fp, Loader=yaml.SafeLoader)
for image in data.get("images"):
logger.debug(f"Adding {image['name']} to the list of images")
all_images.append(image)

client = Minio(
minio_server,
access_key=minio_access_key,
secret_key=minio_secret_key,
)

result = client.bucket_exists(minio_bucket)
if not result:
logger.error(f"Create bucket '{minio_bucket}' first")

for image in all_images:
if "versions" not in image:
continue
Expand Down

0 comments on commit a03949f

Please sign in to comment.