1 Reply Latest reply on Dec 2, 2013 9:48 AM by uttam_84

    Problem while devoloping Vsphere Client Plugin (JAVA)

    uttam_84 Novice

      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

        • 1. Re: Problem while devoloping Vsphere Client Plugin (JAVA)
          uttam_84 Novice

          VIM_sessionkey is not a session id.

          If you are developing a plugin using http protocol the session id will not be received as request parameter by default.

           

          If you support the http communication then you will receive the session id.

           

          To achieve this you have to add this line plugin configuration file

           

          <supportNonSecureCommunication>true</supportNonSecureCommunication>