百度智能云

All Product Document

          Cloud Compute Service

          Snapshot

          Create a Snapshot

          It is used to create a snapshot from the specified disk, and it supports the creation of system disk snapshot and CDS disk snapshot.

          When you create the system disk snapshot, this operation can be performed normally only when the instance is in the Running or Stopped status.

          When you create the CDS disk snapshot, this operation can be performed normally only when the instance is in the InUse or Available status.

          The number of snapshots you can create depends on the total number of disks under the account. At present, it is up to 8 times of the number of disks:

          def create_snapshot(self):
                client_token = generate_client_token()
          
                # Set a snapshot id name
                snapshot_name = 'your-snapshot-name' + client_token
          
                #Disk ID to create snapshot
                volumeId = 'your-choose-volume-id'
                self.assertEqual(
                      type(self.client.create_snapshot(volume_id,
                                                       snapshot_name,
          
                                                       client_token=client_token)), 
                      baidubce.bce_response.BceResponse)

          Query the Snapshot List

          It is used to query all snapshot information, including system disk snapshot and data disk snapshot information:

          def list_snapshots(self): 
          
                #Query the snapshot disk ID in a certain disk
          
                # To query the system disk, enter the instance ID
                volume_id = 'your-volume-id'
          
                # Start position of the query for getting list by batch 
                marker = 'your-marker'
          
                # Maximum number of master instances per page
                max_keys = 100
                self.assertEqual(
                      type(self.client.list_snapshots(marker=marker,
                                                      max_keys=max_keys,
                                                      volume_id=volume_id)), 
                      baidubce.bce_response.BceResponse)

          Query the Snapshot Details

          It is used to query the single snapshot details through the user specified snapshot ID:

          def get_snapshots(self): 
          
                # Snapshot ID tobe queried
                snapshot_id = 'your-snapshot-id'
                self.assertEqual(
                      type(self.client.get_snapshots(snapshot_id=snapshot_id)), 
                      baidubce.bce_response.BceResponse)

          Delete a Snapshot

          It is used to delete a snapshot through the specified snapshot ID.

          This operation can be performed normally only when the snapshot is in the CreatedFailed or Available status.

          def delete_snapshots(self): 
          
                #Snapshot ID to be deleted
                snapshot_id = 'your-snapshot-id'
                self.assertEqual(                type(self.client.delete_snapshots(snapshot_id=snapshot_id)), 
                      baidubce.bce_response.BceResponse)
          Previous
          Security Group
          Next
          image