@@ -2962,14 +2962,19 @@ public Type getType() {
29622962
29632963 @ Override
29642964 public StartupCommand [] initialize () {
2965- VmwareContext context = getServiceContext ();
2965+ String hostApiVersion = "4.1" ;
2966+ VmwareContext context = getServiceContext ();
29662967 try {
29672968 VmwareHypervisorHost hyperHost = getHyperHost (context );
29682969 assert (hyperHost instanceof HostMO );
29692970 if (!((HostMO )hyperHost ).isHyperHostConnected ()) {
29702971 s_logger .info ("Host " + hyperHost .getHyperHostName () + " is not in connected state" );
29712972 return null ;
29722973 }
2974+
2975+ AboutInfo aboutInfo = ((HostMO )hyperHost ).getHostAboutInfo ();
2976+ hostApiVersion = aboutInfo .getApiVersion ();
2977+
29732978 } catch (Exception e ) {
29742979 String msg = "VmwareResource intialize() failed due to : " + VmwareHelper .getExceptionMessage (e );
29752980 s_logger .error (msg );
@@ -2989,25 +2994,6 @@ public StartupCommand[] initialize() {
29892994 cmd .setHypervisorType (HypervisorType .VMware );
29902995 cmd .setStateChanges (changes );
29912996 cmd .setCluster (_cluster );
2992-
2993- String hostApiVersion = "4.1" ;
2994- try {
2995- // take the chance to do left-over dummy VM cleanup from previous run
2996- VmwareContext context = getServiceContext ();
2997- VmwareHypervisorHost hyperHost = getHyperHost (context );
2998-
2999- assert (hyperHost instanceof HostMO );
3000-
3001- AboutInfo aboutInfo = ((HostMO )hyperHost ).getHostAboutInfo ();
3002- hostApiVersion = aboutInfo .getApiVersion ();
3003-
3004- } catch (Throwable e ) {
3005- if (e instanceof RemoteException ) {
3006- s_logger .warn ("Encounter remote exception to vCenter, invalidate VMware session context" );
3007- invalidateServiceContext ();
3008- }
3009- }
3010-
30112997 cmd .setVersion (hostApiVersion );
30122998
30132999 List <StartupStorageCommand > storageCmds = initializeLocalStorage ();
0 commit comments