百度智能云

All Product Document

          Baremetal Compute Sevice

          Image

          Create a Custom Image through an Instance

          It is used to create user-defined images, with a default quota of 20 per account. The created images can be used to create instances.

          Only instances in the Running or Stopped state can execute successfully:

          def create_image_from_instance_id(self): 
              client_token = generate_client_token() 
              # Set the name of the created image 
              image_name = 'your-image-name' 
              # Instance ID used to create the image 
              instance_id='your-choose-instance-id' 
              self.client.create_image_from_instance_id(image_name, 
              instance_id=instance_id,
              client_token=client_token) 

          Query Image List

          Used to query all the image information of the user.

          The queried image information includes system image, custom image and service integration image.

          It supports filtering query by imageType. This parameter is not required, and it is All by default if not set, which means to query all types of images:

          def list_images(self): 
              # Specify what type of image to query 
              #All (all) 
              #System (System image/public image) 
              #Custom (Custom Image) 
              #Integration (Service Integration Image) 
              #Sharing (Shared image) 
              image_type = 'All' 
              # Starting location of query for batch acquisition of lists 
              marker = 'your-marker' 
              # Maximum number contained in each page. 
              max_keys = 100
              self.client.list_images(image_type=image_type, 
                                      marker=marker, 
                                      max_keys=max_keys) 

          Query Image Details

          Used to query the detailed information of a single image based on the specified image ID:

          def get_image(self): 
              # Image ID to be queried 
              image_id='your-choose-image-id' 
              self.client.get_image(image_id) 

          Delete Custom Image

          Used to delete user-designated custom images, which is limited to only custom images, and system images and service integration images cannot be deleted.

          The image, once deleted, cannot be restored and can no longer be used to create or reset an instance:

          def delete_image(self): 
              # Image ID to delete 
              image_id='your-choose-image-id' 
              self.client.delete_image(image_id) 
          Previous
          Instance
          Next
          Deployment Set