openstack-image-manager 0.20240723.0__py3-none-any.whl → 0.20240828.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -92,9 +92,14 @@ class ImageManager:
92
92
  "project", "--share-type", help="Share - Type: 'project' or 'domain'"
93
93
  ),
94
94
  check: bool = typer.Option(
95
+ True,
96
+ "--check/--no-check",
97
+ help="Check the local image definitions against the SCS Image Metadata Standard (and process the images)",
98
+ ),
99
+ check_only: bool = typer.Option(
95
100
  False,
96
- "--check",
97
- help="Check the local image definitions against the SCS Image Metadata Standard",
101
+ "--check-only",
102
+ help="Quit after checking the image definitions against the SCS Image Metadata Standard",
98
103
  ),
99
104
  ):
100
105
  self.CONF = Munch.fromDict(locals())
@@ -209,11 +214,14 @@ class ImageManager:
209
214
  )
210
215
 
211
216
  # check local image definitions with yamale
212
- if self.CONF.check:
217
+ if self.CONF.check or self.CONF.check_only:
213
218
  self.validate_yaml_schema()
214
219
 
220
+ if self.CONF.check_only:
221
+ return
222
+
215
223
  # share image (previously share.py)
216
- elif self.CONF.share_image:
224
+ if self.CONF.share_image:
217
225
  self.create_connection()
218
226
  image = self.conn.get_image(self.CONF.share_image)
219
227
 
@@ -355,6 +363,9 @@ class ImageManager:
355
363
  if "image_description" not in image["meta"]:
356
364
  image["meta"]["image_description"] = image["name"]
357
365
 
366
+ if "image_name" not in image["meta"]:
367
+ image["meta"]["image_name"] = image["name"]
368
+
358
369
  existing_images, imported_image, previous_image = self.process_image(
359
370
  image, versions, sorted_versions, image["meta"].copy()
360
371
  )
@@ -362,7 +373,7 @@ class ImageManager:
362
373
 
363
374
  if imported_image and image["multi"]:
364
375
  self.rename_images(
365
- image["name"], sorted_versions, imported_image, previous_image
376
+ image, sorted_versions, imported_image, previous_image
366
377
  )
367
378
 
368
379
  return managed_images
@@ -511,11 +522,14 @@ class ImageManager:
511
522
  previous_image = None
512
523
  upstream_checksum = ""
513
524
 
525
+ separator = image.get("separator", " ")
526
+ image_name = image["name"]
527
+
514
528
  for version in sorted_versions:
515
529
  if image["multi"]:
516
- name = f"{image['name']} ({version})"
530
+ name = f"{image_name}{separator}({version})"
517
531
  else:
518
- name = f"{image['name']} {version}"
532
+ name = f"{image_name}{separator}{version}"
519
533
 
520
534
  logger.info(f"Processing image '{name}'")
521
535
  logger.debug(f"Checking existence of '{name}'")
@@ -550,7 +564,7 @@ class ImageManager:
550
564
  and version == sorted_versions[-1]
551
565
  and not existence
552
566
  ):
553
- previous = f"{image['name']} ({sorted_versions[-2]})"
567
+ previous = f"{image['name']}{separator}({sorted_versions[-2]})"
554
568
  existence = previous in cloud_images and image["name"] in cloud_images
555
569
 
556
570
  elif (
@@ -825,7 +839,7 @@ class ImageManager:
825
839
 
826
840
  def rename_images(
827
841
  self,
828
- name: str,
842
+ image: dict,
829
843
  sorted_versions: list,
830
844
  imported_image: Image,
831
845
  previous_image: Image,
@@ -834,16 +848,18 @@ class ImageManager:
834
848
  Rename outdated images in Glance (only applies to images of type multi)
835
849
 
836
850
  Params:
837
- name: the name of the image from images.yml
851
+ image: image dict from images.yml
838
852
  sorted_versions: list with all sorted image versions
839
853
  imported_image: the newly imported image
840
854
  previous_image: the previous latest image
841
855
  """
856
+ name = image["name"]
857
+ separator = image.get("separator", " ")
842
858
  cloud_images = self.get_images()
843
859
 
844
860
  if len(sorted_versions) > 1:
845
- latest = f"{name} ({sorted_versions[-1]})"
846
- previous_latest = f"{name} ({sorted_versions[-2]})"
861
+ latest = f"{name}{separator}({sorted_versions[-1]})"
862
+ previous_latest = f"{name}{separator}({sorted_versions[-2]})"
847
863
 
848
864
  if name in cloud_images and previous_latest not in cloud_images:
849
865
  logger.info(f"Renaming {name} to {previous_latest}")
@@ -865,7 +881,7 @@ class ImageManager:
865
881
  )
866
882
  create_date = create_date.replace("-", "")
867
883
 
868
- previous_latest = f"{name} ({create_date})"
884
+ previous_latest = f"{name}{separator}({create_date})"
869
885
 
870
886
  logger.info(
871
887
  f"Setting internal_version: {create_date} for {previous_latest}"
@@ -874,9 +890,7 @@ class ImageManager:
874
890
  previous_image.id, **{"internal_version": create_date}
875
891
  )
876
892
  else:
877
- previous_latest = (
878
- f"{name} ({previous_image['properties']['internal_version']})"
879
- )
893
+ previous_latest = f"{name}{separator}({previous_image['properties']['internal_version']})"
880
894
 
881
895
  logger.info(f"Renaming old latest '{name}' to '{previous_latest}'")
882
896
  self.conn.image.update_image(previous_image.id, name=previous_latest)
@@ -885,7 +899,7 @@ class ImageManager:
885
899
  self.conn.image.update_image(imported_image.id, name=name)
886
900
 
887
901
  elif len(sorted_versions) == 1:
888
- latest = f"{name} ({sorted_versions[-1]})"
902
+ latest = f"{name}{separator}({sorted_versions[-1]})"
889
903
 
890
904
  if latest in cloud_images:
891
905
  logger.info(f"Renaming {latest} to {name}")
@@ -1102,23 +1116,29 @@ class ImageManager:
1102
1116
  """Validate all image.yaml files against the SCS Metadata spec"""
1103
1117
  schema = yamale.make_schema("etc/schema.yaml")
1104
1118
  try:
1119
+ validation_error_log = []
1105
1120
  for file in os.listdir(self.CONF.images):
1106
1121
  try:
1107
1122
  data = yamale.make_data(self.CONF.images + file)
1108
1123
  yamale.validate(schema, data)
1109
1124
  except YamaleError as e:
1110
- self.exit_with_error = True
1111
1125
  for result in e.results:
1112
1126
  logger.error(
1113
1127
  f"Error validating data '{result.data}' with '{result.schema}'"
1114
1128
  )
1115
1129
  for error in result.errors:
1116
1130
  logger.error(f"\t{error}")
1131
+ validation_error_log.append((file, error))
1117
1132
  else:
1118
1133
  logger.debug(f"Image file {file} is valid")
1119
1134
  except FileNotFoundError:
1120
1135
  logger.error(f"Invalid path '{self.CONF.images}'")
1121
1136
 
1137
+ if len(validation_error_log) > 0:
1138
+ sys.exit(
1139
+ f"Image definition validation failed with these error(s): {validation_error_log}"
1140
+ )
1141
+
1122
1142
  def share_image_with_project(self, image, project):
1123
1143
  member = self.conn.image.find_member(project.id, image.id)
1124
1144
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openstack-image-manager
3
- Version: 0.20240723.0
3
+ Version: 0.20240828.0
4
4
  Summary: OpenStack image manager
5
5
  Author-email: OSISM community <info@osism.tech>
6
6
  License: Apache License
@@ -222,18 +222,18 @@ Classifier: Programming Language :: Python :: 3.11
222
222
  Requires-Python: >=3.8
223
223
  Description-Content-Type: text/markdown
224
224
  License-File: LICENSE
225
- Requires-Dist: loguru ==0.7.2
226
- Requires-Dist: minio ==7.2.7
227
- Requires-Dist: munch ==4.0.0
228
- Requires-Dist: natsort ==8.4.0
229
- Requires-Dist: openstacksdk ==3.3.0
230
- Requires-Dist: paramiko ==3.4.0
231
- Requires-Dist: patool ==2.3.0
232
- Requires-Dist: requests ==2.32.3
233
- Requires-Dist: ruamel.yaml ==0.18.6
234
- Requires-Dist: tabulate ==0.9.0
235
- Requires-Dist: typer[all] ==0.12.3
236
- Requires-Dist: yamale ==5.2.1
225
+ Requires-Dist: loguru==0.7.2
226
+ Requires-Dist: minio==7.2.8
227
+ Requires-Dist: munch==4.0.0
228
+ Requires-Dist: natsort==8.4.0
229
+ Requires-Dist: openstacksdk==3.3.0
230
+ Requires-Dist: paramiko==3.4.1
231
+ Requires-Dist: patool==2.4.0
232
+ Requires-Dist: requests==2.32.3
233
+ Requires-Dist: ruamel.yaml==0.18.6
234
+ Requires-Dist: tabulate==0.9.0
235
+ Requires-Dist: typer[all]==0.12.5
236
+ Requires-Dist: yamale==5.2.1
237
237
 
238
238
  # openstack-image-manager
239
239
 
@@ -0,0 +1,8 @@
1
+ openstack_image_manager/__init__.py,sha256=z6lQHDMfCV8IkUz5pM1QYfQ37O2Rdy82jYovN8N9DIU,240
2
+ openstack_image_manager/main.py,sha256=uDj3ZpehvA2VzAHd7itHcyT56XEnY1gYTdkjRD-2kz0,47297
3
+ openstack_image_manager-0.20240828.0.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
4
+ openstack_image_manager-0.20240828.0.dist-info/METADATA,sha256=EhhClCe6kY3we9ahgEDLk-IGPrz7WQYaQ0YBGvxJ-2s,14850
5
+ openstack_image_manager-0.20240828.0.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
6
+ openstack_image_manager-0.20240828.0.dist-info/entry_points.txt,sha256=IrOGjHJbCa6-jmCQiqiKFqHeVvjGa1p25s2mLkt0da8,78
7
+ openstack_image_manager-0.20240828.0.dist-info/top_level.txt,sha256=iLfREddId51T97Dr9IGRQtJXKJgVy1PB6uHCaQk1j44,24
8
+ openstack_image_manager-0.20240828.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (71.1.0)
2
+ Generator: setuptools (74.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- openstack_image_manager/__init__.py,sha256=z6lQHDMfCV8IkUz5pM1QYfQ37O2Rdy82jYovN8N9DIU,240
2
- openstack_image_manager/main.py,sha256=DL_998wsL7HhoWiwooRXjrPxupKZLgzYoqbkKa7IHHc,46458
3
- openstack_image_manager-0.20240723.0.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
4
- openstack_image_manager-0.20240723.0.dist-info/METADATA,sha256=rzvLeVJtIcUtx4bjoxKL-ZJITgDZHmLLDhHlDpkOUlU,14862
5
- openstack_image_manager-0.20240723.0.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
6
- openstack_image_manager-0.20240723.0.dist-info/entry_points.txt,sha256=IrOGjHJbCa6-jmCQiqiKFqHeVvjGa1p25s2mLkt0da8,78
7
- openstack_image_manager-0.20240723.0.dist-info/top_level.txt,sha256=iLfREddId51T97Dr9IGRQtJXKJgVy1PB6uHCaQk1j44,24
8
- openstack_image_manager-0.20240723.0.dist-info/RECORD,,