OpenNebulaAPI { public int createInstance(String gcmadress) { String vmTemplate = "NAME=vm-4-RoQ\n" + "CONTEXT=[\n" + "FILES=\"/nebuladata/scripts/init-RoQ.sh\",\n" + "GATEWAY=\"192.168.0.1\",\n" + "HOSTNAME=\"RoQ-VM-$VMID\",\n" + "TARGET=\"vdb\",\n" + "GCM=\"" + gcmadress + "\"]\n" + "CPU=0.2\n" + "DISK=[\n" + "IMAGE=\"RoQ-OpenNebula\",\n" + "TARGET=\"vda\" ]\n" + "FEATURES=[\n" + "ACPI=\"yes\" ]\n" + "GRAPHICS=[\n" + "KEYMAP=\"fr\",\n" + "LISTEN=\"0.0.0.0\",\n" + "TYPE=\"vnc\" ]\n" + "MEMORY=512\n" + "NIC=[\n" + "NETWORK=\"RoQ\" ]\n" + "OS=[\n" + "ARCH=\"x86_64\",\n" + "BOOT=\"hd\" ]"; logger.info("Trying to allocate the virtual machine... "); OneResponse rc = VirtualMachine .allocate(this.oneConnection, vmTemplate); if (rc.isError()) { logger.error("Failed to allocate VM !" + rc.getErrorMessage() + "\n" + vmTemplate); } else { int newVMID = Integer.parseInt(rc.getMessage()); logger.info("ok, ID " + newVMID + "."); VirtualMachine vm = new VirtualMachine(newVMID, oneConnection); vmAllocated.add(vm); return newVMID; } return -1; } OpenNebulaAPI(String user, String password, String endpoint); int createInstance(String gcmadress); void deleteInstance(int vmID); void cleanAllInstances();  }
@Ignore @Test public void testVM() { int vmID = nebulaAPI.createInstance("127.0.0.1"); try { Thread.sleep(3000); } catch (Exception e) { } deleteVM(vmID); }