Updated on 2025-08-18 GMT+08:00

Changing or Resetting the Lite Server OS

Scenario

You can change or reset the Lite Server node OS if a BMS is used. Change the OS in any of the following ways:

  • (Recommended) Change or reset the OS on the server page of the ModelArts console.
  • Change the OS on the BMS console.
  • Change the OS using BMS Go SDK.
  • Change the OS by encapsulating APIs using Python.

Constraints

  • Node status: The Lite Server node must be in the stopped, OS resetting failed, or OS changing failed state. Otherwise, the operation may fail as the system cannot be uninstalled and the disk will be uninstalled repeatedly.
  • OS: The target OS must be an IMS public image or private shared image in the region.

Impact

There will be the following impacts when you reset or change the Lite Server node OS:

  1. System disk ID change: The EVS system disk ID will be changed, which is different from that in the order. As a result, the EVS system disk capacity cannot be scaled out. When you scale out the system disk, a message is displayed, indicating that the current order has expired, the capacity cannot be expanded, and the order needs to be renewed.
  2. userdata configuration: When you change the OS, userdata injection may not take effect, especially in configdriver mode. Ensure that the userdata parameter is imported during node creation, or manually configure necessary settings after the change. Therefore, mount an EVS disk or an SFS disk to expand the storage capacity after changing or resetting the OS.
  3. Application and model: The deployed model or application may be impacted after you change the OS, as the dependent software package or library may need to be reinstalled or configured. Reconfigure necessary dependencies to ensure proper running of applications.
  4. BMS risks: For BMS, upgrading OS kernel or driver may cause incompatibility, affecting system startup or basic functions. To perform an upgrade, contact the cloud service provider.

Before changing or resetting an OS, you need to ensure that the node is shut down, check the current settings, back up important data, and contact technical support if necessary.

Changing or Resetting the OS on the Server Page of the ModelArts Console

  1. Log in to the ModelArts console.
  2. In the navigation pane on the left, choose Lite Serves under Resource Management. Access the nodes page.
  3. Locate the target Lite Server in the list and choose > Change OS or Reset OS on the right. In the displayed dialog box, confirm the information and click OK.

    The Lite Server node is in the state of changing or resetting OS.

Changing the OS on the BMS Console

  1. Obtain the OS image.

    The OS image is provided by the cloud service. You can receive the image on the shared image page of IMS, as shown in the following figure.
    Figure 1 Shared image

  2. Change OS.

    Stop the BMS corresponding to the Lite Server resource. The OS must be stopped.

    Locate the target BMS in the list and choose More > Change OS in the Operation column.

    Figure 2 Changing OS

    On the Change OS page, select the shared image received in the previous step.

Changing the OS Using BMS Go SDK

The following is the sample code for changing the OS of a BMS using the Go language through SDK.

package main

import (
	"fmt"
        "os"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
	bms "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/bms/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/bms/v1/model"
	region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/bms/v1/region"
)

func main() {
	// Hardcoded or plaintext AK/SK is risky. For security, encrypt your AK/SK and store them in the configuration file or environment variables.
	// In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, set environment variables HUAWEICLOUD_SDK_AK and HUAWEICLOUD_SDK_SK.
	ak := os.Getenv("HUAWEICLOUD_SDK_AK")
	sk := os.Getenv("HUAWEICLOUD_SDK_SK")

	auth := basic.NewCredentialsBuilder().
		WithAk(ak).
		WithSk(sk).
		Build()

	client := bms.NewBmsClient(
		bms.BmsClientBuilder().
			WithRegion(region.ValueOf("cn-north-4")).
			WithCredential(auth).
			Build())
	keyname := "KeyPair-name"
	userdata := "aGVsbG8gd29ybGQsIHdlbGNvbWUgdG8gam9pbiB0aGUgY29uZmVyZW5jZQ=="
	request := &model.ChangeBaremetalServerOsRequest{
		ServerId: "****input your bms instance id****",
		Body: &model.OsChangeReq{
			OsChange: &model.OsChange{
				Keyname: &keyname,
				Imageid: "****input your ims image id****",
				Metadata: &model.MetadataInstall{
					UserData: &userdata,
				},
			},
		},
	}

	response, err := client.ChangeBaremetalServerOs(request)
	if err == nil {
		fmt.Printf("%+v\n", response)
	} else {
		fmt.Println(err)
	}
}

Changing the OS by Encapsulating APIs Using Python

The following is the sample code for changing the BMS OS using Python through APIs:

# -*- coding: UTF-8 -*-

import requests
import json
import time
import requests.packages.urllib3.exceptions
from urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
class ServerOperation(object):

    ################################ IAM authentication API#################################################

    def __init__(self, account, password, region_name, username=None, project_id=None):
        """
        :param username:  if IAM user,here is small user, else  big user
        :param account: account big  big user
        :param password: account
        :param region_name:
        """
        self.account = account
        self.username = username
        self.password = password
        self.region_name = region_name
        self.project_id = project_id
        self.ma_endpoint = "https://modelarts.{}.myhuaweicloud.com".format(region_name)
        self.service_endpoint = "https://bms.{}.myhuaweicloud.com".format(region_name)
        self.iam_endpoint = "https://iam.{}.myhuaweicloud.com".format(region_name)
        self.headers = {"Content-Type": "application/json",
                        "X-Auth-Token": self.get_project_token_by_account(self.iam_endpoint)}

    def get_project_token_by_account(self, iam_endpoint):
        body = {
            "auth": {
                "identity": {
                    "methods": [
                        "password"
                    ],
                    "password": {
                        "user": {
                            "name": self.username if self.username else self.account,
                            "password": self.password,
                            "domain": {
                                "name": self.account
                            }
                        }
                    }
                },
                "scope": {
                    "project": {
                        "name": self.region_name
                    }
                }
            }
        }
        headers = {
            "Content-Type": "application/json"
        }
        import json
        url = iam_endpoint + "/v3/auth/tokens"
        response = requests.post(url, headers=headers, data=json.dumps(body), verify=True)
        token = (response.headers['X-Subject-Token'])
        return token
    def change_os(self, server_id):
        url = "{}/v1/{}/baremetalservers/{}/changeos".format(self.service_endpoint, self.project_id, server_id)
        print(url)
        body = {
            "os-change": {
                "adminpass": "@Server",
                "imageid": "40d88eea-6e41-418a-ad6c-c177fe1876b8"
            }
        }
        response = requests.post(url, headers=self.headers, data=json.dumps(body), verify=False)
        print(json.dumps(response.json(), indent=1))
        return response.json()

if __name__ == '__main__':
    # Prepare for calling the API and initialize the authentication.
    server = ServerOperation(username="xxx",
                             account="xxx",
                             password="xxx",
                             project_id="xxx",
                             region_name="cn-north-4")

    server.change_os(server_id="0c84bb62-35bd-4e1c-ba08-a3a686bc5097")