VMware {code} Community
myelaman
Enthusiast
Enthusiast

Need help in getting datacenter name in vsphere webclient SDK 6.0

we were using 5.5 SDK and retrieving datacenter name .Now,with 6.0 SDK,the dc name code throws null pointer exception.Please suggest

 

 

serverConnection sc = si.getServerConnection();
         
         String dcName = null;
         _logger.info(" Server connection url :  " + sc.getUrl());
         Object dvsObject = MorUtil.createExactManagedEntity(sc, dvsMor);
        
        
        if(dvsObject != null && dvsObject instanceof DistributedVirtualSwitch){
            DistributedVirtualSwitch dvsObj = (DistributedVirtualSwitch)dvsObject;
            
            ManagedEntity me = dvsObj.getParent();
                
            ManagedObjectReference networkMor = me.getMOR();

 

The above line throws null pointer.Please suggest an example to retrieve the dc name from dvs object.

Is there any change in amanged object entity hierarchy and folder hierarchy in 6.0?

Marianne

erverConnection sc = si.getServerConnection();
         
         String dcName = null;
         _logger.info(" Server connection url :  " + sc.getUrl());
         Object dvsObject = MorUtil.createExactManagedEntity(sc, dvsMor);
        
        
        if(dvsObject != null && dvsObject instanceof DistributedVirtualSwitch){
            DistributedVirtualSwitch dvsObj = (DistributedVirtualSwitch)dvsObject;
            
            ManagedEntity me = dvsObj.getParent();
                
            ManagedObjectReference networkMor = me.getMOR();
0 Kudos
1 Reply
laurentsd
VMware Employee
VMware Employee

I am not familiar with viJava and this is not a VMware API.  To check the object hierarchy on your setup I recommend using the MOB  (https://VC_IP/mob)

0 Kudos