package nebula;


public class Main {
	public static String usageString = "nebula command line : ";
	//nebula vm [stuff]
	public static void vm_do(String[] args,VirtualMachines vms){
		switch(args[1]){
			case "create":
			    //create a vm and print info
				break;
			case "list":
				vms.displayVM();
				break;
			case "delete":
			case "suspend":
			case "restart": 
			case "detail":
				if(args.length==2 ){
					//print usage
				}else{
					String id=args[2];
					int parsedId = 0;
					try{
						parsedId = Integer.parseInt(args[2]);
					}catch(NumberFormatException nfe){
						System.out.println("error: ID must be an integer");
					}
					switch(args[1]){
					case "delete":
						vms.deleteVM(parsedId);
						break;
					case "suspend":
						vms.suspendVM(parsedId);
						break;
					case "restart":
						vms.restartVM(parsedId);
						break;
					case "detail":
						//details
						break;
					}
				}
				break;
			case "migrate":
				if(args.length<4){
					//print usage
				}else{
					String vm_id_str=args[2];
					String destination_node_str=args[3];
					int vm_id=0;int destination_node=0;
					try{
						vm_id=Integer.parseInt(vm_id_str);
						destination_node=Integer.parseInt(destination_node_str);
					}catch(NumberFormatException nfe){
						System.out.println("error: ID must be an integer");
					}
					
				}
		}
	}
	
	//nebula node [stuff]
	public static void node_do(String[] args,Nodes ns){
		switch(args[1]){
		case "list":
			ns.listNodes();
			break;
		default:
			//print the usage
		}
	}
	public static void P(String arg){ System.out.println(arg); };
	public static String help_text= "nebula API tool"
			+ "usage :    ";
	public static void main(String[] args) {
		
		if(args.length==0){
			P(help_text);
		}
		else{
			switch(args[0]){
			case "help":
				P(help_text);
				break;
			case "vm":
				if(args.length==1){
					//print usage
				}else{
					vm_do(args, new VirtualMachines());
				}
				break;
			case "node":
				node_do(args,new Nodes());
				break;
			case "version":
				(new Nebula()).getVersion();
				break;
			}
		}
	}

}

@@ -1228,24 +1228,88 @@
 _node_str);%0A
+%09%09%09%09%09%09new VirtualMachines().migrateVM(vm_id, destination_node);%0A
 %09%09%09%09%09%7Dcatch(
@@ -1328,32 +1328,32 @@
 Exception nfe)%7B%0A
-
 %09%09%09%09%09%09System.out
@@ -1663,16 +1663,18 @@
 rg); %7D;%0A
+%09%0A
 %09public 
@@ -1718,16 +1718,19 @@
 tool
+ %5Cn
 %22%0A%09%09%09+ %22
 usag
@@ -1729,21 +1729,487 @@
 %09+ %22
-usage :    %22;
+version : retrieves version of Open Nebula used %5Cn%22%0A%09%09%09+ %22node list : retrieves the list of nodes %5Cn%22%0A%09%09%09+ %22vm list : retrieves the list of all virtual machines %5Cn%22%0A%09%09%09+ %22vm delete $id : deletes the virtual machine with the given id %5Cn%22%0A%09%09%09+ %22vm suspend $id : suspends the virtual machine with the given id %5Cn%22%0A%09%09%09+ %22vm restart $id : restarts the virtual machine with the given id %5Cn%22%0A%09%09%09+ %22vm migrate $vmid $nodeid : migrate the virtual machine with the given id to the node%22;%0A%09
 %0A%09pu

Add doc