mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
feat(region,host): support riscv64 usage (#25439)
* feat(region): include riscv64 usage statistics Signed-off-by: wangyf0611 <wangyufeng@iscas.ac.cn> * feat(host): support openRuyi guest initialization Signed-off-by: wangyf0611 <wangyufeng@iscas.ac.cn> --------- Signed-off-by: wangyf0611 <wangyufeng@iscas.ac.cn>
This commit is contained in:
@@ -4691,7 +4691,7 @@ func usageTotalGuestResourceCount(
|
|||||||
policyResult rbacutils.SPolicyResult,
|
policyResult rbacutils.SPolicyResult,
|
||||||
) map[string]SGuestCountStat {
|
) map[string]SGuestCountStat {
|
||||||
countStat := make(map[string]SGuestCountStat)
|
countStat := make(map[string]SGuestCountStat)
|
||||||
for _, arch := range []string{apis.OS_ARCH_ALL, apis.OS_ARCH_X86_64, apis.OS_ARCH_AARCH64} {
|
for _, arch := range []string{apis.OS_ARCH_ALL, apis.OS_ARCH_X86_64, apis.OS_ARCH_AARCH64, apis.OS_ARCH_RISCV64} {
|
||||||
allStat := usageTotalGuestResourceCountByArch(
|
allStat := usageTotalGuestResourceCountByArch(
|
||||||
ctx, scope, ownerId, rangeObjs, status,
|
ctx, scope, ownerId, rangeObjs, status,
|
||||||
hypervisors, includeSystem, pendingDelete,
|
hypervisors, includeSystem, pendingDelete,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func GetRootfsDrivers() []newRootFsDriverFunc {
|
|||||||
|
|
||||||
func Init(cloudrootDir string) error {
|
func Init(cloudrootDir string) error {
|
||||||
linuxFsDrivers := []newRootFsDriverFunc{
|
linuxFsDrivers := []newRootFsDriverFunc{
|
||||||
NewFangdeRootFs, NewUnionOSRootFs,
|
NewOpenRuyiRootFs, NewFangdeRootFs, NewUnionOSRootFs,
|
||||||
NewAnolisRootFs, NewRockyRootFs, NewOpenCloudOsRootFs, NewAlmaLinuxRootFs,
|
NewAnolisRootFs, NewRockyRootFs, NewOpenCloudOsRootFs, NewAlmaLinuxRootFs,
|
||||||
NewOpenKylinRootfs, NewUOSDesktopRootfs,
|
NewOpenKylinRootfs, NewUOSDesktopRootfs,
|
||||||
NewGalaxyKylinRootFs, NewNeoKylinRootFs,
|
NewGalaxyKylinRootFs, NewNeoKylinRootFs,
|
||||||
|
|||||||
73
pkg/hostman/guestfs/fsdriver/openruyi.go
Normal file
73
pkg/hostman/guestfs/fsdriver/openruyi.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
// Copyright 2019 Yunion
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package fsdriver
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"yunion.io/x/jsonutils"
|
||||||
|
|
||||||
|
"yunion.io/x/onecloud/pkg/cloudcommon/types"
|
||||||
|
deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SOpenRuyiRootFs struct {
|
||||||
|
*sRedhatLikeRootFs
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOpenRuyiRootFs(part IDiskPartition) IRootFsDriver {
|
||||||
|
return &SOpenRuyiRootFs{sRedhatLikeRootFs: newRedhatLikeRootFs(part)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *SOpenRuyiRootFs) GetName() string {
|
||||||
|
return "openRuyi"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *SOpenRuyiRootFs) String() string {
|
||||||
|
return "OpenRuyiRootFs"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *SOpenRuyiRootFs) RootSignatures() []string {
|
||||||
|
sig := d.sLinuxRootFs.RootSignatures()
|
||||||
|
return append([]string{"/etc/os-release", "/usr/lib/rpm/openruyi"}, sig...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseOpenRuyiVersion(osRelease string) string {
|
||||||
|
for _, line := range strings.Split(osRelease, "\n") {
|
||||||
|
line = strings.TrimSpace(line)
|
||||||
|
if strings.HasPrefix(line, "VERSION_ID=") {
|
||||||
|
return strings.Trim(strings.TrimSpace(strings.TrimPrefix(line, "VERSION_ID=")), `"'`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *SOpenRuyiRootFs) GetReleaseInfo(rootFs IDiskPartition) *deployapi.ReleaseInfo {
|
||||||
|
rel, _ := rootFs.FileGetContents("/etc/os-release", false)
|
||||||
|
return deployapi.NewReleaseInfo(d.GetName(), parseOpenRuyiVersion(string(rel)), d.GetArch(rootFs))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *SOpenRuyiRootFs) DeployNetworkingScripts(rootFs IDiskPartition, nics []*types.SServerNic) error {
|
||||||
|
return d.sRedhatLikeRootFs.deployNetworkingScripts(rootFs, nics, d.GetReleaseInfo(rootFs))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *SOpenRuyiRootFs) EnableSerialConsole(rootFs IDiskPartition, sysInfo *jsonutils.JSONDict) error {
|
||||||
|
return d.enableSerialConsoleSystemd(rootFs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *SOpenRuyiRootFs) DisableSerialConsole(rootFs IDiskPartition) error {
|
||||||
|
d.disableSerialConsoleSystemd(rootFs)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
59
pkg/hostman/guestfs/fsdriver/openruyi_test.go
Normal file
59
pkg/hostman/guestfs/fsdriver/openruyi_test.go
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
// Copyright 2019 Yunion
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package fsdriver
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOpenRuyiRootSignatures(t *testing.T) {
|
||||||
|
driver := NewOpenRuyiRootFs(nil)
|
||||||
|
want := []string{
|
||||||
|
"/etc/os-release",
|
||||||
|
"/usr/lib/rpm/openruyi",
|
||||||
|
"/bin",
|
||||||
|
"/etc",
|
||||||
|
"/boot",
|
||||||
|
"/lib",
|
||||||
|
"/usr",
|
||||||
|
}
|
||||||
|
if got := driver.RootSignatures(); !reflect.DeepEqual(got, want) {
|
||||||
|
t.Fatalf("RootSignatures() = %#v, want %#v", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParseOpenRuyiVersion(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
osRelease string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{name: "double quoted", osRelease: "NAME=\"openRuyi\"\nVERSION_ID=\"Creek\"\n", want: "Creek"},
|
||||||
|
{name: "single quoted", osRelease: "VERSION_ID='River'\n", want: "River"},
|
||||||
|
{name: "unquoted", osRelease: "VERSION_ID=Lake\n", want: "Lake"},
|
||||||
|
{name: "whitespace and CRLF", osRelease: "NAME=openRuyi\r\n VERSION_ID = ignored\r\n VERSION_ID=\"Creek\" \r\n", want: "Creek"},
|
||||||
|
{name: "similarly named key", osRelease: "BUILD_VERSION_ID=Creek\n", want: ""},
|
||||||
|
{name: "empty value", osRelease: "VERSION_ID=\"\"\n", want: ""},
|
||||||
|
{name: "missing", osRelease: "NAME=\"openRuyi\"\n", want: ""},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := parseOpenRuyiVersion(tt.osRelease); got != tt.want {
|
||||||
|
t.Fatalf("parseOpenRuyiVersion() = %q, want %q", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user