Skip to content

Commit 29a58b1

Browse files
committed
vm/snapshot: add new param for custom label name
Modify the `snapshot` method from VM Class to be able to pass arbitrary string for the name label of the VM' snapshot Signed-off-by: Olivier Hoareau <olivier.hoareau@vates.tech>
1 parent 1a9c4ba commit 29a58b1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/vm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,11 @@ def migrate(self, target_host, sr=None, network=None):
291291
self.host = target_host
292292
self.create_vdis_list()
293293

294-
def snapshot(self, ignore_vdis=None) -> Snapshot:
294+
def snapshot(self, ignore_vdis=None, name=None) -> Snapshot:
295295
logging.info("Snapshot VM")
296-
args: dict[str, str | bool] = {'uuid': self.uuid, 'new-name-label': 'Snapshot of %s' % self.uuid}
296+
297+
name_label = name or f"Snapshot of {self.uuid}"
298+
args: dict[str, str | bool] = {'uuid': self.uuid, 'new-name-label': name_label}
297299
if ignore_vdis:
298300
args['ignore-vdi-uuids'] = ','.join(ignore_vdis)
299301
snap_uuid = self.host.xe('vm-snapshot', args)

0 commit comments

Comments
 (0)