Merge pull request #15721 from ioito/hotfix/qx-vender-update-20230106

fix(region): vender update
This commit is contained in:
Zexi Li
2023-01-06 15:32:01 +08:00
committed by GitHub
5 changed files with 46 additions and 7 deletions
+1 -1
View File
@@ -81,7 +81,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.20230104114513-eab695f13003
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230106031511-6cd3cbab4611
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
+2 -2
View File
@@ -1158,8 +1158,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.20230104114513-eab695f13003 h1:WuLDIwQcBRHLvFpkL9+hXOra6nADUkjvkeT+GcHbuyk=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230104114513-eab695f13003/go.mod h1:yEMFtIKPyIdIfPzsw7oTcH41JXc8G5StUAQw3ZoGj5I=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230106031511-6cd3cbab4611 h1:rD+r9RDhgVpB2nnBUv5GxaTCjiJshnOVOOkkHtT9zLc=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230106031511-6cd3cbab4611/go.mod h1:yEMFtIKPyIdIfPzsw7oTcH41JXc8G5StUAQw3ZoGj5I=
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=
+1 -1
View File
@@ -1439,7 +1439,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.20230104114513-eab695f13003
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230106031511-6cd3cbab4611
## explicit; go 1.18
yunion.io/x/cloudmux/pkg/apis
yunion.io/x/cloudmux/pkg/apis/billing
+1
View File
@@ -448,6 +448,7 @@ func (self *SInstance) GetVNCInfo(input *cloudprovider.ServerVncInput) (*cloudpr
Protocol: "aliyun",
InstanceId: self.InstanceId,
Hypervisor: api.HYPERVISOR_ALIYUN,
OsName: string(self.GetOsType()),
}
return ret, nil
}
+41 -3
View File
@@ -20,6 +20,8 @@ import (
"strings"
"time"
"yunion.io/x/jsonutils"
"yunion.io/x/cloudmux/pkg/apis"
api "yunion.io/x/cloudmux/pkg/apis/compute"
"yunion.io/x/cloudmux/pkg/cloudprovider"
@@ -313,6 +315,17 @@ func (self *SInstance) GetProjectId() string {
return ""
}
func (self *SInstance) Refresh() error {
new, _, err := self.node.cluster.region.GetInstances(self.InstancesSet.InstanceId, self.node.NodeId, MAX_RESULT, "")
if err != nil {
return err
}
if len(new) == 1 {
return jsonutils.Update(self, &new[0])
}
return nil
}
func (self *SInstance) GetStatus() string {
switch self.InstancesSet.InstanceState.Name {
case "stopped":
@@ -323,7 +336,26 @@ func (self *SInstance) GetStatus() string {
}
func (self *SInstance) GetVNCInfo(input *cloudprovider.ServerVncInput) (*cloudprovider.ServerVncOutput, error) {
return nil, cloudprovider.ErrNotImplemented
params := map[string]string{}
params["instanceId"] = self.InstancesSet.InstanceId
resp, err := self.node.cluster.region.invoke("GetVncInfo", params)
if err != nil {
return nil, err
}
result := struct {
GetVncInfoResult *cloudprovider.ServerVncOutput `json:"getVncInfoResult"`
}{}
err = resp.Unmarshal(&result)
if err != nil {
return nil, err
}
result.GetVncInfoResult.InstanceId = self.InstancesSet.InstanceId
result.GetVncInfoResult.Hypervisor = self.GetHypervisor()
return result.GetVncInfoResult, nil
}
func (self *SInstance) RebuildRoot(ctx context.Context, config *cloudprovider.SManagedVMRebuildRootConfig) (string, error) {
@@ -331,11 +363,17 @@ func (self *SInstance) RebuildRoot(ctx context.Context, config *cloudprovider.SM
}
func (self *SInstance) StartVM(ctx context.Context) error {
return cloudprovider.ErrNotImplemented
params := map[string]string{}
params["InstanceId.1"] = self.InstancesSet.InstanceId
_, err := self.node.cluster.region.invoke("StartInstances", params)
return err
}
func (self *SInstance) StopVM(ctx context.Context, opts *cloudprovider.ServerStopOptions) error {
return cloudprovider.ErrNotImplemented
params := map[string]string{}
params["InstanceId.1"] = self.InstancesSet.InstanceId
_, err := self.node.cluster.region.invoke("StopInstances", params)
return err
}
func (self *SInstance) UpdateUserData(userData string) error {