cloudpub 1.3.2__py3-none-any.whl → 1.4.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.
@@ -620,7 +620,7 @@ class AzureService(BaseService[AzurePublishingMetadata]):
620
620
  tech_config.disk_versions = [disk_version]
621
621
 
622
622
  # We just want to append a new image if the SAS is not already present.
623
- elif not is_sas_present(tech_config, metadata.image_path):
623
+ elif not is_sas_present(tech_config, metadata.image_path, metadata.check_base_sas_only):
624
624
  # Here we can have the metadata.disk_version set or empty.
625
625
  # When set we want to get the existing disk_version which matches its value.
626
626
  log.debug("Scanning the disk versions from %s" % metadata.destination)
@@ -51,6 +51,9 @@ class AzurePublishingMetadata(PublishingMetadata):
51
51
  legacy_sku_id (str, optional):
52
52
  Only required when ``support_legacy == True``. The SKU ID for Gen1.
53
53
  Defaults to ``{sku_id}-gen1``
54
+ check_base_sas_only (bool, optional):
55
+ Indicates to skip checking SAS parameters when set as ``True``.
56
+ Default to ``False``
54
57
  **kwargs
55
58
  Arguments for :class:`~cloudpub.common.PublishingMetadata`.
56
59
  """
@@ -60,6 +63,7 @@ class AzurePublishingMetadata(PublishingMetadata):
60
63
  self.support_legacy = support_legacy
61
64
  self.recommended_sizes = recommended_sizes or []
62
65
  self.legacy_sku_id = kwargs.pop("legacy_sku_id", None)
66
+ self.check_base_sas_only = kwargs.pop("check_base_sas_only", False)
63
67
 
64
68
  if generation == "V1" or not support_legacy:
65
69
  self.legacy_sku_id = None
@@ -113,7 +117,7 @@ def get_image_type_mapping(architecture: str, generation: str) -> str:
113
117
  return gen_map.get(generation, "")
114
118
 
115
119
 
116
- def is_sas_eq(sas1: str, sas2: str) -> bool:
120
+ def is_sas_eq(sas1: str, sas2: str, base_only=False) -> bool:
117
121
  """
118
122
  Compare 2 SAS URI and determine where they're equivalent.
119
123
 
@@ -127,10 +131,12 @@ def is_sas_eq(sas1: str, sas2: str) -> bool:
127
131
  This comparison is necessary as each time a SAS URI is generated it returns a different value.
128
132
 
129
133
  Args:
130
- sas1:
134
+ sas1 (str):
131
135
  The left SAS to compare the equivalency
132
- sas2:
136
+ sas2 (str):
133
137
  The right SAS to compare the equivalency
138
+ base_only (bool):
139
+ When True it will only compare the base SAS and not its arguments. Defaults to False.
134
140
 
135
141
  Returns:
136
142
  True when both SAS URIs are equivalent, False otherwise.
@@ -147,25 +153,26 @@ def is_sas_eq(sas1: str, sas2: str) -> bool:
147
153
  log.debug("Got different base SAS: %s - Expected: %s" % (base_sas1, base_sas2))
148
154
  return False
149
155
 
150
- # Parameters lengh differs
151
- if len(params_sas1) != len(params_sas2):
152
- log.debug(
153
- "Got different lengh of SAS parameters: len(%s) - Expected len(%s)"
154
- % (params_sas1, params_sas2)
155
- )
156
- return False
157
-
158
- # Parameters values differs
159
- for k, v in params_sas1.items():
160
- if v != params_sas2.get(k, None):
161
- log.debug("The SAS parameter %s doesn't match %s." % (v, params_sas2.get(k, None)))
156
+ if not base_only:
157
+ # Parameters lengh differs
158
+ if len(params_sas1) != len(params_sas2):
159
+ log.debug(
160
+ "Got different lengh of SAS parameters: len(%s) - Expected len(%s)"
161
+ % (params_sas1, params_sas2)
162
+ )
162
163
  return False
163
164
 
165
+ # Parameters values differs
166
+ for k, v in params_sas1.items():
167
+ if v != params_sas2.get(k, None):
168
+ log.debug("The SAS parameter %s doesn't match %s." % (v, params_sas2.get(k, None)))
169
+ return False
170
+
164
171
  # Equivalent SAS
165
172
  return True
166
173
 
167
174
 
168
- def is_sas_present(tech_config: VMIPlanTechConfig, sas_uri: str) -> bool:
175
+ def is_sas_present(tech_config: VMIPlanTechConfig, sas_uri: str, base_only: bool = False) -> bool:
169
176
  """
170
177
  Check whether the given SAS URI is already present in the disk_version.
171
178
 
@@ -174,12 +181,14 @@ def is_sas_present(tech_config: VMIPlanTechConfig, sas_uri: str) -> bool:
174
181
  The plan's technical configuraion to seek the SAS_URI.
175
182
  sas_uri (str)
176
183
  The SAS URI to check whether it's present or not in disk version.
184
+ base_only (bool):
185
+ When True it will only compare the base SAS and not its arguments. Defaults to False.
177
186
  Returns:
178
187
  bool: True when the SAS is present in the plan, False otherwise.
179
188
  """
180
189
  for disk_version in tech_config.disk_versions:
181
190
  for img in disk_version.vm_images:
182
- if is_sas_eq(img.source.os_disk.uri, sas_uri):
191
+ if is_sas_eq(img.source.os_disk.uri, sas_uri, base_only):
183
192
  return True
184
193
  return False
185
194
 
@@ -262,11 +271,16 @@ def prepare_vm_images(
262
271
  return [VMImageDefinition.from_json(json_gen1)]
263
272
 
264
273
 
265
- def _len_vm_images(disk_versions: List[DiskVersion]) -> int:
266
- count = 0
267
- for disk_version in disk_versions:
268
- count = count + len(disk_version.vm_images)
269
- return count
274
+ def _all_skus_present(old_skus: List[VMISku], disk_versions: List[DiskVersion]) -> bool:
275
+ image_types = set()
276
+ for sku in old_skus:
277
+ image_types.add(sku.image_type)
278
+
279
+ for dv in disk_versions:
280
+ for img in dv.vm_images:
281
+ if img.image_type not in image_types:
282
+ return False
283
+ return True
270
284
 
271
285
 
272
286
  def _build_skus(
@@ -352,7 +366,7 @@ def update_skus(
352
366
 
353
367
  # If we have SKUs for each image we don't need to update them as they're already
354
368
  # properly set.
355
- if len(old_skus) == _len_vm_images(disk_versions):
369
+ if _all_skus_present(old_skus, disk_versions):
356
370
  return old_skus
357
371
 
358
372
  # Update SKUs to create the alternate gen.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cloudpub
3
- Version: 1.3.2
3
+ Version: 1.4.0
4
4
  Summary: Services for publishing products in cloud environments
5
5
  Home-page: https://github.com/release-engineering/cloudpub
6
6
  Author: Jonathan Gangi
@@ -10,11 +10,11 @@ cloudpub/models/aws.py,sha256=arzFqLmFw8O9Otk_VatLR5dmQ9FsdWT3f0Ibap7EW0o,42850
10
10
  cloudpub/models/common.py,sha256=iZ503VVFL9y0P_wXiK0f3flXV32VWBs9i-9NoYfJZUg,4970
11
11
  cloudpub/models/ms_azure.py,sha256=nzTp9IvAW-WEJuN20IAc93yY6YPHCTE0j116EfQUsPg,55974
12
12
  cloudpub/ms_azure/__init__.py,sha256=eeYXPd_wzDBmh0Hmzd5o4yzocFzM6n4r8qpCDy00kYk,117
13
- cloudpub/ms_azure/service.py,sha256=LV7z9WliYAIBMMb_N8CFRpW6o5cCLZjUmqSpIC-7vDU,26559
13
+ cloudpub/ms_azure/service.py,sha256=cMgKcOfgW0UwPPSGGH6Iiyqz2JidrEeowiY-SHq1mSU,26589
14
14
  cloudpub/ms_azure/session.py,sha256=7ZjBLBX4XSzx60Bxhn96kh64RJ3oQs734Tw3ZVSnFrU,6349
15
- cloudpub/ms_azure/utils.py,sha256=xgb2hXYN4G6QjU8es3sRWAYvjK8AYMyu8-lTFKduIwI,19955
16
- cloudpub-1.3.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
17
- cloudpub-1.3.2.dist-info/METADATA,sha256=y-EFMAsx7uIl7gZGRCsXoL5INQnbm-DH2sHinJu1dv0,831
18
- cloudpub-1.3.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
19
- cloudpub-1.3.2.dist-info/top_level.txt,sha256=YnnJuTiWBpRI9zMkYUVcZNuvjzzJYblASj-7Q8m3Gzg,9
20
- cloudpub-1.3.2.dist-info/RECORD,,
15
+ cloudpub/ms_azure/utils.py,sha256=h6bEtMrlPsbayR-SlVEzlzxEC1i4fdSqH8Fn-m_xaMQ,20730
16
+ cloudpub-1.4.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
17
+ cloudpub-1.4.0.dist-info/METADATA,sha256=HIJ-yCcFQULM5vIGMg-29OCQEInd5E5oLjDWaGwldEE,831
18
+ cloudpub-1.4.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
19
+ cloudpub-1.4.0.dist-info/top_level.txt,sha256=YnnJuTiWBpRI9zMkYUVcZNuvjzzJYblASj-7Q8m3Gzg,9
20
+ cloudpub-1.4.0.dist-info/RECORD,,