[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-API] [PATCH] xe snapshot-* accepts uuid= for consistency
# HG changeset patch # User David Scott <dave.scott@xxxxxxxxxxxxx> # Date 1270119140 -3600 # Node ID d01d746c3e7345cac33b85278a6b3cee4626f1aa # Parent 6b20fa61bdaea02e0bd4e772d13eac38efde0990 CA-38723: make "xe snapshot-" commands advertise "uuid" parameters (rather than "snapshot-uuid") for consistency with other commands but still secretly accept "snapshot-uuid" to avoid breaking anything. Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx> diff -r 6b20fa61bdae -r d01d746c3e73 ocaml/xapi/cli_frontend.ml --- a/ocaml/xapi/cli_frontend.ml Thu Apr 01 11:51:32 2010 +0100 +++ b/ocaml/xapi/cli_frontend.ml Thu Apr 01 11:52:20 2010 +0100 @@ -984,8 +984,8 @@ "snapshot-revert", { - reqd = ["snapshot-uuid"]; - optn = []; + reqd = []; + optn = ["uuid"]; help ="Revert an existing VM to a previous checkpointed or snapshotted state."; implementation = No_fd Cli_operations.snapshot_revert; flags =[Standard]; @@ -1057,8 +1057,8 @@ "snapshot-reset-powerstate", { - reqd=["snapshot-uuid"]; - optn=["force"]; + reqd=[]; + optn=["uuid"; "force"]; help="Force the VM powerstate to halted in the management toolstack database only. This command is used to recover a snapshot that is marked as 'suspended'. This is a potentially dangerous operation: you must ensure that you do not need the memory image anymore (ie. you will not be able to resume your snapshot anymore)."; implementation= No_fd Cli_operations.snapshot_reset_powerstate; flags=[Standard; Vm_selectors]; @@ -1257,8 +1257,8 @@ "snapshot-export-to-template", { - reqd=["filename"; "snapshot-uuid"]; - optn=["preserve-power-state"]; + reqd=["filename"]; + optn=["uuid"; "preserve-power-state"]; help="Export a snapshot to <filename>."; implementation= With_fd Cli_operations.snapshot_export; flags=[Standard]; @@ -1266,8 +1266,8 @@ "snapshot-clone", { - reqd=["new-name-label"; "snapshot-uuid"]; - optn=["new-name-description"]; + reqd=["new-name-label"]; + optn=["uuid"; "new-name-description"]; help="Create a new template by cloning an existing snapshot, using storage-level fast disk clone operation where available."; implementation= No_fd Cli_operations.snapshot_clone; flags=[Standard]; @@ -1275,8 +1275,8 @@ "snapshot-copy", { - reqd=["new-name-label"; "snapshot-uuid"]; - optn=["new-name-description"; "sr-uuid"]; + reqd=["new-name-label"]; + optn=["uuid"; "new-name-description"; "sr-uuid"]; help="Create a new template by copying an existing VM, but without using storage-level fast disk clone operation (even if this is available). The disk images of the copied VM are guaranteed to be 'full images' - i.e. not part of a CoW chain."; implementation= No_fd Cli_operations.snapshot_copy; flags=[Standard]; @@ -1284,8 +1284,8 @@ "snapshot-uninstall", { - reqd=["snapshot-uuid"]; - optn=["force"]; + reqd=[]; + optn=["uuid"; "force"]; help="Uninstall a snapshot. This operation will destroy those VDIs that are marked RW and connected to this snapshot only. To simply destroy the VM record, use snapshot-destroy."; implementation= With_fd Cli_operations.snapshot_uninstall; flags=[Standard]; @@ -1293,8 +1293,8 @@ "snapshot-destroy", { - reqd=["snapshot-uuid"]; - optn=[]; + reqd=[]; + optn=["uuid"]; help="Destroy a snapshot. This leaves the storage associated with the snapshot intact. To delete storage too, use snapshot-uninstall."; implementation=No_fd Cli_operations.snapshot_destroy; flags=[]; @@ -1302,8 +1302,8 @@ "snapshot-disk-list", { - reqd=["snapshot-uuid"]; - optn=["vbd-params";"vdi-params"]; + reqd=[]; + optn=["uuid"; "vbd-params";"vdi-params"]; help="List the disks on the selected VM(s)."; implementation= No_fd (Cli_operations.snapshot_disk_list false); flags=[Standard; Vm_selectors]; diff -r 6b20fa61bdae -r d01d746c3e73 ocaml/xapi/cli_operations.ml --- a/ocaml/xapi/cli_operations.ml Thu Apr 01 11:51:32 2010 +0100 +++ b/ocaml/xapi/cli_operations.ml Thu Apr 01 11:52:20 2010 +0100 @@ -2171,6 +2171,11 @@ let vm_snapshot_with_quiesce printer = vm_clone_aux Client.VM.snapshot_with_quiesce "Snapshotted" printer false let vm_checkpoint printer = vm_clone_aux Client.VM.checkpoint "Checkpointed " printer false +let get_snapshot_uuid params = + if List.mem_assoc "snapshot-uuid" params + then List.assoc "snapshot-uuid" params + else List.assoc "uuid" params + let snapshot_revert printer rpc session_id params = let snap_uuid = List.assoc "snapshot-uuid" params in let snap_ref = Client.VM.get_by_uuid rpc session_id snap_uuid in @@ -2179,7 +2184,7 @@ let snapshot_op op printer rpc session_id params = let new_name = List.assoc "new-name-label" params in let desc = if List.mem_assoc "new-name-description" params then Some (List.assoc "new-name-description" params) else None in - let uuid = List.assoc "snapshot-uuid" params in + let uuid = get_snapshot_uuid params in let ref = Client.VM.get_by_uuid ~rpc ~session_id ~uuid in let new_ref = op ~rpc ~session_id ~vm:ref ~new_name in ignore (may (fun desc -> Client.VM.set_name_description rpc session_id new_ref desc) desc); @@ -2194,13 +2199,13 @@ snapshot_op op printer rpc session_id params let snapshot_destroy printer rpc session_id params = - let snap_uuid = List.assoc "snapshot-uuid" params in + let snap_uuid = get_snapshot_uuid params in let snap_ref = Client.VM.get_by_uuid rpc session_id snap_uuid in if Client.VM.get_power_state rpc session_id snap_ref <> `Halted then Client.VM.hard_shutdown ~rpc ~session_id ~vm:snap_ref; Client.VM.destroy ~rpc ~session_id ~self:snap_ref let snapshot_uninstall fd printer rpc session_id params = - let snap_uuid = List.assoc "snapshot-uuid" params in + let snap_uuid = get_snapshot_uuid params in let snap_ref = Client.VM.get_by_uuid rpc session_id snap_uuid in vm_uninstall_common fd printer rpc session_id params [snap_ref] @@ -2220,7 +2225,7 @@ let snapshot_reset_powerstate printer rpc session_id params = if not (List.mem_assoc "force" params) then failwith "This operation is extremely dangerous and may cause data loss. This operation must be forced (use --force)."; - let snapshot_uuid = List.assoc "snapshot-uuid" params in + let snapshot_uuid = get_snapshot_uuid params in let snapshot = Client.VM.get_by_uuid rpc session_id snapshot_uuid in Client.VM.power_state_reset rpc session_id snapshot @@ -2309,7 +2314,7 @@ let ( _ : unit list) = do_vm_op printer rpc session_id op params ["vbd-params";"vdi-params"] in () let snapshot_disk_list is_cd_list printer rpc session_id params = - let snapshot_uuid = List.assoc "snapshot-uuid" params in + let snapshot_uuid = get_snapshot_uuid params in let snapshot_ref = Client.VM.get_by_uuid rpc session_id snapshot_uuid in let snapshot = vm_record rpc session_id snapshot_ref in vm_disk_list_aux snapshot is_cd_list printer rpc session_id params 2 files changed, 26 insertions(+), 21 deletions(-) ocaml/xapi/cli_frontend.ml | 32 ++++++++++++++++---------------- ocaml/xapi/cli_operations.ml | 15 ++++++++++----- Attachment:
xen-api.hg.patch _______________________________________________ xen-api mailing list xen-api@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/mailman/listinfo/xen-api
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |