From b8b0d3dba53551d74a0745f39205d88e9dc4a030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Thu, 13 Jun 2024 20:32:21 +0800 Subject: [PATCH] fix(region): support sangfor (#20524) --- go.mod | 2 +- go.sum | 4 +- pkg/apis/compute/cloudaccount_const.go | 7 +- pkg/apis/compute/guest_const.go | 2 + pkg/apis/compute/host_const.go | 2 + pkg/compute/guestdrivers/sangfor.go | 237 ++++++++++++++++++ pkg/compute/hostdrivers/managedvirtual.go | 6 +- pkg/compute/hostdrivers/sangfor.go | 41 +++ pkg/compute/models/guest_actions.go | 8 +- pkg/compute/regiondrivers/sangfor.go | 41 +++ pkg/compute/tasks/guest_create_disk_task.go | 5 + pkg/mcclient/options/base.go | 2 +- pkg/mcclient/options/compute/servers.go | 4 +- vendor/modules.txt | 2 +- .../pkg/apis/compute/cloudaccount_const.go | 1 + .../cloudmux/pkg/apis/compute/guest_const.go | 1 + .../x/cloudmux/pkg/apis/compute/host_const.go | 1 + 17 files changed, 354 insertions(+), 12 deletions(-) create mode 100644 pkg/compute/guestdrivers/sangfor.go create mode 100644 pkg/compute/hostdrivers/sangfor.go create mode 100644 pkg/compute/regiondrivers/sangfor.go diff --git a/go.mod b/go.mod index 8e82253e10b..ba2d87c27bc 100644 --- a/go.mod +++ b/go.mod @@ -94,7 +94,7 @@ require ( k8s.io/cri-api v0.22.17 k8s.io/klog/v2 v2.2.0 moul.io/http2curl/v2 v2.3.0 - yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240604034047-e1e06dfdf1f9 + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240611023744-6cfb14a28b9f yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 yunion.io/x/jsonutils v1.0.1-0.20240203102553-4096f103b401 yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91 diff --git a/go.sum b/go.sum index 3cc3952b629..e9e7831bcf6 100644 --- a/go.sum +++ b/go.sum @@ -1309,8 +1309,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240604034047-e1e06dfdf1f9 h1:D5VDFE0Ab9rmBT3/MtO4Dqk1oZxLxS90Io3ToC915q8= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240604034047-e1e06dfdf1f9/go.mod h1:quoJjGTJ2PjAY0+3YeN5JuN136whECKmfkJQwIsXKjM= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240611023744-6cfb14a28b9f h1:JpZpsVjbP+8VlLKBPSfDKUBDxZrCA3Lmwm1iWq1jmbY= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240611023744-6cfb14a28b9f/go.mod h1:quoJjGTJ2PjAY0+3YeN5JuN136whECKmfkJQwIsXKjM= yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug= yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws= yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634= diff --git a/pkg/apis/compute/cloudaccount_const.go b/pkg/apis/compute/cloudaccount_const.go index 49323094534..cb4e6ca817b 100644 --- a/pkg/apis/compute/cloudaccount_const.go +++ b/pkg/apis/compute/cloudaccount_const.go @@ -71,6 +71,7 @@ const ( CLOUD_PROVIDER_CUCLOUD = compute.CLOUD_PROVIDER_CUCLOUD CLOUD_PROVIDER_QINGCLOUD = compute.CLOUD_PROVIDER_QINGCLOUD CLOUD_PROVIDER_ORACLE = compute.CLOUD_PROVIDER_ORACLE + CLOUD_PROVIDER_SANGFOR = compute.CLOUD_PROVIDER_SANGFOR CLOUD_PROVIDER_GENERICS3 = compute.CLOUD_PROVIDER_GENERICS3 CLOUD_PROVIDER_CEPH = compute.CLOUD_PROVIDER_CEPH @@ -117,7 +118,7 @@ var ( PRIVATE_CLOUD_PROVIDERS = []string{CLOUD_PROVIDER_ZSTACK, CLOUD_PROVIDER_OPENSTACK, CLOUD_PROVIDER_APSARA, CLOUD_PROVIDER_HCSO, CLOUD_PROVIDER_HCS, CLOUD_PROVIDER_HCSOP, CLOUD_PROVIDER_INCLOUD_SPHERE, CLOUD_PROVIDER_PROXMOX, CLOUD_PROVIDER_REMOTEFILE, - CLOUD_PROVIDER_H3C, + CLOUD_PROVIDER_H3C, CLOUD_PROVIDER_SANGFOR, } PUBLIC_CLOUD_PROVIDERS = []string{ CLOUD_PROVIDER_ALIYUN, @@ -170,6 +171,7 @@ var ( CLOUD_PROVIDER_CUCLOUD, CLOUD_PROVIDER_QINGCLOUD, CLOUD_PROVIDER_ORACLE, + CLOUD_PROVIDER_SANGFOR, } CLOUD_PROVIDER_HOST_TYPE_MAP = map[string][]string{ @@ -268,6 +270,9 @@ var ( CLOUD_PROVIDER_ORACLE: { HOST_TYPE_ORACLE, }, + CLOUD_PROVIDER_SANGFOR: { + HOST_TYPE_SANGFOR, + }, } ) diff --git a/pkg/apis/compute/guest_const.go b/pkg/apis/compute/guest_const.go index 6f791e5dc14..e36642637b8 100644 --- a/pkg/apis/compute/guest_const.go +++ b/pkg/apis/compute/guest_const.go @@ -216,6 +216,7 @@ const ( HYPERVISOR_CUCLOUD = compute.HYPERVISOR_CUCLOUD HYPERVISOR_QINGCLOUD = compute.HYPERVISOR_QINGCLOUD HYPERVISOR_ORACLE = compute.HYPERVISOR_ORACLE + HYPERVISOR_SANGFOR = compute.HYPERVISOR_SANGFOR // HYPERVISOR_DEFAULT = HYPERVISOR_KVM HYPERVISOR_DEFAULT = HYPERVISOR_KVM @@ -294,6 +295,7 @@ var HYPERVISORS = []string{ HYPERVISOR_CUCLOUD, HYPERVISOR_QINGCLOUD, HYPERVISOR_ORACLE, + HYPERVISOR_SANGFOR, } const ( diff --git a/pkg/apis/compute/host_const.go b/pkg/apis/compute/host_const.go index 7f02c98840e..b6c007bfdb3 100644 --- a/pkg/apis/compute/host_const.go +++ b/pkg/apis/compute/host_const.go @@ -56,6 +56,7 @@ const ( HOST_TYPE_CUCLOUD = compute.HOST_TYPE_CUCLOUD HOST_TYPE_QINGCLOUD = compute.HOST_TYPE_QINGCLOUD HOST_TYPE_ORACLE = compute.HOST_TYPE_ORACLE + HOST_TYPE_SANGFOR = compute.HOST_TYPE_SANGFOR HOST_TYPE_DEFAULT = HOST_TYPE_HYPERVISOR @@ -153,6 +154,7 @@ var HOST_TYPES = []string{ HOST_TYPE_CUCLOUD, HOST_TYPE_QINGCLOUD, HOST_TYPE_ORACLE, + HOST_TYPE_SANGFOR, } var ALL_NIC_TYPES = []compute.TNicType{NIC_TYPE_IPMI, NIC_TYPE_ADMIN, NIC_TYPE_NORMAL} diff --git a/pkg/compute/guestdrivers/sangfor.go b/pkg/compute/guestdrivers/sangfor.go new file mode 100644 index 00000000000..173640583b0 --- /dev/null +++ b/pkg/compute/guestdrivers/sangfor.go @@ -0,0 +1,237 @@ +// 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 guestdrivers + +import ( + "context" + "database/sql" + "fmt" + + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/log" + "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/cloudinit" + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/pkg/utils" + "yunion.io/x/sqlchemy" + + api "yunion.io/x/onecloud/pkg/apis/compute" + "yunion.io/x/onecloud/pkg/cloudcommon/db" + "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" + "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" + "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/onecloud/pkg/mcclient" +) + +type SSangForGuestDriver struct { + SManagedVirtualizedGuestDriver +} + +func init() { + driver := SSangForGuestDriver{} + models.RegisterGuestDriver(&driver) +} + +func (self *SSangForGuestDriver) GetHypervisor() string { + return api.HYPERVISOR_SANGFOR +} + +func (self *SSangForGuestDriver) GetProvider() string { + return api.CLOUD_PROVIDER_SANGFOR +} + +func (self *SSangForGuestDriver) DoScheduleSKUFilter() bool { + return false +} + +func (self *SSangForGuestDriver) DoScheduleStorageFilter() bool { + return false +} + +func (self *SSangForGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { + keys := models.SComputeResourceKeys{} + keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) + keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD + keys.Provider = api.CLOUD_PROVIDER_SANGFOR + keys.Brand = api.CLOUD_PROVIDER_SANGFOR + keys.Hypervisor = api.HYPERVISOR_SANGFOR + return keys +} + +func (self *SSangForGuestDriver) GetDefaultSysDiskBackend() string { + return api.STORAGE_LOCAL +} + +func (self *SSangForGuestDriver) GetMinimalSysDiskSizeGb() int { + return 40 +} + +func (self *SSangForGuestDriver) GetStorageTypes() []string { + storages, _ := models.StorageManager.GetStorageTypesByProvider(self.GetProvider()) + return storages +} + +func (self *SSangForGuestDriver) ChooseHostStorage(host *models.SHost, guest *models.SGuest, diskConfig *api.DiskConfig, storageIds []string) (*models.SStorage, error) { + return chooseHostStorage(self, host, diskConfig.Backend, storageIds), nil +} + +func (self *SSangForGuestDriver) GetDetachDiskStatus() ([]string, error) { + return []string{api.VM_READY, api.VM_RUNNING}, nil +} + +func (self *SSangForGuestDriver) GetAttachDiskStatus() ([]string, error) { + return []string{api.VM_READY, api.VM_RUNNING}, nil +} + +func (self *SSangForGuestDriver) GetRebuildRootStatus() ([]string, error) { + return []string{api.VM_READY, api.VM_RUNNING}, nil +} + +func (self *SSangForGuestDriver) GetChangeConfigStatus(guest *models.SGuest) ([]string, error) { + return []string{api.VM_READY}, nil +} + +func (self *SSangForGuestDriver) GetDeployStatus() ([]string, error) { + return []string{api.VM_READY, api.VM_RUNNING}, nil +} + +func (self *SSangForGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error { + if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY}) { + return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status) + } + return nil +} + +func (self *SSangForGuestDriver) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, input *api.ServerCreateInput) (*api.ServerCreateInput, error) { + if len(input.UserData) > 0 { + _, err := cloudinit.ParseUserData(input.UserData) + if err != nil { + return nil, err + } + } + if len(input.Cdrom) > 0 { + image, err := models.CachedimageManager.GetCachedimageById(ctx, userCred, input.Cdrom, false) + if err != nil { + return nil, err + } + if len(image.ExternalId) > 0 { + hosts, err := image.GetHosts() + if err != nil { + return nil, err + } + if len(input.PreferHost) == 0 && len(hosts) == 1 { + input.PreferHost = hosts[0].Id + } + } + } + return input, nil +} + +func (self *SSangForGuestDriver) GetGuestInitialStateAfterCreate() string { + return api.VM_RUNNING +} + +func (self *SSangForGuestDriver) DoGuestCreateDisksTask(ctx context.Context, guest *models.SGuest, task taskman.ITask) error { + subtask, err := taskman.TaskManager.NewTask(ctx, "SangForGuestCreateDiskTask", guest, task.GetUserCred(), task.GetParams(), task.GetTaskId(), "", nil) + if err != nil { + return errors.Wrapf(err, "NewTask") + } + return subtask.ScheduleRun(nil) +} + +func (self *SSangForGuestDriver) GetGuestInitialStateAfterRebuild() string { + return api.VM_RUNNING +} + +func (self *SSangForGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability { + return cloudprovider.SInstanceCapability{ + Hypervisor: self.GetHypervisor(), + Provider: self.GetProvider(), + DefaultAccount: cloudprovider.SDefaultAccount{ + Linux: cloudprovider.SOsDefaultAccount{ + DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER, + }, + Windows: cloudprovider.SOsDefaultAccount{ + DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER, + }, + }, + } +} + +func (self *SSangForGuestDriver) RemoteDeployGuestSyncHost(ctx context.Context, userCred mcclient.TokenCredential, guest *models.SGuest, host *models.SHost, iVM cloudprovider.ICloudVM) (cloudprovider.ICloudHost, error) { + if hostId := iVM.GetIHostId(); len(hostId) > 0 { + nh, err := db.FetchByExternalIdAndManagerId(models.HostManager, hostId, func(q *sqlchemy.SQuery) *sqlchemy.SQuery { + return q.Equals("manager_id", host.ManagerId) + }) + if err != nil { + log.Debugf("failed to found new hostId(%s) for ivm %s(%s) error: %v", hostId, guest.Name, guest.Id, err) + if errors.Cause(err) != sql.ErrNoRows { + return nil, errors.Wrap(err, "FetchByExternalIdAndManagerId") + } + + // HYPERVISOR_SANGFOR VM被部署到一台全新的宿主机 + zone, err := host.GetZone() + if err != nil { + log.Warningf("host %s GetZone: %s", host.GetId(), err) + } else { + _host, err := models.HostManager.NewFromCloudHost(ctx, userCred, iVM.GetIHost(), host.GetCloudprovider(), zone) + if err != nil { + log.Warningf("NewFromCloudHost %s: %s", iVM.GetIHostId(), err) + } else { + host = _host + } + } + } else { + host = nh.(*models.SHost) + } + } + + if host.GetId() != guest.HostId { + guest.OnScheduleToHost(ctx, userCred, host.GetId()) + } + + return host.GetIHost(ctx) +} + +func (self *SSangForGuestDriver) IsSupportedBillingCycle(bc billing.SBillingCycle) bool { + return false +} + +func (self *SSangForGuestDriver) IsNeedInjectPasswordByCloudInit() bool { + return false +} + +func (self *SSangForGuestDriver) IsSupportSetAutoRenew() bool { + return false +} + +func (self *SSangForGuestDriver) RequestSyncSecgroupsOnHost(ctx context.Context, guest *models.SGuest, host *models.SHost, task taskman.ITask) error { + return nil // do nothing, not support securitygroup +} + +func (self *SSangForGuestDriver) GetMaxSecurityGroupCount() int { + //暂不支持绑定安全组 + return 0 +} + +func (self *SSangForGuestDriver) RequestGuestHotAddIso(ctx context.Context, guest *models.SGuest, path string, boot bool, task taskman.ITask) error { + task.ScheduleRun(nil) + return nil +} + +func (self *SSangForGuestDriver) IsSupportCdrom(guest *models.SGuest) (bool, error) { + return true, nil +} diff --git a/pkg/compute/hostdrivers/managedvirtual.go b/pkg/compute/hostdrivers/managedvirtual.go index ca582973672..5b09c039d5d 100644 --- a/pkg/compute/hostdrivers/managedvirtual.go +++ b/pkg/compute/hostdrivers/managedvirtual.go @@ -59,6 +59,8 @@ func (self *SManagedVirtualizationHostDriver) CheckAndSetCacheImage(ctx context. image.OsVersion = input.OsFullVersion } + size := int64(0) + taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { lockman.LockRawObject(ctx, models.CachedimageManager.Keyword(), fmt.Sprintf("%s-%s", storageCache.Id, image.ImageId)) @@ -138,11 +140,12 @@ func (self *SManagedVirtualizationHostDriver) CheckAndSetCacheImage(ctx context. }() log.Infof("upload image %s id: %s", image.ImageName, image.ExternalId) } else { - _, err = iStorageCache.GetIImageById(cachedImage.ExternalId) + _, err := iStorageCache.GetIImageById(cachedImage.ExternalId) if err != nil { return nil, errors.Wrapf(err, "iStorageCache.GetIImageById(%s) for %s", cachedImage.ExternalId, iStorageCache.GetGlobalId()) } image.ExternalId = cachedImage.ExternalId + size = cachedImage.Size } if err != nil { return nil, err @@ -155,6 +158,7 @@ func (self *SManagedVirtualizationHostDriver) CheckAndSetCacheImage(ctx context. ret := jsonutils.NewDict() ret.Add(jsonutils.NewString(image.ExternalId), "image_id") + ret.Add(jsonutils.NewInt(size), "size") return ret, nil }) return nil diff --git a/pkg/compute/hostdrivers/sangfor.go b/pkg/compute/hostdrivers/sangfor.go new file mode 100644 index 00000000000..d1f4c8aae34 --- /dev/null +++ b/pkg/compute/hostdrivers/sangfor.go @@ -0,0 +1,41 @@ +// 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 hostdrivers + +import ( + api "yunion.io/x/onecloud/pkg/apis/compute" + "yunion.io/x/onecloud/pkg/compute/models" +) + +type SSangForHostDriver struct { + SManagedVirtualizationHostDriver +} + +func init() { + driver := SSangForHostDriver{} + models.RegisterHostDriver(&driver) +} + +func (self *SSangForHostDriver) GetHostType() string { + return api.HOST_TYPE_SANGFOR +} + +func (self *SSangForHostDriver) GetHypervisor() string { + return api.HYPERVISOR_SANGFOR +} + +func (self *SSangForHostDriver) GetProvider() string { + return api.CLOUD_PROVIDER_SANGFOR +} diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index 6e9ba0d99bd..440c09ebb72 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -3095,13 +3095,15 @@ func (self *SGuest) PerformChangeConfig(ctx context.Context, userCred mcclient.T } func (self *SGuest) ChangeConfToSchedDesc(addCpu, addMem int, schedInputDisks []*api.DiskConfig) *schedapi.ScheduleInput { + region, _ := self.GetRegion() devs, _ := self.GetIsolatedDevices() desc := &schedapi.ScheduleInput{ ServerConfig: schedapi.ServerConfig{ ServerConfigs: &api.ServerConfigs{ - Hypervisor: self.Hypervisor, - PreferHost: self.HostId, - Disks: schedInputDisks, + Hypervisor: self.Hypervisor, + PreferRegion: region.Id, + PreferHost: self.HostId, + Disks: schedInputDisks, }, Memory: addMem, Ncpu: addCpu, diff --git a/pkg/compute/regiondrivers/sangfor.go b/pkg/compute/regiondrivers/sangfor.go new file mode 100644 index 00000000000..a5670e54790 --- /dev/null +++ b/pkg/compute/regiondrivers/sangfor.go @@ -0,0 +1,41 @@ +// 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 regiondrivers + +import ( + api "yunion.io/x/onecloud/pkg/apis/compute" + "yunion.io/x/onecloud/pkg/compute/models" +) + +type SSangForRegionDriver struct { + SManagedVirtualizationRegionDriver +} + +func init() { + driver := SSangForRegionDriver{} + models.RegisterRegionDriver(&driver) +} + +func (self *SSangForRegionDriver) GetProvider() string { + return api.CLOUD_PROVIDER_SANGFOR +} + +func (self *SSangForRegionDriver) IsSupportedElasticcacheSecgroup() bool { + return false +} + +func (self *SSangForRegionDriver) GetMaxElasticcacheSecurityGroupCount() int { + return 1 +} diff --git a/pkg/compute/tasks/guest_create_disk_task.go b/pkg/compute/tasks/guest_create_disk_task.go index 29c5f7701e3..07b38b2121a 100644 --- a/pkg/compute/tasks/guest_create_disk_task.go +++ b/pkg/compute/tasks/guest_create_disk_task.go @@ -448,6 +448,10 @@ type CloudpodsGuestCreateDiskTask struct { NutanixGuestCreateDiskTask } +type SangForGuestCreateDiskTask struct { + NutanixGuestCreateDiskTask +} + func init() { taskman.RegisterTask(GuestCreateBackupDisksTask{}) taskman.RegisterTask(GuestCreateDiskTask{}) @@ -457,4 +461,5 @@ func init() { taskman.RegisterTask(ProxmoxGuestCreateDiskTask{}) taskman.RegisterTask(NutanixGuestCreateDiskTask{}) taskman.RegisterTask(CloudpodsGuestCreateDiskTask{}) + taskman.RegisterTask(SangForGuestCreateDiskTask{}) } diff --git a/pkg/mcclient/options/base.go b/pkg/mcclient/options/base.go index 23461395408..6646c1b055f 100644 --- a/pkg/mcclient/options/base.go +++ b/pkg/mcclient/options/base.go @@ -245,7 +245,7 @@ type BaseListOptions struct { Manager []string `help:"List objects belonging to the cloud provider" json:"manager,omitempty"` Account string `help:"List objects belonging to the cloud account" json:"account,omitempty"` - Provider []string `help:"List objects from the provider" choices:"OneCloud|VMware|Aliyun|Apsara|Qcloud|Azure|Aws|Huawei|OpenStack|Ucloud|VolcEngine|ZStack|Google|Ctyun|Cloudpods|Nutanix|BingoCloud|IncloudSphere|JDcloud|Proxmox|Ceph|CephFS|Ecloud|HCSO|HCS|HCSOP|H3C|S3|RemoteFile|Ksyun|Baidu|QingCloud|OracleCloud" json:"provider,omitempty"` + Provider []string `help:"List objects from the provider" choices:"OneCloud|VMware|Aliyun|Apsara|Qcloud|Azure|Aws|Huawei|OpenStack|Ucloud|VolcEngine|ZStack|Google|Ctyun|Cloudpods|Nutanix|BingoCloud|IncloudSphere|JDcloud|Proxmox|Ceph|CephFS|Ecloud|HCSO|HCS|HCSOP|H3C|S3|RemoteFile|Ksyun|Baidu|QingCloud|OracleCloud|SangFor" json:"provider,omitempty"` Brand []string `help:"List objects belonging to a special brand"` CloudEnv string `help:"Cloud environment" choices:"public|private|onpremise|private_or_onpremise" json:"cloud_env,omitempty"` PublicCloud *bool `help:"List objects belonging to public cloud" json:"public_cloud"` diff --git a/pkg/mcclient/options/compute/servers.go b/pkg/mcclient/options/compute/servers.go index 9557eb9cbb9..611006a9102 100644 --- a/pkg/mcclient/options/compute/servers.go +++ b/pkg/mcclient/options/compute/servers.go @@ -44,7 +44,7 @@ type ServerListOptions struct { Gpu *bool `help:"Show gpu servers"` Secgroup string `help:"Secgroup ID or Name"` AdminSecgroup string `help:"AdminSecgroup ID or Name"` - Hypervisor string `help:"Show server of hypervisor" choices:"kvm|esxi|pod|baremetal|aliyun|azure|aws|huawei|ucloud|volcengine|zstack|openstack|google|ctyun|incloudsphere|nutanix|bingocloud|cloudpods|ecloud|jdcloud|remotefile|h3c|hcs|hcso|hcsop|proxmox|ksyun|baidu|cucloud|qingcloud"` + Hypervisor string `help:"Show server of hypervisor" choices:"kvm|esxi|pod|baremetal|aliyun|azure|aws|huawei|ucloud|volcengine|zstack|openstack|google|ctyun|incloudsphere|nutanix|bingocloud|cloudpods|ecloud|jdcloud|remotefile|h3c|hcs|hcso|hcsop|proxmox|ksyun|baidu|cucloud|qingcloud|sangfor"` Region string `help:"Show servers in cloudregion"` WithEip *bool `help:"Show Servers with EIP"` WithoutEip *bool `help:"Show Servers without EIP"` @@ -361,7 +361,7 @@ func (o ServerCreateCommonConfig) Data() (*computeapi.ServerConfigs, error) { type ServerConfigs struct { ServerCreateCommonConfig - Hypervisor string `help:"Hypervisor type" choices:"kvm|pod|esxi|baremetal|container|aliyun|azure|qcloud|aws|huawei|openstack|ucloud|volcengine|zstack|google|ctyun|incloudsphere|bingocloud|cloudpods|ecloud|jdcloud|remotefile|h3c|hcs|hcso|hcsop|proxmox"` + Hypervisor string `help:"Hypervisor type" choices:"kvm|pod|esxi|baremetal|container|aliyun|azure|qcloud|aws|huawei|openstack|ucloud|volcengine|zstack|google|ctyun|incloudsphere|bingocloud|cloudpods|ecloud|jdcloud|remotefile|h3c|hcs|hcso|hcsop|proxmox|sangfor"` Backup bool `help:"Create server with backup server"` BackupHost string `help:"Perfered host where virtual backup server should be created"` AutoSwitchToBackupOnHostDown bool `help:"Auto switch to backup server on host down"` diff --git a/vendor/modules.txt b/vendor/modules.txt index c285e2a0b83..1f621a3025d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1690,7 +1690,7 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.2.0 ## explicit; go 1.12 sigs.k8s.io/yaml -# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240604034047-e1e06dfdf1f9 +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240611023744-6cfb14a28b9f ## explicit; go 1.18 yunion.io/x/cloudmux/pkg/apis yunion.io/x/cloudmux/pkg/apis/billing diff --git a/vendor/yunion.io/x/cloudmux/pkg/apis/compute/cloudaccount_const.go b/vendor/yunion.io/x/cloudmux/pkg/apis/compute/cloudaccount_const.go index f0c0940f50e..6ff14ebf8e9 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/apis/compute/cloudaccount_const.go +++ b/vendor/yunion.io/x/cloudmux/pkg/apis/compute/cloudaccount_const.go @@ -46,6 +46,7 @@ const ( CLOUD_PROVIDER_QINGCLOUD = "QingCloud" CLOUD_PROVIDER_VOLCENGINE = "VolcEngine" CLOUD_PROVIDER_ORACLE = "OracleCloud" + CLOUD_PROVIDER_SANGFOR = "SangFor" CLOUD_PROVIDER_GENERICS3 = "S3" CLOUD_PROVIDER_CEPH = "Ceph" diff --git a/vendor/yunion.io/x/cloudmux/pkg/apis/compute/guest_const.go b/vendor/yunion.io/x/cloudmux/pkg/apis/compute/guest_const.go index 124e93ee9dc..26d36e132e2 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/apis/compute/guest_const.go +++ b/vendor/yunion.io/x/cloudmux/pkg/apis/compute/guest_const.go @@ -79,6 +79,7 @@ const ( HYPERVISOR_QINGCLOUD = "qingcloud" HYPERVISOR_VOLCENGINE = "volcengine" HYPERVISOR_ORACLE = "oracle" + HYPERVISOR_SANGFOR = "sangfor" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/apis/compute/host_const.go b/vendor/yunion.io/x/cloudmux/pkg/apis/compute/host_const.go index 2662b4e2b54..4af5e7e3bdf 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/apis/compute/host_const.go +++ b/vendor/yunion.io/x/cloudmux/pkg/apis/compute/host_const.go @@ -48,6 +48,7 @@ const ( HOST_TYPE_QINGCLOUD = "qingcloud" HOST_TYPE_VOLCENGINE = "volcengine" HOST_TYPE_ORACLE = "oracle" + HOST_TYPE_SANGFOR = "sangfor" // # possible status HOST_ONLINE = "online"