blob: 10cb4a1bcae0c8ce30c97f9170cec2cec584f791 [file] [log] [blame]
Jiri Brouliked3a9e62018-02-13 16:08:40 +01001/**
2 * Control live snapshots
3 *
4 * Expected parameters:
5 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
6 * SALT_MASTER_URL Full Salt API address [http://10.10.10.1:8000].
7 * CREATE_LIVE_SNAPSHOT Ensures that the live snapshot exists (bool)
8 * ROLLBACK_LIVE_SNAPSHOT Rollback to a state before live snapshot was taken (bool)
9 * REMOVE_LIVE_SNAPSHOT Ensures that the live snapshot does not exist (bool)
10 * MERGE_LIVE_SNAPSHOT Ensures that the live snapshot is merged into it's base image (bool)
11 * NODE_PROVIDER KVM node that hosts the VM (for ex. kvm02)
12 * TARGET Unique identification of the VM being snapshoted without domain name (for ex. ctl01)
13 * SNAPSHOT_NAME Snapshot name
Martin Polreichbbb14f92019-05-02 16:15:33 +020014 * LIBVIRT_IMAGES_PATH Path where snapshot image and dumpxml are being put
Jiri Brouliked3a9e62018-02-13 16:08:40 +010015 * DISK_NAME Disk name of the snapshot
16 *
17**/
18
19def common = new com.mirantis.mk.Common()
20def salt = new com.mirantis.mk.Salt()
21def virsh = new com.mirantis.mk.Virsh()
22def python = new com.mirantis.mk.Python()
23
24def pepperEnv = "pepperEnv"
25timeout(time: 12, unit: 'HOURS') {
26 node() {
27
28 stage('Setup virtualenv for Pepper') {
29 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
30 }
31
32 if (CREATE_LIVE_SNAPSHOT.toBoolean() == true) {
33 stage('Create live snapshot') {
Martin Polreichbbb14f92019-05-02 16:15:33 +020034 virsh.liveSnapshotPresent(pepperEnv, NODE_PROVIDER, TARGET, SNAPSHOT_NAME, LIBVIRT_IMAGES_PATH, DISK_NAME)
Jiri Brouliked3a9e62018-02-13 16:08:40 +010035 }
36 }
37
38 if (REMOVE_LIVE_SNAPSHOT.toBoolean() == true) {
39 stage('Remove live snapshot') {
Martin Polreichbbb14f92019-05-02 16:15:33 +020040 virsh.liveSnapshotAbsent(pepperEnv, NODE_PROVIDER, TARGET, SNAPSHOT_NAME, LIBVIRT_IMAGES_PATH)
Jiri Brouliked3a9e62018-02-13 16:08:40 +010041 }
42 }
43
44 if (ROLLBACK_LIVE_SNAPSHOT.toBoolean() == true) {
45 stage('Rollback live snapshot') {
46 sleep(30)
Martin Polreichbbb14f92019-05-02 16:15:33 +020047 virsh.liveSnapshotRollback(pepperEnv, NODE_PROVIDER, TARGET, SNAPSHOT_NAME, LIBVIRT_IMAGES_PATH)
Jiri Brouliked3a9e62018-02-13 16:08:40 +010048 }
49 }
50
51 if (MERGE_LIVE_SNAPSHOT.toBoolean() == true) {
52 stage('Merge live snapshot') {
53 sleep(30)
Martin Polreichbbb14f92019-05-02 16:15:33 +020054 virsh.liveSnapshotMerge(pepperEnv, NODE_PROVIDER, TARGET, SNAPSHOT_NAME, LIBVIRT_IMAGES_PATH, DISK_NAME)
Jiri Brouliked3a9e62018-02-13 16:08:40 +010055 }
56 }
57 }
58}