Sirocco CIMI Java SDK


The Sirocco CIMI Java SDK defines a Java binding for the DMTF CIMI API 1.0 providing an easy to use Java API hiding the details of the CIMI REST and HTTP protocols.

Installation

Maven developers require a dependency on the sirocco-cimi-java-sdk module. The following dependency needs to be added to the pom:

<dependency>
<groupId>org.ow2.sirocco.cimi</groupId>
<artifactId>sirocco-cimi-java-sdk</artifactId>
<version>0.6.2</version>
</dependency>

Non-maven developers can download the sirocco-cimi-java-sdk zip or tarball  containing the Sirocco CIMI Java SDK jars, dependencies and Javadoc.

Source code

GitHub repository sirocco-cimi-client  

Getting started

Refer to the Java API documentation for details on the Sirocco CIMI Java API packages and classes.

To utilize the client API it is first necessary to login to obtain a CimiClient, for example:

CimiClient cimiClient = CimiClient.login(cimiEndpointUrl, login,password);

The following code snippet shows the creation of a Machine using  given machine configuration, machine image and credential identifiers. It waits for the creation job to be completed then it prints the IP address(es) of the created machine:

MachineCreate machineCreate = new MachineCreate();
MachineTemplate machineTemplate = new MachineTemplate();
machineTemplate.setMachineConfigRef(configId);
machineTemplate.setMachineImageRef(imageId);
machineTemplate.setCredentialRef(credId);
machineCreate.setMachineTemplate(machineTemplate);
machineCreate.setName("myMachine");
machineCreate.setDescription("a test machine");
CreateResult<Machine> result = Machine.createMachine(cimiClient,machineCreate);
String machineId=result.getResource().getId();
System.out.println("Creating machine "+machineId);
result.getJob().waitForCompletion(60, TimeUnit.SECONDS);

Machine machine=Machine.getMachineByReference(cimiClient, machineId);

for(MachineNetworkInterface nic: machine.getNetworkInterfaces()) {
   System.out.println("IP address: "+nic.getAddresses().get(0));
}

The following code snippet shows how to retrieve all available machine configurations:

for(MachineConfiguration machineConfig: MachineConfiguration.getMachineConfigurations(cimiClient))
{
System.out.println("Number of CPU: "+machineConfig.getCpu());
System.out.println("Memory size: "+machineConfig.getMemory()+" KB");
System.out.println("Disks: ");
for(MachineConfiguration.Disk disk: machineConfig.getDisks()) {
System.out.println("Disk capacity "+disk.capacity);
}
}