3.5.3.1 Java

By using the Oracle VM Manager Web Services Client library in your code, the SOAP API is almost completely abstracted. As a result, the method to list all server details as presented in the OvmWsSoapClient class is a simple call directly to the equivalent method exposed directly through the library:

@Override
public List<Server> serverGetAll() throws WsException
{
    try
    {
        return api.serverGetAll();
    }
    catch (final WsException_Exception ex)
    {
        throw convertException(ex);
    }
}

From the WsDevClient code, a call to list all Servers uses the serverGetAll method defined in the OvmWsSoapClient:

final List<Server> servers = api.serverGetAll();

This populates a list, allowing you to loop through it to work with Server details as required:

for (final Server server : servers)
            {
                if (testServerName.equals(server.getName()))
                {
                    testServer = server;
                }
                printServer(server);
            }

Using the methods exposed by the Server model class, it is possible to print out various attributes specific to the Server. In the sample code, we reference the printServer method which is contained within the WsDevClient class. This method performs a variety of tasks. For the purpose of illustrating how you are able to work with a Server object, we have truncated the code in the following listing:

private void printServer(final Server server)
    {
        System.out.println("Server id: " + server.getId());
        System.out.println("\tname: " + server.getName());
        System.out.println("\tdescription: " + server.getDescription());
        System.out.println("\tGeneration: " + server.getGeneration());
        System.out.println("\tServerPool id: " + server.getServerPoolId());
        System.out.println("\tCluster id: " + server.getClusterId());
        System.out.println("\tCpuCompatibilityGroup id: " + 
             server.getCpuCompatibilityGroupId());
        System.out.println("\tServerController id: " + 
             server.getServerControllerId());
...
    }