VMware Cloud Community
10five10
Contributor
Contributor

Can not shutdown host programatically - license problem

Hi, All,

I've set up a single ESXi 6 host, from which I run several virtual machines.

In order to shut down the host when it is not necessary, I can use VSphere client, but I would prefer a programmable solution (for example to schedule, or to shut down the host from an android app).

So I investigated the API, and found the solution by tweaking the "hello world" application provided by vmware  :

...

        System.out.println(serviceContent.getAbout().getFullName());

        System.out.println("Server type is "+serviceContent.getAbout().getApiType());

        System.out.println("API version is "+serviceContent.getAbout().getApiVersion());

       

             // Added

        ManagedObjectReference si=serviceContent.getSearchIndex();

        ManagedObjectReference o=vimPort.findByIp(si, null, "192.168.x.x", false); // seach for host o is a managedobjectreference "HostSystem"

       

        System.out.println("Shutting down "+o.getType()+" "+o.getValue());

       vimPort.shutdownHostTask(o,false); //gentle shutdown

...

Unfortunately, running the code results in a "license" exception :

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Current license or ESXi version prohibits execution of the requested operation.

    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)

    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:125)

    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)

    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)

    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:135)

    at com.sun.proxy.$Proxy28.shutdownHostTask(Unknown Source)

    at HelloVmware.main(HelloVmware.java:55)

How is it possible that I can shut down from VSphere client, and this operation becomes impossible when accessing the same function from the API ?  Isn't it a bug ?

0 Kudos
3 Replies
suvrobhattachar
Enthusiast
Enthusiast

can you please explain in short what you are looking for .

0 Kudos
10five10
Contributor
Contributor

I try to shutdown the host system using provided API (vim25)

0 Kudos
maaca
Enthusiast
Enthusiast

Just a guess - you are usin ESXi in Free edition, right? In the past, Free edition had fully disabled API. Since some (5.X) version it is enabled, but only in read-only mode. So you can access the API, but it will not do anything for you, unless you buy higher edition.

0 Kudos