1515// specific language governing permissions and limitations
1616// under the License.
1717package com .cloud .hypervisor .xen .resource ;
18-
19- import java .io .File ;
20- import java .util .ArrayList ;
21- import java .util .List ;
18+ import com .xensource .xenapi .Connection ;
19+ import com .xensource .xenapi .Host ;
20+ import com .xensource .xenapi .HostPatch ;
21+ import com .xensource .xenapi .PoolPatch ;
22+ import org .apache .cloudstack .hypervisor .xenserver .XenserverConfigs ;
23+ import java .util .Map ;
24+ import java .util .Set ;
2225
2326import javax .ejb .Local ;
2427
2528import org .apache .log4j .Logger ;
2629
30+ import com .cloud .agent .api .StartupRoutingCommand ;
2731import com .cloud .resource .ServerResource ;
28- import com .cloud .utils .exception .CloudRuntimeException ;
29- import com .cloud .utils .script .Script ;
3032
3133@ Local (value = ServerResource .class )
3234public class XenServer620Resource extends XenServer610Resource {
@@ -41,19 +43,6 @@ protected String getGuestOsType(String stdType, boolean bootFromCD) {
4143 return CitrixHelper .getXenServer620GuestOsType (stdType , bootFromCD );
4244 }
4345
44- @ Override
45- protected List <File > getPatchFiles () {
46- List <File > files = new ArrayList <File >();
47- String patch = "scripts/vm/hypervisor/xenserver/xenserver60/patch" ;
48- String patchfilePath = Script .findScript ("" , patch );
49- if (patchfilePath == null ) {
50- throw new CloudRuntimeException ("Unable to find patch file " + patch );
51- }
52- File file = new File (patchfilePath );
53- files .add (file );
54- return files ;
55- }
56-
5746 @ Override
5847 public long getStaticMax (String os , boolean b , long dynamicMinRam , long dynamicMaxRam ) {
5948 long recommendedValue = CitrixHelper .getXenServer620StaticMax (os , b );
@@ -83,4 +72,37 @@ public long getStaticMin(String os, boolean b, long dynamicMinRam, long dynamicM
8372 }
8473 return dynamicMinRam ;
8574 }
75+
76+ protected boolean hostHasHotFix (Connection conn , String hotFixUuid ) {
77+ try {
78+ Host host = Host .getByUuid (conn , _host .uuid );
79+ Host .Record re = host .getRecord (conn );
80+ Set <HostPatch > patches = re .patches ;
81+ PoolPatch poolPatch = PoolPatch .getByUuid (conn , hotFixUuid );
82+ for (HostPatch patch : patches ) {
83+ PoolPatch pp = patch .getPoolPatch (conn );
84+ if (pp .equals (poolPatch ) && patch .getApplied (conn )) {
85+ return true ;
86+ }
87+ }
88+ } catch (Exception e ) {
89+ s_logger .debug ("can't get patches information for hotFix: " + hotFixUuid );
90+ }
91+ return false ;
92+ }
93+
94+ protected void fillHostInfo (Connection conn , StartupRoutingCommand cmd ) {
95+ super .fillHostInfo (conn , cmd );
96+ Map <String , String > details = cmd .getHostDetails ();
97+ Boolean hotFix62ESP1004 = hostHasHotFix (conn , XenserverConfigs .XSHotFix62ESP1004 );
98+ if ( hotFix62ESP1004 != null && hotFix62ESP1004 ) {
99+ details .put (XenserverConfigs .XS620HotFix , XenserverConfigs .XSHotFix62ESP1004 );
100+ } else {
101+ Boolean hotFix62ESP1 = hostHasHotFix (conn , XenserverConfigs .XSHotFix62ESP1 );
102+ if ( hotFix62ESP1 != null && hotFix62ESP1 ) {
103+ details .put (XenserverConfigs .XS620HotFix , XenserverConfigs .XSHotFix62ESP1 );
104+ }
105+ }
106+ cmd .setHostDetails (details );
107+ }
86108}
0 commit comments