LibVirtClient { public boolean createVM(String vmName, UUID vmUuid, Flavor flavor, String vmImage) throws Exception { String template; Connect conn; try { log.info("[LibVirtClient] Connecting to local hypervisor"); conn = new Connect("qemu+tcp: log.info("Creating template"); template = buildTemplate( vmName, vmUuid, flavor.getMemory(),flavor.getvCpu(), vmImage); log.info("[LibVirtClient] Resulting template: \n" + template); log.info("[LibVirtClient] Creating VM"); Domain domain = conn.domainCreateXML(template, 0); conn.close(); updateQuota(-flavor.getvCpu(), -0); } catch (LibvirtException e) { mManager.monitoringPublish("There has been a problem creating the VM"); e.printStackTrace(); return false; } return true; } LibVirtClient(); boolean createVM(String vmName,
							  UUID   vmUuid,
			                  Flavor flavor,
	                          String vmImage); boolean deleteVM(UUID vmId); Quota getQuota(); boolean migrate(String vmId, String remoteIp); String buildTemplate(String name, UUID uuid, long memory,
			int vCpu, String vmImage);  }
@Test public void createVM () { long memory; try { Process p=Runtime.getRuntime().exec("free"); p.waitFor(); BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream())); String line=reader.readLine(); if (line != null) { line=reader.readLine(); if (line != null) { memory = Long.valueOf(line.replaceAll(" *"," ").split(" ")[3]); System.out.println("================"); System.out.println(memory); } else { } } else { } } catch (Exception e){ } }