BCC instance

BCC BCC

  • API Reference
    • Appendix
    • Automatic Snapshot Policy Related Interfaces
      • Bind automatic snapshot policy
      • Create automatic snapshot policy
      • Delete automatic snapshot policy
      • Query details of automatic snapshot policy
      • Query the list of automatic snapshot policies
      • Unbind automatic snapshot policy
      • Update automatic snapshot policy
    • Cluster Management Related Interfaces
      • Create EHC Cluster
      • Delete EHC Cluster
      • EHC Cluster List
      • Modify EHC Cluster
    • Common Request Headers and Response Headers
    • Dedicated Cluster Related Interfaces
      • Canceling Dedicated Cluster Auto-Renewal
      • Create a dedicated cluster
      • Dedicated Cluster Renewal
      • Dedicated Cluster Tag Binding
      • Dedicated Cluster Tag Unbinding
      • Enabling Dedicated Cluster Auto-Renewal
      • Querying Dedicated Cluster Details
      • Querying Dedicated Cluster List
      • Resizing Dedicated Cluster
    • Deployment Group Related Interfaces
      • Adjust Deployment Group
      • Create Deployment Group
      • Delete Deployment Group
      • Get Deployment Group Details
      • Modify deployment group
      • Query the deployment group list
      • Remove Instance from Deployment Group
    • Disk Related Interfaces
      • Attach a CDS disk
      • Bind a tag to a disk
      • Cancel Auto-renewal
      • Create a CDS disk
      • Detach a CDS disk
      • Disk Expansion and Type Change
      • Enable auto-renewal
      • Get Purchasable Disk Information
      • Modify disk properties
      • Query CDS Price
      • Query disk details
      • Query the disk list
      • Release a CDS disk (new)
      • Release a CDS disk
      • Rename a disk
      • Renew a disk
      • Roll back disk data
      • Shift charge for disks
      • Unbind a tag from a disk
    • Error response
    • General Description
    • Image Related Interfaces
      • Bind a tag to an image
      • Cancel cross-region replication of custom images
      • Create a custom image
      • Delete a custom image
      • Import an image
      • Modify Custom Image Name
      • Query available public image based on instance specifications
      • Query image details
      • Query List of Users with Shared Image Access
      • Query OS information based on instance IDs in batch
      • Query the image list
      • Replicate a custom image across regions
      • Share a custom image
      • Unbind a tag from an image
      • Unshare a custom image
    • Instance Related Interfaces
      • Add an instance to a security group
      • Add IPv6
      • Batch Adding Secondary IP Addresses for Primary Network Interface Card
      • Batch Convert to Postpay
      • Batch Unsubscribe Prepaid Instances
      • Billing Change - Convert to Subscription
      • Bind a role
      • Bind a tag to an instance
      • Change the instance subnet
      • Change the instance VPC
      • Convert to prepay in batch
      • Create an instance (by specifying instance package specifications)
      • Create automatic renewal rules
      • Create instance
      • Delete automatic renewal rules
      • Delete secondary IP address from the primary network interface card in batch
      • Early Release of Prepaid Instances
      • Enter rescue mode
      • Exit rescue mode
      • Instance Resizing (By Specifying Instance Package Specification)
      • Modify instance attributes
      • Modify instance description
      • Modify instance hostname
      • Modify the instance password
      • Query Instance List by Instance ID
      • Query instance list
      • Query Multiple Instance Details
      • Query recycle bin instance list
      • Query resizing specifications
      • Query the custom data of the instance
      • Query the details of a specified instance
      • Query the list of BCC instances eligible for no charge for stopped instances
      • Query the VNC address of the instance
      • Reboot an instance
      • Reinstall an instance
      • Reinstall OS for Instances (Batch Reinstallation)
      • Release instances in batch
      • Release IPv6
      • Release Postpay Instances (Release via POST Request)
      • Release recycle bin instances
      • Remove an instance from a security group
      • Remove the relationship between an instance and its deployment group
      • Renew an instance
      • Resize instances in batches
      • Resuming Billing for BCC in Recycle Bin
      • Retrieve a list of instance roles
      • Retrieve network interface card information for an instance
      • Set Auto-release of Spot Instance EIP
      • Set Instance Deletion Protection
      • Setting Auto-Release for Postpay
      • Start an instance
      • Starting Instances (Batch Start)
      • Stop an instance
      • Stopping Instances (Batch Stop)
      • Unbind a role
      • Unbind a tag from an instance
    • Key Pair Related Interfaces
      • Bind a key pair
      • Change description of key pair
      • Create a key pair
      • Delete a key pair
      • Import a key pair
      • Query key pair details
      • Query the key pair list
      • Rename a key pair
      • Unbind a key pair
    • Maintenance platform APIs
      • Maintenance Records Related Interfaces
      • Maintenance Task Related Interfaces
      • Pre-authorization Related Interfaces
    • Other APIs
      • Query instance package price
      • Query instance package specifications (new)
      • Querying Availability Zones By Package Specification
    • Overview
    • Region and Availability Zone Related Interfaces
      • Query list of availability zones
      • Retrieve the Domain Name List API
    • Reserved Instance Related Interfaces
      • Accept Reserved Instance Transfer
      • Adjust reserved instance
      • Bind Tag to Reserved Instance
      • Create Auto-renewal Rule for Reserved Instance
      • Create reserved instances
      • Disable Auto-renewal Rule for Reserved Instance
      • Initiate Reserved Instance Transfer
      • Query Reserved Instance
      • Reject Reserved Instance Transfer
      • Renew reserved instances
      • Reserved Instance Inbound List
      • Reserved Instance Outbound List
      • Revoke Reserved Instance Transfer
      • Unbind Tag from Reserved Instance
    • Security Group Related Interfaces
      • Authorize security group rules
      • Create a security group
      • Delete a security group
      • Delete security group rules
      • Instance associating with security group
      • Query the security group list
      • Replace security group for instance
      • Revoke security group rules
      • Unbind security group from instance
      • Update security group rules
    • Service domain
    • Snapshot Related Interfaces
      • Bind a tag to a snapshot chain
      • Create a snapshot
      • Delete a snapshot
      • Query snapshot chain list
      • Query snapshot details
      • Query the snapshot list
      • Replicate a snapshot across regions
      • Unbind a tag from a snapshot chain
    • Spot Instance Related Interfaces
      • Cancel Spot Instance Order
      • Create spot instances
      • Query Spot Instance Packages
      • Query Spot Price
  • Cloud Assistant API and SDK Reference
    • Python SDK
      • Batch Retrieval of bsm-agent State within Instances
      • CaClient
      • Command Interface
      • Historical records
      • Initialization
      • Install SDK
      • Log API
  • Cloud Assistant API Reference
    • Batch Retrieve Instance BSM-Agent Status
    • Command Interface
    • Common Request and Response Headers
    • Error response
    • General Description
    • Historical records
    • Log API
    • Service domain
  • FAQs
    • Billing class
    • Common Questions Overview
    • Images
    • Instances
    • Network class
    • Performance
    • Reserved Instance
    • Security class
    • Snapshots
    • Storage class
    • Virtual machine operation and maintenance class
  • Fault handling
    • GPU Instance Downtime Troubleshooting
    • Linux Baidu Cloud Compute Entering Single User Mode to Reset Paasword Reports Error-Authentication token lock busy
    • Linux Baidu Cloud Compute Entering Single User Mode to Reset Paasword Reports Error-Authentication token manipulation error
    • Linux Baidu Cloud Compute Entering Single User Mode to Reset Root Paasword
    • Linux Baidu Cloud Compute Execution Yum Update Reports Dependency Conflict
    • Linux Baidu Cloud Compute Setting Login Method
    • Unable to Remotely Connect to Linux Instance
    • Unable to Remotely Connect to Windows Instance
    • Windows Server Cannot Ping
  • Function Release Records
  • Go-SDK
    • Automatic snapshot policy
    • Availability zone
    • Dedicated CDS Cluster
    • Deployment group
    • Disk
    • Elastic high-performance computing cluster
    • Image
    • Initialization
    • Instance
    • Key pair
    • Overview
    • Region
    • Reserved Instance
    • Security group
    • Snapshot
  • Java-SDK
    • Automatic snapshot policy
    • Availability zone
    • BCC instance
    • BccClient
    • Deployment group
    • Disk
    • Exception handling
    • Image
    • Install the SDK Package
    • Key pair
    • Log
    • Overview
    • Quick Start
    • Region
    • Reserved Instance
    • Security group
    • Snapshot
    • Version Change Records
  • Operation guide
    • Deployment group
      • Adjust Deployment Group for Existing Instances
      • Create BCC Instance within Deployment Group
      • Create Deployment Group
      • Delete Deployment Group
      • Modify Deployment Group Information
      • Overview of deployment policy
      • Remove BCC Instance from Deployment Group
    • Elastic high-performance computing cluster
      • Create Elastic High-performance Computing Cluster
      • Overview of elastic hyper-computing cluster
    • Image
      • Baidu AI Cloud Image Service Agreement
      • Create a custom image
      • Creating Linux Image Based on Local System
      • Cross-region image replication
      • Data and Personal Information Protection Statement
      • Delete a custom image
      • How to Set Network Adapter Multi-Queue Properties
      • Image List
      • Image Overview
      • Image Quick Guide
      • Import Custom Image
        • Checking Network Configuration
        • Checking Virtio Driver
        • Creating Instance Using Imported Custom Image
        • Detecting Image Using Image Detection Tool
        • Image format check
        • Image Format Conversion
        • Image Import Restrictions
        • Import Overview
        • Install cloudbase-init
        • Installing Virtio Driver
        • System Optimization Operations (Linux)
      • OS Official End of Maintenance Plan
      • Public Image Release Records
        • 2023 BCC Public Image Release Records
        • 2023 EBC Public Image Release Records
        • 2024 BCC Public Image Release Records
        • 2024 EBC Public Image Release Records
        • 2025 BCC Public Image Release Records
      • Reinstall OS
      • Share a custom image
      • Windows Image Creation
    • Instance
      • Batch Sequential Naming
      • Change Availability Zone
      • Change Charge Type
        • Postpay to Subscription
        • Subscription to Postpay
      • Change Instance Configuration
      • Create instance
        • Create Instance Navigation
        • Create Instance via Custom Image
        • Create Instance via Purchase Page
        • Create Instances with Launch Templates
        • Purchase Instance with Same Configuration
      • Cross-AZ migration
      • Functional restrictions
      • Instance Overview
      • Modify instance name
      • Postpay Instance No Charge for Stopped Instances
      • Reboot an instance
      • Reclaim instance
      • Release an instance
      • Renew an instance
      • Reset password
      • Set IAM Role
      • Sign in to instance
        • Log in to Linux Instance
          • Connect to Baidu Cloud Compute Using SmartTerm
          • Connect to Linux instance using user name-password certification
          • Log in to Linux Instance Using SSH Key on Linux or Mac
          • Log in to Linux Instance Using SSH Key via SecureCRT
          • Remotely sign in to Baidu Cloud Computer via VNC
          • Sign in to Linux instances via SSH key in Putty
          • Sign in to Linux instances via SSH key in Xshell
        • Log in to Windows Instance
          • Remotely sign in to Baidu Cloud Computer via VNC
          • Sign in to Windows instance via remote desktop
        • Login Method Overview
      • Spot instances
        • Create spot instances
        • What Is Spot Instance
      • Start an instance
      • Stop an instance
        • Elastic Baremetal Instance and Elastic High-performance Computing Cluster Instance Halt Capability Configuration Instructions
        • Stop an instance
      • View instance
    • Launch Template
    • Network
      • Bind and Unbind EIP
      • Change Internal IP
      • Change subnet
      • Change VPC
      • Configure Dual Network Interface Card External Network Access for Windows Baidu Cloud Compute
      • Configure IPv6 Address
      • Elastic network interface
        • Configure elastic network interface
        • Create elastic network interface
        • Elastic Network Interface Overview
        • Mount elastic network interface
      • Elastic RDMA Network Interface
        • Elastic RDMA Network Interface Overview
        • Instructions for use
    • Operations and Monitor
      • Cloud Assistant
        • Cloud Assistant Overview
        • Cloud Assistant Usage Notes
        • Create command
        • FAQs
        • Historical records
        • Identity and access management
        • Instance list
        • My commands
        • Public commands
        • Upload files
      • Evacuate Faulty Instance
      • Instance Health Check
      • Maintenance Platform
        • Maintenance Platform Access Instructions
        • Maintenance Platform Overview
        • Maintenance Records Query
        • Maintenance Task
        • Pre-authorization Rule Settings
      • Monitor and Alarm
      • Self-Service Diagnostic Tool
        • Application Performance Diagnostic Tool Btune
        • Self-Service Diagnostic Tool Overview
      • Use Rescue Mode
    • Reserved Instance
      • FAQ
      • Introduction to reserved instance
      • Renew reserved instances
      • Reserved Instance AZ Change
      • Reserved Instance Cross-Account Transfer
      • Reserved Instance EHC Cluster Change
      • Reserved Instance Purchase
    • Resource Assessment
    • Security
      • Identity and access management
        • Identity and access management
        • Price Permission Control
      • Key pair
        • Bind SSH Key Pair
        • Create SSH Key Pair
        • Delete SSH Key Pair
        • SSH Key Pair Overview
        • Unbind SSH Key Pair
      • Security group
        • Associate with security group
        • Copy security group
        • Create a security group
        • Delete a security group
        • Disassociate security group
        • Edit security group
        • Security group overview
    • Server Migration
      • Migration Operation Steps
      • Server Migration Operation Process
      • Server Migration Overview
    • Snapshot
      • Automatic snapshot
      • Create disk snapshot
      • Delete a snapshot
      • Rollback snapshot
      • Snapshot Overview
    • Storage
      • Overview
      • System disk expansion
    • Tag Management
      • Configure Tag
      • Tag Management Overview
      • View Resource Bill Based on Tag
  • Operations Reference
    • Linux Operations Reference
      • Baidu Cloud Compute Delete or Modify File Prompting File System Read-Only
      • CentOS 7 Install Docker
      • Configure Linux Analysis Tools atop and kdump
      • Enter Single User Mode
        • CentOS 6 Enter Single User
        • CentOS 7 Enter Single User
        • CentOS 8 Enter Single User
        • FreeBSD 11 Single User Modify Password SOP
        • opensuse42
          • 3 Enter Single User
        • Ubuntu Enter Single User
        • OpenSUSE 42_3 Enter Single User
      • How to Enable or Disable Intel CPU Vulnerability Patch in Linux Image
      • How to Handle System Boot Exception Caused by fstab Configuration
      • How to Resolve Unable to Log in to Linux BCC Instance via SSH
      • Linux BCC Instance Insufficient Space Issue Resolution
      • Linux BCC Instance Lagging Issue
      • Linux Format and Mount Instance Mount Local Disk
      • Linux Modify Default Remote Connection Port
      • Linux Server CPU and Memory Full Issue Troubleshooting
      • Linux System Install Graphical Interface and Remote Connection
        • CentOS
          • CentOS 8 Install Graphical Interface and Connect Using VNC Viewer
          • CentOS6
            • 5 Install KDE Desktop Graphical Interface and Connect Using VNC Viewer
          • CentOS7
            • 2 Install GNOME Graphical Interface and Connect Using VNC Viewer
          • Install GNOME GUI on CentOS 7_2 and Connect via VNC Viewer
          • Install GUI on CentOS 8 and Connect via VNC Viewer
          • Install KDE Desktop GUI on CentOS 6_5 and Connect via VNC Viewer
        • opensuse
          • opensuse42
            • 3 Install Graphical Interface and Connect Using VNC Viewer
          • Install GUI on OpenSUSE 42_3 and Connect via VNC Viewer
        • Ubuntu
          • Ubuntu14
            • 04 Install Graphical Interface and Connect Using VNC Viewer
          • Ubuntu18
            • 04 Install Graphical Interface and Connect Using VNC Viewer
          • Install GUI on Ubuntu 14_04 and Connect via VNC Viewer
          • Install GUI on Ubuntu 18_04 and Connect via VNC Viewer
      • Performance test
        • Linux CPU Performance Test
        • Linux Disk IO Performance Test
        • Linux Network Performance Test
      • Ubunut16_04 Subscription Extended Security Maintenance (ESM)
    • Server configuration
      • Debian 9 Software Source Configuration Update
      • Linux PIP Configuration with Baidu Source
      • Online Instance with OFED Driver Kernel Replacement Solution
      • Windows PIP Configuration with Baidu Source
    • Windows Operations Reference
      • Blue Screen Crash General Handling Method
      • Configure Multi-User Access to Windows Server
      • Connecting to Windows Server Using Xshell
      • Data Disk Not Displayed After Server Reboot
      • Desktop and Application Color Turning Black Handling Method
      • Local Playback of Sound from Windows Server
      • Performance Resources
      • Remote Connection to Windows Unable to Use Clipboard
      • System Activation
      • System Black Screen Handling Method
      • Tutorial on Disabling Windows Firewall
      • Windows Allow Single User to Connect Multiple Sessions Method
      • Windows automatic update-related configuration
      • Windows BCC Instance Achieve SID Uniqueness After Joining Domain
      • Windows BCC Instance Lagging Issue
      • Windows CPU and Memory Full Troubleshooting Steps
      • Windows Delete Hardware Reserved Memory
      • Windows Instance Disk Space Insufficient Cleanup Tutorial
      • Windows Modify Default Remote Connection Port
      • Windows Quick Login
      • Windows Server Disable IE Enhanced Security Configuration Tutorial
      • Windows Set Only Allow Local & Fixed IP Access Remote Port
      • Windows Virtual Machine Auto Login Failure Handling Method
  • Product Description
    • Application scenarios
    • Correspondence Between Original and New Model Names
    • Discontinued Instance Specifications
    • Models and Their Regions
    • Product advantages
    • Usage restrictions
    • What Is Baidu Cloud Compute BCC
    • Instance specification
  • Product pricing
    • Billing overview
    • Charge type
      • Postpay Pricing
      • Reserved instances
      • Subscription (Prepay) Pricing
      • Reserved Instance
    • Refund policy
  • Python-SDK
    • BccClient
    • Disk
    • Image
    • Initialization
    • Install the SDK Package
    • Instance
    • Overview
    • Region
    • Reserved Instance
    • Security group
    • Snapshot
    • Version Change Records
  • Python3-SDK
    • Automatic snapshot policy
    • BccClient
    • Dedicated CDS Cluster
    • Deployment group
    • Disk
    • Image
    • Initialization
    • Install the SDK Package
    • Instance
    • Key pair
    • Overview
    • Region
    • Reserved Instance
    • Security group
    • Snapshot
  • Quick Start
    • Baidu Cloud Compute Security Description
    • Quick Configuration of Linux Baidu Cloud Compute
    • Quick Configuration of Windows Baidu Cloud Compute
  • Resources
    • Baidu AI Cloud Image Service Agreement
    • Image Quick Guide
  • Service Level Agreement (SLA)
    • Baidu Intelligent Cloud Baidu Cloud Compute Trusted Cloud
    • BCC Service Level Agreement SLA (V3_0)
  • Tag Service API Reference
    • Appendix 1
    • Domain name
    • General Description
    • Interface List
      • Create tag
      • Delete tag
      • Tag List
      • View resources bound to a tag
    • Introduction
  • Transfer
    • Site Offline Migration Solution
    • Site Smooth Migration Solution
  • Typical Practices
    • Connecting to Windows Server Using Xshell
    • Environment Setup
      • Manual Deployment of SQL Server 2008 R2 Express Edition
      • One-Click Setup for Linux Palworld Server
      • One-Click Setup for Windows Palworld Server
      • Set Up FTP Service on Linux
      • Setting Up Baota on Linux
      • Setting Up Baota on Windows
      • Tutorial on Setting Up IIS and FTP on Windows
      • Typical Practice for Setting Up Access VPN
      • Installing MySQL 8_0 Using Yum on CentOS 7 yum
    • Set Up FTP Service on Linux
    • Tag Management Practice
    • Tutorial on Disabling IE Enhanced Security Configuration on Windows Server 2008
    • Tutorial on Disabling Windows Firewall
    • Website Building Tutorial
      • Building a Website Using IIS Service on Windows 2008 and Windows 2012
      • Deploy SSL Certificate on Baidu Cloud Compute - Apache
      • Deploy SSL Certificate on Baidu Cloud Compute - IIS
      • Deploy SSL Certificate on Baidu Cloud Compute - Nginx
      • Deploy SSL Certificate on Baidu Cloud Compute - Tomcat
      • Installing and Configuring Apache Environment on Windows
      • Installing and Configuring Nginx Environment on Windows
      • CentOS-7_2 LNMP Environment Deployment
      • Deploy LAMP Environment on CentOS-7_2
  • Video Zone
    • Fault handling
    • Operation guide
      • Basic Functions
      • Environment Setup
      • Network Related
      • Operations Reference
      • Paasword Function
    • Operation guide
    • Product introduction
All documents
menu
No results found, please re-enter

BCC BCC

  • API Reference
    • Appendix
    • Automatic Snapshot Policy Related Interfaces
      • Bind automatic snapshot policy
      • Create automatic snapshot policy
      • Delete automatic snapshot policy
      • Query details of automatic snapshot policy
      • Query the list of automatic snapshot policies
      • Unbind automatic snapshot policy
      • Update automatic snapshot policy
    • Cluster Management Related Interfaces
      • Create EHC Cluster
      • Delete EHC Cluster
      • EHC Cluster List
      • Modify EHC Cluster
    • Common Request Headers and Response Headers
    • Dedicated Cluster Related Interfaces
      • Canceling Dedicated Cluster Auto-Renewal
      • Create a dedicated cluster
      • Dedicated Cluster Renewal
      • Dedicated Cluster Tag Binding
      • Dedicated Cluster Tag Unbinding
      • Enabling Dedicated Cluster Auto-Renewal
      • Querying Dedicated Cluster Details
      • Querying Dedicated Cluster List
      • Resizing Dedicated Cluster
    • Deployment Group Related Interfaces
      • Adjust Deployment Group
      • Create Deployment Group
      • Delete Deployment Group
      • Get Deployment Group Details
      • Modify deployment group
      • Query the deployment group list
      • Remove Instance from Deployment Group
    • Disk Related Interfaces
      • Attach a CDS disk
      • Bind a tag to a disk
      • Cancel Auto-renewal
      • Create a CDS disk
      • Detach a CDS disk
      • Disk Expansion and Type Change
      • Enable auto-renewal
      • Get Purchasable Disk Information
      • Modify disk properties
      • Query CDS Price
      • Query disk details
      • Query the disk list
      • Release a CDS disk (new)
      • Release a CDS disk
      • Rename a disk
      • Renew a disk
      • Roll back disk data
      • Shift charge for disks
      • Unbind a tag from a disk
    • Error response
    • General Description
    • Image Related Interfaces
      • Bind a tag to an image
      • Cancel cross-region replication of custom images
      • Create a custom image
      • Delete a custom image
      • Import an image
      • Modify Custom Image Name
      • Query available public image based on instance specifications
      • Query image details
      • Query List of Users with Shared Image Access
      • Query OS information based on instance IDs in batch
      • Query the image list
      • Replicate a custom image across regions
      • Share a custom image
      • Unbind a tag from an image
      • Unshare a custom image
    • Instance Related Interfaces
      • Add an instance to a security group
      • Add IPv6
      • Batch Adding Secondary IP Addresses for Primary Network Interface Card
      • Batch Convert to Postpay
      • Batch Unsubscribe Prepaid Instances
      • Billing Change - Convert to Subscription
      • Bind a role
      • Bind a tag to an instance
      • Change the instance subnet
      • Change the instance VPC
      • Convert to prepay in batch
      • Create an instance (by specifying instance package specifications)
      • Create automatic renewal rules
      • Create instance
      • Delete automatic renewal rules
      • Delete secondary IP address from the primary network interface card in batch
      • Early Release of Prepaid Instances
      • Enter rescue mode
      • Exit rescue mode
      • Instance Resizing (By Specifying Instance Package Specification)
      • Modify instance attributes
      • Modify instance description
      • Modify instance hostname
      • Modify the instance password
      • Query Instance List by Instance ID
      • Query instance list
      • Query Multiple Instance Details
      • Query recycle bin instance list
      • Query resizing specifications
      • Query the custom data of the instance
      • Query the details of a specified instance
      • Query the list of BCC instances eligible for no charge for stopped instances
      • Query the VNC address of the instance
      • Reboot an instance
      • Reinstall an instance
      • Reinstall OS for Instances (Batch Reinstallation)
      • Release instances in batch
      • Release IPv6
      • Release Postpay Instances (Release via POST Request)
      • Release recycle bin instances
      • Remove an instance from a security group
      • Remove the relationship between an instance and its deployment group
      • Renew an instance
      • Resize instances in batches
      • Resuming Billing for BCC in Recycle Bin
      • Retrieve a list of instance roles
      • Retrieve network interface card information for an instance
      • Set Auto-release of Spot Instance EIP
      • Set Instance Deletion Protection
      • Setting Auto-Release for Postpay
      • Start an instance
      • Starting Instances (Batch Start)
      • Stop an instance
      • Stopping Instances (Batch Stop)
      • Unbind a role
      • Unbind a tag from an instance
    • Key Pair Related Interfaces
      • Bind a key pair
      • Change description of key pair
      • Create a key pair
      • Delete a key pair
      • Import a key pair
      • Query key pair details
      • Query the key pair list
      • Rename a key pair
      • Unbind a key pair
    • Maintenance platform APIs
      • Maintenance Records Related Interfaces
      • Maintenance Task Related Interfaces
      • Pre-authorization Related Interfaces
    • Other APIs
      • Query instance package price
      • Query instance package specifications (new)
      • Querying Availability Zones By Package Specification
    • Overview
    • Region and Availability Zone Related Interfaces
      • Query list of availability zones
      • Retrieve the Domain Name List API
    • Reserved Instance Related Interfaces
      • Accept Reserved Instance Transfer
      • Adjust reserved instance
      • Bind Tag to Reserved Instance
      • Create Auto-renewal Rule for Reserved Instance
      • Create reserved instances
      • Disable Auto-renewal Rule for Reserved Instance
      • Initiate Reserved Instance Transfer
      • Query Reserved Instance
      • Reject Reserved Instance Transfer
      • Renew reserved instances
      • Reserved Instance Inbound List
      • Reserved Instance Outbound List
      • Revoke Reserved Instance Transfer
      • Unbind Tag from Reserved Instance
    • Security Group Related Interfaces
      • Authorize security group rules
      • Create a security group
      • Delete a security group
      • Delete security group rules
      • Instance associating with security group
      • Query the security group list
      • Replace security group for instance
      • Revoke security group rules
      • Unbind security group from instance
      • Update security group rules
    • Service domain
    • Snapshot Related Interfaces
      • Bind a tag to a snapshot chain
      • Create a snapshot
      • Delete a snapshot
      • Query snapshot chain list
      • Query snapshot details
      • Query the snapshot list
      • Replicate a snapshot across regions
      • Unbind a tag from a snapshot chain
    • Spot Instance Related Interfaces
      • Cancel Spot Instance Order
      • Create spot instances
      • Query Spot Instance Packages
      • Query Spot Price
  • Cloud Assistant API and SDK Reference
    • Python SDK
      • Batch Retrieval of bsm-agent State within Instances
      • CaClient
      • Command Interface
      • Historical records
      • Initialization
      • Install SDK
      • Log API
  • Cloud Assistant API Reference
    • Batch Retrieve Instance BSM-Agent Status
    • Command Interface
    • Common Request and Response Headers
    • Error response
    • General Description
    • Historical records
    • Log API
    • Service domain
  • FAQs
    • Billing class
    • Common Questions Overview
    • Images
    • Instances
    • Network class
    • Performance
    • Reserved Instance
    • Security class
    • Snapshots
    • Storage class
    • Virtual machine operation and maintenance class
  • Fault handling
    • GPU Instance Downtime Troubleshooting
    • Linux Baidu Cloud Compute Entering Single User Mode to Reset Paasword Reports Error-Authentication token lock busy
    • Linux Baidu Cloud Compute Entering Single User Mode to Reset Paasword Reports Error-Authentication token manipulation error
    • Linux Baidu Cloud Compute Entering Single User Mode to Reset Root Paasword
    • Linux Baidu Cloud Compute Execution Yum Update Reports Dependency Conflict
    • Linux Baidu Cloud Compute Setting Login Method
    • Unable to Remotely Connect to Linux Instance
    • Unable to Remotely Connect to Windows Instance
    • Windows Server Cannot Ping
  • Function Release Records
  • Go-SDK
    • Automatic snapshot policy
    • Availability zone
    • Dedicated CDS Cluster
    • Deployment group
    • Disk
    • Elastic high-performance computing cluster
    • Image
    • Initialization
    • Instance
    • Key pair
    • Overview
    • Region
    • Reserved Instance
    • Security group
    • Snapshot
  • Java-SDK
    • Automatic snapshot policy
    • Availability zone
    • BCC instance
    • BccClient
    • Deployment group
    • Disk
    • Exception handling
    • Image
    • Install the SDK Package
    • Key pair
    • Log
    • Overview
    • Quick Start
    • Region
    • Reserved Instance
    • Security group
    • Snapshot
    • Version Change Records
  • Operation guide
    • Deployment group
      • Adjust Deployment Group for Existing Instances
      • Create BCC Instance within Deployment Group
      • Create Deployment Group
      • Delete Deployment Group
      • Modify Deployment Group Information
      • Overview of deployment policy
      • Remove BCC Instance from Deployment Group
    • Elastic high-performance computing cluster
      • Create Elastic High-performance Computing Cluster
      • Overview of elastic hyper-computing cluster
    • Image
      • Baidu AI Cloud Image Service Agreement
      • Create a custom image
      • Creating Linux Image Based on Local System
      • Cross-region image replication
      • Data and Personal Information Protection Statement
      • Delete a custom image
      • How to Set Network Adapter Multi-Queue Properties
      • Image List
      • Image Overview
      • Image Quick Guide
      • Import Custom Image
        • Checking Network Configuration
        • Checking Virtio Driver
        • Creating Instance Using Imported Custom Image
        • Detecting Image Using Image Detection Tool
        • Image format check
        • Image Format Conversion
        • Image Import Restrictions
        • Import Overview
        • Install cloudbase-init
        • Installing Virtio Driver
        • System Optimization Operations (Linux)
      • OS Official End of Maintenance Plan
      • Public Image Release Records
        • 2023 BCC Public Image Release Records
        • 2023 EBC Public Image Release Records
        • 2024 BCC Public Image Release Records
        • 2024 EBC Public Image Release Records
        • 2025 BCC Public Image Release Records
      • Reinstall OS
      • Share a custom image
      • Windows Image Creation
    • Instance
      • Batch Sequential Naming
      • Change Availability Zone
      • Change Charge Type
        • Postpay to Subscription
        • Subscription to Postpay
      • Change Instance Configuration
      • Create instance
        • Create Instance Navigation
        • Create Instance via Custom Image
        • Create Instance via Purchase Page
        • Create Instances with Launch Templates
        • Purchase Instance with Same Configuration
      • Cross-AZ migration
      • Functional restrictions
      • Instance Overview
      • Modify instance name
      • Postpay Instance No Charge for Stopped Instances
      • Reboot an instance
      • Reclaim instance
      • Release an instance
      • Renew an instance
      • Reset password
      • Set IAM Role
      • Sign in to instance
        • Log in to Linux Instance
          • Connect to Baidu Cloud Compute Using SmartTerm
          • Connect to Linux instance using user name-password certification
          • Log in to Linux Instance Using SSH Key on Linux or Mac
          • Log in to Linux Instance Using SSH Key via SecureCRT
          • Remotely sign in to Baidu Cloud Computer via VNC
          • Sign in to Linux instances via SSH key in Putty
          • Sign in to Linux instances via SSH key in Xshell
        • Log in to Windows Instance
          • Remotely sign in to Baidu Cloud Computer via VNC
          • Sign in to Windows instance via remote desktop
        • Login Method Overview
      • Spot instances
        • Create spot instances
        • What Is Spot Instance
      • Start an instance
      • Stop an instance
        • Elastic Baremetal Instance and Elastic High-performance Computing Cluster Instance Halt Capability Configuration Instructions
        • Stop an instance
      • View instance
    • Launch Template
    • Network
      • Bind and Unbind EIP
      • Change Internal IP
      • Change subnet
      • Change VPC
      • Configure Dual Network Interface Card External Network Access for Windows Baidu Cloud Compute
      • Configure IPv6 Address
      • Elastic network interface
        • Configure elastic network interface
        • Create elastic network interface
        • Elastic Network Interface Overview
        • Mount elastic network interface
      • Elastic RDMA Network Interface
        • Elastic RDMA Network Interface Overview
        • Instructions for use
    • Operations and Monitor
      • Cloud Assistant
        • Cloud Assistant Overview
        • Cloud Assistant Usage Notes
        • Create command
        • FAQs
        • Historical records
        • Identity and access management
        • Instance list
        • My commands
        • Public commands
        • Upload files
      • Evacuate Faulty Instance
      • Instance Health Check
      • Maintenance Platform
        • Maintenance Platform Access Instructions
        • Maintenance Platform Overview
        • Maintenance Records Query
        • Maintenance Task
        • Pre-authorization Rule Settings
      • Monitor and Alarm
      • Self-Service Diagnostic Tool
        • Application Performance Diagnostic Tool Btune
        • Self-Service Diagnostic Tool Overview
      • Use Rescue Mode
    • Reserved Instance
      • FAQ
      • Introduction to reserved instance
      • Renew reserved instances
      • Reserved Instance AZ Change
      • Reserved Instance Cross-Account Transfer
      • Reserved Instance EHC Cluster Change
      • Reserved Instance Purchase
    • Resource Assessment
    • Security
      • Identity and access management
        • Identity and access management
        • Price Permission Control
      • Key pair
        • Bind SSH Key Pair
        • Create SSH Key Pair
        • Delete SSH Key Pair
        • SSH Key Pair Overview
        • Unbind SSH Key Pair
      • Security group
        • Associate with security group
        • Copy security group
        • Create a security group
        • Delete a security group
        • Disassociate security group
        • Edit security group
        • Security group overview
    • Server Migration
      • Migration Operation Steps
      • Server Migration Operation Process
      • Server Migration Overview
    • Snapshot
      • Automatic snapshot
      • Create disk snapshot
      • Delete a snapshot
      • Rollback snapshot
      • Snapshot Overview
    • Storage
      • Overview
      • System disk expansion
    • Tag Management
      • Configure Tag
      • Tag Management Overview
      • View Resource Bill Based on Tag
  • Operations Reference
    • Linux Operations Reference
      • Baidu Cloud Compute Delete or Modify File Prompting File System Read-Only
      • CentOS 7 Install Docker
      • Configure Linux Analysis Tools atop and kdump
      • Enter Single User Mode
        • CentOS 6 Enter Single User
        • CentOS 7 Enter Single User
        • CentOS 8 Enter Single User
        • FreeBSD 11 Single User Modify Password SOP
        • opensuse42
          • 3 Enter Single User
        • Ubuntu Enter Single User
        • OpenSUSE 42_3 Enter Single User
      • How to Enable or Disable Intel CPU Vulnerability Patch in Linux Image
      • How to Handle System Boot Exception Caused by fstab Configuration
      • How to Resolve Unable to Log in to Linux BCC Instance via SSH
      • Linux BCC Instance Insufficient Space Issue Resolution
      • Linux BCC Instance Lagging Issue
      • Linux Format and Mount Instance Mount Local Disk
      • Linux Modify Default Remote Connection Port
      • Linux Server CPU and Memory Full Issue Troubleshooting
      • Linux System Install Graphical Interface and Remote Connection
        • CentOS
          • CentOS 8 Install Graphical Interface and Connect Using VNC Viewer
          • CentOS6
            • 5 Install KDE Desktop Graphical Interface and Connect Using VNC Viewer
          • CentOS7
            • 2 Install GNOME Graphical Interface and Connect Using VNC Viewer
          • Install GNOME GUI on CentOS 7_2 and Connect via VNC Viewer
          • Install GUI on CentOS 8 and Connect via VNC Viewer
          • Install KDE Desktop GUI on CentOS 6_5 and Connect via VNC Viewer
        • opensuse
          • opensuse42
            • 3 Install Graphical Interface and Connect Using VNC Viewer
          • Install GUI on OpenSUSE 42_3 and Connect via VNC Viewer
        • Ubuntu
          • Ubuntu14
            • 04 Install Graphical Interface and Connect Using VNC Viewer
          • Ubuntu18
            • 04 Install Graphical Interface and Connect Using VNC Viewer
          • Install GUI on Ubuntu 14_04 and Connect via VNC Viewer
          • Install GUI on Ubuntu 18_04 and Connect via VNC Viewer
      • Performance test
        • Linux CPU Performance Test
        • Linux Disk IO Performance Test
        • Linux Network Performance Test
      • Ubunut16_04 Subscription Extended Security Maintenance (ESM)
    • Server configuration
      • Debian 9 Software Source Configuration Update
      • Linux PIP Configuration with Baidu Source
      • Online Instance with OFED Driver Kernel Replacement Solution
      • Windows PIP Configuration with Baidu Source
    • Windows Operations Reference
      • Blue Screen Crash General Handling Method
      • Configure Multi-User Access to Windows Server
      • Connecting to Windows Server Using Xshell
      • Data Disk Not Displayed After Server Reboot
      • Desktop and Application Color Turning Black Handling Method
      • Local Playback of Sound from Windows Server
      • Performance Resources
      • Remote Connection to Windows Unable to Use Clipboard
      • System Activation
      • System Black Screen Handling Method
      • Tutorial on Disabling Windows Firewall
      • Windows Allow Single User to Connect Multiple Sessions Method
      • Windows automatic update-related configuration
      • Windows BCC Instance Achieve SID Uniqueness After Joining Domain
      • Windows BCC Instance Lagging Issue
      • Windows CPU and Memory Full Troubleshooting Steps
      • Windows Delete Hardware Reserved Memory
      • Windows Instance Disk Space Insufficient Cleanup Tutorial
      • Windows Modify Default Remote Connection Port
      • Windows Quick Login
      • Windows Server Disable IE Enhanced Security Configuration Tutorial
      • Windows Set Only Allow Local & Fixed IP Access Remote Port
      • Windows Virtual Machine Auto Login Failure Handling Method
  • Product Description
    • Application scenarios
    • Correspondence Between Original and New Model Names
    • Discontinued Instance Specifications
    • Models and Their Regions
    • Product advantages
    • Usage restrictions
    • What Is Baidu Cloud Compute BCC
    • Instance specification
  • Product pricing
    • Billing overview
    • Charge type
      • Postpay Pricing
      • Reserved instances
      • Subscription (Prepay) Pricing
      • Reserved Instance
    • Refund policy
  • Python-SDK
    • BccClient
    • Disk
    • Image
    • Initialization
    • Install the SDK Package
    • Instance
    • Overview
    • Region
    • Reserved Instance
    • Security group
    • Snapshot
    • Version Change Records
  • Python3-SDK
    • Automatic snapshot policy
    • BccClient
    • Dedicated CDS Cluster
    • Deployment group
    • Disk
    • Image
    • Initialization
    • Install the SDK Package
    • Instance
    • Key pair
    • Overview
    • Region
    • Reserved Instance
    • Security group
    • Snapshot
  • Quick Start
    • Baidu Cloud Compute Security Description
    • Quick Configuration of Linux Baidu Cloud Compute
    • Quick Configuration of Windows Baidu Cloud Compute
  • Resources
    • Baidu AI Cloud Image Service Agreement
    • Image Quick Guide
  • Service Level Agreement (SLA)
    • Baidu Intelligent Cloud Baidu Cloud Compute Trusted Cloud
    • BCC Service Level Agreement SLA (V3_0)
  • Tag Service API Reference
    • Appendix 1
    • Domain name
    • General Description
    • Interface List
      • Create tag
      • Delete tag
      • Tag List
      • View resources bound to a tag
    • Introduction
  • Transfer
    • Site Offline Migration Solution
    • Site Smooth Migration Solution
  • Typical Practices
    • Connecting to Windows Server Using Xshell
    • Environment Setup
      • Manual Deployment of SQL Server 2008 R2 Express Edition
      • One-Click Setup for Linux Palworld Server
      • One-Click Setup for Windows Palworld Server
      • Set Up FTP Service on Linux
      • Setting Up Baota on Linux
      • Setting Up Baota on Windows
      • Tutorial on Setting Up IIS and FTP on Windows
      • Typical Practice for Setting Up Access VPN
      • Installing MySQL 8_0 Using Yum on CentOS 7 yum
    • Set Up FTP Service on Linux
    • Tag Management Practice
    • Tutorial on Disabling IE Enhanced Security Configuration on Windows Server 2008
    • Tutorial on Disabling Windows Firewall
    • Website Building Tutorial
      • Building a Website Using IIS Service on Windows 2008 and Windows 2012
      • Deploy SSL Certificate on Baidu Cloud Compute - Apache
      • Deploy SSL Certificate on Baidu Cloud Compute - IIS
      • Deploy SSL Certificate on Baidu Cloud Compute - Nginx
      • Deploy SSL Certificate on Baidu Cloud Compute - Tomcat
      • Installing and Configuring Apache Environment on Windows
      • Installing and Configuring Nginx Environment on Windows
      • CentOS-7_2 LNMP Environment Deployment
      • Deploy LAMP Environment on CentOS-7_2
  • Video Zone
    • Fault handling
    • Operation guide
      • Basic Functions
      • Environment Setup
      • Network Related
      • Operations Reference
      • Paasword Function
    • Operation guide
    • Product introduction
  • Document center
  • arrow
  • BCCBCC
  • arrow
  • Java-SDK
  • arrow
  • BCC instance
Table of contents on this page
  • Create an instance (by specifying instance package specifications)
  • Create an instance (deprecated; it is recommended to use the "Create Instance" API instead (by specifying instance package specifications))
  • Create a spot instance
  • Query spot instance packages
  • Query the market price of spot instances
  • Cancel a spot instance order
  • Query instance list
  • Query the list of BCC instances eligible for no charge for stopped instances
  • Query instance details
  • Query the instance list by the instance ID
  • Start an instance
  • Stop an instance
  • Stop instances in batch
  • Reboot an instance
  • Modify the instance password
  • Modify instance attributes
  • Modify instance attributes
  • Modify instance description
  • Reinstall an instance
  • Reinstall instance (batch reinstallation)
  • Shift charge - convert to prepay
  • Release an instance
  • Release instance (release via POST request)
  • Release instances in batch
  • Release prepaid instance (POST)
  • Instance scaling
  • Instance scaling (by specified instance package specifications)
  • Add an instance to a security group
  • Remove an instance from a security group
  • Query the VNC address of the instance
  • Renew an instance
  • Bind a tag to an instance
  • Unbind a tag from an instance
  • Change the instance subnet
  • Query instance package specifications
  • Query instance package price
  • Query resizing specifications
  • Retrieve network interface card information for an instance
  • Change the instance VPC
  • Convert to prepay in batch
  • Query recycle bin instance list
  • Release recycle bin instances
  • Remove the relationship between an instance and its deployment group
  • Add IPv6
  • Release IPv6
  • Add secondary IPs to the primary network interface card in batch
  • Delete secondary IP address from the primary network interface card in batch
  • Create automatic renewal rules
  • Delete automatic renewal rules
  • Query the custom data of the instance

BCC instance

Updated at:2025-10-20

A BCC instance refers to an active cloud server instance on Baidu AI Cloud, serving as a management entity for advanced features like billing and permission control.

Create an instance (by specifying instance package specifications)

You can create BCC instances with the following code, including general-purpose BCC instances, storage-optimized BCC instances, compute-optimized BCC instances, big data BCC instances, GPU-based BCC instances and FPGA-based BCC instances:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.Billing;
7import com.baidubce.services.bcc.model.CreateCdsModel;
8import com.baidubce.services.bcc.model.Reservation;
9import com.baidubce.services.bcc.model.StorageType;
10import com.baidubce.services.bcc.model.instance.CreateInstanceRequest;
11import com.baidubce.services.bcc.model.instance.CreateInstanceResponse;
12import java.util.ArrayList;
13import java.util.List;
14import static com.baidubce.services.bcc.model.instance.FpgaCardType.KU115;
15import static com.baidubce.services.bcc.model.instance.GpuCardType.P4;
16public class Main {
17    public static void main(String[] args) {
18        String endpoint = "bcc.bj.baidubce.com";
19        String ak = "ak";
20        String sk = "sk";
21        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
22                .withProtocol(Protocol.HTTP)
23                .withCredentials(new DefaultBceCredentials(ak, sk))
24                .withEndpoint(endpoint);
25        BccClient client = new BccClient(bccClientConfiguration);
26        CreateInstanceRequest instanceRequest = new CreateInstanceRequest();
27// Image ID
28        instanceRequest.setImageId("m-***");
29// Type of virtual machine instance to be created
30        instanceRequest.setSpec("bcc.g5.c1m4");
31// Size of system disk for virtual machine instance to be created, in GB. The default is 40 GB, with a range of [40, 2048]GB. Sizes exceeding 40 GB are charged according to cloud disk server prices. Note that the specified size of system disk must meet the minimum disk space requirement of the image used.
32        instanceRequest.setRootDiskSizeInGb(20);
33// Medium of the system disk for the virtual machine instance to be created. By default, an SSD cloud disk is used
34        instanceRequest.setRootDiskStorageType("enhanced_ssd_pl1");
35// Specify zone information. By default, it is empty and automatically selected by the system. The list of availability zones can be queried by calling the Query Availability Zone List API. The naming convention for zoneName is lowercase "country-region-availability zone sequence", such as "cn-bj-a" for Beijing availability zone A.
36        instanceRequest.setZoneName("cn-bj-a");
37// Name of the virtual machine. By default, no name is specified. If a name is specified: For batch creation, the name serves as a prefix. The backend will append a suffix, generated as follows: name{-sequence number}.
38        instanceRequest.setName("instance-***");
39        List<CreateCdsModel> createCdsList = new ArrayList<CreateCdsModel>();
40        createCdsList.add(new CreateCdsModel()
41                .withCdsSizeInGB(50)
42                .withStorageType("enhanced_ssd_pl1"));
43// List of CDS disks to be created
44        instanceRequest.setCreateCdsList(createCdsList);
45// Public network bandwidth, in Mbps. It must be an integer between 0 and 200. A value of 0 indicates that no public IP will be assigned, with a default of 0 Mbps
46        instanceRequest.setNetworkCapacityInMbps(10);
47// Count of virtual machine instances to be created (purchased) in batch, which must be an integer greater than 0 (optional). The default is 1
48        instanceRequest.setPurchaseCount(1);
49// Hostname of the virtual machine. By default, no hostname is specified. If a hostname is specified: For batch creation, the hostname serves as a prefix. The backend will append a suffix, generated as follows: name{-sequence number}.
50        instanceRequest.setHostname("hostn***");
51// Whether to automatically generate sequential suffixes for name and hostname (optional parameter) Yes: true No: false
52        instanceRequest.setAutoSeqSuffix(true);
53// Administrator password for the instance to be created: 8-16 characters; it must contain English letters, numbers and symbols (limited to !@#$%^*()) simultaneously.
54        instanceRequest.setAdminPass("***");
55// Order and billing-related parameters
56        instanceRequest.setBilling(new Billing()
57                .withPaymentTiming("Postpaid"));
58// Specify subnet information. If empty, it is the default subnet
59        instanceRequest.setSubnetId("sbn-***");
60// Specify security group information. If empty, it is the default security group
61        instanceRequest.setSecurityGroupId("g-***");
62// Whether the specified tag for the instance to be created needs to be associated with an existing tag key; default is false. Note: When the value is true, ensure that the tag key already exists
63        instanceRequest.setRelationTag(true);
64// Automatic snapshot policy ID
65        instanceRequest.setAspId("asp-***");
66// Specify IDs of deployment groups where the instance is located
67        instanceRequest.setDeployId("dset-***");
68        List<String> eniIds = new ArrrayList();
69        eniIds.add("eni-***");
70// Optional parameter. A list of short IDs for elastic network interface cards to be mounted. During batch creation, elastic network interface cards will be evenly distributed among instances based on the count provided. Ensure that the count of elastic network interface card IDs provided is an integer multiple of the count of instances and that the count of ENIs assigned to each instance does not exceed the maximum count that can be mounted by the instance. Elastic baremetal compute (EBC) instances are not currently supported. The maximum number of eniIds is 50,000.
71        instanceRequest.setEniIds(eniIds);
72        CreateInstanceResponse instance = client.createInstance(instanceRequest);
73        System.out.println(instance.getInstanceIds());
74    }
75}
  1. Creating a BCC request is an asynchronous process. A return code of 200 indicates that the order has been generated, and the progress of creating the BCC virtual machine can be monitored by checking the returned instance ID information.
  2. This API is used to create one or more identical virtual machine instances.
  3. Creating an instance requires real-name verification. Those who have not completed the verification can navigate to the Security Certification section in the Baidu Open Cloud Official Website Console to complete real-name certification.
  4. To create a postpaid instance, the account's cash balance combined with general coupons must exceed 100. For prepaid instances, the account's cash balance must at least match the cost of the instance.
  5. Batch creation is supported. If any instance fails during batch creation, all instances will be rolled back, resulting in no successful creations. If CDS is included in the creation, it will also be rolled back.
  6. By default, an instance can attach up to five cloud disk servers.
  7. When creating CDS disks and temporary data disks, the disk capacity must be an exact multiple of 5.
  8. Instance creation allows for the creation and addition of temporary data disks, but does not support creating or adding temporary data disks independently.
  9. Temporary data disks cannot be attached, detached, or deleted after creation.
  10. The maximum size of a temporary data disk for a general-purpose instance is capped at 500 GB.
  11. When specifying a subnet and security group during creation, both must be specified together or left unspecified. The chosen subnet and security group must belong to the same VPC. If neither is specified, the default subnet and security group will be used.
  12. Specify the public IP bandwidth during creation, with charges based on the selected bandwidth.
  13. The creation API is asynchronous. Instance status can be queried using the Query Instance Details API.
  14. Each instance is limited to purchasing a maximum of one temporary data disk.
  15. The default type for a temporary data disk in an instance is hp1.
  16. When creating a storage-optimized instance, you need to purchase a temporary data disk. Specify its size through the ephemeralDisks field. The default is an NVMe-type data disk, so you don't need to enter a value unless a specific size is required.
  17. For detailed instructions on creating requests, please refer to the BCC API documentation [Create Instance (by Specified Instance Package Specifications)](BCC/API Reference/Instance Related Interfaces/Create an instance (by specifying instance package specifications).md) )

Create an instance (deprecated; it is recommended to use the "Create Instance" API instead (by specifying instance package specifications))

You can create BCC instances with the following code, including dedicated instances, general-purpose type I instances, general-purpose type II instances, storage-optimized BCC instances and compute-optimized BCC instances;

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.Billing;
7import com.baidubce.services.bcc.model.CreateCdsModel;
8import com.baidubce.services.bcc.model.Reservation;
9import com.baidubce.services.bcc.model.StorageType;
10import com.baidubce.services.bcc.model.instance.CreateInstanceRequest;
11import com.baidubce.services.bcc.model.instance.CreateInstanceResponse;
12import java.util.ArrayList;
13import java.util.List;
14import static com.baidubce.services.bcc.model.instance.FpgaCardType.KU115;
15import static com.baidubce.services.bcc.model.instance.GpuCardType.P4;
16public class Main {
17    public static void main(String[] args) {
18        String endpoint = "bcc.bj.baidubce.com";
19        String ak = "ak";
20        String sk = "sk";
21        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
22                .withProtocol(Protocol.HTTP)
23                .withCredentials(new DefaultBceCredentials(ak, sk))
24                .withEndpoint(endpoint);
25        BccClient client = new BccClient(bccClientConfiguration);
26        CreateInstanceRequest instanceRequest = new CreateInstanceRequest();
27// Image ID
28        instanceRequest.setImageId("m-***");
29// Type of virtual machine instance to be created
30        instanceRequest.setInstanceType("N6");
31// CPU core count for the VM instance to be created
32        instanceRequest.setCpuCount(1);
33// Memory capacity for virtual machine instance to be created, in GB
34        instanceRequest.setMemoryCapacityInGB(4);
35// Size of system disk for virtual machine instance to be created, in GB. The default is 40 GB, with a range of [40, 2048]GB. Sizes exceeding 40 GB are charged according to cloud disk server prices. Note that the specified size of system disk must meet the minimum disk space requirement of the image used.
36        instanceRequest.setRootDiskSizeInGb(20);
37// Medium of the system disk for the virtual machine instance to be created. By default, an SSD cloud disk is used
38        instanceRequest.setRootDiskStorageType("enhanced_ssd_pl1");
39// Specify zone information. By default, it is empty and automatically selected by the system. The list of availability zones can be queried by calling the Query Availability Zone List API. The naming convention for zoneName is lowercase "country-region-availability zone sequence", such as "cn-bj-a" for Beijing availability zone A.
40        instanceRequest.setZoneName("cn-bj-a");
41// Name of the virtual machine. By default, no name is specified. If a name is specified: For batch creation, the name serves as a prefix. The backend will append a suffix, generated as follows: name{-sequence number}.
42        instanceRequest.setName("instance-***");
43        List<CreateCdsModel> createCdsList = new ArrayList<CreateCdsModel>();
44        createCdsList.add(new CreateCdsModel()
45                .withCdsSizeInGB(50)
46                .withStorageType("enhanced_ssd_pl1"));
47// List of CDS disks to be created
48        instanceRequest.setCreateCdsList(createCdsList);
49// Public network bandwidth, in Mbps. It must be an integer between 0 and 200. A value of 0 indicates that no public IP will be assigned, with a default of 0 Mbps
50        instanceRequest.setNetworkCapacityInMbps(10);
51// Count of virtual machine instances to be created (purchased) in batch, which must be an integer greater than 0 (optional). The default is 1
52        instanceRequest.setPurchaseCount(1);
53// Hostname of the virtual machine. By default, no hostname is specified. If a hostname is specified: For batch creation, the hostname serves as a prefix. The backend will append a suffix, generated as follows: name{-sequence number}.
54        instanceRequest.setHostname("hostn***");
55// Whether to automatically generate sequential suffixes for name and hostname (optional parameter) Yes: true No: false
56        instanceRequest.setAutoSeqSuffix(true);
57// Administrator password for the instance to be created: 8-16 characters; it must contain English letters, numbers and symbols (limited to !@#$%^*()) simultaneously.
58        instanceRequest.setAdminPass("***");
59// Order and billing-related parameters
60        instanceRequest.setBilling(new Billing()
61                .withPaymentTiming("Postpaid"));
62// Specify subnet information. If empty, it is the default subnet
63        instanceRequest.setSubnetId("sbn-***");
64// Specify security group information. If empty, it is the default security group
65        instanceRequest.setSecurityGroupId("g-***");
66// Whether the specified tag for the instance to be created needs to be associated with an existing tag key; default is false. Note: When the value is true, ensure that the tag key already exists
67        instanceRequest.setRelationTag(true);
68// Automatic snapshot policy ID
69        instanceRequest.setAspId("asp-***");
70// Specify IDs of deployment groups where the instance is located
71        instanceRequest.setDeployId("dset-***");
72        CreateInstanceResponse instance = client.createInstance(instanceRequest);
73        System.out.println(instance.getInstanceIds());
74    }
75}
  1. Creating a BCC request is an asynchronous process. A return code of 200 indicates that the order has been generated, and the progress of creating the BCC virtual machine can be monitored by checking the returned instance ID information.
  2. This API is used to create one or more identical virtual machine instances.
  3. Creating an instance requires real-name verification. Those who have not completed the verification can navigate to the Security Certification section in the Baidu Open Cloud Official Website Console to complete real-name certification.
  4. To create a postpaid instance, the account's cash balance combined with general coupons must exceed 100. For prepaid instances, the account's cash balance must at least match the cost of the instance.
  5. Batch creation is supported. If any instance fails during batch creation, all instances will be rolled back, resulting in no successful creations. If CDS is included in the creation, it will also be rolled back.
  6. By default, an instance can attach up to five cloud disk servers.
  7. When creating CDS disks and temporary data disks, the disk capacity must be an exact multiple of 5.
  8. Instance creation allows for the creation and addition of temporary data disks, but does not support creating or adding temporary data disks independently.
  9. Temporary data disks cannot be attached, detached, or deleted after creation.
  10. The maximum size of a temporary data disk for a general-purpose instance is capped at 500 GB.
  11. When specifying a subnet and security group during creation, both must be specified together or left unspecified. The chosen subnet and security group must belong to the same VPC. If neither is specified, the default subnet and security group will be used.
  12. Specify the public IP bandwidth during creation, with charges based on the selected bandwidth.
  13. The creation API is asynchronous. Instance status can be queried using the Query Instance Details API.
  14. This API enables you to designate a dedicated server for instance creation. Dedicated instances are not charged. These instances allow only the creation of temporary disks and the specification of disk types through ephemeralDisks.
  15. Each instance is limited to purchasing a maximum of one temporary data disk.
  16. The default type for a temporary data disk in an instance is hp1.
  17. Use the instanceType field to select the type of virtual machine (VM) you want to create. To see the currently supported VM types, refer to InstanceType. The parameters (instanceType, cpuCount, and memoryCapacityInGB) define the required machine type and configuration.
  18. When creating a storage-optimized instance, you need to purchase a temporary data disk. Specify its size through the ephemeralDisks field. The default is an NVMe-type data disk, so you don't need to enter a value unless a specific size is required.
  19. For detailed instructions on creating requests, please refer to the BCC API documentation [Create Instance](BCC/API Reference/Instance Related Interfaces/Create instance.md)
  20. You need to use specified configurations (including CPU, memory, local data disk, FPGA card type and a dedicated image) to create an FPGA BCC virtual machine. For details, please refer to the BCC API documentation [Optional Specification Configuration of FPGA BCC](BCC/API Reference/Appendix.md#FPGA-purpose BCC Optional Specification Configuration)
  21. You need to use specified configurations (including CPU, memory, local data disk and GPU card type) to create an GPU BCC virtual machine. For details, please refer to the BCC API documentation[Optional Specification Configuration of GPU BCC](BCC/API Reference/Appendix.md#GPU-purpose BCC Optional Specification Configuration).

Create a spot instance

You can be used to create BCC spot instances, including general-purpose type I and general-purpose type III instances with the following code:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.Billing;
7import com.baidubce.services.bcc.model.CreateCdsModel;
8import com.baidubce.services.bcc.model.instance.CreateInstanceRequest;
9import com.baidubce.services.bcc.model.instance.CreateInstanceResponse;
10import java.util.ArrayList;
11import java.util.List;
12public class Main {
13    public static void main(String[] args) {
14        String endpoint = "bcc.bj.baidubce.com";
15        String ak = "ak";
16        String sk = "sk";
17        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
18                .withProtocol(Protocol.HTTP)
19                .withCredentials(new DefaultBceCredentials(ak, sk))
20                .withEndpoint(endpoint);
21        BccClient client = new BccClient(bccClientConfiguration);
22        CreateInstanceRequest instanceRequest = new CreateInstanceRequest();
23// Image ID
24        instanceRequest.setImageId("m-***");
25// Type of virtual machine instance to be created
26        instanceRequest.setSpec("bcc.g5.c1m4");
27// Spot instance bidding model; market price: "market" custom: "custom".
28        instanceRequest.setBidModel("market");
29// CPU core count for the VM instance to be created
30        instanceRequest.setCpuCount(1);
31// Memory capacity for virtual machine instance to be created, in GB
32        instanceRequest.setMemoryCapacityInGB(4);
33// Size of system disk for virtual machine instance to be created, in GB. The default is 40 GB, with a range of [40, 2048]GB. Sizes exceeding 40 GB are charged according to cloud disk server prices. Note that the specified size of system disk must meet the minimum disk space requirement of the image used.
34        instanceRequest.setRootDiskSizeInGb(20);
35// Medium of the system disk for the virtual machine instance to be created. By default, an SSD cloud disk is used
36        instanceRequest.setRootDiskStorageType("enhanced_ssd_pl1");
37// Specify zone information. By default, it is empty and automatically selected by the system. The list of availability zones can be queried by calling the Query Availability Zone List API. The naming convention for zoneName is lowercase "country-region-availability zone sequence", such as "cn-bj-a" for Beijing availability zone A.
38        instanceRequest.setZoneName("cn-bj-a");
39// Name of the virtual machine. By default, no name is specified. If a name is specified: For batch creation, the name serves as a prefix. The backend will append a suffix, generated as follows: name{-sequence number}.
40        instanceRequest.setName("instance-***");
41        List<CreateCdsModel> createCdsList = new ArrayList<CreateCdsModel>();
42        createCdsList.add(new CreateCdsModel()
43                .withCdsSizeInGB(50)
44                .withStorageType("enhanced_ssd_pl1"));
45// List of CDS disks to be created
46        instanceRequest.setCreateCdsList(createCdsList);
47// Public network bandwidth, in Mbps. It must be an integer between 0 and 200. A value of 0 indicates that no public IP will be assigned, with a default of 0 Mbps
48        instanceRequest.setNetworkCapacityInMbps(10);
49// Count of virtual machine instances to be created (purchased) in batch, which must be an integer greater than 0 (optional). The default is 1
50        instanceRequest.setPurchaseCount(1);
51// Hostname of the virtual machine. By default, no hostname is specified. If a hostname is specified: For batch creation, the hostname serves as a prefix. The backend will append a suffix, generated as follows: name{-sequence number}.
52        instanceRequest.setHostname("host***");
53// Whether to automatically generate sequential suffixes for name and hostname (optional parameter) Yes: true No: false
54        instanceRequest.setAutoSeqSuffix(true);
55// Administrator password for the instance to be created: 8-16 characters; it must contain English letters, numbers and symbols (limited to !@#$%^*()) simultaneously.
56        instanceRequest.setAdminPass("***");
57// Order and billing-related parameters
58        instanceRequest.setBilling(new Billing()
59                .withPaymentTiming("Postpaid"));
60// Specify subnet information. If empty, it is the default subnet
61        instanceRequest.setSubnetId("sbn-***");
62// Specify security group information. If empty, it is the default security group
63        instanceRequest.setSecurityGroupId("g-***");
64// Whether the specified tag for the instance to be created needs to be associated with an existing tag key; default is false. Note: When the value is true, ensure that the tag key already exists
65        instanceRequest.setRelationTag(true);
66// Automatic snapshot policy ID
67        instanceRequest.setAspId("asp-***");
68// Specify IDs of deployment groups where the instance is located
69        instanceRequest.setDeployId("dset-***");
70        CreateInstanceResponse instance = client.createBidInstance(instanceRequest);
71        System.out.println(instance.getInstanceIds());
72    }
73}
  1. Submitting a BCC creation request is an asynchronous process. A 200 response indicates that the order has been generated, and the creation progress of the BCC virtual machine can then be monitored by querying the returned spot instance ID.
  2. This API is designed to create one or more identical virtual machine spot instances.
  3. Creating a spot instance requires real-name authentication. Users who have not completed authentication can do so under the security certification tab in the Baidu Open Cloud Official Website Console.
  4. To create a postpaid spot instance, the account's cash balance combined with general vouchers must exceed 100. For prepaid spot instances, the account's cash balance must be at least equal to the instance cost.
  5. Batch creation is supported. If any instance fails during batch creation, all instances will be rolled back, resulting in no successful creations. If CDS is included in the creation, it will also be rolled back.
  6. By default, an instance can attach up to five cloud disk servers.
  7. When creating CDS disks and temporary data disks, the disk capacity must be an exact multiple of 5.
  8. The maximum size of a temporary data disk for a general-purpose instance is capped at 500 GB.
  9. When specifying a subnet and security group during creation, both must be specified together or left unspecified. The chosen subnet and security group must belong to the same VPC. If neither is specified, the default subnet and security group will be used.
  10. Specify the public IP bandwidth during creation, with charges based on the selected bandwidth.
  11. The creation API is asynchronous. Instance status can be queried using the }Query Instance Details API )

Query spot instance packages

You can query BCC virtual machine spot instance packages with the following code

Java
1public static void listBidFlavor(BccClient bccClient) {
2 // Execute operation to query spot instance packages
3    ListBccBidFlavorResponse listBccBidFlavorResponse = bccClient.listBidFlavor();
4    for(ZoneResource zoneResource: listBccBidFlavorResponse.getZoneResources()) {
5        System.out.println(zoneResource.getZoneName());    
6    }
7}

Query the market price of spot instances

You can query the market price of spot instances with the following code

Java
1public static void getBidInstancePrice(BccClient bccClient) {
2    GetBidInstancePriceRequest getBidInstancePriceRequest = new GetBidInstancePriceRequest();
3 // Set spot instance type to be queried as general-purpose BCC type I
4    getBidInstancePriceRequest.setInstanceType(InstanceType.N1.name());
5 // Set spot instance type to be queried as general-purpose BCC type III
6    getBidInstancePriceRequest.setInstanceType(InstanceType.N3.name());
7 // Set count of CPU cores for spot instance to be queried
8    getBidInstancePriceRequest.setCpuCount(cpuCount);
9 // Set memory size in GB for spot instance to be queried
10    getBidInstancePriceRequest.setMemoryCapacityInGB(memoryCapacityInGB);
11 // Set system disk size for spot instance to be queried
12    getBidInstancePriceRequest.setRootDiskSizeInGb(rootDiskSizeInGb);
13 // Set system disk medium for spot instance to be queried
14    getBidInstancePriceRequest.setRootDiskStorageType(rootDiskStorageType);
15    
16    List<CreateCdsModel> createCdsModelList = new ArrayList<CreateCdsModel>();
17 // Create a high-performance blank CDS data disk
18    createCdsModelList.add(new CreateCdsModel().withStorageType(StorageType.hp1).withCdsSizeInGB(5));
19 // Set list of CDS disks for spot instance to be queried
20    getBidInstancePriceRequest.setCreateCdsList(createCdsList);
21 // Set count of spot instances to be queried for purchase
22    getBidInstancePriceRequest.setPurchaseCount(purchaseCount);
23 // Execute operations to query market price of spot instances
24    GetBidInstancePriceResponse getBidInstancePriceResponse = bccClient.getBidInstancePrice(getBidInstancePriceRequest);
25    
26 // Retrieve total price of spot instances to be queried
27    System.out.println(getBidInstancePriceResponse.getMoney());
28 // Retrieve count of spot instances to be queried for purchase
29    System.out.println(getBidInstancePriceResponse.getCount());
30 // Retrieve unit price of spot instances to be queried
31    System.out.println(getBidInstancePriceResponse.getPerMoney());
32}

Cancel a spot instance order

You can cancel a spot instance order with the following code

Java
1public static void cancelBidOrder(BccClient bccClient) {
2    CancelBidOrderRequest cancelBidOrderRequest = new CancelBidOrderRequest();
3 // Set order ID of spot instance to be canceled
4    cancelBidOrderRequest.setOrderId();
5 // Execute operations to cancel spot instance orders
6    CancelBidOrderResponse cancelBidOrderResponse = client.cancelBidOrder(cancelBidOrderRequest);
7    cancelBidOrderResponse.getOrderId();
8}

Query instance list

You can query the list of BCC virtual machine instances with the following code, supporting filtering by intranet IP, dedicated server ID and availability zone name:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.InstanceModel;
5import com.baidubce.services.bcc.model.instance.ListInstancesRequest;
6import com.baidubce.services.bcc.model.instance.ListInstancesResponse;
7public class ListInstances {
8    public static void main(String[] args) {
9 // Set your AK, SK and the endpoint to be accessed
10        String endpoint = "bcc.bj.baidubce.com";
11        String ak = "ak";
12        String sk = "sk";
13 // Set default configuration
14        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration().withProtocol(Protocol.HTTP).withCredentials(new DefaultBceCredentials(ak, sk)).withEndpoint(endpoint);
15 // Create a BCC client
16        BccClient client = new BccClient(bccClientConfiguration);
17        ListInstancesRequest listInstancesRequest = new ListInstancesRequest();
18 // Starting position of batch list query, which is a system-generated string
19        listInstancesRequest.setMarker("i-***");   
20 // Maximum number of items included per page, maximum: 1,000, default: 1,000
21        listInstancesRequest.setMaxKeys(1);  
22 // Intranet IP
23        listInstancesRequest.setInternalIp("192.168.***.***");  
24 // Dedicated server ID
25        listInstancesRequest.setDedicatedHostId("d-***");  
26 // Availability zone information
27        listInstancesRequest.setZoneName("cn-bj-d");  
28 // Multiple tags, separated by commas, format: tagKey:tagValue or tagKey
29        listInstancesRequest.setKeypairId("***");
30        ListInstancesResponse listInstancesResponse = client.listInstances(listInstancesRequest);
31        for (InstanceModel instanceModel : listInstancesResponse.getInstances()) {
32            System.out.println(instanceModel);
33        }
34    }
35}

Query the list of BCC instances eligible for no charge for stopped instances

You can query a list of instances in terms of no charge for stopped instances with the following code, supporting filtering by intranet IP, key pair ID and availability zone name:

Java
1public static void getInstanceNoChargeList(BccClient bccClient) {
2    ListGetInstanceNoChargeRequest listGetInstanceNoChargeRequest = listGetInstanceNoChargeRequest();
3 // Set pagination flag
4    listGetInstanceNoChargeRequest.setMarker(instanceId);
5 // Set size of data returned per page, defaulting to 1,000, maximum 1,000
6    listGetInstanceNoChargeRequest.setMaxKeys(maxKeys);
7 // Query by internalIp
8    listGetInstanceNoChargeRequest.setInternalIp(internalIp);
9 // Query by keypairId
10    listGetInstanceNoChargeRequest.setKeypairId(keypairId);
11 // Query by availability zone name
12    listGetInstanceNoChargeRequest.setZoneName(zoneName);
13 // Execute the API to query non-chargeable instances that can be shut down
14    ListInstancesResponse response = bccClient.getInstanceNoChargeList(listGetInstanceNoChargeRequest);
15    for(InstanceModel instanceModel: response.getInstances()){
16        System.out.println(instanceModel.getId());
17    }
18}

Query instance details

You can query the detailed information of the specified BCC virtual machine with the following code:

Java
1public static void getInstanceDetail(BccClient bccClient) {
2 // Query detailed information on a specified BCC virtual machine
3    InstanceModel instanceModel = bccClient.getInstance(instanceId).getInstance();
4    System.out.println(instanceModel.getName());
5}

Query the instance list by the instance ID

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.ListInstanceByIdsRequest;
5import com.baidubce.services.bcc.model.instance.ListInstancesResponse;
6import java.util.Arrays;
7public class Main {
8    public static void main(String[] args) {
9 // Set your AK, SK and the endpoint to be accessed
10        String endpoint = "bcc.bj.baidubce.com";
11        String ak = "ak";
12        String sk = "sk";
13 // Set default configuration
14        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration().withProtocol(Protocol.HTTP)
15                .withCredentials(new DefaultBceCredentials(ak, sk)).withEndpoint(endpoint);
16 // Create a BCC client
17        BccClient client = new BccClient(bccClientConfiguration);
18 // Query instance list by instance ID
19        ListInstanceByIdsRequest request = new ListInstanceByIdsRequest()
20                .withInstanceIds(Arrays.asList("i-sZcdKAZR", "i-CH47zOoW"));
21        ListInstancesResponse response = client.listInstanceByIds(request);
22        System.out.println(response);
23    }
24}

Start an instance

You can start a specified BCC virtual machine instance with the following code:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4public class StartInstance {
5    public static void main(String[] args) {
6 // Set your AK, SK and the endpoint to be accessed
7        String endpoint = "http://bcc.bj.baidubce.com";
8        String ak = "ak";
9        String sk = "sk";
10 // Set default configuration
11        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
12                .withProtocol(Protocol.HTTP)
13                .withCredentials(new DefaultBceCredentials(ak, sk))
14                .withEndpoint(endpoint);
15 // Create a BCC client
16        BccClient client = new BccClient(bccClientConfiguration);
17 // Set BCC virtual machine ID
18        String instanceId = "i-***";
19 // Execute BCC modification operation
20        client.startInstance(instanceId);
21    }
22}

After a successful API call, instances enter the Starting status. Instance status must be Stopped for this API to return successfully; otherwise, a 409 error will be returned.

Stop an instance

You can stop a specified BCC virtual machine instance with the following code:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.instance.StopInstanceRequest;
7public class StopInstance {
8    public static void main(String[] args) {
9 // Set your AK, SK and the endpoint to be accessed
10        String endpoint = "http://bcc.bj.baidubce.com";
11        String ak = "ak";
12        String sk = "sk";
13 // Set default configuration
14        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
15                .withProtocol(Protocol.HTTP)
16                .withCredentials(new DefaultBceCredentials(ak, sk))
17                .withEndpoint(endpoint);
18 // Create a BCC client
19        BccClient client = new BccClient(bccClientConfiguration);
20        StopInstanceRequest stopInstanceRequest = new StopInstanceRequest();
21 // Set BCC virtual machine ID
22        stopInstanceRequest.setInstanceId("i-***");
23 // Set whether to force stopping, which is equivalent to a power-off operation and may result in the loss of data not written to the disk in the instance OS
24        stopInstanceRequest.setForceStop(Boolean.FALSE);
25 // Set whether to charge for stopped instances. TRUE means no charge for stopped instances, FALSE means charge for stopped instances. Note: Only users in the allow list can enable no charge for stopped instances
26        stopInstanceRequest.setStopWithNoCharge(Boolean.FALSE);
27 // Execute operation to stop the BCC virtual machine
28        client.stopInstance(stopInstanceRequest);
29    }
30}
  • Once the instance has been successfully stopped, the system will transition to the "Stopped" status in the background.
  • This operation is only applicable to instances in the Running status; otherwise, a 409 error will occur.
  • The instance supports forced stopping, similar to a power-off operation, which might lead to the loss of data that hasn't been saved to the disk in the instance's OS.

Stop instances in batch

You can stop a specified BCC virtual machine instance in batch with the following code:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import java.util.Arrays;
7import com.baidubce.services.bcc.model.instance.BatchStopInstanceRequest;
8public class StopInstance {
9    public static void main(String[] args) {
10 // Set your AK, SK and the endpoint to be accessed
11        String endpoint = "http://bcc.bj.baidubce.com";
12        String ak = "ak";
13        String sk = "sk";
14 // Set default configuration
15        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
16                .withProtocol(Protocol.HTTP)
17                .withCredentials(new DefaultBceCredentials(ak, sk))
18                .withEndpoint(endpoint);
19 // Create a BCC client
20        BccClient client = new BccClient(bccClientConfiguration);
21        BatchStopInstanceRequest stopInstanceRequest = new BatchStopInstanceRequest();
22 // Set BCC virtual machine IDs, with no more than 100 elements in the list
23        stopInstanceRequest.setInstanceIds(Arrays.asList("i-KEmEve**","i-0nPl9W**"));
24 // Set whether to force stopping, which is equivalent to a power-off operation and may result in the loss of data not written to the disk in the instance OS
25        stopInstanceRequest.setForceStop(Boolean.FALSE);
26 // Set whether to charge for stopped instances. TRUE means no charge for stopped instances, FALSE means charge for stopped instances. Note: Only users in the allow list can enable no charge for stopped instances
27        stopInstanceRequest.setStopWithNoCharge(Boolean.FALSE);
28 // Execute operation to stop the BCC virtual machine
29        client.batchStopInstance(stopInstanceRequest);
30    }
31}
  • Once the instance has been successfully stopped, the system will transition to the "Stopped" status in the background.
  • This operation is only applicable to instances in the Running status; otherwise, a 409 error will occur.
  • The instance supports forced stopping, similar to a power-off operation, which might lead to the loss of data that hasn't been saved to the disk in the instance's OS.

Reboot an instance

You can reboot a specified BCC virtual machine instance with the following code:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.RebootInstanceRequest;
5public class RebootInstance {
6    public static void main(String[] args) {
7 // Set your AK, SK and the endpoint to be accessed
8        String endpoint = "http://bcc.bj.baidubce.com";
9        String ak = "ak";
10        String sk = "sk";
11 // Set default configuration
12        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
13                .withProtocol(Protocol.HTTP)
14                .withCredentials(new DefaultBceCredentials(ak, sk))
15                .withEndpoint(endpoint);
16 // Create a BCC client
17        BccClient client = new BccClient(bccClientConfiguration);
18 // Set BCC virtual machine ID
19        String instanceId = "i-***";
20 // Execute BCC modification operation
21        client.rebootInstance(new RebootInstanceRequest().withInstanceId(instanceId));
22    }
23}
  • This operation is only applicable to instances in the Running status; otherwise, a 409 error will occur.
  • After a successful API call, the instances will enter the Starting status.
  • It supports forced reboot, which is similar to a power failure reboot on a traditional server and may lead to the loss of data not saved to the disk from the instance's OS.

Modify the instance password

You can modify the administrator password of a specified virtual machine with the following code:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.instance.ModifyInstancePasswordRequest;
7public class Main {
8    public static void main(String[] args) {
9 // Set your AK, SK and the endpoint to be accessed
10        String endpoint = "bcc.bj.baidubce.com";
11        String ak = "ak";
12        String sk = "sk";
13 // Set default configuration
14        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
15                .withProtocol(Protocol.HTTP)
16                .withCredentials(new DefaultBceCredentials(ak, sk))
17                .withEndpoint(endpoint);
18 // Create a BCC client
19        BccClient bccClient = new BccClient(bccClientConfiguration);
20        ModifyInstancePasswordRequest modifyInstancePasswordRequest = new ModifyInstancePasswordRequest();
21 // Set BCC virtual machine ID
22        modifyInstancePasswordRequest.setInstanceId("i-***");
23 // Set new passwords for BCC virtual machine
24        modifyInstancePasswordRequest.setAdminPass("***");
25        
26        bccClient.modifyInstancePassword(modifyInstancePasswordRequest);
27    }
28}

This API can only be used for instances in the Running or Stopped state; otherwise, a 409 error will be returned.

Modify instance attributes

Modify instance attributes

You can modify the attributes of a specified virtual machine with the following code, currently only supporting modification of the name attribute of the BCC virtual machine:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.ModifyInstanceAttributesRequest;
5public class ModifyAttributeInstance {
6    public static void main(String[] args) {
7 // Set your AK, SK and the endpoint to be accessed
8        String endpoint = "http://bcc.bj.baidubce.com";
9        String ak = "ak";
10        String sk = "sk";
11 // Set default configuration
12        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
13                .withProtocol(Protocol.HTTP)
14                .withCredentials(new DefaultBceCredentials(ak, sk))
15                .withEndpoint(endpoint);
16 // Create a BCC client
17        BccClient client = new BccClient(bccClientConfiguration);
18 // Set BCC virtual machine ID
19        String instanceId = "i-***";
20 // Set description of virtual machine
21        String newName = "newInstanceName";
22 // Execute BCC modification operation
23        client.modifyInstanceAttributes(
24                new ModifyInstanceAttributesRequest()
25                        .withInstanceId(instanceId)
26                        .withName(newName)
27        );
28    }
29}

Modify instance description

You can modify the description information of a specific instance with the following code:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.ModifyInstanceDescRequest;
5public class ModifyDescInstance {
6    public static void main(String[] args) {
7 // Set your AK, SK and the endpoint to be accessed
8        String endpoint = "http://bcc.bj.baidubce.com";
9        String ak = "ak";
10        String sk = "sk";
11 // Set default configuration
12        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
13                .withProtocol(Protocol.HTTP)
14                .withCredentials(new DefaultBceCredentials(ak, sk))
15                .withEndpoint(endpoint);
16 // Create a BCC client
17        BccClient client = new BccClient(bccClientConfiguration);
18 // Set BCC virtual machine ID
19        String instanceId = "i-***";
20 // Set description of virtual machine
21        String newDesc = "modify desc";
22 // Execute BCC modification operation
23        client.modifyInstanceDesc(
24                new ModifyInstanceDescRequest()
25                        .withInstanceId(instanceId)
26                        .withDesc(newDesc)
27        );
28    }
29}

This API can only be called for instances that are either Running or Stopped. If not, a 409 error will be returned.

Reinstall an instance

You can rebuild a specified BCC virtual machine instance using an image with the following code:

Java
1package com.baidubce.services.bcc;
2import com.baidubce.BceClientConfiguration;
3import com.baidubce.Protocol;
4import com.baidubce.auth.DefaultBceCredentials;
5import com.baidubce.services.bcc.model.instance.RebuildInstanceRequest;
6public class RebuildInstance {
7    public static void main(String[] args) {
8// Set your AK, SK and the endpoint to be accessed
9        String endpoint = "bcc.bj.baidubce.com";
10        String ak = "ak";
11        String sk = "sk";
12// Set default configuration
13        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration().withProtocol(Protocol.HTTP).withCredentials(new DefaultBceCredentials(ak, sk)).withEndpoint(endpoint);
14// Create a BCC client
15        BccClient client = new BccClient(bccClientConfiguration);
16        RebuildInstanceRequest req = new RebuildInstanceRequest();
17// Specified instance ID
18        req.setInstanceId("i-***");  
19// Specified image ID
20        req.setImageId("m-***");  
21// Machine password (8-16 characters; it must contain English letters, numbers and symbols (limited to !@#$%^*()) simultaneously). The password must be encrypted for transmission
22        req.setAdminPass("***");  
23// Key pair ID to be bound to the instance being reinstalled. Either the adminPass or keypairId parameter must be specified
24        req.setKeypairId("k-***");  
25
26        client.rebuildInstance(req);
27    }
28}

After reinstallation, any snapshots based on the original system disk will be automatically deleted, but custom images based on the original system disk will be retained.

Reinstall instance (batch reinstallation)

You can rebuild a specified BCC virtual machine instance in batch using an image with the following code:

Java
1package com.baidubce.services.bcc;
2import com.baidubce.BceClientConfiguration;
3import com.baidubce.Protocol;
4import com.baidubce.auth.DefaultBceCredentials;
5import com.baidubce.services.bcc.model.instance.RebuildBatchInstanceRequest;
6import java.util.ArrayList;
7import java.util.List;
8public class BatchRebuildInstances {
9    public static void main(String[] args) {
10// Set your AK, SK and the endpoint to be accessed
11        String endpoint = "bcc.bj.baidubce.com";
12        String ak = "ak";
13        String sk = "sk";
14// Set default configuration
15        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration().withProtocol(Protocol.HTTP).withCredentials(new DefaultBceCredentials(ak, sk)).withEndpoint(endpoint);
16// Create a BCC client
17        BccClient client = new BccClient(bccClientConfiguration);
18        RebuildBatchInstanceRequest req = new RebuildBatchInstanceRequest();
19        List<String> instanceIds = new ArrayList<String>();
20        instanceIds.add("i-***");
21        instanceIds.add("i-***");
22// The list of specified instance IDs, maximum 100
23        req.setInstanceIds(instanceIds);  
24// Specified image ID
25        req.setImageId("m-***");  
26// Machine password (8-16 characters; it must contain English letters, numbers and symbols (limited to !@#$%^*()) simultaneously). The password must be encrypted for transmission
27        req.setAdminPass("***");  
28// Key pair ID to be bound to the instance being reinstalled. Either the adminPass or keypairId parameter must be specified
29        req.setKeypairId("k-***");  
30        client.rebuildBatchInstance(req);
31    }
32}

After reinstallation, any snapshots based on the original system disk will be automatically deleted, but custom images based on the original system disk will be retained.

Shift charge - convert to prepay

You can convert the billing mode of an instance from postpay to prepay with the following code

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.instance.ChangeToPrepaidRequest;
7import com.baidubce.services.bcc.model.instance.ChangeToPrepaidResponse;
8public class Main {
9    public static void main(String[] args) {
10 // Set your AK, SK and the endpoint to be accessed
11        String endpoint = "bcc.bj.baidubce.com";
12        String ak = "ak";
13        String sk = "sk";
14 // Set default configuration
15        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
16                .withProtocol(Protocol.HTTP)
17                .withCredentials(new DefaultBceCredentials(ak, sk))
18                .withEndpoint(endpoint);
19 // Create a BCC client
20        BccClient client = new BccClient(bccClientConfiguration);
21        ChangeToPrepaidRequest changeToPrepaidRequest = new ChangeToPrepaidRequest();
22 changeToPrepaidRequest.setInstanceId("i-lC39****"); // Virtual machine ID
23 changeToPrepaidRequest.setDuration(2);  // Prepaid duration in months
24        ChangeToPrepaidResponse response = client.changeToPrepaid(changeToPrepaidRequest);
25 System.out.println(response.getOrderId()); // Order ID
26    }
27}

Release an instance

For BCC virtual machine instances with expired postpay (Postpaid) or prepay (Prepaid) billing modes, you can release them with the following code:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6public class Main {
7    public static void main(String[] args) {
8 // Set your AK, SK and the endpoint to be accessed
9        String endpoint = "bcc.bj.baidubce.com";
10        String ak = "ak";
11        String sk = "sk";
12 // Set default configuration
13        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
14                .withProtocol(Protocol.HTTP)
15                .withCredentials(new DefaultBceCredentials(ak, sk))
16                .withEndpoint(endpoint);
17 // Create a BCC client
18        BccClient client = new BccClient(bccClientConfiguration);
19 client.releaseInstance("i-eRnq****");   // ID of the instance to be released
20    }
21}
  • Release a single cloud server instance. Upon release, the physical resources used by the instance are reclaimed, and all associated data will be permanently deleted and cannot be restored.
  • Only postpaid instances or expired prepaid instances are eligible for release.
  • Once an instance is released, any associated CDS disks will be automatically detached, and snapshots based on these CDS disks will be retained.
  • After the instance is released, snapshots of the original system disk will be deleted automatically, but custom images created from the original system disk will remain available.

Release instance (release via POST request)

  • Release a single cloud server instance. Upon release, the physical resources used by the instance are reclaimed, and all associated data will be permanently deleted and cannot be restored.
  • By default, only the instance and its system disks are released. Users can choose to release the attached EIPs and data disks as well, though this applies only to all attached disks together and not to individual ones.
Java
1package com.baidubce.services.bcc;
2import com.baidubce.BceClientConfiguration;
3import com.baidubce.Protocol;
4import com.baidubce.auth.DefaultBceCredentials;
5import com.baidubce.services.bcc.model.instance.ReleaseInstanceByPostRequest;
6public class ReleaseInstance {
7    public static void main(String[] args) {
8 // Set your AK, SK and the endpoint to be accessed
9        String endpoint = "bcc.bj.baidubce.com";
10        String ak = "ak";
11        String sk = "sk";
12 // Set default configuration
13        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration().withProtocol(Protocol.HTTP).withCredentials(new DefaultBceCredentials(ak, sk)).withEndpoint(endpoint);
14 // Create a BCC client
15        BccClient client = new BccClient(bccClientConfiguration);
16        ReleaseInstanceByPostRequest req = new ReleaseInstanceByPostRequest();
17 // Instance ID
18        req.setInstanceId("i-***");  
19 // Whether to release both EIPs and data disks currently attached on instance
20        req.setRelatedReleaseFlag(true);  
21 // Whether to release cloud disk server snapshots
22        req.setDeleteCdsSnapshotFlag(true);  
23        client.releaseInstanceByPost(req);
24        }
25    }

Release instances in batch

  • Release cloud server instances in bulk. Once released, the physical resources allocated to the instances are reclaimed, and all associated data is permanently lost and unrecoverable.
  • By default, only the instance and its system disks are released. Users can choose to release the attached EIPs and data disks as well, though this applies only to all attached disks together and not to individual ones.
Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.instance.ReleaseMultipleInstancesRequest;
7import java.util.ArrayList;
8import java.util.List;
9public class Main {
10    public static void main(String[] args) {
11 // Set your AK, SK and the endpoint to be accessed
12        String endpoint = "bcc.bj.baidubce.com";
13        String ak = "ak";
14        String sk = "sk";
15 // Set default configuration
16        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
17                .withProtocol(Protocol.HTTP)
18                .withCredentials(new DefaultBceCredentials(ak, sk))
19                .withEndpoint(endpoint);
20 // Create a BCC client
21        BccClient bccClient = new BccClient(bccClientConfiguration);
22        ReleaseMultipleInstancesRequest releaseMultipleInstancesRequest = new ReleaseMultipleInstancesRequest();
23 // Set list of instance IDs to be released, with no more than 100 elements in the list
24        List<String> instanceIds = new ArrayList<String>();
25        instanceIds.add("i-***");
26        instanceIds.add("i-***");
27        releaseMultipleInstancesRequest.setInstanceIds(instanceIds);
28 // Whether to release both EIPs and data disks currently attached on instance
29        releaseMultipleInstancesRequest.setRelatedReleaseFlag(true);
30 // Whether to release cloud disk server snapshots
31        releaseMultipleInstancesRequest.setDeleteCdsSnapshotFlag(true);
32 // Whether to move the instance to the recycle bin upon instance release
33        releaseMultipleInstancesRequest.setBccRecycleFlag(true);
34 // Whether to delete the associated ENI upon instance release
35        releaseMultipleInstancesRequest.setDeleteRelatedEnisFlag(true);
36        bccClient.releaseMultipleInstanceByPost(releaseMultipleInstancesRequest);
37    }
38}

Release prepaid instance (POST)

Release a prepaid cloud server instance. Once released, the physical resources allocated to the instance are reclaimed, and all associated data is permanently deleted and unrecoverable.

By default, only the cloud server instance and its system disk are released during the release process. Users can opt to release the attached EIP and data disks as well. However, associated EIP and data disks must either be fully released or fully retained; partial release is not supported.

When choosing to release the EIP and data disks together, cloud disk server snapshots can also be included for release. If data disks are retained, cloud disk server snapshots cannot be included in the release process.

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.instance.ReleasePrepaidInstanceRequest;
7import java.util.ArrayList;
8import java.util.List;
9public class Main {
10    public static void main(String[] args) {
11 // Set your AK, SK and the endpoint to be accessed
12        String endpoint = "bcc.bj.baidubce.com";
13        String ak = "ak";
14        String sk = "sk";
15 // Set default configuration
16        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
17                .withProtocol(Protocol.HTTP)
18                .withCredentials(new DefaultBceCredentials(ak, sk))
19                .withEndpoint(endpoint);
20 // Create a BCC client
21        BccClient bccClient = new BccClient(bccClientConfiguration);
22        ReleasePrepaidInstanceRequest releasePrepaidInstanceRequest = new ReleasePrepaidInstanceRequest();
23 // Set list of instance IDs to be released
24        releasePrepaidInstanceRequest.setInstanceId("i-***");
25 // Whether to release the EIPs and data disks currently attached on the instance at the same time (the deleteCdsSnapshotFlag field will only be valid if this field is true. If this field is false, the value of the deleteCdsSnapshotFlag field is invalid)
26        releasePrepaidInstanceRequest.setRelatedReleaseFlag(true);
27 // Whether to release cloud disk server snapshots
28        releasePrepaidInstanceRequest.setDeleteCdsSnapshotFlag(true);
29 // Whether to delete the associated ENI upon instance release
30        releasePrepaidInstanceRequest.setDeleteRelatedEnisFlag(true);
31        bccClient.releasePrepaidInstanceByPost(releasePrepaidInstanceRequest);
32    }
33}

Instance scaling

Support scaling the CPU and memory of BCC virtual machines. Refer to the following code for details:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.instance.ResizeInstanceRequest;
7public class Main {
8    public static void main(String[] args) {
9 // Set your AK, SK and the endpoint to be accessed
10        String endpoint = "bcc.bj.baidubce.com";
11        String ak = "ak";
12        String sk = "sk";
13 // Set default configuration
14        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
15                .withProtocol(Protocol.HTTP)
16                .withCredentials(new DefaultBceCredentials(ak, sk))
17                .withEndpoint(endpoint);
18 // Create a BCC client
19        BccClient client = new BccClient(bccClientConfiguration);
20        ResizeInstanceRequest resizeInstanceRequest = new ResizeInstanceRequest();
21 resizeInstanceRequest.setInstanceId("i-lC39****");  // ID of the instance to be resized
22 resizeInstanceRequest.setCpuCount(4);   // Count of CPU cores
23 resizeInstanceRequest.setMemoryCapacityInGB(16);  // Memory size in GB
24 resizeInstanceRequest.setEnableJumboFrame(false); // Set whether to enable Jumbo frames. true indicates that Jumbo frames are enabled, while false indicates that they are disabled. The default is empty. When empty: If resizing to a specification that does not support Jumbo frames, Jumbo frames will not be enabled; if resizing from a specification that does not support Jumbo frames to one that does, Jumbo frames will not be enabled; if resizing between specifications that support Jumbo frames, if Jumbo frames are enabled before resizing, they will remain enabled after resizing; if they are not enabled before resizing, they will remain disabled after resizing.
25        client.resizeInstance(resizeInstanceRequest);
26    }
27}
  • When the instance is prepaid, downscaling operations are not allowed
  • When the instance is postpaid, elastic scaling is allowed
  • Scaling operations can only be performed when the instance is in the Running or Stopped status
  • The instance will be rebooted once after scaling.
  • As this is an asynchronous API, you can check the scaling status by the Query Instance Details API is completed
  • For dedicated instances, you can specify CPU, memory and temporary disk size. For the temporary disk size of dedicated instances, Only expansion is supported, while contraction is not supported. For details, please refer to the API documentation [Instance Scaling](BCC/API Reference/Instance Related Interfaces/Instance scaling.md)

Instance scaling (by specified instance package specifications)

Scale a specified virtual machine. Scaling operations for CPU and memory are supported by updating the instance's package specifications.

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.instance.ResizeInstanceRequest;
7public class Main {
8    public static void main(String[] args) {
9 // Set your AK, SK and the endpoint to be accessed
10        String endpoint = "bcc.bj.baidubce.com";
11        String ak = "ak";
12        String sk = "sk";
13 // Set default configuration
14        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
15                .withProtocol(Protocol.HTTP)
16                .withCredentials(new DefaultBceCredentials(ak, sk))
17                .withEndpoint(endpoint);
18 // Create a BCC client
19        BccClient bccClient = new BccClient(bccClientConfiguration);
20        ResizeInstanceRequest resizeInstanceRequest = new ResizeInstanceRequest();
21 // Set BCC virtual machine ID
22        resizeInstanceRequest.setInstanceId("i-***");
23 // Set new package specifications
24        resizeInstanceRequest.setSpec("bcc.g5.c4m16");
25 // Set whether to enable Jumbo frames. true indicates that Jumbo frames are enabled, while false indicates that they are disabled. The default is empty. When empty: If resizing to a specification that does not support Jumbo frames, Jumbo frames will not be enabled; if resizing from a specification that does not support Jumbo frames to one that does, Jumbo frames will not be enabled; if resizing between specifications that support Jumbo frames, if Jumbo frames are enabled before resizing, they will remain enabled after resizing; if they are not enabled before resizing, they will remain disabled after resizing.
26        resizeInstanceRequest.setEnableJumboFrame(false);
27        bccClient.resizeInstanceBySpec(resizeInstanceRequest);
28    }
29}
  • Scaling operations can only be performed when the instance is in the Running or Stopped status
  • The instance will be rebooted once after scaling.
  • As this is an asynchronous API, you can check the scaling status by the Query Instance Details API is completed

Add an instance to a security group

You can add a specified BCC virtual machine instance to a designated security group with the following code:

Java
1public static void bindInstanceToSecurityGroup(BccClient bccClient) {
2    BindSecurityGroupRequest bindSecurityGroupRequest = new BindSecurityGroupRequest();
3 // Set security group ID
4    bindSecurityGroupRequest.setSecurityGroupId(securityGroupId);
5 // Set BCC virtual machine instance ID
6    bindSecurityGroupRequest.setInstanceId(instanceId);
7 // Execute operations to add the instance to the security group
8    bccClient.bindInstanceToSecurityGroup(bindSecurityGroupRequest);
9}

Each instance can be associated with a maximum of 10 security groups.

Remove an instance from a security group

You can remove a specified instance from a designated security group with the following code:

Java
1public static void unbindInstanceFromSecurityGroup(BccClient bccClient) {
2    UnbindSecurityGroupRequest unbindSecurityGroupRequest = new UnbindSecurityGroupRequest();
3 // Set security group ID
4    unbindSecurityGroupRequest.setSecurityGroupId(securityGroupId);
5 // Set BCC virtual machine instance ID
6    unbindSecurityGroupRequest.setInstanceId(instanceId);
7 // Execute operations to remove the instance from the security group
8    bccClient.unbindInstanceFromSecurityGroup(unbindSecurityGroupRequest);
9}
  • Each instance must be associated with at least one security group, with the default being the system's default security group.
  • If an instance is part of only one security group, attempting to remove it from this group will cause a 403 error.

Query the VNC address of the instance

You can query the VNC URL of a specified BCC virtual machine instance with the following code:

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.GetInstanceVncResponse;
5public class GetInstanceVnc {
6    public static void main(String[] args) {
7 // Set your AK, SK and the endpoint to be accessed
8        String endpoint = "bcc.bj.baidubce.com";
9        String ak = "ak";
10        String sk = "sk";
11 // Set default configuration
12        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration().withProtocol(Protocol.HTTP).withCredentials(new DefaultBceCredentials(ak, sk)).withEndpoint(endpoint);
13 // Create a BCC client
14        BccClient client = new BccClient(bccClientConfiguration);
15 // i-*** represents virtual machine instance ID
16        GetInstanceVncResponse response = client.getInstanceVnc("i-***");  
17        System.out.println(response.getVncUrl());
18    }
19}
  • The VNC address becomes invalid after one use
  • The URL address is valid for 10 minutes

Renew an instance

Renewing a BCC virtual machine extends its expiration period. You can renew the disk with the following code:

Java
1package com.baidubce.services.bcc;
2import com.baidubce.BceClientConfiguration;
3import com.baidubce.Protocol;
4import com.baidubce.auth.DefaultBceCredentials;
5import com.baidubce.services.bcc.model.Billing;
6import com.baidubce.services.bcc.model.Reservation;
7import com.baidubce.services.bcc.model.instance.PurchaseReservedInstanceRequeset;
8import com.baidubce.services.bcc.model.instance.PurchaseReservedInstanceResponse;
9public class PurchaseReservedInstance {
10    public static void main(String[] args) {
11 // Set your AK, SK and the endpoint to be accessed
12        String endpoint = "bcc.bj.baidubce.com";
13        String ak = "ak";
14        String sk = "sk";
15 // Set default configuration
16        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration().withProtocol(Protocol.HTTP).withCredentials(new DefaultBceCredentials(ak, sk)).withEndpoint(endpoint);
17 // Create a BCC client
18        BccClient client = new BccClient(bccClientConfiguration);
19        PurchaseReservedInstanceRequeset req = new PurchaseReservedInstanceRequeset();
20 // Virtual machine instance ID
21        req.setInstanceId("i-***");  
22 // Idempotency Token, an ASCII string with a length not exceeding 64 bits
23        req.setClientToken("random-uuid");  
24 // Order details
25        req.setBilling(new Billing()  
26 // Renewal method; this API is for renewing prepaid instances.
27                .withPaymentTiming("Prepaid")  
28 // Renewal period and unit, unit in months
29                .withReservation(new Reservation()  
30 // Renewal period
31                .withReservationLength(1))  
32        );
33 // Set the instance's associated renewal flag, defaulting to an empty string
34        req.setRelatedRenewFlag("CDS");  
35        
36        PurchaseReservedInstanceResponse res = client.purchaseReservedInstance(req);
37        System.out.println(res);
38    }
39}
  • Renewal actions cannot be performed on a BCC virtual machine instance while it's being scaled.
  • If the instance was suspended due to unpaid debt, it will automatically reboot after the renewal process is successfully completed.
  • This API operates asynchronously.
  • Dedicated instances do not support renewal functionality.

Bind a tag to an instance

You can bind tags to an instance with the following code

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.TagModel;
7import com.baidubce.services.bcc.model.instance.BindTagsRequest;
8import java.util.ArrayList;
9import java.util.List;
10public class Main {
11    public static void main(String[] args) {
12 // Set your AK, SK and the endpoint to be accessed
13        String endpoint = "bcc.bj.baidubce.com";
14        String ak = "ak";
15        String sk = "sk";
16 // Set default configuration
17        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
18                .withProtocol(Protocol.HTTP)
19                .withCredentials(new DefaultBceCredentials(ak, sk))
20                .withEndpoint(endpoint);
21 // Create a BCC client
22        BccClient bccClient = new BccClient(bccClientConfiguration);
23        BindTagsRequest bindTagsRequest = new BindTagsRequest();
24 // Set the tag to be bound
25        List<TagModel> changeTags = new ArrayList<TagModel>();
26        TagModel tagModel = new TagModel().withTagKey("Key***").withTagValue("Value***");
27        changeTags.add(tagModel);
28        bindTagsRequest.setChangeTags(changeTags);
29 // Set corresponding instance ID
30        bindTagsRequest.setInstanceId("i-***");
31        
32        bccClient.bindInstanceToTags(bindTagsRequest);
33    }
34}
  • Assign tags to an instance to facilitate classification and searching.

Unbind a tag from an instance

You can unbind tags from an instance with the following code

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.TagModel;
7import com.baidubce.services.bcc.model.instance.UnbindTagsRequest;
8import java.util.ArrayList;
9import java.util.List;
10public class Main {
11    public static void main(String[] args) {
12 // Set your AK, SK and the endpoint to be accessed
13        String endpoint = "bcc.bj.baidubce.com";
14        String ak = "ak";
15        String sk = "sk";
16 // Set default configuration
17        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
18                .withProtocol(Protocol.HTTP)
19                .withCredentials(new DefaultBceCredentials(ak, sk))
20                .withEndpoint(endpoint);
21 // Create a BCC client
22        BccClient bccClient = new BccClient(bccClientConfiguration);
23        UnbindTagsRequest unbindTagsRequest = new UnbindTagsRequest();
24 // Set the tag to be bound
25        List<TagModel> changeTags = new ArrayList<TagModel>();
26        TagModel tagModel = new TagModel().withTagKey("Key***").withTagValue("Value***");
27        changeTags.add(tagModel);
28        unbindTagsRequest.setChangeTags(changeTags);
29 // Set corresponding instance ID
30        unbindTagsRequest.setInstanceId("i-***");
31        
32        bccClient.unbindInstanceFromTags(unbindTagsRequest);
33    }
34}
  • Remove tags that are defined on an instance.
  • You can unbind multiple tags at the same time.

Change the instance subnet

Java
1package com.baidubce.services.bcc;
2import com.baidubce.BceClientConfiguration;
3import com.baidubce.Protocol;
4import com.baidubce.auth.DefaultBceCredentials;
5import com.baidubce.services.bcc.model.instance.ChangeInstanceSubnetRequest;
6public class ChangeSubnet {
7    public static void main(String[] args) {
8 // Set your AK, SK and the endpoint to be accessed
9        String endpoint = "bcc.bj.baidubce.com";
10        String ak = "ak";
11        String sk = "sk";
12 // Set default configuration
13        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration().withProtocol(Protocol.HTTP).withCredentials(new DefaultBceCredentials(ak, sk)).withEndpoint(endpoint);
14 // Create a BCC client
15        BccClient client = new BccClient(bccClientConfiguration);
16        ChangeInstanceSubnetRequest req = new ChangeInstanceSubnetRequest();
17 // Virtual machine instance ID
18        req.setInstanceId("i-***");  
19 // Subnet ID after change
20        req.setSubnetId("sbn-***");  
21 // Whether to reboot after change
22        req.setReboot(true);  
23 // Change regular security group, which takes effect only when changing the VPC and cannot be set simultaneously with EnterpriseSecurityGroupIds
24        req.setSecurityGroupIds(Collections.singletonList("g-***"));
25 // Change enterprise security group, which takes effect only when changing the VPC and cannot be set simultaneously with SecurityGroupIds
26        req.setEnterpriseSecurityGroupIds(Collections.singletonList("esg-***"));
27        client.updateInstanceSubnet(req);
28    }
29}
  • Change the subnet to which an instance belongs. By default, the instance will automatically reboot after a subnet change. However, users can opt out of this. Subnet changes are only supported within the same availability zone (AZ), and cross-AZ or cross-VPC changes are not allowed. When switching from a normal subnet to a NAT-dedicated subnet, you must manually unbind the EIP first.

Query instance package specifications

Query the list of instance package specifications. When creating a virtual machine, it is recommended to specify the desired machine type and configuration using the parameter (spec).

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.flavor.ListFlavorSpecRequest;
7import com.baidubce.services.bcc.model.flavor.ListBccFlavorSpecResponse;
8public class Main {
9    public static void main(String[] args) {
10 // Set your AK, SK and the endpoint to be accessed
11        String endpoint = "bcc.bj.baidubce.com";
12        String ak = "ak";
13        String sk = "sk";
14 // Set default configuration
15        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
16                .withProtocol(Protocol.HTTP)
17                .withCredentials(new DefaultBceCredentials(ak, sk))
18                .withEndpoint(endpoint);
19 // Create a BCC client
20        BccClient bccClient = new BccClient(bccClientConfiguration);
21        ListFlavorSpecRequest listFlavorSpecRequest = new ListFlavorSpecRequest();
22 // Set availability zone
23        listFlavorSpecRequest.setZoneName("cn-bj-d");
24        
25        ListBccFlavorSpecResponse response = bccClient.listFlavorSpec(listFlavorSpecRequest);
26        System.out.println(response);
27    }
28}
  • By default, fetch the instance package specifications for all availability zones in the current region. To retrieve specifications for a particular availability zone, set the appropriate parameter.

Query instance package price

Query the pricing information associated with the instance resource package specifications.

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.BccClient;
5import com.baidubce.services.bcc.BccClientConfiguration;
6import com.baidubce.services.bcc.model.instance.BccPriceRequest;
7import com.baidubce.services.bcc.model.instance.BccPriceResponse;
8public class Main {
9    public static void main(String[] args) {
10 // Set your AK, SK and the endpoint to be accessed
11        String endpoint = "bcc.bj.baidubce.com";
12        String ak = "ak";
13        String sk = "sk";
14 // Set default configuration
15        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
16                .withProtocol(Protocol.HTTP)
17                .withCredentials(new DefaultBceCredentials(ak, sk))
18                .withEndpoint(endpoint);
19 // Create a BCC client
20        BccClient bccClient = new BccClient(bccClientConfiguration);
21        BccPriceRequest bccPriceRequest = new BccPriceRequest();
22 // Set instance family
23        bccPriceRequest.setSpecId("g5");
24 // Set instance package specifications
25        bccPriceRequest.setSpec("bcc.g5.c2m8");
26 // Set availability zone
27        bccPriceRequest.setZoneName("cn-bj-d");
28 // Set charge type
29        bccPriceRequest.setPaymentTiming("prepay");
30 // Set purchase period (in months)
31        bccPriceRequest.setPurchaseLength(2);
32 // Set purchase count
33        bccPriceRequest.setPurchaseCount(2);
34        
35        BccPriceResponse response = bccClient.getPriceBySpec(bccPriceRequest);
36        System.out.println(response);
37    }
38}
  • By setting the instance family, you can obtain the prices of all packages under the current instance family.
  • Set instance package specifications to retrieve the price of the current package
  • Bill type: Postpaid and Prepaid

Query resizing specifications

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.ListAvailableResizeSpecRequest;
5import com.baidubce.services.bcc.model.instance.ListAvailableResizeSpecResponse;
6public class Main {
7    public static void main(String[] args) {
8 // Set your AK, SK and the endpoint to be accessed
9        String endpoint = "bcc.bj.baidubce.com";
10        String ak = "ak";
11        String sk = "sk";
12 // Set default configuration
13        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
14                .withProtocol(Protocol.HTTP)
15                .withCredentials(new DefaultBceCredentials(ak, sk))
16                .withEndpoint(endpoint);
17 // Create a BCC client
18        BccClient client = new BccClient(bccClientConfiguration);
19        ListAvailableResizeSpecRequest request = new ListAvailableResizeSpecRequest()
20                .withSpec("bcc.ic4.c1m1").withZone("cn-bj-a");
21        ListAvailableResizeSpecResponse response = client.listAvailableResizeSpec(request);
22        System.out.println(response);
23    }
24}

Retrieve network interface card information for an instance

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.ListInstanceEnisRequest;
5public class Main {
6    public static void main(String[] args) {
7 // Set your AK, SK and the endpoint to be accessed
8        String endpoint = "bcc.bj.baidubce.com";
9        String ak = "ak";
10        String sk = "sk";
11 // Set default configuration
12        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
13                .withProtocol(Protocol.HTTP)
14                .withCredentials(new DefaultBceCredentials(ak, sk))
15                .withEndpoint(endpoint);
16 // Create a BCC client
17        BccClient client = new BccClient(bccClientConfiguration);
18 // Set instance ID
19        ListInstanceEnisRequest request = new ListInstanceEnisRequest().withInstanceId("i-CH47****");
20        System.out.println(client.listRecycleInstance());
21    }
22}

Change the instance VPC

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.model.AbstractBceResponse;
5import com.baidubce.services.bcc.model.instance.ChangeVpcRequest;
6import java.util.Arrays;
7public class Main {
8    public static void main(String[] args) {
9 // Set your AK, SK and the endpoint to be accessed
10        String endpoint = "bcc.bj.baidubce.com";
11        String ak = "ak";
12        String sk = "sk";
13 // Set default configuration
14        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
15                .withProtocol(Protocol.HTTP)
16                .withCredentials(new DefaultBceCredentials(ak, sk))
17                .withEndpoint(endpoint);
18 // Create a BCC client
19        BccClient client = new BccClient(bccClientConfiguration);
20 // Change VPC
21        ChangeVpcRequest request = new ChangeVpcRequest()
22                .withInstanceId("i-sZcd****")
23                .withSubnetId("sbn-3rgdxbbn****")
24                .withSecurityGroupIds(Arrays.asList("g-63vdycz*****"));
25        AbstractBceResponse response = client.changeVpc(request);
26        System.out.println(response.getMetadata().getBceRequestId());
27    }
28}
  • Instances will be rebooted in the startup status, but they will not be rebooted in the stopped status

Convert to prepay in batch

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.BatchChangeToPrepaidRequest;
5import com.baidubce.services.bcc.model.instance.BatchChangeToPrepaidResponse;
6import com.baidubce.services.bcc.model.instance.ChangeToPrepaidRequest;
7import java.util.ArrayList;
8import java.util.List;
9public class Main {
10    public static void main(String[] args) {
11 // Set your AK, SK and the endpoint to be accessed
12        String endpoint = "bcc.bj.baidubce.com";
13        String ak = "ak";
14        String sk = "sk";
15 // Set default configuration
16        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
17                .withProtocol(Protocol.HTTP)
18                .withCredentials(new DefaultBceCredentials(ak, sk))
19                .withEndpoint(endpoint);
20 // Create a BCC client
21        BccClient client = new BccClient(bccClientConfiguration);
22 // Specify the virtual machine IDs for shifting charge and the duration of the subscription (in months), with no more than 100 virtual machines
23        BatchChangeToPrepaidRequest request = new BatchChangeToPrepaidRequest();
24        List<ChangeToPrepaidRequest> configList = new ArrayList<>();
25        configList.add(new ChangeToPrepaidRequest().withInstanceId("i-sZcdKAZR").withDuration(1));
26        configList.add(new ChangeToPrepaidRequest().withInstanceId("i-CH47zOoW").withDuration(1));
27        request.setConfig(configList);
28
29        BatchChangeToPrepaidResponse response = client.batchChangeToPrepaid(request);
30        System.out.println(response);
31    }
32}

Query recycle bin instance list

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.ListInstancesResponse;
5import com.baidubce.services.bcc.model.instance.ListRecycleInstanceRequest;
6import java.util.Calendar;
7import java.util.Date;
8public class Main {
9    public static void main(String[] args) {
10 // Set your AK, SK and the endpoint to be accessed
11        String endpoint = "bcc.bj.baidubce.com";
12        String ak = "ak";
13        String sk = "sk";
14 // Set default configuration
15        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
16                .withProtocol(Protocol.HTTP)
17                .withCredentials(new DefaultBceCredentials(ak, sk))
18                .withEndpoint(endpoint);
19 // Create a BCC client
20        BccClient client = new BccClient(bccClientConfiguration);
21 // Query postpaid instances that enter the recycle bin within a specified time range
22        Date today = new Date();
23        Calendar calendar = Calendar.getInstance();
24        calendar.setTime(today);
25        calendar.add(Calendar.DATE, -1);
26        Date lastDay = calendar.getTime();
27        ListRecycleInstanceRequest request = new ListRecycleInstanceRequest()
28                .withRecycleBegin(lastDay)
29                .withRecycleEnd(today);
30                .withPaymentTiming(PaymentTiming.Postpaid)
31        ListInstancesResponse response = client.listRecycleInstance(request);
32        System.out.println(response);
33    }
34}

Release recycle bin instances

You can release a specified instance from the recycle bin with the following code

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.ListInstancesResponse;
5import com.baidubce.services.bcc.model.instance.ListRecycleInstanceRequest;
6import java.util.Calendar;
7import java.util.Date;
8public class Main {
9    public static void main(String[] args) {
10 // Set your AK, SK and the endpoint to be accessed
11        String endpoint = "bcc.bj.baidubce.com";
12        String ak = "ak";
13        String sk = "sk";
14 // Set default configuration
15        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
16                .withProtocol(Protocol.HTTP)
17                .withCredentials(new DefaultBceCredentials(ak, sk))
18                .withEndpoint(endpoint);
19 // Create a BCC client
20        BccClient client = new BccClient(bccClientConfiguration);
21        client.deleteRecycledInstance("i-***");
22    }
23}

Remove the relationship between an instance and its deployment group

You can delete the relationship between an instance and a deployment group with the following code

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.ListInstancesResponse;
5import com.baidubce.services.bcc.model.instance.ListRecycleInstanceRequest;
6import java.util.Calendar;
7import java.util.Date;
8public class Main {
9    public static void main(String[] args) {
10 // Set your AK, SK and the endpoint to be accessed
11        String endpoint = "bcc.bj.baidubce.com";
12        String ak = "ak";
13        String sk = "sk";
14 // Set default configuration
15        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
16                .withProtocol(Protocol.HTTP)
17                .withCredentials(new DefaultBceCredentials(ak, sk))
18                .withEndpoint(endpoint);
19 // Create a BCC client
20        BccClient client = new BccClient(bccClientConfiguration);
21        DeleteInstanceDeploysetRequest deleteInstanceDeploysetRequest = new DeleteInstanceDeploysetRequest();
22        deleteInstanceDeploysetRequest
23                .withDeployId("dset-NXyUzFou")
24                .withInstanceIdList(Collections.singletonList("i-pKq2Bnhf"));
25        client.deleteInstanceDeploySet(deleteInstanceDeploysetRequest);
26    }
27}

Add IPv6

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.InstanceIpv6Request;
5import com.baidubce.services.bcc.model.instance.InstanceAddIpv6Response;
6public class Main {
7    public static void main(String[] args) {
8 // Set your AK, SK and the endpoint to be accessed
9        String endpoint = "bcc.bj.baidubce.com";
10        String ak = "ak";
11        String sk = "sk";
12 // Set default configuration
13        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
14                .withProtocol(Protocol.HTTP)
15                .withCredentials(new DefaultBceCredentials(ak, sk))
16                .withEndpoint(endpoint);
17 // Create a BCC client
18        BccClient client = new BccClient(bccClientConfiguration);
19 // Add IPv6
20        InstanceIpv6Request request = new InstanceIpv6Request();
21        request.setInstanceId("i-0nPl9WFJ");
22        request.setIpv6Address("2400:da00:e003:0:41c:4100:0:5");
23        request.setReboot(false);
24        InstanceAddIpv6Response response = client.addIpv6(request);
25        System.out.println(response);
26    }
27}

Release IPv6

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.InstanceIpv6Request;
5public class Main {
6    public static void main(String[] args) {
7 // Set your AK, SK and the endpoint to be accessed
8        String endpoint = "bcc.bj.baidubce.com";
9        String ak = "ak";
10        String sk = "sk";
11 // Set default configuration
12        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
13                .withProtocol(Protocol.HTTP)
14                .withCredentials(new DefaultBceCredentials(ak, sk))
15                .withEndpoint(endpoint);
16 // Create a BCC client
17        BccClient client = new BccClient(bccClientConfiguration);
18 // Release IPv6
19        InstanceIpv6Request request = new InstanceIpv6Request();
20        request.setInstanceId("i-0nPl9WFJ");
21        request.setIpv6Address("2400:da00:e003:0:41c:4100:0:5");
22        request.setReboot(false);
23        client.delIpv6(request);
24    }
25}

Add secondary IPs to the primary network interface card in batch

You can add secondary IPs to the primary network interface card for BCC in batch with the following code

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.BatchAddIpRequest;
5public class Main {
6    public static void main(String[] args) {
7 // Set your AK, SK and the endpoint to be accessed
8        String endpoint = "bcc.bj.baidubce.com";
9        String ak = "ak";
10        String sk = "sk";
11 // Set default configuration
12        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
13                .withProtocol(Protocol.HTTP)
14                .withCredentials(new DefaultBceCredentials(ak, sk))
15                .withEndpoint(endpoint);
16 // Create a BCC client
17        BccClient client = new BccClient(bccClientConfiguration);
18 // Allocate IPv6 to the primary network interface card, with no more than 100 IPs
19        BatchAddIpRequest request = new BatchAddIpRequest();
20        request.setInstanceId("i-udU7HS0a");
21        request.setAllocateMultiIpv6Addr(true);
22        request.setSecondaryPrivateIpAddressCount(2);
23        client.batchAddIp(request);
24    }
25}

Delete secondary IP address from the primary network interface card in batch

You can delete secondary IP address from the primary network interface card for BCC in batch with the following code

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.BatchDeleteIpRequest;
5import java.util.Collections;
6public class Main {
7    public static void main(String[] args) {
8 // Set your AK, SK and the endpoint to be accessed
9        String endpoint = "bcc.bj.baidubce.com";
10        String ak = "ak";
11        String sk = "sk";
12 // Set default configuration
13        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
14                .withProtocol(Protocol.HTTP)
15                .withCredentials(new DefaultBceCredentials(ak, sk))
16                .withEndpoint(endpoint);
17 // Create a BCC client
18        BccClient client = new BccClient(bccClientConfiguration);
19 // Release IPv6 to the primary network interface card, maximum 100 IPs
20        InstanceIpv6Request request = new InstanceIpv6Request();
21        request.setInstanceId("i-0nPl9WFJ");
22        request.setPrivateIps(Collections.singletonList("2400:da00:e003:0:41c:4100:0:5"));
23        client.batchDeleteIp(request);
24    }
25}

Create automatic renewal rules

You can create automatic renewal rules for BCC with the following code

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.BatchDeleteIpRequest;
5import java.util.Collections;
6public class Main {
7    public static void main(String[] args) {
8 // Set your AK, SK and the endpoint to be accessed
9        String endpoint = "bcc.bj.baidubce.com";
10        String ak = "ak";
11        String sk = "sk";
12 // Set default configuration
13        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
14                .withProtocol(Protocol.HTTP)
15                .withCredentials(new DefaultBceCredentials(ak, sk))
16                .withEndpoint(endpoint);
17 // Create a BCC client
18        BccClient client = new BccClient(bccClientConfiguration);
19 // Create auto-renewal rules
20        client.createAutoRenewRule(new BccAutoRenewRequest()
21                    .withInstanceId("i-dl2s537H")
22                    .withRenewTimeUnit("month")
23                    .withRenewTime(1)
24                    .withRenewEip(true)
25                    .withRenewCds(true));
26    }
27}

Delete automatic renewal rules

You can delete auto-renewal rules for BCC with the following code

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.BatchDeleteIpRequest;
5import java.util.Collections;
6public class Main {
7    public static void main(String[] args) {
8 // Set your AK, SK and the endpoint to be accessed
9        String endpoint = "bcc.bj.baidubce.com";
10        String ak = "ak";
11        String sk = "sk";
12 // Set default configuration
13        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
14                .withProtocol(Protocol.HTTP)
15                .withCredentials(new DefaultBceCredentials(ak, sk))
16                .withEndpoint(endpoint);
17 // Create a BCC client
18        BccClient client = new BccClient(bccClientConfiguration);
19 // Delete auto-renewal rules
20        client.deleteAutoRenewRule(new BccAutoRenewRequest()
21                    .withInstanceId("i-dl2s537H")
22                    .withRenewEip(true)
23                    .withRenewCds(true));
24    }
25}

Query the custom data of the instance

You can query the custom data of the instance with the following code

Java
1import com.baidubce.BceClientConfiguration;
2import com.baidubce.Protocol;
3import com.baidubce.auth.DefaultBceCredentials;
4import com.baidubce.services.bcc.model.instance.BatchDeleteIpRequest;
5import java.util.Collections;
6public class Main {
7    public static void main(String[] args) {
8 // Set your AK, SK and the endpoint to be accessed
9        String endpoint = "bcc.bj.baidubce.com";
10        String ak = "ak";
11        String sk = "sk";
12 // Set default configuration
13        BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
14                .withProtocol(Protocol.HTTP)
15                .withCredentials(new DefaultBceCredentials(ak, sk))
16                .withEndpoint(endpoint);
17 // Create a BCC client
18        BccClient client = new BccClient(bccClientConfiguration);
19 // Set request body and send request
20        GetInstanceUserDataAttrRequest request = new GetInstanceUserDataAttrRequest();
21        request.withInstanceId("i-b34ycow2");
22        GetInstanceUserDataAttrResponse response = client.getInstanceUserDataAttribute(request);
23        toJsonPrettyString("getInstanceUserDataAttribute", response);
24    }
25}

Previous
Availability zone
Next
BccClient