Ñò ›ˆQc@sädZddkZddklZddkZddklZddklZei Z ei Z dei fd„ƒYZ de fd „ƒYZ d e fd „ƒYZd e fd „ƒYZde eifd„ƒYZd„ZdS(sCCommands for interacting with Google Compute Engine disk snapshots.iÿÿÿÿN(t appcommands(t command_base(tgcutil_loggingtSnapshotCommandcBseeZdZdZddddddfZddddddfZd Zd „Zd „Zd „Z RS(s7Base command for working with the snapshots collection.tnamet descriptions creation-timetcreationTimestamptstatuss disk-size-gbt diskSizeGbs source-diskt sourceDiskt snapshotscCstt|ƒi||ƒdS(N(tsuperRt__init__(tselfRt flag_values((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyR 5scCs1|iƒ|_|iƒ|_|iƒ|_dS(sœSet the Google Compute Engine API for the command. Args: api: The Google Compute Engine API used by this command. Returns: None. N(R t_snapshots_apitdiskst _disks_apitzonest _zones_api(R tapi((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pytSetApi8s cKsKh|id6|i|ƒd6}x$|iƒD]\}}|||RtREADYtFAILEDcCstt|ƒi||ƒtidddd|ƒtidddd|ƒtidddd|ƒtid td d|ƒdS( NRtsSnapshot description.Rt source_disks"The source disk for this snapshot.tzonesThe zone of the disk.twait_until_completes?Whether the program should wait until the snapshot is complete.(R R(R tflagst DEFINE_stringtNonetDEFINE_booleantFalse(R RR((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyR cs"    c Csq|iip:|iƒ}|ptidƒ‚n|d|i_nd}|idƒo|i|i|iiƒ}n|i|i |d|iiƒ}h|i d6}h|i dƒd6|i |ƒd6|ii d 6|d 6}||d <|i i|}|iƒ}|iioQ|i|it|ƒ}|id ƒp%|i|ƒ}|i||ƒ}qmn|S( sšAdd the specified snapshot. Args: snapshot_name: The name of the snapshot to add Returns: The result of inserting the snapshot. s2You cannot create a snapshot if you have no disks.Rtunusedtv1beta14RRRtkindRR tbodyterror(t_flagsR,t_PromptForDiskRt CommandErrort_IsUsingAtLeastApiVersiontGetZoneForResourceRtNormalizePerZoneResourceNameRt_GetResourceApiKindRRRtinserttexecuteR.tWaitForOperationttimetgett_InternalGetSnapshott_WaitUntilSnapshotIsComplete( R RtdiskR-R,Rtsnapshot_resourcetsnapshot_requesttresult((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pytHandlews<         cCs%|ii|i|ƒ}|iƒS(s¿A simple implementation of getting current snapshot state. Args: snapshot_name: the name of the snapshot to get. Returns: Json containing full snapshot information. (RRDR RA(R RRI((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyRE©s cCsÔ||i}tiƒ}tid|iiƒxztiƒ||iijo\||ijoLtid||iiƒti|iiƒ|i |ƒ}||i}q2W||ijoti d|ƒn|S(sÆWaits for the snapshot to complete. Periodically polls the server for current snapshot status. Exits if the status of the snapshot is READY or FAILED or the maximum waiting timeout has been reached. In both cases returns the last known snapshot details. Args: result: the current state of the snapshot. snapshot_name: the name of the snapshot to watch. Returns: Json containing full snapshot information. s3Will wait for snapshot to complete for: %d seconds.s;Waiting for snapshot. Current status: %s. Sleeping for %ss.s3Timeout reached. Snapshot %s has not yet completed.( t status_fieldRCtLOGGERtinfoR9t max_wait_timet_TERMINAL_STATUStsleep_between_pollstsleepREtwarn(R RJRtcurrent_statust start_time((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyRF¶s"      ( R!R"R#tpositional_argsRLRPR RKRERF(((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyR(\s   2 t GetSnapshotcBs&eZdZdZd„Zd„ZRS(sGet a machine snapshot.scCstt|ƒi||ƒdS(N(R RWR (R RR((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyR ÜscCs%|ii|i|ƒ}|iƒS(s˜Get the specified snapshot. Args: snapshot_name: The name of the snapshot to get Returns: The result of getting the snapshot. (RRDR RA(R RRI((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyRKßs (R!R"R#RVR RK(((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyRW×s tDeleteSnapshotcBs,eZdZdZdZd„Zd„ZRS(s%Delete one or more machine snapshots.ssDelete snapshotcCstt|ƒi||ƒdS(N(R RXR (R RR((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyR ôscGsdg}x0|D](}|i|ii|i|ƒƒq W|i|ƒ\}}|i|dƒ|fS(sÀDelete the specified snapshots. Args: *snapshot_names: The names of the snapshots to delete Returns: Tuple (results, exceptions) - results of deleting the snapshots. t operationList(tappendRtdeleteR tExecuteRequeststMakeListResult(R tsnapshot_namestrequestsRtresultst exceptions((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyRK÷s (R!R"R#RVt safety_promptR RK(((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyRXîs  t ListSnapshotscBseZdZd„ZRS(s)List the machine snapshots for a project.cCs |iiS(s+Returns the function for listing snapshots.(Rtlist(R ((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pytListFunc s(R!R"R#Re(((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyRcscCsDtidtƒtidtƒtidtƒtidtƒdS(Nt addsnapshott getsnapshottdeletesnapshott listsnapshots(RtAddCmdR(RWRXRc(((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyt AddCommandss(R#RCtgoogle.apputilsRtgflagsR/tgcutilRRtFLAGSRMtGoogleComputeCommandRR(RWRXtGoogleComputeListCommandRcRk(((sb/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_compute_engine/gcutil/snapshot_cmds.pyts    ;{