public static void Main(String[] args) { VMSnapshot obj = new VMSnapshot(); cb = AppUtil.AppUtil.initialize("VMSnapshot" , VMSnapshot.constructOptions() , args); Boolean valid = obj.customValidation(); if (valid) { cb.connect(); String vmName = cb.get_option("vmname"); ManagedObjectReference vmMor = cb.getServiceUtil().GetDecendentMoRef(null, "VirtualMachine", vmName); if (vmMor != null) { String op = cb.get_option("operation"); Boolean res = false; if (op.Equals("create")) { res = obj.createSnapshot(vmMor); } else if (op.Equals("list")) { res = obj.listSnapshot(vmMor); } else if (op.Equals("revert")) { res = obj.revertSnapshot(vmMor); } else if (op.Equals("removeall")) { res = obj.removeAllSnapshot(vmMor); if (!res) { Console.WriteLine("Operation " + op + " cannot be performed."); } } else if (op.Equals("remove")) { res = obj.removeSnapshot(vmMor); } else { Console.WriteLine("Invalid operation" + op.ToString() + ". Valid Operations are [create|list|revert|remoeveall|remove]"); cb.disConnect(); Console.WriteLine("Press any key to exit: "); Console.Read(); Environment.Exit(1); } if (res) { Console.WriteLine("Operation " + op + " completed sucessfully"); } } else { Console.WriteLine("No VM " + vmName + " found"); } cb.disConnect(); } else { Console.WriteLine("Operation can not be performed"); } Console.WriteLine("Press any key to exit: "); Console.Read(); Environment.Exit(1); }