Quantcast
Channel: VMware Communities : All Content - vSphere Management SDK
Viewing all articles
Browse latest Browse all 1860

Problem while devoloping Vsphere Client Plugin (JAVA)

$
0
0

Hi,

 

I need to perform the CIM operations on ESX host through manged vCenter.

 

I have vCenter5.0 running on Win2008DataCenter and also having ESX host.

 

I have attached this host to vCenter.

 

To Perform the CIM operations I faced two major problems.

 

1: HttpRequest object is having parameters serviceUrl,vimSessionKey.

   I need to authenticte to the vCenter using service url & session Key but it is failed.

     The Code snippet given below:

 

     String sessionStr = "vmware_soap_session=\"" +sessionID+ "\";

     ServiceInstance si = new ServiceInstance(new URL(url),sessionStr, true);

 

     Here sessionID is vimSessionKey and url is serviceURL. But the authentication is failed.

2: I have authenticated vCenter by skipping first problem and acquired CIM services for required host and executed CIM query using wbem CIM client.

     But I have got the error CIM_ERR_ACCESS_DENIED.

     Folder rootFolder = si.getRootFolder();

     HostSystem host = (HostSystem) new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem")[0];

     HostServiceTicket ticket = host.acquireCimServicesTicket();

     String sessionId = ticket.getSessionId()

     String namespace = "root/cimv2";
            UserPrincipal userPr = new UserPrincipal(sessionId);
            PasswordCredential pwCred = new PasswordCredential(sessionId);
            CIMNameSpace ns = new CIMNameSpace(urlStr, namespace);
            CIMClient cimClient = new CIMClient(ns, userPr, pwCred);

 

     Here I have executed the CIM query...........

 

     When I used the username and password for ESX host it has given the result. But with sessionId i got error.

 

 

 

 

Please help me in this regard.

 

Regards,

Uttama


Viewing all articles
Browse latest Browse all 1860

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>