mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): hcs vender update (#15391)
This commit is contained in:
@@ -83,7 +83,7 @@ require (
|
||||
k8s.io/client-go v0.19.3
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221116084146-820fb31ddff8
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221117091109-7f94a8910b85
|
||||
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656
|
||||
yunion.io/x/jsonutils v1.0.1-0.20220819091305-3bab322ab4fd
|
||||
yunion.io/x/log v1.0.0
|
||||
|
||||
@@ -1162,8 +1162,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.20221116084146-820fb31ddff8 h1:n1yIfyx/jK3BiWIYdq9hZBR/pokTyiourwSTdXFWbVk=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221116084146-820fb31ddff8/go.mod h1:drc/WDD65r6wI1tSejk19xcl9QwmzZlgJGXN7a9o2KQ=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221117091109-7f94a8910b85 h1:ZmH9nfWPIMiq6Qs9RnzBt7p9hYZdKVXDrnI3hU0rJMo=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221117091109-7f94a8910b85/go.mod h1:drc/WDD65r6wI1tSejk19xcl9QwmzZlgJGXN7a9o2KQ=
|
||||
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656 h1:0zlZD5uhZoIHgLVAWCz2aHaYk2ZrNsACCYD7R6EIBII=
|
||||
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
|
||||
Vendored
+1
-1
@@ -1428,7 +1428,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.20221116084146-820fb31ddff8
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221117091109-7f94a8910b85
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+7
@@ -17,4 +17,11 @@ package compute
|
||||
const (
|
||||
MODELARTS_POOL_SKU_AVAILABLE = "available"
|
||||
MODELARTS_POOL_SKU_SOLDOUT = "soldout"
|
||||
|
||||
MODELARTS_POOL_SKU_X86 = "x86"
|
||||
MODELARTS_POOL_SKU_ARM = "arm64"
|
||||
|
||||
MODELARTS_POOL_SKU_CPU = "CPU"
|
||||
MODELARTS_POOL_SKU_GPU = "GPU"
|
||||
MODELARTS_POOL_SKU_ASCEND = "ASCEND"
|
||||
)
|
||||
|
||||
+6
-4
@@ -92,9 +92,9 @@ type VolumeImageMetadata struct {
|
||||
type SDisk struct {
|
||||
multicloud.SDisk
|
||||
huawei.HuaweiDiskTags
|
||||
//details *SResourceDetail
|
||||
|
||||
region *SRegion
|
||||
region *SRegion
|
||||
storage *SStorage
|
||||
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
@@ -192,8 +192,10 @@ func (self *SDisk) GetCreatedAt() time.Time {
|
||||
}
|
||||
|
||||
func (self *SDisk) GetIStorage() (cloudprovider.ICloudStorage, error) {
|
||||
return nil, cloudprovider.ErrNotImplemented
|
||||
// return self.storage, nil
|
||||
if self.storage != nil {
|
||||
return self.storage, nil
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SDisk) GetDiskFormat() string {
|
||||
|
||||
+1
@@ -486,6 +486,7 @@ func (self *SHcsClient) _url(product, version, regionId string, resource string)
|
||||
"images", "cloudimages", "nat_gateways",
|
||||
"lbaas", "products", "snat_rules",
|
||||
"dnat_rules", "vpc/peerings",
|
||||
"ports",
|
||||
} {
|
||||
if strings.HasPrefix(resource, prefix) {
|
||||
url = fmt.Sprintf("%s.%s.%s/%s/%s", product, regionId, self.authUrl, version, resource)
|
||||
|
||||
+22
-19
@@ -355,7 +355,7 @@ func (self *SInstance) GetIDisks() ([]cloudprovider.ICloudDisk, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
disk.storage = &SStorage{zone: self.host.zone, storageType: disk.VolumeType}
|
||||
disks = append(disks, *disk)
|
||||
}
|
||||
|
||||
@@ -496,10 +496,13 @@ func (self *SInstance) GetMachine() string {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetOsArch() string {
|
||||
if flavor, err := self.host.zone.region.GetICloudSku(self.Flavor.Id); err == nil {
|
||||
image, err := self.host.zone.region.GetImage(self.Image.Id)
|
||||
if err == nil {
|
||||
return image.GetOsArch()
|
||||
}
|
||||
flavor, err := self.host.zone.region.GetICloudSku(self.Flavor.Id)
|
||||
if err == nil {
|
||||
return flavor.GetCpuArch()
|
||||
} else {
|
||||
log.Debugf("GetOSArch.GetICloudSku %s: %s", self.Flavor.Id, err)
|
||||
}
|
||||
|
||||
t := self.GetInstanceType()
|
||||
@@ -517,17 +520,14 @@ func (self *SInstance) AssignSecurityGroup(secgroupId string) error {
|
||||
}
|
||||
|
||||
func (self *SInstance) SetSecurityGroups(secgroupIds []string) error {
|
||||
currentSecgroups, err := self.GetSecurityGroupIds()
|
||||
ports, err := self.host.zone.region.GetPorts(self.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrapf(err, "GetPorts")
|
||||
}
|
||||
|
||||
add, remove, _ := compareSet(currentSecgroups, secgroupIds)
|
||||
err = self.host.zone.region.AssignSecurityGroups(add, self.GetId())
|
||||
if err != nil {
|
||||
return err
|
||||
for i := range ports {
|
||||
return self.host.zone.region.SetSecurityGroups(secgroupIds, ports[i].Id)
|
||||
}
|
||||
return self.host.zone.region.UnassignSecurityGroups(remove, self.GetId())
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetHypervisor() string {
|
||||
@@ -851,13 +851,15 @@ func (self *SRegion) CreateInstance(name string, imageId string, instanceType st
|
||||
return nil, fmt.Errorf("no server id returned with job %s", jsonutils.Marshal(job))
|
||||
}
|
||||
|
||||
func (self *SRegion) AssignSecurityGroups(secgroupIds []string, instanceId string) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
// https://support.huaweicloud.com/api-ecs/zh-cn_topic_0067161717.html
|
||||
func (self *SRegion) UnassignSecurityGroups(secgroupIds []string, instanceId string) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
func (self *SRegion) SetSecurityGroups(secgroupIds []string, portId string) error {
|
||||
res := fmt.Sprintf("ports/%s", portId)
|
||||
params := map[string]interface{}{
|
||||
"port": map[string]interface{}{
|
||||
"security_groups": secgroupIds,
|
||||
},
|
||||
}
|
||||
return self.update("vpc", "v2.0", res, params)
|
||||
}
|
||||
|
||||
// https://support.huaweicloud.com/api-ecs/zh-cn_topic_0020212207.html
|
||||
@@ -972,7 +974,8 @@ func (self *SRegion) DeployVM(instanceId string, name string, password string, k
|
||||
"new_password": password,
|
||||
},
|
||||
}
|
||||
return self.perform("ecs", "v1", "cloudservers/"+instanceId, "os-reset-password", params, nil)
|
||||
res := fmt.Sprintf("cloudservers/%s/os-reset-password", instanceId)
|
||||
return self.update("ecs", "v1", res, params)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+2
-2
@@ -148,7 +148,7 @@ func (region *SRegion) GetINetworkInterfaces() ([]cloudprovider.ICloudNetworkInt
|
||||
func (self *SRegion) GetPort(id string) (*Port, error) {
|
||||
port := &Port{}
|
||||
res := fmt.Sprintf("ports/%s", id)
|
||||
return port, self.vpcGet(res, port)
|
||||
return port, self.get("vpc", "v2.0", res, port)
|
||||
}
|
||||
|
||||
// https://support.huaweicloud.com/api-vpc/zh-cn_topic_0133195888.html
|
||||
@@ -158,5 +158,5 @@ func (self *SRegion) GetPorts(instanceId string) ([]Port, error) {
|
||||
if len(instanceId) > 0 {
|
||||
params.Set("device_id", instanceId)
|
||||
}
|
||||
return ports, self.vpcList("ports", params, &ports)
|
||||
return ports, self.list("vpc", "v2.0", "ports", params, &ports)
|
||||
}
|
||||
|
||||
+10
@@ -92,6 +92,16 @@ func (self *SModelartsPoolSku) GetCpuArch() string {
|
||||
return self.Spec.CpuArch
|
||||
}
|
||||
|
||||
func (sku *SModelartsPoolSku) GetProcessorType() string {
|
||||
if len(sku.GetNpuType()) != 0 {
|
||||
return compute.MODELARTS_POOL_SKU_ASCEND
|
||||
}
|
||||
if len(sku.GetGpuType()) != 0 {
|
||||
return compute.MODELARTS_POOL_SKU_GPU
|
||||
}
|
||||
return compute.MODELARTS_POOL_SKU_CPU
|
||||
}
|
||||
|
||||
func (self *SModelartsPoolSku) GetCpuCoreCount() int {
|
||||
return self.Spec.Cpu
|
||||
}
|
||||
|
||||
+10
@@ -91,6 +91,16 @@ func (self *SModelartsPoolSku) GetCpuArch() string {
|
||||
return self.Spec.CpuArch
|
||||
}
|
||||
|
||||
func (sku *SModelartsPoolSku) GetProcessorType() string {
|
||||
if len(sku.GetNpuType()) != 0 {
|
||||
return compute.MODELARTS_POOL_SKU_ASCEND
|
||||
}
|
||||
if len(sku.GetGpuType()) != 0 {
|
||||
return compute.MODELARTS_POOL_SKU_GPU
|
||||
}
|
||||
return compute.MODELARTS_POOL_SKU_CPU
|
||||
}
|
||||
|
||||
func (self *SModelartsPoolSku) GetCpuCoreCount() int {
|
||||
return self.Spec.Cpu
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user