We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent adadeaa commit 2b5ef3dCopy full SHA for 2b5ef3d
1 file changed
lib/tools/tasks/snapshot.py
@@ -0,0 +1,28 @@
1
+"""Snapshot tasks.
2
+"""
3
+from concurrent.futures import ThreadPoolExecutor
4
+from datetime import date
5
+
6
+from lib.host import Host
7
+from lib.vm import VM
8
9
+from .. import logger
10
11
+def create_snapshot(host: Host, vm_uuids: list[str]):
12
+ """Create a snapshot for a list of VMs in host.
13
14
+ :param `lib.Host` host:
15
+ The target parent which hosts the VMs.
16
+ :param list[str] vm_uuids:
17
+ uuids of target VMs.
18
+ """
19
+ # init VMs list
20
+ vms = [VM(uuid, host) for uuid in vm_uuids]
21
22
+ snapshot_name = f"utd-{date.today().strftime('%Y%m%d')}"
23
24
+ logger.debug(f"[{host}] Create snapshot '{snapshot_name}' for VMs: {vm_uuids}")
25
26
+ with ThreadPoolExecutor() as executor:
27
+ for vm in vms:
28
+ executor.submit(vm.snapshot, None, snapshot_name)
0 commit comments