package nebula;

import java.util.Iterator;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.opennebula.client.vm.VirtualMachine;
import org.opennebula.client.vm.VirtualMachinePool;

public class VirtualMachines extends Nebula {

	private VirtualMachinePool vmPool;
	
	public VirtualMachines(){
		super();
		vmPool = new VirtualMachinePool(client);
	}
	
	public void displayVM(){
		
		Iterator<VirtualMachine> vms = vmPool.iterator();
		while(vms.hasNext()){
			
			try {
				
				VirtualMachine vm = vms.next();
				System.out.print("ID : "+vm.getId()+"; ");
				System.out.print("NAME : "+vm.getName()+"; ");
				System.out.print("STATUS : "+vm.lcmStateStr()+"; ");
				String monitoring = vm.monitoring().getMessage();
				Document document = DocumentHelper.parseText(monitoring);
				System.out.print("HOST : "+document.selectSingleNode("//HOSTNAME").getText()+"; ");
				System.out.print("HYPERVISEUR : "+document.selectSingleNode("//VMMMAD").getText()+"; ");
				System.out.println("CPU : "+document.selectSingleNode("//CPU").getText()+"; ");
				
			} catch (DocumentException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
		
	}
	
}

@@ -836,16 +836,60 @@
 oring);%0A
+%09%09%09%09if (vm.state() == 3)%7B // ie VM running%0A%09
 %09%09%09%09Syst
@@ -964,32 +964,33 @@
 xt()+%22; %22);%0A%09%09%09%09
+%09
 System.out.print
@@ -1058,32 +1058,33 @@
 xt()+%22; %22);%0A%09%09%09%09
+%09
 System.out.print
@@ -1087,16 +1087,23 @@
 rint
-ln
 (%22CPU 
+used in %25
 : %22+
@@ -1162,123 +1162,412 @@
 %09%09%09%09
-%0A%09%09%09%7D catch (DocumentException e) %7B%0A%09%09%09%09// TODO Auto-generated catch block%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%09%0A%09%09%7D%0A%09%09
+%09System.out.println(%22Memory used in kB: %22+document.selectSingleNode(%22//MEMORY%22).getText()+%22; %22);%0A%09%09%09%09%7D%0A%09%09%09%09%0A%09%09%09%7D catch (DocumentException e) %7B%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%09%0A%09%09%7D%0A%09%09%0A%09%7D%0A%09%0A%09public void suspendVM(Integer id)%7B%0A%09%09VirtualMachine vm = new VirtualMachine(39, client);%0A%09%09vm.suspend();%0A%09%7D%0A%09%0A%09public void restartVM(Integer id)%7B%0A%09%09VirtualMachine vm = new VirtualMachine(39, client);%0A%09%09vm.resume();
 %0A%09%7D%0A

Add suspend and resume VM