16
16
// under the License.
17
17
package com .cloud .upgrade .dao ;
18
18
19
+ import com .cloud .upgrade .SystemVmTemplateRegistration ;
19
20
import com .cloud .utils .exception .CloudRuntimeException ;
21
+ import org .apache .log4j .Logger ;
20
22
21
23
import java .io .InputStream ;
22
24
import java .sql .Connection ;
23
25
24
- public class Upgrade41900to41910 implements DbUpgrade {
26
+ public class Upgrade41900to41910 implements DbUpgrade , DbUpgradeSystemVmTemplate {
27
+ final static Logger LOG = Logger .getLogger (Upgrade41900to41910 .class );
28
+ private SystemVmTemplateRegistration systemVmTemplateRegistration ;
25
29
26
30
@ Override
27
31
public String [] getUpgradableVersionRange () {
28
- return new String [] {"4.19.0.0" , "4.19.1.0" };
32
+ return new String []{"4.19.0.0" , "4.19.1.0" };
29
33
}
30
34
31
35
@ Override
@@ -46,11 +50,12 @@ public InputStream[] getPrepareScripts() {
46
50
throw new CloudRuntimeException ("Unable to find " + scriptFile );
47
51
}
48
52
49
- return new InputStream [] {script };
53
+ return new InputStream []{script };
50
54
}
51
55
52
56
@ Override
53
57
public void performDataMigration (Connection conn ) {
58
+ addIndexes (conn );
54
59
}
55
60
56
61
@ Override
@@ -61,6 +66,25 @@ public InputStream[] getCleanupScripts() {
61
66
throw new CloudRuntimeException ("Unable to find " + scriptFile );
62
67
}
63
68
64
- return new InputStream [] {script };
69
+ return new InputStream []{script };
70
+ }
71
+
72
+ private void addIndexes (Connection conn ) {
73
+ DbUpgradeUtils .addIndexIfNeeded (conn , "vm_stats" , "vm_id" );
74
+ }
75
+
76
+ @ Override
77
+ public void updateSystemVmTemplates (Connection conn ) {
78
+ LOG .debug ("Updating System Vm template IDs" );
79
+ initSystemVmTemplateRegistration ();
80
+ try {
81
+ systemVmTemplateRegistration .updateSystemVmTemplates (conn );
82
+ } catch (Exception e ) {
83
+ throw new CloudRuntimeException ("Failed to find / register SystemVM template(s)" );
84
+ }
85
+ }
86
+
87
+ private void initSystemVmTemplateRegistration () {
88
+ systemVmTemplateRegistration = new SystemVmTemplateRegistration ("" );
65
89
}
66
90
}
0 commit comments