Skip to content

Commit 2f08c98

Browse files
committed
feat(oracle): add ability to retain snapshot after cleanup
1 parent 8b6a0b5 commit 2f08c98

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pycloudlib/oci/cloud.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,15 @@ def launch(
340340
self.created_instances.append(instance)
341341
return instance
342342

343-
def snapshot(self, instance, clean=True, name=None):
343+
def snapshot(self, instance, clean=True, name=None, keep=False):
344344
"""Snapshot an instance and generate an image from it.
345345
346346
Args:
347347
instance: Instance to snapshot
348348
clean: run instance clean method before taking snapshot
349349
name: (Optional) Name of created image
350350
Returns:
351-
An image object
351+
The image id of the snapshot
352352
"""
353353
if clean:
354354
instance.clean()
@@ -366,7 +366,11 @@ def snapshot(self, instance, clean=True, name=None):
366366
current_data=image_data,
367367
desired_state="AVAILABLE",
368368
)
369-
370-
self.created_images.append(image_data.id)
369+
370+
# only add image to created_images list for cleanup if keep is False
371+
if not keep:
372+
self.created_images.append(image_data.id)
373+
else:
374+
self._log.info("Keeping image %s", image_data.display_name)
371375

372376
return image_data.id

0 commit comments

Comments
 (0)