百度智能云

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.

          Use the following codes to create a image from the specified instance

          // Instance ID used to create the image 
          instanceId := "i-3EavdPl8" 
          // Set the name of the created image 
          imageName := "testCreateImage" 
          queryArgs := &CreateImageArgs{ 
          	 ImageName:  testImageName, 
          	 InstanceId: testInstanceId, 
          } 
          if res, err := bbcClient.CreateImageFromInstanceId(queryArgs); err != nil { 
              fmt.Println("Create image failed: ", err) 
          } else { 
              fmt.Println("Create image success, result: ", res) 
          } 

          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.
          • Support filtering query by imageType. This parameter is not required. If not set, it defaults to All, which means to query all types of images.

          Use the following codes to query the image list

          // Specify what type of image to query 
          // All (all) 
          // System (System image/public image) 
          // Custom (Custom Image) 
          // Integration (Service Integration Image) 
          // Sharing (Shared image) 
          imageType := "All" 
          // Starting location of query for batch acquisition of lists 
          marker := "your-marker" 
          // Maximum number contained in each page. 
          maxKeys := 100 
          queryArgs := &ListImageArgs{ 
              Marker:    marker, 
              MaxKeys:   maxKeys, 
              ImageType: imageType, 
          } 
          if res, err := bbcClient.ListImage(queryArgs); err != nil { 
              fmt.Println("List image failed: ", err) 
          } else { 
              fmt.Println("List image success, result: ", res) 
          } 

          Query Image Details

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

          Use the following codes to query image details.

          // Image ID to be queried 
          image_id :="your-choose-image-id"
          if res, err := bbcClient.GetImageDetail(testImageId); err != nil { 
              fmt.Println("Get image failed: ", err) 
          } else { 
              fmt.Println("Get image success, result: ", res) 
          } 

          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 nor used to create or reset instances.

          Use the following codes to delete the specified image

          imageId := "your-choose-image-id" 
          if err := bbcClient.DeleteImage(testImageId); err != nil { 
              fmt.Println("Delete image failed: ", err) 
          } 
          Previous
          Instance
          Next
          Deployment Set