1616// under the License.
1717package com .cloud .hypervisor .vmware .mo ;
1818
19+ import com .cloud .hypervisor .Hypervisor ;
1920import org .apache .logging .log4j .Logger ;
2021import org .apache .logging .log4j .LogManager ;
2122
@@ -45,9 +46,9 @@ public class BaseMO {
4546 protected VmwareContext _context ;
4647 protected ManagedObjectReference _mor ;
4748
48- protected static String [] propertyPathsForUnmanagedVmsThinListing = new String [] {"name" , "config.template" ,
49- "runtime.powerState " , "summary.guest.guestId " , "summary.guest.guestFullName " , "runtime.host " ,
50- "config.bootOptions" , "config.firmware" };
49+ protected static String [] propertyPathsForUnmanagedVmsThinListing = new String [] {"name" , "config.template" , "runtime.powerState" ,
50+ "config.guestId " , "config.guestFullName " , "summary.guest.guestId " , "summary.guest.guestFullName " ,
51+ "runtime.host" , " config.bootOptions" , "config.firmware" };
5152
5253 private String _name ;
5354
@@ -207,6 +208,11 @@ private UnmanagedInstanceTO createUnmanagedInstanceTOFromThinListingDynamicPrope
207208 boolean isTemplate = false ;
208209 boolean excludeByKeyword = false ;
209210
211+ String configGuestId = null ;
212+ String configGuestFullName = null ;
213+ String summaryGuestId = null ;
214+ String summaryGuestFullName = null ;
215+
210216 for (DynamicProperty objProp : objProps ) {
211217 if (objProp .getName ().equals ("name" )) {
212218 vmName = (String ) objProp .getVal ();
@@ -219,10 +225,14 @@ private UnmanagedInstanceTO createUnmanagedInstanceTOFromThinListingDynamicPrope
219225 } else if (objProp .getName ().equals ("runtime.powerState" )) {
220226 VirtualMachinePowerState powerState = (VirtualMachinePowerState ) objProp .getVal ();
221227 vm .setPowerState (convertPowerState (powerState ));
228+ } else if (objProp .getName ().equals ("config.guestFullName" )) {
229+ configGuestFullName = (String ) objProp .getVal ();
230+ } else if (objProp .getName ().equals ("config.guestId" )) {
231+ configGuestId = (String ) objProp .getVal ();
222232 } else if (objProp .getName ().equals ("summary.guest.guestFullName" )) {
223- vm . setOperatingSystem (( String ) objProp .getVal () );
233+ summaryGuestFullName = ( String ) objProp .getVal ();
224234 } else if (objProp .getName ().equals ("summary.guest.guestId" )) {
225- vm . setOperatingSystemId (( String ) objProp .getVal () );
235+ summaryGuestId = ( String ) objProp .getVal ();
226236 } else if (objProp .getName ().equals ("config.bootOptions" )) {
227237 VirtualMachineBootOptions bootOptions = (VirtualMachineBootOptions ) objProp .getVal ();
228238 String bootMode = "LEGACY" ;
@@ -238,6 +248,11 @@ private UnmanagedInstanceTO createUnmanagedInstanceTOFromThinListingDynamicPrope
238248 setUnmanagedInstanceTOHostAndCluster (vm , hostMor , hostClusterNamesMap );
239249 }
240250 }
251+
252+ vm .setHypervisorType (Hypervisor .HypervisorType .VMware .name ());
253+ vm .setOperatingSystem (StringUtils .isNotBlank (summaryGuestFullName ) ? summaryGuestFullName : configGuestFullName );
254+ vm .setOperatingSystemId (StringUtils .isNotBlank (summaryGuestId ) ? summaryGuestId : configGuestId );
255+
241256 if (isTemplate || excludeByKeyword ) {
242257 return null ;
243258 }
0 commit comments