mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 16:13:56 +08:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1b2e2b508 | ||
|
|
eb4b22eaec | ||
|
|
a14ab9820d | ||
|
|
94d2bc456d | ||
|
|
5cd48cec5f | ||
|
|
c039a56be1 | ||
|
|
c24235c137 | ||
|
|
85f85e394d | ||
|
|
5fdde01bea | ||
|
|
59e1534222 | ||
|
|
f6da9ad66a | ||
|
|
b55c2f7d21 | ||
|
|
24e29349bf | ||
|
|
aa7c5f1b1a | ||
|
|
a3b1b99cc4 | ||
|
|
899afd7065 | ||
|
|
2bf31dbd3a | ||
|
|
35d8cba97f | ||
|
|
8a1be0852d | ||
|
|
ef29136266 | ||
|
|
adaa7fa2ce | ||
|
|
62a4bce191 | ||
|
|
1ecbb46e59 | ||
|
|
58ca8180b6 | ||
|
|
08819e2201 | ||
|
|
b4f5f1a996 | ||
|
|
85f6e95c18 | ||
|
|
8a71e73afd | ||
|
|
407f155df1 | ||
|
|
ab0c6f1284 | ||
|
|
99d1137805 | ||
|
|
95a03ad58b | ||
|
|
659022c792 | ||
|
|
b55ac81e2a | ||
|
|
bd69dc44d7 | ||
|
|
06c303c648 | ||
|
|
15fbc035ab | ||
|
|
a25de48df9 | ||
|
|
be065e872d | ||
|
|
4c27add0ba | ||
|
|
d238540dcb | ||
|
|
fdd0bf77e6 | ||
|
|
ab5fcdad3d | ||
|
|
38d23b0739 | ||
|
|
b45811166b | ||
|
|
2ee1af186d | ||
|
|
14e537fc65 |
18
Makefile
18
Makefile
@@ -89,6 +89,9 @@ vet:
|
||||
cmd/esxi-agent: prepare_dir
|
||||
CGO_ENABLED=0 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
|
||||
|
||||
cmd/fetcherfs: prepare_dir
|
||||
CGO_ENABLED=0 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
|
||||
|
||||
cmd/%: prepare_dir
|
||||
$(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@
|
||||
|
||||
@@ -101,6 +104,21 @@ deb/%: cmd/%
|
||||
pkg/%: prepare_dir
|
||||
$(GO_INSTALL) $(REPO_PREFIX)/$@
|
||||
|
||||
rpm/fetcherfs: cmd/fetcherfs
|
||||
docker run --rm \
|
||||
--name docker-centos-build-fetcherfs \
|
||||
-v $(CURDIR):/data \
|
||||
registry.cn-beijing.aliyuncs.com/yunionio/centos-build:1.1-4 \
|
||||
/bin/bash -c "VERSION=3.6 /data/build/build.sh fetcherfs /opt/yunion/fetchclient/bin"
|
||||
|
||||
deb/fetcherfs: rpm/fetcherfs
|
||||
#VERSION=3.6 $(DEB_BUILD_SCRIPT) fetcherfs /opt/yunion/fetchclient/bin
|
||||
docker run --rm \
|
||||
--name docker-debian-build-fetcherfs \
|
||||
-v $(CURDIR):/data \
|
||||
registry.cn-beijing.aliyuncs.com/yunionio/debian10-base:1.0 \
|
||||
/data/build/convert_rpm2deb.sh
|
||||
|
||||
build:
|
||||
$(MAKE) $(cmdTargets)
|
||||
|
||||
|
||||
18
README-CN.md
18
README-CN.md
@@ -1,12 +1,12 @@
|
||||
# Yunion OneCloud (云联融合云)
|
||||
# Yunion Cloud (云联融合云)
|
||||
|
||||
[](https://circleci.com/gh/yunionio/onecloud)
|
||||
[](https://travis-ci.org/yunionio/onecloud)
|
||||
[](https://goreportcard.com/report/github.com/yunionio/onecloud)
|
||||
[](https://circleci.com/gh/yunionio/yunioncloud)
|
||||
[](https://travis-ci.org/yunionio/yunioncloud)
|
||||
[](https://goreportcard.com/report/github.com/yunionio/yunioncloud)
|
||||
|
||||
## 什么是云联融合云?
|
||||
|
||||
云联融合云(Yunion OneCloud)是一个开源的多云平台。融合云构建在用户分布于多云基础设施之上,通过技术手段将分布于多云的异构IT资源统一管理,将多底层多云的差异向用户屏蔽,并通过网络和调度实现资源的融合与打通,在多云之上进行抽象,向用户呈现统一的使用界面和API接口,让用户就像使用一个云平台一样使用分布于多云的资源,实现一个统一的“云上之云”的云平台。
|
||||
云联融合云(Yunion Cloud)是一个开源的多云平台。融合云构建在用户分布于多云基础设施之上,通过技术手段将分布于多云的异构IT资源统一管理,将多底层多云的差异向用户屏蔽,并通过网络和调度实现资源的融合与打通,在多云之上进行抽象,向用户呈现统一的使用界面和API接口,让用户就像使用一个云平台一样使用分布于多云的资源,实现一个统一的“云上之云”的云平台。
|
||||
|
||||
鉴于企业IT基础设施的两个趋势:1. 企业使用多云基础设施,并且公有云是最主要的基础设施提供者;2. 企业应用将逐步云原生化,企业IT基础设施需要为Kubernetes优化。融合云为此架构而设计。一方面抽象管理底层的多云基础设施,另一方面为多云Kubernetes提供运行环境。融合云为企业未来的的IT基础设施架构而设计。
|
||||
|
||||
@@ -18,18 +18,18 @@
|
||||
|
||||
- 内置私有云
|
||||
|
||||
OneCloud内置完备的私有云实现,提供对用户本地IDC的虚拟机、物理机和负载均衡等资源管理。
|
||||
YunionCloud 内置完备的私有云实现,提供对用户本地IDC的虚拟机、物理机和负载均衡等资源管理。
|
||||
|
||||
- 为多云Kubernetes提供运行环境
|
||||
|
||||
OneCloud自身为运行在Kubernetes的云原生应用,并且能在多云环境部署运行Kubernetes集群。
|
||||
YunionCloud 自身为运行在Kubernetes的云原生应用,并且能在多云环境部署运行Kubernetes集群。
|
||||
|
||||
欢迎安装部署云联融合云,期待大家的反馈!
|
||||
|
||||
|
||||
## 部署
|
||||
|
||||
请参考文档 [安装部署](https://docs.yunion.io/docs/setup/) 搭建 OneCloud 集群。
|
||||
请参考文档 [安装部署](https://docs.yunion.io/docs/setup/) 搭建 YunionCloud 集群。
|
||||
|
||||
|
||||
## 文档
|
||||
@@ -51,4 +51,4 @@
|
||||
|
||||
## License
|
||||
|
||||
OneCloud 使用 Apache license 2.0. 详情请看 [LICENSE](./LICENSE) 。
|
||||
YunionCloud 使用 Apache license 2.0. 详情请看 [LICENSE](./LICENSE) 。
|
||||
|
||||
24
README.md
24
README.md
@@ -1,22 +1,22 @@
|
||||
# Yunion OneCloud
|
||||
# Yunion Cloud
|
||||
|
||||
[](https://circleci.com/gh/yunionio/onecloud)
|
||||
[](https://travis-ci.com/yunionio/onecloud/branches)
|
||||
[](https://goreportcard.com/report/github.com/yunionio/onecloud)
|
||||
[](https://circleci.com/gh/yunionio/yunioncloud)
|
||||
[](https://travis-ci.com/yunionio/yunioncloud/branches)
|
||||
[](https://goreportcard.com/report/github.com/yunionio/yunioncloud)
|
||||
|
||||
### [README in Chinese](./README-CN.md)
|
||||
|
||||
## What is Yunion OneCloud?
|
||||
## What is Yunion Cloud?
|
||||
|
||||
Yunion OneCloud is an open source unified-IaaS cloud platform.
|
||||
Yunion Cloud is an open source unified-IaaS cloud platform.
|
||||
|
||||
As its name sugguests, 'Yun' means 'cloud' in Chinese and 'Yunion OneCloud' means to unify many distinct clouds into the one that behaves like an integral cloud platform.
|
||||
As its name sugguests, 'Yun' means 'cloud' in Chinese and 'Yunion Cloud' means to unify many distinct clouds into the one that behaves like an integral cloud platform.
|
||||
|
||||
As trends show, the enterprise IT infrastructure in the future would be unavoidably heterogeneous and the public clouds should be the major infrastructure providers for many enterprises. Further, the infrastructure would most likely be prepared for the cloud-native applications running on Kubernetes. Yunion OneCloud is built to provide the cloud architecture for this scenario such that it is the middle layer between the underlying cloud infrustructures and the overlay kubernetes clusters across many clouds.
|
||||
As trends show, the enterprise IT infrastructure in the future would be unavoidably heterogeneous and the public clouds should be the major infrastructure providers for many enterprises. Further, the infrastructure would most likely be prepared for the cloud-native applications running on Kubernetes. Yunion Cloud is built to provide the cloud architecture for this scenario such that it is the middle layer between the underlying cloud infrustructures and the overlay kubernetes clusters across many clouds.
|
||||
|
||||
Many may consider Yunion OneCloud as a multi-cloud management platform (MCMP). Rather, we would view it as an IaaS platform as it does not only manage the resources and services from many clouds, but also hides the differences of underlying technologies and exposes one set of APIs that allow programatically interacting with the compute/storage/networking resources across many clouds.
|
||||
Many may consider Yunion Cloud as a multi-cloud management platform (MCMP). Rather, we would view it as an IaaS platform as it does not only manage the resources and services from many clouds, but also hides the differences of underlying technologies and exposes one set of APIs that allow programatically interacting with the compute/storage/networking resources across many clouds.
|
||||
|
||||
Yunion OneCloud is working on abstracting APIs for the following resources:
|
||||
Yunion Cloud is working on abstracting APIs for the following resources:
|
||||
|
||||
* Compute, including virtual machines, images, etc.
|
||||
* Storage, including disks, snapshots, object storages, etc.
|
||||
@@ -30,7 +30,7 @@ over the following many cloud providers:
|
||||
* Private clouds, including OpenStack, etc.
|
||||
* Public clouds, including Aliyun, AWS, Azure, Tencent Cloud, Huawei Cloud, etc.
|
||||
|
||||
You are welcome to install and try Yunion OneCloud. Looking forward to your feedback.
|
||||
You are welcome to install and try Yunion Cloud. Looking forward to your feedback.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -38,7 +38,7 @@ Please refers to [install & deployment](https://docs.yunion.io/docs/setup/) (cur
|
||||
|
||||
## Documentations
|
||||
|
||||
- [Yunion OneCloud Documents](https://docs.yunion.io/)
|
||||
- [Yunion Cloud Documents](https://docs.yunion.io/)
|
||||
|
||||
- [Swagger API](https://docs.yunion.cn/apiv2/)
|
||||
|
||||
|
||||
23
build/convert_rpm2deb.sh
Executable file
23
build/convert_rpm2deb.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$ROOT_DIR" ]; then
|
||||
ROOT_DIR=$(dirname $(dirname $(readlink -f "$BASH_SOURCE")))
|
||||
fi
|
||||
|
||||
RPMS_DIR=$ROOT_DIR/_output/rpms
|
||||
DEBS_DIR=$ROOT_DIR/_output/debs
|
||||
|
||||
case $(uname -m) in
|
||||
x86_64)
|
||||
CURRENT_ARCH=amd64
|
||||
;;
|
||||
aarch64)
|
||||
CURRENT_ARCH=arm64
|
||||
;;
|
||||
esac
|
||||
|
||||
mkdir -p $DEBS_DIR && cd $DEBS_DIR
|
||||
|
||||
find $RPMS_DIR -type f -name *.rpm -exec alien --target=$CURRENT_ARCH {} \;
|
||||
9
build/docker/Dockerfile.debian-base
Normal file
9
build/docker/Dockerfile.debian-base
Normal file
@@ -0,0 +1,9 @@
|
||||
# registry.cn-beijing.aliyuncs.com/yunionio/debian10-base:1.0
|
||||
|
||||
FROM debian:10
|
||||
|
||||
RUN apt update && apt install -y alien
|
||||
|
||||
RUN apt-get clean autoclean && \
|
||||
apt-get autoremove --yes && \
|
||||
rm -rf /var/lib/{apt,dpkg,cache,log}/
|
||||
3
build/docker/Makefile
Normal file
3
build/docker/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
debian10-base:
|
||||
docker buildx build --platform linux/arm64,linux/amd64 --push \
|
||||
-t registry.cn-beijing.aliyuncs.com/yunionio/debian10-base:1.0 -f ./Dockerfile.debian-base .
|
||||
@@ -171,11 +171,6 @@ const (
|
||||
CPU_MODE_HOST = "host"
|
||||
)
|
||||
|
||||
const (
|
||||
OS_ARCH_X86 = "x86"
|
||||
OS_ARCH_ARM = "arm"
|
||||
)
|
||||
|
||||
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}
|
||||
|
||||
|
||||
@@ -131,7 +131,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,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func (job *SStatusProbeJob) Name() string {
|
||||
|
||||
func (job *SStatusProbeJob) Do(ctx context.Context, now time.Time) error {
|
||||
bStatus := job.baremetal.GetStatus()
|
||||
if bStatus == api.BAREMETAL_READY || bStatus == api.BAREMETAL_RUNNING {
|
||||
if bStatus == api.BAREMETAL_READY || bStatus == api.BAREMETAL_RUNNING || bStatus == api.BAREMETAL_UNKNOWN {
|
||||
ps, err := job.baremetal.GetPowerStatus()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "GetPowerStatus")
|
||||
|
||||
@@ -1550,6 +1550,11 @@ func (b *SBaremetalInstance) StartBaremetalResetBMCTask(userCred mcclient.TokenC
|
||||
}
|
||||
|
||||
func (b *SBaremetalInstance) StartBaremetalIpmiProbeTask(userCred mcclient.TokenCredential, taskId string, data jsonutils.JSONObject) error {
|
||||
session := b.manager.GetClientSession()
|
||||
data, _ = b.manager.fetchBaremetal(session, b.GetId())
|
||||
if err := b.SaveDesc(data); err != nil {
|
||||
return err
|
||||
}
|
||||
b.StartNewTask(tasks.NewBaremetalIpmiProbeTask, userCred, taskId, data)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package ipmitool
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
@@ -115,21 +116,21 @@ func (ipmi *LanPlusIPMI) GetMode() string {
|
||||
return "rmcp"
|
||||
}
|
||||
|
||||
func (ipmi *LanPlusIPMI) GetCommand(args ...string) *procutils.Command {
|
||||
func (ipmi *LanPlusIPMI) GetCommand(args ...string) (*procutils.Command, context.CancelFunc) {
|
||||
nArgs := []string{
|
||||
"--signal=KILL",
|
||||
fmt.Sprintf("%s", ipmi.GetDefaultTimeout()),
|
||||
"ipmitool", "-I", "lanplus", "-H", ipmi.host,
|
||||
"-I", "lanplus", "-H", ipmi.host,
|
||||
"-p", fmt.Sprintf("%d", ipmi.port),
|
||||
"-U", ipmi.user,
|
||||
"-P", ipmi.password,
|
||||
}
|
||||
nArgs = append(nArgs, args...)
|
||||
return procutils.NewCommand("timeout", nArgs...)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), ipmi.GetDefaultTimeout())
|
||||
return procutils.NewCommandContext(ctx, "ipmitool", nArgs...), cancel
|
||||
}
|
||||
|
||||
func (ipmi *LanPlusIPMI) ExecuteCommand(args ...string) ([]string, error) {
|
||||
cmd := ipmi.GetCommand(args...)
|
||||
cmd, cancel := ipmi.GetCommand(args...)
|
||||
defer cancel()
|
||||
log.Debugf("[LanPlusIPMI] execute command: %s", cmd.String())
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -932,11 +932,7 @@ func (dispatcher *DBModelDispatcher) tryGetModelProperty(ctx context.Context, pr
|
||||
}
|
||||
|
||||
if consts.IsRbacEnabled() {
|
||||
ownerId, err := fetchOwnerId(ctx, dispatcher.modelManager, userCred, query)
|
||||
if err != nil {
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
err = isClassRbacAllowed(dispatcher.modelManager, userCred, ownerId, policy.PolicyActionList, property)
|
||||
_, _, err := FetchCheckQueryOwnerScope(ctx, userCred, query, dispatcher.modelManager, policy.PolicyActionList, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/i18n"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
@@ -177,8 +176,10 @@ func (manager *SI18nManager) RemoveI18ns(ctx context.Context, userCred mcclient.
|
||||
}
|
||||
|
||||
func (manager *SI18nManager) SyncI18ns(ctx context.Context, userCred mcclient.TokenCredential, model IModel, table IModelI18nTable) ([]SI18n, []IModelI18nEntry, compare.SyncResult) {
|
||||
lockman.LockClass(ctx, manager, "")
|
||||
defer lockman.ReleaseClass(ctx, manager, "")
|
||||
//// No need to lock SI18nManager, the resources has been lock in the upper layer - QIU Jian, 20210405
|
||||
// lockman.LockClass(ctx, manager, "")
|
||||
// defer lockman.ReleaseClass(ctx, manager, "")
|
||||
|
||||
syncResult := compare.SyncResult{}
|
||||
|
||||
extItems := manager.getExternalI18nItems(ctx, table)
|
||||
@@ -257,7 +258,7 @@ func (manager *SI18nManager) newFromI18n(ctx context.Context, userCred mcclient.
|
||||
}
|
||||
|
||||
func (self *SI18n) updateFromI18n(ctx context.Context, userCred mcclient.TokenCredential, entry IModelI18nEntry) error {
|
||||
_, err := UpdateWithLock(ctx, self, func() error {
|
||||
_, err := Update(self, func() error {
|
||||
self.KeyValue = entry.GetKeyValue()
|
||||
self.Cn = entry.Lookup(i18n.I18N_TAG_CHINESE)
|
||||
self.En = entry.Lookup(i18n.I18N_TAG_ENGLISH)
|
||||
@@ -273,8 +274,8 @@ func (self *SI18n) updateFromI18n(ctx context.Context, userCred mcclient.TokenCr
|
||||
}
|
||||
|
||||
func (self *SI18n) removeI18n(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
lockman.LockObject(ctx, self)
|
||||
defer lockman.ReleaseObject(ctx, self)
|
||||
// lockman.LockObject(ctx, self)
|
||||
// defer lockman.ReleaseObject(ctx, self)
|
||||
|
||||
err := self.Delete(ctx, userCred)
|
||||
return err
|
||||
|
||||
@@ -385,7 +385,7 @@ func (self *SOpsLogManager) FilterByOwner(q *sqlchemy.SQuery, ownerId mcclient.I
|
||||
}
|
||||
case rbacutils.ScopeDomain:
|
||||
if len(ownerId.GetProjectDomainId()) > 0 {
|
||||
q = q.Filter(sqlchemy.Equals(q.Field("domain_id"), ownerId.GetProjectDomainId()))
|
||||
q = q.Filter(sqlchemy.Equals(q.Field("project_domain_id"), ownerId.GetProjectDomainId()))
|
||||
}
|
||||
default:
|
||||
// systemScope, no filter
|
||||
|
||||
@@ -225,6 +225,8 @@ type ICloudProviderFactory interface {
|
||||
GetTTLRange(zoneType TDnsZoneType, productType TDnsProductType) TTlRange
|
||||
|
||||
IsSupportSAMLAuth() bool
|
||||
|
||||
GetAccountIdEqualizer() func(origin, now string) bool
|
||||
}
|
||||
|
||||
type ICloudProvider interface {
|
||||
@@ -711,6 +713,15 @@ func (factory *baseProviderFactory) GetTTLRange(zoneType TDnsZoneType, productTy
|
||||
return TTlRange{}
|
||||
}
|
||||
|
||||
func (factory *baseProviderFactory) GetAccountIdEqualizer() func(origin, now string) bool {
|
||||
return func(origin, now string) bool {
|
||||
if len(now) > 0 && now != origin {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
type SDnsCapability struct {
|
||||
ZoneTypes []TDnsZoneType
|
||||
DnsTypes map[TDnsZoneType][]TDnsType
|
||||
|
||||
@@ -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"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
@@ -382,7 +383,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_ARM
|
||||
apis.IsARM(guest.OsArch)
|
||||
}
|
||||
|
||||
func (self *SKVMGuestDriver) RequestChangeVmConfig(ctx context.Context, guest *models.SGuest, task taskman.ITask, instanceType string, vcpuCount, vmemSize int64) error {
|
||||
|
||||
@@ -256,3 +256,7 @@ func (driver *SBaseHostDriver) GetStoragecacheQuota(host *models.SHost) int {
|
||||
func (driver *SBaseHostDriver) RequestDeallocateBackupDiskOnHost(ctx context.Context, host *models.SHost, storage *models.SStorage, disk *models.SDisk, task taskman.ITask) error {
|
||||
return fmt.Errorf("Not Implement")
|
||||
}
|
||||
|
||||
func (driver *SBaseHostDriver) RequestSyncOnHost(ctx context.Context, host *models.SHost, task taskman.ITask) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/cmdline"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/baremetal"
|
||||
@@ -589,3 +590,26 @@ func (self *SKVMHostDriver) tryCleanKubernetesData(host *models.SHost, hostname
|
||||
}
|
||||
return cli.Nodes().Delete(context.Background(), hostname, metav1.DeleteOptions{})
|
||||
}
|
||||
|
||||
func (self *SKVMHostDriver) RequestSyncOnHost(ctx context.Context, host *models.SHost, task taskman.ITask) error {
|
||||
log.Infof("Deallocating disk on host %s", host.GetName())
|
||||
header := mcclient.GetTokenHeaders(task.GetUserCred())
|
||||
url := fmt.Sprintf("/hosts/%s/sync", host.Id)
|
||||
body := jsonutils.NewDict()
|
||||
desc := self.GetJsonFromHost(ctx, host)
|
||||
body.Add(desc, "desc")
|
||||
_, err := host.Request(ctx, task.GetUserCred(), "POST", url, header, body)
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SKVMHostDriver) GetJsonFromHost(ctx context.Context, host *models.SHost) *jsonutils.JSONDict {
|
||||
desc := jsonutils.NewDict()
|
||||
desc.Add(jsonutils.NewString(host.Name), "name")
|
||||
// tenant
|
||||
domainFetcher, _ := db.DefaultDomainFetcher(ctx, host.DomainId)
|
||||
if domainFetcher != nil {
|
||||
desc.Add(jsonutils.NewString(domainFetcher.GetProjectDomainId()), "domain_id")
|
||||
desc.Add(jsonutils.NewString(domainFetcher.GetProjectDomain()), "project_domain")
|
||||
}
|
||||
return desc
|
||||
}
|
||||
|
||||
@@ -1378,8 +1378,10 @@ func (self *SCloudaccount) PerformUpdateCredential(ctx context.Context, userCred
|
||||
if err != nil {
|
||||
return nil, httperrors.NewInputParameterError("invalid cloud account info error: %s", err.Error())
|
||||
}
|
||||
|
||||
isEqual := providerDriver.GetAccountIdEqualizer()
|
||||
// for backward compatibility
|
||||
if len(self.AccountId) > 0 && accountId != self.AccountId {
|
||||
if !isEqual(self.AccountId, accountId) {
|
||||
return nil, httperrors.NewConflictError("inconsistent account_id, previous '%s' and now '%s'", self.AccountId, accountId)
|
||||
}
|
||||
|
||||
|
||||
@@ -1731,7 +1731,9 @@ 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_ARM
|
||||
diskConfig.OsArch = apis.OS_ARCH_AARCH64
|
||||
} else {
|
||||
diskConfig.OsArch = image.Properties["os_arch"]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -197,7 +197,7 @@ func (self *SGuest) PerformSaveImage(ctx context.Context, userCred mcclient.Toke
|
||||
osType = "Linux"
|
||||
}
|
||||
properties.Add(jsonutils.NewString(osType), "os_type")
|
||||
if self.OsArch == api.OS_ARCH_ARM {
|
||||
if apis.IsARM(self.OsArch) {
|
||||
var osArch string
|
||||
if osArch = self.GetMetadata("os_arch", nil); len(osArch) == 0 {
|
||||
host := self.GetHost()
|
||||
@@ -272,7 +272,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_ARM {
|
||||
if apis.IsARM(self.OsArch) {
|
||||
var osArch string
|
||||
if osArch = self.GetMetadata("os_arch", nil); len(osArch) == 0 {
|
||||
host := self.GetHost()
|
||||
@@ -729,10 +729,11 @@ func (self *SGuest) PerformAttachdisk(ctx context.Context, userCred mcclient.Tok
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (self *SGuest) StartSyncTask(ctx context.Context, userCred mcclient.TokenCredential, fwOnly bool, parentTaskId string) error {
|
||||
func (self *SGuest) StartSyncTask(ctx context.Context, userCred mcclient.TokenCredential, firewallOnly bool,
|
||||
parentTaskId string) error {
|
||||
|
||||
data := jsonutils.NewDict()
|
||||
if fwOnly {
|
||||
if firewallOnly {
|
||||
data.Add(jsonutils.JSONTrue, "fw_only")
|
||||
} else if err := self.SetStatus(userCred, api.VM_SYNC_CONFIG, ""); err != nil {
|
||||
log.Errorln(err)
|
||||
@@ -2899,14 +2900,11 @@ func (self *SGuest) PerformAssociateEip(ctx context.Context, userCred mcclient.T
|
||||
return nil, err
|
||||
}
|
||||
|
||||
eip, err := self.GetEipOrPublicIp()
|
||||
err = self.IsEipAssociable()
|
||||
if err != nil {
|
||||
log.Errorf("Fail to get Eip %s", err)
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
if eip != nil {
|
||||
return nil, httperrors.NewInvalidStatusError("already associate with eip")
|
||||
}
|
||||
|
||||
eipStr := input.EipId
|
||||
if len(eipStr) == 0 {
|
||||
return nil, httperrors.NewMissingParameterError("eip_id")
|
||||
@@ -2920,7 +2918,7 @@ func (self *SGuest) PerformAssociateEip(ctx context.Context, userCred mcclient.T
|
||||
}
|
||||
}
|
||||
|
||||
eip = eipObj.(*SElasticip)
|
||||
eip := eipObj.(*SElasticip)
|
||||
eipRegion := eip.GetRegion()
|
||||
instRegion := self.getRegion()
|
||||
|
||||
@@ -4353,7 +4351,15 @@ func (guest *SGuest) PerformChangeOwner(ctx context.Context, userCred mcclient.T
|
||||
return nil, errors.Wrapf(err, "unable to change owner for instance snapshot %s", isps[i].GetId())
|
||||
}
|
||||
}
|
||||
return guest.SVirtualResourceBase.PerformChangeOwner(ctx, userCred, query, input)
|
||||
changOwner, err := guest.SVirtualResourceBase.PerformChangeOwner(ctx, userCred, query, input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = guest.StartSyncTask(ctx, userCred, false, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "PerformChangeOwner StartSyncTask err")
|
||||
}
|
||||
return changOwner, nil
|
||||
}
|
||||
|
||||
func (guest *SGuest) AllowPerformResizeDisk(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
|
||||
@@ -199,7 +199,7 @@ func (gtm *SGuestTemplateManager) validateContent(ctx context.Context, userCred
|
||||
}
|
||||
// check Image
|
||||
imageId := input.Disks[0].ImageId
|
||||
image, err := CachedimageManager.getImageInfo(ctx, userCred, imageId, true)
|
||||
image, err := CachedimageManager.getImageInfo(ctx, userCred, imageId, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "getImageInfo of '%s'", imageId)
|
||||
}
|
||||
|
||||
@@ -1214,7 +1214,7 @@ func (manager *SGuestManager) validateCreateData(
|
||||
}
|
||||
|
||||
if arch := imgProperties["os_arch"]; strings.Contains(arch, "aarch") {
|
||||
input.OsArch = api.OS_ARCH_ARM
|
||||
input.OsArch = apis.OS_ARCH_AARCH64
|
||||
}
|
||||
|
||||
if len(imgProperties) == 0 {
|
||||
@@ -4879,6 +4879,28 @@ func (self *SGuest) isInReconcile(userCred mcclient.TokenCredential) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SGuest) IsEipAssociable() error {
|
||||
var eip *SElasticip
|
||||
var err error
|
||||
switch self.Hypervisor {
|
||||
case api.HYPERVISOR_AWS:
|
||||
eip, err = self.GetElasticIp()
|
||||
default:
|
||||
eip, err = self.GetEipOrPublicIp()
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("Fail to get Eip %s", err)
|
||||
return errors.Wrap(err, "IsEipAssociable")
|
||||
}
|
||||
|
||||
if eip != nil {
|
||||
return httperrors.NewInvalidStatusError("already associate with eip")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SGuest) GetEipOrPublicIp() (*SElasticip, error) {
|
||||
return ElasticipManager.getEip(api.EIP_ASSOCIATE_TYPE_SERVER, self.Id, "")
|
||||
}
|
||||
@@ -4894,10 +4916,16 @@ func (self *SGuest) GetPublicIp() (*SElasticip, error) {
|
||||
func (self *SGuest) SyncVMEip(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, extEip cloudprovider.ICloudEIP, syncOwnerId mcclient.IIdentityProvider) compare.SyncResult {
|
||||
result := compare.SyncResult{}
|
||||
|
||||
eip, err := self.GetEipOrPublicIp()
|
||||
eip, err := self.GetPublicIp()
|
||||
if err != nil {
|
||||
result.Error(fmt.Errorf("getEip error %s", err))
|
||||
result.Error(fmt.Errorf("getPublicIp error %s", err))
|
||||
return result
|
||||
} else if eip == nil {
|
||||
eip, err = self.GetElasticIp()
|
||||
if err != nil {
|
||||
result.Error(fmt.Errorf("getEip error %s", err))
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
if eip == nil && extEip == nil {
|
||||
|
||||
@@ -62,6 +62,7 @@ type IHostDriver interface {
|
||||
ValidateAttachStorage(ctx context.Context, userCred mcclient.TokenCredential, host *SHost, storage *SStorage, data *jsonutils.JSONDict) error
|
||||
RequestAttachStorage(ctx context.Context, hoststorage *SHoststorage, host *SHost, storage *SStorage, task taskman.ITask) error
|
||||
RequestDetachStorage(ctx context.Context, host *SHost, storage *SStorage, task taskman.ITask) error
|
||||
RequestSyncOnHost(ctx context.Context, host *SHost, task taskman.ITask) error
|
||||
}
|
||||
|
||||
var hostDrivers map[string]IHostDriver
|
||||
|
||||
@@ -540,7 +540,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 {
|
||||
@@ -3971,7 +3971,7 @@ func (self *SHost) AllowPerformIpmiProbe(ctx context.Context,
|
||||
}
|
||||
|
||||
func (self *SHost) PerformIpmiProbe(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if utils.IsInStringArray(self.Status, []string{api.BAREMETAL_INIT, api.BAREMETAL_READY, api.BAREMETAL_RUNNING, api.BAREMETAL_PROBE_FAIL}) {
|
||||
if utils.IsInStringArray(self.Status, []string{api.BAREMETAL_INIT, api.BAREMETAL_READY, api.BAREMETAL_RUNNING, api.BAREMETAL_PROBE_FAIL, api.BAREMETAL_UNKNOWN}) {
|
||||
return nil, self.StartIpmiProbeTask(ctx, userCred, "")
|
||||
}
|
||||
return nil, httperrors.NewInvalidStatusError("Cannot do Ipmi-probe in status %s", self.Status)
|
||||
@@ -5634,10 +5634,24 @@ func (host *SHost) PerformChangeOwner(ctx context.Context, userCred mcclient.Tok
|
||||
return nil, errors.Wrap(err, "local storage change owner")
|
||||
}
|
||||
}
|
||||
|
||||
err = host.StartSyncTask(ctx, userCred, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "PerformChangeOwner StartSyncTask err")
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SHost) StartSyncTask(ctx context.Context, userCred mcclient.TokenCredential, parentTaskId string) error {
|
||||
if task, err := taskman.TaskManager.NewTask(ctx, "HostSyncTask", self, userCred, jsonutils.NewDict(), parentTaskId, "",
|
||||
nil); err != nil {
|
||||
log.Errorln(err)
|
||||
return err
|
||||
} else {
|
||||
task.ScheduleRun(nil)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (host *SHost) GetChangeOwnerRequiredDomainIds() []string {
|
||||
requires := stringutils2.SSortedStrings{}
|
||||
guests, _ := host.GetGuests()
|
||||
|
||||
@@ -31,11 +31,10 @@ func (man *SI18nResourceBaseManager) SyncI18ns(ctx context.Context, userCred mcc
|
||||
itable := man.getSModelI18nTable(model, table)
|
||||
_, _, r := db.I18nManager.SyncI18ns(ctx, userCred, model, itable)
|
||||
if r.IsError() {
|
||||
log.Infof("SyncI18ns for %s %s result: %s", model.Keyword(), model.GetId(), r.Result())
|
||||
log.Errorf("SyncI18ns for %s %s result: %s", model.Keyword(), model.GetId(), r.Result())
|
||||
return errors.Wrap(r.AllError(), "SyncI18ns")
|
||||
}
|
||||
|
||||
log.Debugf("SyncI18ns for %s %s result: %s", model.Keyword(), model.GetId(), r.Result())
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -51,7 +50,7 @@ func (self *SI18nResourceBase) RemoveI18ns(ctx context.Context, userCred mcclien
|
||||
func (self *SI18nResourceBase) GetModelI18N(ctx context.Context, model db.IModel) *jsonutils.JSONDict {
|
||||
entries, err := db.I18nManager.GetModelI18N(ctx, model)
|
||||
if err != nil {
|
||||
log.Infof("GetI18N %s", err)
|
||||
log.Errorf("GetModelI18N error %s", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -66,7 +65,7 @@ func (self *SI18nResourceBase) GetModelI18N(ctx context.Context, model db.IModel
|
||||
func (self *SI18nResourceBase) GetModelKeyI18N(ctx context.Context, model db.IModel, keyName string) (string, bool) {
|
||||
entries, err := db.I18nManager.GetModelKeyI18N(ctx, model, keyName)
|
||||
if err != nil {
|
||||
log.Infof("GetModelKeyI18N %s", err)
|
||||
log.Errorf("GetModelKeyI18N error %s", err)
|
||||
return "", false
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@ func (guest *SGuest) purge(ctx context.Context, userCred mcclient.TokenCredentia
|
||||
guest.DetachAllNetworks(ctx, userCred)
|
||||
guest.EjectIso(userCred)
|
||||
guest.DeleteEip(ctx, userCred)
|
||||
guest.purgeInstanceSnapshots(ctx, userCred)
|
||||
guest.DeleteAllDisksInDB(ctx, userCred)
|
||||
if !utils.IsInStringArray(guest.Hypervisor, HypervisorIndependentInstanceSnapshot) {
|
||||
guest.DeleteAllInstanceSnapshotInDB(ctx, userCred)
|
||||
@@ -138,6 +139,30 @@ func (guest *SGuest) purge(ctx context.Context, userCred mcclient.TokenCredentia
|
||||
return guest.RealDelete(ctx, userCred)
|
||||
}
|
||||
|
||||
func (guest *SGuest) purgeInstanceSnapshots(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
lockman.LockObject(ctx, guest)
|
||||
defer lockman.ReleaseObject(ctx, guest)
|
||||
|
||||
iss, err := guest.GetInstanceSnapshots()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unable to GetInstanceSnapshots")
|
||||
}
|
||||
for i := range iss {
|
||||
err := iss[i].purge(ctx, userCred)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "unable to purge InstanceSnapshot %s", iss[i].Id)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (is *SInstanceSnapshot) purge(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
lockman.LockObject(ctx, is)
|
||||
defer lockman.ReleaseObject(ctx, is)
|
||||
|
||||
return is.RealDelete(ctx, userCred)
|
||||
}
|
||||
|
||||
func (storage *SStorage) purgeDisks(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
lockman.LockObject(ctx, storage)
|
||||
defer lockman.ReleaseObject(ctx, storage)
|
||||
|
||||
@@ -1093,6 +1093,7 @@ func (self *SServerSku) SyncWithPrivateCloudSku(ctx context.Context, userCred mc
|
||||
}
|
||||
|
||||
func (self *SServerSku) constructSku(extSku cloudprovider.ICloudSku) {
|
||||
self.ExternalId = extSku.GetGlobalId()
|
||||
self.InstanceTypeFamily = extSku.GetInstanceTypeFamily()
|
||||
self.InstanceTypeCategory = extSku.GetInstanceTypeCategory()
|
||||
|
||||
|
||||
@@ -136,8 +136,6 @@ type ComputeOptions struct {
|
||||
EnableHostHealthCheck bool `help:"enable host health check" default:"true"`
|
||||
HostHealthTimeout int `help:"second of wait host reconnect" default:"60"`
|
||||
|
||||
FetchEtcdServiceInfoAndUseEtcdLock bool `default:"true" help:"fetch etcd service info and use etcd lock"`
|
||||
|
||||
GuestTemplateCheckInterval int `help:"interval between two consecutive inspections of Guest Template in hour unit" default:"12"`
|
||||
|
||||
ScheduledTaskQueueSize int `help:"the maximum number of scheduled tasks that are being executed simultaneously" default:"100"`
|
||||
|
||||
@@ -70,11 +70,9 @@ func StartService() {
|
||||
log.Fatalf("unable to init esxi configs: %v", err)
|
||||
}
|
||||
|
||||
if opts.FetchEtcdServiceInfoAndUseEtcdLock {
|
||||
err := initEtcdLockOpts(opts)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
// always try to init etcd options
|
||||
if err := initEtcdLockOpts(opts); err != nil {
|
||||
log.Errorf("try to init etcd options error: %v", err)
|
||||
}
|
||||
|
||||
app := app_common.InitApp(baseOpts, true)
|
||||
@@ -174,13 +172,23 @@ func initDefaultEtcdClient(opts *common_options.DBOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
onKeepaliveFailure := func() {
|
||||
cli := etcd.Default()
|
||||
if opts.LockmanMethod == common_options.LockMethodEtcd {
|
||||
log.Fatalf("etcd keepalive failed and exit when lockman_method is %s", common_options.LockMethodEtcd)
|
||||
}
|
||||
if err := cli.RestartSession(); err != nil {
|
||||
log.Errorf("restart default session error: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
err = etcd.InitDefaultEtcdClient(&etcd.SEtcdOptions{
|
||||
EtcdEndpoint: opts.EtcdEndpoints,
|
||||
EtcdUsername: opts.EtcdUsername,
|
||||
EtcdPassword: opts.EtcdPassword,
|
||||
EtcdEnabldSsl: opts.EtcdUseTLS,
|
||||
TLSConfig: tlsConfig,
|
||||
}, nil)
|
||||
}, onKeepaliveFailure)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "init default etcd client")
|
||||
}
|
||||
@@ -197,7 +205,6 @@ func initEtcdLockOpts(opts *options.ComputeOptions) error {
|
||||
}
|
||||
if etcdEndpoint != nil {
|
||||
opts.EtcdEndpoints = []string{etcdEndpoint.Url}
|
||||
opts.LockmanMethod = common_options.LockMethodEtcd
|
||||
if len(etcdEndpoint.CertId) > 0 {
|
||||
dir, err := ioutil.TempDir("", "etcd-cluster-tls")
|
||||
if err != nil {
|
||||
|
||||
29
pkg/compute/tasks/host_sync_task.go
Normal file
29
pkg/compute/tasks/host_sync_task.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
)
|
||||
|
||||
type HostSyncTask struct {
|
||||
taskman.STask
|
||||
}
|
||||
|
||||
func init() {
|
||||
taskman.RegisterTask(HostSyncTask{})
|
||||
}
|
||||
|
||||
func (self *HostSyncTask) OnInit(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
host := obj.(*models.SHost)
|
||||
err := host.GetHostDriver().RequestSyncOnHost(ctx, host, self)
|
||||
if err != nil {
|
||||
self.SetStageFailed(ctx, jsonutils.NewString(err.Error()))
|
||||
log.Errorf("syncHost:%s err:%v", host.GetId(), err)
|
||||
}
|
||||
}
|
||||
@@ -359,7 +359,7 @@ func FormatPartition(path, fs, uuid string) error {
|
||||
cmd = []string{"mkfs.ext3"}
|
||||
cmdUuid = []string{"tune2fs", "-U", uuid}
|
||||
case fs == "ext4":
|
||||
cmd = []string{"mkfs.ext4", "-O", "^64bit", "-E", "lazy_itable_init=1"}
|
||||
cmd = []string{"mkfs.ext4", "-O", "^64bit", "-E", "lazy_itable_init=1", "-T", "largefile"}
|
||||
cmdUuid = []string{"tune2fs", "-U", uuid}
|
||||
case fs == "ext4dev":
|
||||
cmd = []string{"mkfs.ext4dev", "-E", "lazy_itable_init=1"}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,17 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/hostman/host_health"
|
||||
"yunion.io/x/onecloud/pkg/hostman/hostinfo"
|
||||
"yunion.io/x/onecloud/pkg/hostman/hostutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
)
|
||||
|
||||
type actionFunc func(context.Context, string, jsonutils.JSONObject) (interface{}, error)
|
||||
|
||||
var (
|
||||
keyWords = []string{"hosts"}
|
||||
)
|
||||
@@ -33,6 +38,15 @@ func AddHostHandler(prefix string, app *appsrv.Application) {
|
||||
for _, keyword := range keyWords {
|
||||
app.AddHandler("POST", fmt.Sprintf("%s/%s/shutdown-servers-on-host-down", prefix, keyword),
|
||||
auth.Authenticate(setOnHostDown))
|
||||
|
||||
for action, f := range map[string]actionFunc{
|
||||
"sync": hostSync,
|
||||
} {
|
||||
app.AddHandler("POST",
|
||||
fmt.Sprintf("%s/%s/<sid>/%s", prefix, keyword, action),
|
||||
auth.Authenticate(hostActions(f)),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,3 +57,25 @@ func setOnHostDown(ctx context.Context, w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
hostutils.ResponseOk(ctx, w)
|
||||
}
|
||||
|
||||
func hostActions(f actionFunc) appsrv.FilterHandler {
|
||||
return func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
|
||||
params, _, body := appsrv.FetchEnv(ctx, w, r)
|
||||
if body == nil {
|
||||
body = jsonutils.NewDict()
|
||||
}
|
||||
var sid = params["<sid>"]
|
||||
res, err := f(ctx, sid, body)
|
||||
if err != nil {
|
||||
hostutils.Response(ctx, w, err)
|
||||
} else if res != nil {
|
||||
hostutils.Response(ctx, w, res)
|
||||
} else {
|
||||
hostutils.ResponseOk(ctx, w)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func hostSync(ctx context.Context, sid string, body jsonutils.JSONObject) (interface{}, error) {
|
||||
return hostinfo.Instance().UpdateSyncInfo(sid, body)
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
@@ -714,7 +715,7 @@ func (h *SHostInfo) detectOvsKOVersion() error {
|
||||
lines := strings.Split(string(output), "\n")
|
||||
for i := 0; i < len(lines); i++ {
|
||||
line := lines[i]
|
||||
if strings.HasPrefix(line, "version:") || (h.IsAarch64() && strings.HasPrefix(line, "vermagic")) {
|
||||
if strings.HasPrefix(line, "version:") || strings.HasPrefix(line, "vermagic") {
|
||||
log.Infof("kernel module openvswitch %s", line)
|
||||
return nil
|
||||
}
|
||||
@@ -930,6 +931,25 @@ func (h *SHostInfo) getDomainInfo(hostId string) {
|
||||
h.Project_domain = strings.ReplaceAll(project_domain, " ", "+")
|
||||
}
|
||||
|
||||
func (h *SHostInfo) UpdateSyncInfo(hostId string, body jsonutils.JSONObject) (interface{}, error) {
|
||||
if h.GetHostId() != hostId {
|
||||
return nil, nil
|
||||
}
|
||||
descObj, err := body.Get("desc")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
domainId, _ := descObj.GetString("domain_id")
|
||||
projectDomain, _ := descObj.GetString("project_domain")
|
||||
if len(domainId) != 0 {
|
||||
h.Domain_id = domainId
|
||||
}
|
||||
if len(projectDomain) != 0 {
|
||||
h.Project_domain = strings.ReplaceAll(projectDomain, " ", "+")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (h *SHostInfo) setHostname(name string) {
|
||||
h.FullName = name
|
||||
err := sysutils.SetHostname(name)
|
||||
@@ -1723,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"
|
||||
@@ -559,7 +558,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_ARM
|
||||
self.OsArch = apis.OS_ARCH_AARCH64
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ func (manager *SAssignmentManager) FetchAll(
|
||||
grpproj.Field("project_id"),
|
||||
grpproj.Field("role_id"),
|
||||
)
|
||||
q2 = q2.Join(memberships, sqlchemy.Equals(grpproj.Field("group_id"), memberships.Field("group_id")))
|
||||
q2 = q2.LeftJoin(memberships, sqlchemy.Equals(grpproj.Field("group_id"), memberships.Field("group_id")))
|
||||
if len(userId) > 0 {
|
||||
q2 = q2.Filter(sqlchemy.Equals(memberships.Field("user_id"), userId))
|
||||
}
|
||||
|
||||
@@ -78,10 +78,12 @@ type SLoadbalancer struct {
|
||||
MasterZoneId string //实例的主可用区ID。
|
||||
SlaveZoneId string //实例的备可用区ID。
|
||||
InternetChargeType TInternetChargeType //公网实例的计费方式。取值:paybybandwidth:按带宽计费 paybytraffic:按流量计费(默认值) 说明 当 PayType参数的值为PrePay时,只支持按带宽计费。
|
||||
PayType string //实例的计费类型,取值:PayOnDemand:按量付费 PrePay:预付费
|
||||
ResourceGroupId string //企业资源组ID。
|
||||
LoadBalancerSpec string //负载均衡实例的的性能规格
|
||||
Bandwidth int //按带宽计费的公网型实例的带宽峰值
|
||||
InternetChargeTypeAlias TInternetChargeType
|
||||
|
||||
PayType string //实例的计费类型,取值:PayOnDemand:按量付费 PrePay:预付费
|
||||
ResourceGroupId string //企业资源组ID。
|
||||
LoadBalancerSpec string //负载均衡实例的的性能规格
|
||||
Bandwidth int //按带宽计费的公网型实例的带宽峰值
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetName() string {
|
||||
@@ -270,13 +272,18 @@ func (lb *SLoadbalancer) GetLoadbalancerSpec() string {
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetChargeType() string {
|
||||
switch lb.InternetChargeType {
|
||||
chargeType := lb.InternetChargeType
|
||||
if len(lb.InternetChargeTypeAlias) > 0 {
|
||||
chargeType = lb.InternetChargeTypeAlias
|
||||
}
|
||||
switch chargeType {
|
||||
case "paybybandwidth":
|
||||
return api.LB_CHARGE_TYPE_BY_BANDWIDTH
|
||||
case "paybytraffic":
|
||||
return api.LB_CHARGE_TYPE_BY_TRAFFIC
|
||||
default:
|
||||
return string(chargeType)
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetCreatedAt() time.Time {
|
||||
@@ -306,15 +313,20 @@ func (lb *SLoadbalancer) GetILoadBalancerBackendGroupById(groupId string) (cloud
|
||||
func (lb *SLoadbalancer) GetIEIP() (cloudprovider.ICloudEIP, error) {
|
||||
if lb.AddressType == "internet" {
|
||||
eip := SEipAddress{
|
||||
region: lb.region,
|
||||
IpAddress: lb.Address,
|
||||
InstanceId: lb.GetGlobalId(),
|
||||
InstanceType: EIP_INTANNCE_TYPE_SLB,
|
||||
Status: EIP_STATUS_INUSE,
|
||||
AllocationId: lb.GetGlobalId(),
|
||||
AllocationTime: lb.CreateTime,
|
||||
Bandwidth: lb.Bandwidth,
|
||||
InternetChargeType: lb.InternetChargeType,
|
||||
region: lb.region,
|
||||
IpAddress: lb.Address,
|
||||
InstanceId: lb.GetGlobalId(),
|
||||
InstanceType: EIP_INTANNCE_TYPE_SLB,
|
||||
Status: EIP_STATUS_INUSE,
|
||||
AllocationId: lb.GetGlobalId(),
|
||||
AllocationTime: lb.CreateTime,
|
||||
Bandwidth: lb.Bandwidth,
|
||||
}
|
||||
switch lb.GetChargeType() {
|
||||
case api.LB_CHARGE_TYPE_BY_BANDWIDTH:
|
||||
eip.InternetChargeType = InternetChargeByBandwidth
|
||||
case api.LB_CHARGE_TYPE_BY_TRAFFIC:
|
||||
eip.InternetChargeType = InternetChargeByTraffic
|
||||
}
|
||||
return &eip, nil
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ func (self *SInstanceType) GetAttachedDiskSizeGB() int {
|
||||
}
|
||||
|
||||
func (self *SInstanceType) GetAttachedDiskCount() int {
|
||||
return 6
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *SInstanceType) GetDataDiskTypes() string {
|
||||
|
||||
@@ -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"
|
||||
@@ -180,8 +181,8 @@ func (self *SImage) GetOsType() string {
|
||||
}
|
||||
|
||||
func (self *SImage) GetOsArch() string {
|
||||
if self.ImageType == cloudprovider.CachedImageTypeCustomized {
|
||||
return "x86_64"
|
||||
if self.GetImageType() == cloudprovider.CachedImageTypeCustomized {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -810,7 +810,8 @@ func (self *SHost) addDisks(ctx context.Context, dc *SDatacenter, ds *SDatastore
|
||||
size = 30 * 1024
|
||||
}
|
||||
} else {
|
||||
imagePath, err := self.FileUrlPathToDsPath(imagePath)
|
||||
var err error
|
||||
imagePath, err = self.FileUrlPathToDsPath(imagePath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "SHost.FileUrlPathToDsPath")
|
||||
}
|
||||
|
||||
@@ -143,6 +143,24 @@ func (self *SESXiProviderFactory) GetClientRC(info cloudprovider.SProviderInfo)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SESXiProviderFactory) GetAccountIdEqualizer() func(origin, now string) bool {
|
||||
return func(origin, now string) bool {
|
||||
if len(now) == 0 {
|
||||
return true
|
||||
}
|
||||
originUserName, nowUserName := origin, now
|
||||
index1 := strings.Index(origin, "@")
|
||||
index2 := strings.Index(now, "@")
|
||||
if index1 != -1 {
|
||||
originUserName = originUserName[:index1]
|
||||
}
|
||||
if index2 != -1 {
|
||||
nowUserName = nowUserName[:index2]
|
||||
}
|
||||
return originUserName == nowUserName
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
factory := SESXiProviderFactory{}
|
||||
cloudprovider.RegisterFactory(&factory)
|
||||
|
||||
@@ -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"
|
||||
@@ -417,9 +418,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)
|
||||
|
||||
@@ -196,11 +196,11 @@ func (flavor *SFlavor) GetGlobalId() string {
|
||||
}
|
||||
|
||||
func (flavor *SFlavor) GetInstanceTypeFamily() string {
|
||||
return flavor.GetName()
|
||||
return api.InstanceFamilies[api.SkuCategoryGeneralPurpose]
|
||||
}
|
||||
|
||||
func (flavor *SFlavor) GetInstanceTypeCategory() string {
|
||||
return flavor.GetName()
|
||||
return api.SkuCategoryGeneralPurpose
|
||||
}
|
||||
|
||||
func (flavor *SFlavor) GetPrepaidStatus() string {
|
||||
@@ -248,7 +248,7 @@ func (flavor *SFlavor) GetAttachedDiskSizeGB() int {
|
||||
}
|
||||
|
||||
func (flavor *SFlavor) GetAttachedDiskCount() int {
|
||||
return 6
|
||||
return 0
|
||||
}
|
||||
|
||||
func (flavor *SFlavor) GetDataDiskTypes() string {
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/util/osprofile"
|
||||
|
||||
"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"
|
||||
@@ -243,7 +244,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"
|
||||
@@ -311,7 +312,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) {
|
||||
@@ -329,7 +330,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: "-",
|
||||
},
|
||||
|
||||
@@ -158,11 +158,11 @@ func (region *SRegion) DeleteOffering(offeringId string) error {
|
||||
}
|
||||
|
||||
func (offering *SInstanceOffering) GetInstanceTypeFamily() string {
|
||||
return offering.AllocatorStrategy
|
||||
return api.InstanceFamilies[api.SkuCategoryGeneralPurpose]
|
||||
}
|
||||
|
||||
func (offering *SInstanceOffering) GetInstanceTypeCategory() string {
|
||||
return offering.AllocatorStrategy
|
||||
return api.SkuCategoryGeneralPurpose
|
||||
}
|
||||
|
||||
func (offering *SInstanceOffering) GetPrepaidStatus() string {
|
||||
@@ -210,7 +210,7 @@ func (offering *SInstanceOffering) GetAttachedDiskSizeGB() int {
|
||||
}
|
||||
|
||||
func (offering *SInstanceOffering) GetAttachedDiskCount() int {
|
||||
return 6
|
||||
return 0
|
||||
}
|
||||
|
||||
func (offering *SInstanceOffering) GetDataDiskTypes() string {
|
||||
@@ -218,7 +218,7 @@ func (offering *SInstanceOffering) GetDataDiskTypes() string {
|
||||
}
|
||||
|
||||
func (offering *SInstanceOffering) GetDataDiskMaxCount() int {
|
||||
return 6
|
||||
return 0
|
||||
}
|
||||
|
||||
func (offering *SInstanceOffering) GetNicType() string {
|
||||
|
||||
@@ -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_ARM {
|
||||
if apis.IsARM(d.OsArch) {
|
||||
host := getter.Host()
|
||||
if !host.IsArmHost() {
|
||||
h.Exclude(predicates.ErrHostCpuArchitectureNotMatch)
|
||||
|
||||
@@ -14,22 +14,31 @@
|
||||
|
||||
package imagetools
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
)
|
||||
|
||||
func normalizeOsArch(osArch string, osType string, osDist string) string {
|
||||
if len(osArch) > 0 {
|
||||
if strings.ToLower(osArch) == "x86_64" {
|
||||
return "x86_64"
|
||||
} else {
|
||||
return "i386"
|
||||
switch strings.ToLower(osArch) {
|
||||
case "x86_64", "64":
|
||||
return apis.OS_ARCH_X86_64
|
||||
case "x86", "x86_32", "32":
|
||||
return apis.OS_ARCH_X86
|
||||
case "arm", "arm64", "aarch", "aarch64":
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,11 @@ func ruleToAcl(lport string, rule *agentmodels.SecurityGroupRule) (*ovn_nb.ACL,
|
||||
|
||||
matches = append(matches, l4proto)
|
||||
if len(portMatches) > 0 {
|
||||
matches = append(matches, strings.Join(portMatches, " || "))
|
||||
portMatch := strings.Join(portMatches, " || ")
|
||||
if len(portMatches) > 1 {
|
||||
portMatch = "( " + portMatch + " )"
|
||||
}
|
||||
matches = append(matches, portMatch)
|
||||
}
|
||||
}
|
||||
switch rule.Protocol {
|
||||
|
||||
Reference in New Issue
Block a user