Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 180329

vSphere SDK API to fetch list of datastores.

$
0
0

Hi

Is there API to fetch list of datastores attached to a datacentre.

Currently we have below code which takes more than 1 hour to fetch 100 datastores. We invoke this method 100 times to fetch datastore.

 

 

//input parameters: user name - user name on Vsphere

  password - password of user

  hostname - hostname of system.

 

 

//create connection to ESX.

//create service refernce

ManagedObjectReference _svcRef = new ManagedObjectReference();

  _svcRef.setType("ServiceInstance");

  _svcRef.set_value("ServiceInstance");

 

 

VimServiceLocator _locator = new VimServiceLocator();

  _locator.setMaintainSession(true);

VimPortType _service = _locator.getVimPort(new URL(urlStr));

 

 

ServiceContent _sic = _service.retrieveServiceContent(_svcRef);

ManagedObjectReference _propCol = _sic.getPropertyCollector();

ManagedObjectReference _rootFolder = _sic.getRootFolder();

 

 

  if (_sic.getSessionManager() != null) {

  _service.login(_sic.getSessionManager(), username, password, null);

//Create connection to ESX host - end

//The above menthod is called once during the class instantion.(aka constructor

 

 

//this line is call mutiple times to fetch datastore object.

//customer has reported a performance issue with this code. When datastore number is around 100 , it takes around 1+ hour to fetch details.

_service.findByDnsName(_sic.getSearchIndex(),null,hostname,false);   


Viewing all articles
Browse latest Browse all 180329

Trending Articles