blob: 59418b0d67e8b7051a0e2ec9c3078b61261ddeb4 [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
14 * PATH Path where snapshot image and dumpxml are being put
15 * 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') {
34 virsh.liveSnapshotPresent(pepperEnv, NODE_PROVIDER, TARGET, SNAPSHOT_NAME, PATH, DISK_NAME)
35 }
36 }
37
38 if (REMOVE_LIVE_SNAPSHOT.toBoolean() == true) {
39 stage('Remove live snapshot') {
40 virsh.liveSnapshotAbsent(pepperEnv, NODE_PROVIDER, TARGET, SNAPSHOT_NAME, PATH)
41 }
42 }
43
44 if (ROLLBACK_LIVE_SNAPSHOT.toBoolean() == true) {
45 stage('Rollback live snapshot') {
46 sleep(30)
47 virsh.liveSnapshotRollback(pepperEnv, NODE_PROVIDER, TARGET, SNAPSHOT_NAME, PATH)
48 }
49 }
50
51 if (MERGE_LIVE_SNAPSHOT.toBoolean() == true) {
52 stage('Merge live snapshot') {
53 sleep(30)
54 virsh.liveSnapshotMerge(pepperEnv, NODE_PROVIDER, TARGET, SNAPSHOT_NAME, PATH, DISK_NAME)
55 }
56 }
57 }
58}