mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-30 17:13:08 +08:00
fix(cloudcommon): unify OS_ARCH constants
This commit is contained in:
@@ -175,11 +175,6 @@ const (
|
||||
CPU_MODE_HOST = "host"
|
||||
)
|
||||
|
||||
const (
|
||||
OS_ARCH_X86 = "x86"
|
||||
OS_ARCH_AARCH64 = "aarch64"
|
||||
)
|
||||
|
||||
var VM_RUNNING_STATUS = []string{VM_START_START, VM_STARTING, VM_RUNNING, VM_BLOCK_STREAM, VM_BLOCK_STREAM_FAIL}
|
||||
var VM_CREATING_STATUS = []string{VM_CREATE_NETWORK, VM_CREATE_DISK, VM_START_DEPLOY, VM_DEPLOYING}
|
||||
|
||||
|
||||
@@ -132,7 +132,3 @@ const (
|
||||
HOST_HEALTH_STATUS_RUNNING = "running"
|
||||
HOST_HEALTH_LOCK_PREFIX = "host-health"
|
||||
)
|
||||
|
||||
const (
|
||||
CPU_ARCH_AARCH64 = "aarch64"
|
||||
)
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
package apis
|
||||
|
||||
import "yunion.io/x/pkg/utils"
|
||||
|
||||
const (
|
||||
SERVICE_TYPE_IMAGE = "image"
|
||||
SERVICE_TYPE_OFFLINE_CLOUDMETA = "offlinecloudmeta"
|
||||
@@ -60,3 +62,22 @@ var (
|
||||
SERVICE_TYPE_INFLUXDB,
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
OS_ARCH_X86 = "x86"
|
||||
OS_ARCH_ARM = "arm"
|
||||
|
||||
OS_ARCH_I386 = "i386"
|
||||
OS_ARCH_X86_32 = "x86_32"
|
||||
OS_ARCH_X86_64 = "x86_64"
|
||||
OS_ARCH_AARCH32 = "aarch32"
|
||||
OS_ARCH_AARCH64 = "aarch64"
|
||||
)
|
||||
|
||||
func IsARM(osArch string) bool {
|
||||
return utils.IsInStringArray(osArch, []string{
|
||||
OS_ARCH_ARM,
|
||||
OS_ARCH_AARCH32,
|
||||
OS_ARCH_AARCH64,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -56,12 +56,6 @@ const (
|
||||
IMAGE_STATUS_UPDATING = "updating"
|
||||
)
|
||||
|
||||
const (
|
||||
IMAGE_OS_ARCH_X86 = "x86" // x86 32位
|
||||
IMAGE_OS_ARCH_X86_64 = "x86_64" //
|
||||
IMAGE_OS_ARCH_ARM = "aarch64" // arm 64位 little endian
|
||||
)
|
||||
|
||||
var (
|
||||
ImageDeadStatus = []string{IMAGE_STATUS_DEACTIVATED, IMAGE_STATUS_KILLED, IMAGE_STATUS_DELETED, IMAGE_STATUS_PENDING_DELETE}
|
||||
)
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
@@ -40,11 +39,16 @@ func (manager *SMultiArchResourceBaseManager) ListItemFilter(
|
||||
query apis.MultiArchResourceBaseListInput,
|
||||
) (*sqlchemy.SQuery, error) {
|
||||
if len(query.OsArch) > 0 {
|
||||
if query.OsArch == compute.OS_ARCH_X86 {
|
||||
if query.OsArch == apis.OS_ARCH_X86 {
|
||||
q = q.Filter(sqlchemy.OR(
|
||||
sqlchemy.Startswith(q.Field("os_arch"), query.OsArch),
|
||||
sqlchemy.IsNullOrEmpty(q.Field("os_arch")),
|
||||
))
|
||||
} else if query.OsArch == apis.OS_ARCH_ARM {
|
||||
q = q.Filter(sqlchemy.OR(
|
||||
sqlchemy.Startswith(q.Field("os_arch"), query.OsArch),
|
||||
sqlchemy.Equals(q.Field("os_arch"), apis.OS_ARCH_AARCH64),
|
||||
))
|
||||
} else {
|
||||
q = q.Startswith("os_arch", query.OsArch)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
"yunion.io/x/pkg/utils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
host_api "yunion.io/x/onecloud/pkg/apis/host"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
@@ -384,7 +385,7 @@ func (self *SKVMGuestDriver) RequestAssociateEip(ctx context.Context, userCred m
|
||||
func (self *SKVMGuestDriver) NeedStopForChangeSpec(guest *models.SGuest, cpuChanged, memChanged bool) bool {
|
||||
return guest.GetMetadata("hotplug_cpu_mem", nil) != "enable" ||
|
||||
(memChanged && guest.GetMetadata("__hugepage", nil) == "native") ||
|
||||
guest.OsArch == api.OS_ARCH_AARCH64
|
||||
apis.IsARM(guest.OsArch)
|
||||
}
|
||||
|
||||
func (self *SKVMGuestDriver) RequestChangeVmConfig(ctx context.Context, guest *models.SGuest, task taskman.ITask, instanceType string, vcpuCount, vmemSize int64) error {
|
||||
|
||||
@@ -1748,7 +1748,7 @@ func fillDiskConfigByImage(ctx context.Context, userCred mcclient.TokenCredentia
|
||||
diskConfig.SizeMb = image.MinDiskMB // MB
|
||||
}
|
||||
if strings.Contains(image.Properties["os_arch"], "aarch") {
|
||||
diskConfig.OsArch = api.OS_ARCH_AARCH64
|
||||
diskConfig.OsArch = apis.OS_ARCH_AARCH64
|
||||
} else {
|
||||
diskConfig.OsArch = image.Properties["os_arch"]
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ func (self *SGuest) PerformSaveImage(ctx context.Context, userCred mcclient.Toke
|
||||
input.OsType = "Linux"
|
||||
}
|
||||
input.OsArch = self.OsArch
|
||||
if self.OsArch == api.OS_ARCH_AARCH64 {
|
||||
if apis.IsARM(self.OsArch) {
|
||||
if osArch := self.GetMetadata("os_arch", nil); len(osArch) == 0 {
|
||||
host := self.GetHost()
|
||||
input.OsArch = host.CpuArchitecture
|
||||
@@ -275,7 +275,7 @@ func (self *SGuest) PerformSaveGuestImage(ctx context.Context, userCred mcclient
|
||||
osType = "Linux"
|
||||
}
|
||||
properties.Add(jsonutils.NewString(osType), "os_type")
|
||||
if self.OsArch == api.OS_ARCH_AARCH64 {
|
||||
if apis.IsARM(self.OsArch) {
|
||||
var osArch string
|
||||
if osArch = self.GetMetadata("os_arch", nil); len(osArch) == 0 {
|
||||
host := self.GetHost()
|
||||
|
||||
@@ -1217,7 +1217,7 @@ func (manager *SGuestManager) validateCreateData(
|
||||
}
|
||||
|
||||
if arch := imgProperties["os_arch"]; strings.Contains(arch, "aarch") {
|
||||
input.OsArch = api.OS_ARCH_AARCH64
|
||||
input.OsArch = apis.OS_ARCH_AARCH64
|
||||
}
|
||||
|
||||
if len(imgProperties) == 0 {
|
||||
|
||||
@@ -541,7 +541,7 @@ func (manager *SHostManager) CustomizeFilterList(ctx context.Context, q *sqlchem
|
||||
}
|
||||
|
||||
func (self *SHost) IsArmHost() bool {
|
||||
return self.CpuArchitecture == api.CPU_ARCH_AARCH64
|
||||
return self.CpuArchitecture == apis.OS_ARCH_AARCH64
|
||||
}
|
||||
|
||||
func (self *SHost) GetZone() *SZone {
|
||||
|
||||
@@ -17,6 +17,7 @@ package fsdriver
|
||||
import (
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/types"
|
||||
deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis"
|
||||
)
|
||||
@@ -75,7 +76,7 @@ func (m *SEsxiRootFs) GetReleaseInfo(IDiskPartition) *deployapi.ReleaseInfo {
|
||||
return &deployapi.ReleaseInfo{
|
||||
Distro: "ESXi",
|
||||
Version: version,
|
||||
Arch: "x86_64",
|
||||
Arch: apis.OS_ARCH_X86_64,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/types"
|
||||
deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis"
|
||||
@@ -329,24 +330,24 @@ func (l *sLinuxRootFs) GetArch(rootFs IDiskPartition) string {
|
||||
files := rootFs.ListDir("/lib64", false)
|
||||
for i := 0; i < len(files); i++ {
|
||||
if strings.HasPrefix(files[i], "ld-") {
|
||||
if strings.Contains(files[i], "aarch64") {
|
||||
return "aarch64"
|
||||
if strings.Contains(files[i], apis.OS_ARCH_AARCH64) {
|
||||
return apis.OS_ARCH_AARCH64
|
||||
} else if strings.Contains(files[i], "x86") {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
}
|
||||
}
|
||||
}
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
} else {
|
||||
files := rootFs.ListDir("/lib", false)
|
||||
for i := 0; i < len(files); i++ {
|
||||
if strings.HasPrefix(files[i], "ld-") {
|
||||
if strings.Contains(files[i], "arm") {
|
||||
return "aarch32"
|
||||
return apis.OS_ARCH_AARCH32
|
||||
}
|
||||
}
|
||||
}
|
||||
return "x86"
|
||||
return apis.OS_ARCH_X86_32
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/types"
|
||||
deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis"
|
||||
"yunion.io/x/onecloud/pkg/util/macutils"
|
||||
@@ -124,7 +125,7 @@ func (m *SMacOSRootFs) GetReleaseInfo(IDiskPartition) *deployapi.ReleaseInfo {
|
||||
return &deployapi.ReleaseInfo{
|
||||
Distro: distro,
|
||||
Version: version,
|
||||
Arch: "x86_64",
|
||||
Arch: apis.OS_ARCH_X86_64,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
"yunion.io/x/pkg/util/version"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
identityapi "yunion.io/x/onecloud/pkg/apis/identity"
|
||||
"yunion.io/x/onecloud/pkg/hostman/guestfs/fsdriver"
|
||||
@@ -1742,11 +1743,11 @@ func (h *SHostInfo) GetCpuArchitecture() string {
|
||||
}
|
||||
|
||||
func (h *SHostInfo) IsAarch64() bool {
|
||||
return h.GetCpuArchitecture() == "aarch64"
|
||||
return h.GetCpuArchitecture() == apis.OS_ARCH_AARCH64
|
||||
}
|
||||
|
||||
func (h *SHostInfo) IsX8664() bool {
|
||||
return h.GetCpuArchitecture() == "x86_64"
|
||||
return h.GetCpuArchitecture() == apis.OS_ARCH_X86_64
|
||||
}
|
||||
|
||||
func NewHostInfo() (*SHostInfo, error) {
|
||||
|
||||
@@ -36,7 +36,6 @@ import (
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/apis/compute"
|
||||
api "yunion.io/x/onecloud/pkg/apis/image"
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
@@ -562,7 +561,7 @@ func (self *SImage) PostCreate(ctx context.Context, userCred mcclient.TokenCrede
|
||||
dict.Set(api.IMAGE_OS_ARCH, jsonutils.NewString(osArch))
|
||||
}
|
||||
db.Update(self, func() error {
|
||||
self.OsArch = compute.OS_ARCH_AARCH64
|
||||
self.OsArch = apis.OS_ARCH_AARCH64
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
@@ -174,7 +175,7 @@ func (self *SImage) GetOsType() string {
|
||||
|
||||
func (self *SImage) GetOsArch() string {
|
||||
if self.GetImageType() == cloudprovider.ImageTypeCustomized {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
}
|
||||
return publisherGetOsArch(self.Publisher, self.Offer, self.Sku, self.Version)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ package azure
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
)
|
||||
|
||||
type SPublisherDriver struct {
|
||||
@@ -53,7 +55,7 @@ var publisherDrivers = map[string]SPublisherDriver{
|
||||
return parts[0]
|
||||
},
|
||||
GetOsArch: func(offer, sku, version string) string {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
},
|
||||
GetName: func(offer, sku, version string) string {
|
||||
return fmt.Sprintf("%s-%s-%s", offer, sku, version)
|
||||
@@ -80,7 +82,7 @@ var publisherDrivers = map[string]SPublisherDriver{
|
||||
return sku
|
||||
},
|
||||
GetOsArch: func(offer, sku, version string) string {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
},
|
||||
GetName: func(offer, sku, version string) string {
|
||||
return fmt.Sprintf("%s-%s", offer, version)
|
||||
@@ -107,7 +109,7 @@ var publisherDrivers = map[string]SPublisherDriver{
|
||||
return sku
|
||||
},
|
||||
GetOsArch: func(offer, sku, version string) string {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
},
|
||||
GetName: func(offer, sku, version string) string {
|
||||
return fmt.Sprintf("%s-%s", offer, version)
|
||||
@@ -134,7 +136,7 @@ var publisherDrivers = map[string]SPublisherDriver{
|
||||
return sku
|
||||
},
|
||||
GetOsArch: func(offer, sku, version string) string {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
},
|
||||
GetName: func(offer, sku, version string) string {
|
||||
return fmt.Sprintf("%s-%s", offer, version)
|
||||
@@ -161,7 +163,7 @@ var publisherDrivers = map[string]SPublisherDriver{
|
||||
return sku
|
||||
},
|
||||
GetOsArch: func(offer, sku, version string) string {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
},
|
||||
GetName: func(offer, sku, version string) string {
|
||||
return fmt.Sprintf("%s-%s-%s", offer, sku, version)
|
||||
@@ -188,7 +190,7 @@ var publisherDrivers = map[string]SPublisherDriver{
|
||||
return version
|
||||
},
|
||||
GetOsArch: func(offer, sku, version string) string {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
},
|
||||
GetName: func(offer, sku, version string) string {
|
||||
return fmt.Sprintf("%s-%s-%s", offer, sku, version)
|
||||
@@ -215,7 +217,7 @@ var publisherDrivers = map[string]SPublisherDriver{
|
||||
return sku
|
||||
},
|
||||
GetOsArch: func(offer, sku, version string) string {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
},
|
||||
GetName: func(offer, sku, version string) string {
|
||||
return fmt.Sprintf("%s-%s", offer, version)
|
||||
@@ -242,7 +244,7 @@ var publisherDrivers = map[string]SPublisherDriver{
|
||||
return sku
|
||||
},
|
||||
GetOsArch: func(offer, sku, version string) string {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
},
|
||||
GetName: func(offer, sku, version string) string {
|
||||
return fmt.Sprintf("%s-%s", offer, version)
|
||||
@@ -299,5 +301,5 @@ func publisherGetOsArch(publisher, offer, sku, version string) string {
|
||||
if ok {
|
||||
return driver.GetOsArch(offer, sku, version)
|
||||
}
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
@@ -425,9 +426,9 @@ func stdVersion(osDist string, osVersion string, osArch string) (string, error)
|
||||
// 架构
|
||||
arch := ""
|
||||
switch osArch {
|
||||
case "64", "x86_64":
|
||||
case "64", apis.OS_ARCH_X86_64:
|
||||
arch = "64bit"
|
||||
case "32", "x86_32":
|
||||
case "32", apis.OS_ARCH_X86_32:
|
||||
arch = "32bit"
|
||||
default:
|
||||
return "", fmt.Errorf("unsupported arch %s.reference: https://support.huaweicloud.com/api-ims/zh-cn_topic_0031617666.html", osArch)
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
@@ -232,7 +233,7 @@ func (image *SImage) GetOsVersion() string {
|
||||
}
|
||||
|
||||
func (image *SImage) GetOsArch() string {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
}
|
||||
|
||||
func (image *SImage) GetMinOsDiskSizeGb() int {
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud"
|
||||
@@ -316,7 +317,7 @@ func (self *SRegion) GetImportImageParams(name string, osArch, osDist, osVersion
|
||||
continue
|
||||
}
|
||||
if !utils.IsInStringArray(osArch, _imageSet.Architecture) {
|
||||
osArch = "x86_64"
|
||||
osArch = apis.OS_ARCH_X86_64
|
||||
}
|
||||
for _, _osVersion := range _imageSet.OsVersions {
|
||||
if strings.HasPrefix(osVersion, _osVersion) {
|
||||
@@ -334,7 +335,7 @@ func (self *SRegion) GetImportImageParams(name string, osArch, osDist, osVersion
|
||||
}
|
||||
if len(osType) == 0 {
|
||||
osType = "Other Linux"
|
||||
osArch = "x86_64"
|
||||
osArch = apis.OS_ARCH_X86_64
|
||||
osVersion = "-"
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/multicloud/qcloud"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
)
|
||||
@@ -97,7 +98,7 @@ func init() {
|
||||
osArch: "test",
|
||||
osDist: "Centos",
|
||||
osVersion: "3.4",
|
||||
OutputArch: "x86_64",
|
||||
OutputArch: apis.OS_ARCH_X86_64,
|
||||
OutputDist: "CentOS",
|
||||
OutputOsVersion: "-",
|
||||
},
|
||||
@@ -121,39 +122,39 @@ func init() {
|
||||
osArch: "",
|
||||
osDist: "",
|
||||
osVersion: "7.1",
|
||||
OutputArch: "x86_64",
|
||||
OutputArch: apis.OS_ARCH_X86_64,
|
||||
OutputDist: "Other Linux",
|
||||
OutputOsVersion: "-",
|
||||
},
|
||||
{
|
||||
osArch: "x86_64",
|
||||
osArch: apis.OS_ARCH_X86_64,
|
||||
osDist: "Windows Server",
|
||||
osVersion: "2008 R2 Datacenter Evaluation",
|
||||
OutputArch: "x86_64",
|
||||
OutputArch: apis.OS_ARCH_X86_64,
|
||||
OutputDist: "Windows Server 2008",
|
||||
OutputOsVersion: "-",
|
||||
},
|
||||
{
|
||||
osArch: "x86_64",
|
||||
osArch: apis.OS_ARCH_X86_64,
|
||||
osDist: "Ubuntu",
|
||||
osVersion: "16.04.5",
|
||||
OutputArch: "x86_64",
|
||||
OutputArch: apis.OS_ARCH_X86_64,
|
||||
OutputDist: "Ubuntu",
|
||||
OutputOsVersion: "16",
|
||||
},
|
||||
{
|
||||
osArch: "x86_64",
|
||||
osArch: apis.OS_ARCH_X86_64,
|
||||
osDist: "Windows%20Server%202008%20R2%20Datacenter",
|
||||
osVersion: "6.1",
|
||||
OutputArch: "x86_64",
|
||||
OutputArch: apis.OS_ARCH_X86_64,
|
||||
OutputDist: "Windows Server 2008",
|
||||
OutputOsVersion: "-",
|
||||
},
|
||||
{
|
||||
osArch: "x86_64",
|
||||
osArch: apis.OS_ARCH_X86_64,
|
||||
osDist: "Windows Server 2012 R2 Datacenter Evaluation",
|
||||
osVersion: "6.2",
|
||||
OutputArch: "x86_64",
|
||||
OutputArch: apis.OS_ARCH_X86_64,
|
||||
OutputDist: "Windows Server 2012",
|
||||
OutputOsVersion: "-",
|
||||
},
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package guest
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
)
|
||||
@@ -54,7 +54,7 @@ func (f *CPUPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core.Pr
|
||||
|
||||
useRsvd := h.UseReserved()
|
||||
getter := c.Getter()
|
||||
if d.OsArch == compute.OS_ARCH_AARCH64 {
|
||||
if apis.IsARM(d.OsArch) {
|
||||
host := getter.Host()
|
||||
if !host.IsArmHost() {
|
||||
h.Exclude(predicates.ErrHostCpuArchitectureNotMatch)
|
||||
|
||||
@@ -17,28 +17,28 @@ package imagetools
|
||||
import (
|
||||
"strings"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/image"
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
)
|
||||
|
||||
func normalizeOsArch(osArch string, osType string, osDist string) string {
|
||||
if len(osArch) > 0 {
|
||||
switch strings.ToLower(osArch) {
|
||||
case "x86_64", "64":
|
||||
return api.IMAGE_OS_ARCH_X86_64
|
||||
return apis.OS_ARCH_X86_64
|
||||
case "x86", "x86_32", "32":
|
||||
return api.IMAGE_OS_ARCH_X86
|
||||
return apis.OS_ARCH_X86
|
||||
case "arm", "arm64", "aarch", "aarch64":
|
||||
return api.IMAGE_OS_ARCH_ARM
|
||||
return apis.OS_ARCH_AARCH64
|
||||
default:
|
||||
return osArch
|
||||
}
|
||||
} else {
|
||||
if osType == "linux" {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_AARCH64
|
||||
} else if osDist == "Windows Server 2003" {
|
||||
return "i386"
|
||||
return apis.OS_ARCH_I386
|
||||
} else {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/util/procutils"
|
||||
"yunion.io/x/onecloud/pkg/util/regutils2"
|
||||
)
|
||||
@@ -609,16 +610,16 @@ func (w *SWinRegTool) GetArch(hostCpuArch string) string {
|
||||
prodKey := `HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\CurrentVersion`
|
||||
ver := w.GetRegistry(prodKey)
|
||||
if len(ver) > 0 {
|
||||
if hostCpuArch == "aarch64" {
|
||||
return "aarch64"
|
||||
if hostCpuArch == apis.OS_ARCH_AARCH64 {
|
||||
return apis.OS_ARCH_AARCH64
|
||||
} else {
|
||||
return "x86_64"
|
||||
return apis.OS_ARCH_X86_64
|
||||
}
|
||||
} else {
|
||||
if hostCpuArch == "aarch64" {
|
||||
return "aarch32"
|
||||
if hostCpuArch == apis.OS_ARCH_AARCH32 {
|
||||
return apis.OS_ARCH_AARCH32
|
||||
} else {
|
||||
return "x86"
|
||||
return apis.OS_ARCH_X86_32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user