mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #18016 from gouqi11/addSyncDesc
feat(region): support update description
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.20230913064313-95c98d413a45
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230914032754-392126ecb5f6
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
|
||||
yunion.io/x/jsonutils v1.0.1-0.20230613121553-0f3b41e2ef19
|
||||
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
|
||||
|
||||
@@ -1174,8 +1174,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.20230913064313-95c98d413a45 h1:4o1GFcBuW6Wx6UNltfrpwhyAAMSaSM4ys/YcU+0vHbE=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230913064313-95c98d413a45/go.mod h1:2sgCN7nRPQL3woLfdgqLDd92vwAHqtlz3KKiHxC5BAw=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230914032754-392126ecb5f6 h1:CREi73JRqSJ3P1f5fEtHz3/bS9gx81YorIy9ZnPjzOA=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230914032754-392126ecb5f6/go.mod h1:2sgCN7nRPQL3woLfdgqLDd92vwAHqtlz3KKiHxC5BAw=
|
||||
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=
|
||||
|
||||
@@ -459,6 +459,7 @@ func (drv *SManagedVirtualizedGuestDriver) RequestDeployGuestOnHost(ctx context.
|
||||
log.Debugf("RequestDeployGuestOnHost: %s", config)
|
||||
|
||||
desc := cloudprovider.SManagedVMCreateConfig{}
|
||||
desc.Description = guest.Description
|
||||
// 账号必须在desc.GetConfig()之前设置,避免默认用户不能正常注入
|
||||
osInfo := struct {
|
||||
OsType string
|
||||
@@ -1434,7 +1435,7 @@ func (drv *SManagedVirtualizedGuestDriver) RequestRemoteUpdate(ctx context.Conte
|
||||
return err
|
||||
}
|
||||
|
||||
err = iVM.UpdateVM(ctx, guest.Name)
|
||||
err = iVM.UpdateVM(ctx, cloudprovider.SInstanceUpdateOptions{NAME: guest.Name, Description: guest.Description})
|
||||
if err != nil {
|
||||
if errors.Cause(err) != cloudprovider.ErrNotSupported {
|
||||
return errors.Wrap(err, "iVM.UpdateVM")
|
||||
|
||||
@@ -1672,6 +1672,9 @@ func (self *SDBInstance) SyncWithCloudDBInstance(ctx context.Context, userCred m
|
||||
self.Category = ext.GetCategory()
|
||||
self.Status = ext.GetStatus()
|
||||
self.Port = ext.GetPort()
|
||||
if len(ext.GetDescription()) > 0 {
|
||||
self.Description = ext.GetDescription()
|
||||
}
|
||||
if iops := ext.GetIops(); iops > 0 {
|
||||
self.Iops = iops
|
||||
}
|
||||
@@ -1775,6 +1778,7 @@ func (manager *SDBInstanceManager) newFromCloudDBInstance(ctx context.Context, u
|
||||
instance.ConnectionStr = extInstance.GetConnectionStr()
|
||||
instance.StorageType = extInstance.GetStorageType()
|
||||
instance.InternalConnectionStr = extInstance.GetInternalConnectionStr()
|
||||
instance.Description = extInstance.GetDescription()
|
||||
|
||||
instance.MaintainTime = extInstance.GetMaintainTime()
|
||||
instance.SetZoneIds(extInstance)
|
||||
@@ -2159,4 +2163,10 @@ func (self *SDBInstance) GetExpiredAt() time.Time {
|
||||
|
||||
func (db *SDBInstance) PostUpdate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
db.SVirtualResourceBase.PostUpdate(ctx, userCred, query, data)
|
||||
if len(db.ExternalId) > 0 && (data.Contains("name") || data.Contains("description")) {
|
||||
err := db.StartRemoteUpdateTask(ctx, userCred, false, "")
|
||||
if err != nil {
|
||||
log.Errorf("StartRemoteUpdateTask fail: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2091,7 +2091,7 @@ func (manager *SGuestManager) validateEip(userCred mcclient.TokenCredential, inp
|
||||
|
||||
func (self *SGuest) PostUpdate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
self.SVirtualResourceBase.PostUpdate(ctx, userCred, query, data)
|
||||
if len(self.ExternalId) > 0 && (data.Contains("name") || data.Contains("__meta__")) {
|
||||
if len(self.ExternalId) > 0 && (data.Contains("name") || data.Contains("__meta__") || data.Contains("description")) {
|
||||
err := self.StartRemoteUpdateTask(ctx, userCred, false, "")
|
||||
if err != nil {
|
||||
log.Errorf("StartRemoteUpdateTask fail: %s", err)
|
||||
@@ -3049,7 +3049,7 @@ func (g *SGuest) syncWithCloudVM(ctx context.Context, userCred mcclient.TokenCre
|
||||
|
||||
g.Hypervisor = extVM.GetHypervisor()
|
||||
|
||||
if len(g.Description) == 0 {
|
||||
if len(extVM.GetDescription()) > 0 {
|
||||
g.Description = extVM.GetDescription()
|
||||
}
|
||||
g.IsEmulated = extVM.IsEmulated()
|
||||
|
||||
@@ -2412,6 +2412,13 @@ func (self *SManagedVirtualizationRegionDriver) RequestRemoteUpdateDBInstance(ct
|
||||
return nil, errors.Wrap(err, "iRds.SetTags")
|
||||
}
|
||||
logclient.AddActionLogWithStartable(task, instance, logclient.ACT_UPDATE_TAGS, tagsUpdateInfo, userCred, true)
|
||||
|
||||
err = iRds.Update(ctx, cloudprovider.SDBInstanceUpdateOptions{NAME: instance.Name, Description: instance.Description})
|
||||
if err != nil {
|
||||
if errors.Cause(err) != cloudprovider.ErrNotSupported {
|
||||
return nil, errors.Wrap(err, "iRds.Update")
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
})
|
||||
return nil
|
||||
|
||||
@@ -243,10 +243,11 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return self.host.zone.region.cli.delete(&modules.Servers, self.Id)
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
if self.Name != name {
|
||||
input := api.ServerUpdateInput{}
|
||||
input.Name = name
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
if self.Name != input.NAME {
|
||||
param := api.ServerUpdateInput{}
|
||||
param.Name = input.NAME
|
||||
param.Description = input.Description
|
||||
self.host.zone.region.cli.update(&modules.Servers, self.Id, input)
|
||||
return cloudprovider.WaitMultiStatus(self, []string{api.VM_READY, api.VM_RUNNING}, time.Second*5, time.Minute*3)
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1432,7 +1432,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.20230913064313-95c98d413a45
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230914032754-392126ecb5f6
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+5
@@ -112,3 +112,8 @@ type SDBInstanceRecoveryConfig struct {
|
||||
Databases map[string]string
|
||||
OriginDBInstanceExternalId string
|
||||
}
|
||||
|
||||
type SDBInstanceUpdateOptions struct {
|
||||
NAME string
|
||||
Description string
|
||||
}
|
||||
|
||||
+5
@@ -350,3 +350,8 @@ type ServerVncOutput struct {
|
||||
|
||||
Hypervisor string `json:"hypervisor"`
|
||||
}
|
||||
|
||||
type SInstanceUpdateOptions struct {
|
||||
NAME string
|
||||
Description string
|
||||
}
|
||||
|
||||
+3
-1
@@ -368,7 +368,7 @@ type ICloudVM interface {
|
||||
StopVM(ctx context.Context, opts *ServerStopOptions) error
|
||||
DeleteVM(ctx context.Context) error
|
||||
|
||||
UpdateVM(ctx context.Context, name string) error
|
||||
UpdateVM(ctx context.Context, input SInstanceUpdateOptions) error
|
||||
|
||||
UpdateUserData(userData string) error
|
||||
|
||||
@@ -992,6 +992,8 @@ type ICloudDBInstance interface {
|
||||
|
||||
RecoveryFromBackup(conf *SDBInstanceRecoveryConfig) error
|
||||
|
||||
Update(ctx context.Context, input SDBInstanceUpdateOptions) error
|
||||
|
||||
Delete() error
|
||||
}
|
||||
|
||||
|
||||
+16
@@ -869,6 +869,22 @@ func (region *SRegion) ModifyInstanceAutoRenewalAttribute(rdsId string, month in
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) Update(ctx context.Context, input cloudprovider.SDBInstanceUpdateOptions) error {
|
||||
return rds.region.ModifyDBInstanceName(rds.DBInstanceId, input.NAME)
|
||||
}
|
||||
|
||||
func (region *SRegion) ModifyDBInstanceName(id, name string) error {
|
||||
params := map[string]string{
|
||||
"DBInstanceId": id,
|
||||
"DBInstanceDescription": name,
|
||||
}
|
||||
_, err := region.rdsRequest("ModifyDBInstanceDescription", params)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "ModifyDBInstanceDescription")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (region *SRegion) RenewDBInstance(instanceId string, bc billing.SBillingCycle) error {
|
||||
params := map[string]string{
|
||||
"DBInstanceId": instanceId,
|
||||
|
||||
+5
-4
@@ -453,8 +453,8 @@ func (self *SInstance) GetVNCInfo(input *cloudprovider.ServerVncInput) (*cloudpr
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
return self.host.zone.region.UpdateVM(self.InstanceId, name, self.OSType)
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return self.host.zone.region.UpdateVM(self.InstanceId, input, self.OSType)
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
@@ -863,13 +863,14 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return cloudprovider.WaitDeleted(self, 10*time.Second, 300*time.Second) // 5minutes
|
||||
}
|
||||
|
||||
func (self *SRegion) UpdateVM(instanceId string, name, osType string) error {
|
||||
func (self *SRegion) UpdateVM(instanceId string, input cloudprovider.SInstanceUpdateOptions, osType string) error {
|
||||
/*
|
||||
api: ModifyInstanceAttribute
|
||||
https://help.aliyun.com/document_detail/25503.html?spm=a2c4g.11186623.4.1.DrgpjW
|
||||
*/
|
||||
params := make(map[string]string)
|
||||
params["InstanceName"] = name
|
||||
params["InstanceName"] = input.NAME
|
||||
params["Description"] = input.Description
|
||||
return self.modifyInstanceAttribute(instanceId, params)
|
||||
}
|
||||
|
||||
|
||||
+16
@@ -800,3 +800,19 @@ func (rds *SDBInstance) GetTags() (map[string]string, error) {
|
||||
func (rds *SDBInstance) SetTags(tags map[string]string, replace bool) error {
|
||||
return rds.region.SetResourceTags("rds", "INSTANCE", []string{rds.GetId()}, tags, replace)
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) Update(ctx context.Context, input cloudprovider.SDBInstanceUpdateOptions) error {
|
||||
return rds.region.ModifyDBInstanceName(rds.DBInstanceId, input.NAME)
|
||||
}
|
||||
|
||||
func (region *SRegion) ModifyDBInstanceName(id, name string) error {
|
||||
params := map[string]string{
|
||||
"DBInstanceId": id,
|
||||
"DBInstanceDescription": name,
|
||||
}
|
||||
_, err := region.rdsRequest("ModifyDBInstanceDescription", params)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "ModifyDBInstanceDescription")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+5
-4
@@ -444,8 +444,8 @@ func (self *SInstance) GetVNCInfo(input *cloudprovider.ServerVncInput) (*cloudpr
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
return self.host.zone.region.UpdateVM(self.InstanceId, name)
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return self.host.zone.region.UpdateVM(self.InstanceId, input)
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
@@ -785,13 +785,14 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return cloudprovider.WaitDeleted(self, 10*time.Second, 300*time.Second) // 5minutes
|
||||
}
|
||||
|
||||
func (self *SRegion) UpdateVM(instanceId string, name string) error {
|
||||
func (self *SRegion) UpdateVM(instanceId string, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
/*
|
||||
api: ModifyInstanceAttribute
|
||||
https://help.apsara.com/document_detail/25503.html?spm=a2c4g.11186623.4.1.DrgpjW
|
||||
*/
|
||||
params := make(map[string]string)
|
||||
params["InstanceName"] = name
|
||||
params["InstanceName"] = input.NAME
|
||||
params["Description"] = input.Description
|
||||
return self.modifyInstanceAttribute(instanceId, params)
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -412,3 +412,7 @@ func (self *SDisk) Rebuild(ctx context.Context) error {
|
||||
func (self *SDisk) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SDisk) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -429,3 +429,7 @@ func (self *SKubeCluster) CreateIKubeNodePool(opts *cloudprovider.KubeNodePoolCr
|
||||
}
|
||||
return nodegroup, nil
|
||||
}
|
||||
|
||||
func (self *SKubeCluster) GetDescription() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
+4
@@ -174,3 +174,7 @@ func (self *SRegion) DeleteNodegroup(cluster, name string) error {
|
||||
}{}
|
||||
return self.eksRequest("DeleteNodegroup", "/clusters/{name}/node-groups/{nodegroupName}", params, &ret)
|
||||
}
|
||||
|
||||
func (self *SNodeGroup) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+10
-8
@@ -522,9 +522,12 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return self.host.zone.region.DeleteVM(self.InstanceId)
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
self.SetTags(map[string]string{"Name": name}, false)
|
||||
return nil
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return self.host.zone.region.UpdateVM(self.InstanceId, input)
|
||||
}
|
||||
|
||||
func (self *SRegion) UpdateVM(instanceId string, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return self.setTags("instance", instanceId, map[string]string{"Name": input.NAME, "Description": input.Description}, false)
|
||||
}
|
||||
|
||||
func (self *SInstance) RebuildRoot(ctx context.Context, desc *cloudprovider.SManagedVMRebuildRootConfig) (string, error) {
|
||||
@@ -895,11 +898,6 @@ func (self *SRegion) DeleteVM(instanceId string) error {
|
||||
return self.ec2Request("TerminateInstances", params, &ret)
|
||||
}
|
||||
|
||||
func (self *SRegion) UpdateVM(instanceId string, hostname string) error {
|
||||
// https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/UserGuide/set-hostname.html
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SRegion) ReplaceSystemDisk(ctx context.Context, instanceId string, image *SImage, sysDiskSizeGB int, keypair string, userdata string) (string, error) {
|
||||
instance, err := self.GetInstance(instanceId)
|
||||
if err != nil {
|
||||
@@ -1146,3 +1144,7 @@ func (self *SInstance) SaveImage(opts *cloudprovider.SaveImageOptions) (cloudpro
|
||||
}
|
||||
return image, nil
|
||||
}
|
||||
|
||||
func (ins *SInstance) GetDescription() string {
|
||||
return ins.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -59,3 +59,7 @@ func (i *SInternetGateway) Refresh() error {
|
||||
func (i *SInternetGateway) IsEmulated() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SInternetGateway) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+21
-4
@@ -43,6 +43,7 @@ type SElb struct {
|
||||
multicloud.SVirtualResourceBase
|
||||
region *SRegion
|
||||
|
||||
AwsTags
|
||||
Type string `xml:"Type"`
|
||||
Scheme string `xml:"Scheme"`
|
||||
IPAddressType string `xml:"IpAddressType"`
|
||||
@@ -120,7 +121,11 @@ func (self *SElb) GetSysTags() map[string]string {
|
||||
}
|
||||
|
||||
func (self *SElb) GetTags() (map[string]string, error) {
|
||||
return self.region.DescribeElbTags(self.LoadBalancerArn)
|
||||
tagBase, err := self.region.DescribeElbTags(self.LoadBalancerArn)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "DescribeElbTags")
|
||||
}
|
||||
return tagBase.GetTags()
|
||||
}
|
||||
|
||||
func (self *SElb) GetAddress() string {
|
||||
@@ -401,10 +406,14 @@ func (self *SElb) SetTags(tags map[string]string, replace bool) error {
|
||||
}
|
||||
|
||||
func (self *SRegion) setElbTags(arn string, tags map[string]string, replace bool) error {
|
||||
oldTags, err := self.DescribeElbTags(arn)
|
||||
tagBase, err := self.DescribeElbTags(arn)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "DescribeElbTags")
|
||||
}
|
||||
oldTags, err := tagBase.GetTags()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get tags")
|
||||
}
|
||||
added, removed := map[string]string{}, map[string]string{}
|
||||
for k, v := range tags {
|
||||
oldValue, ok := oldTags[k]
|
||||
@@ -467,7 +476,7 @@ func (self *SRegion) RemoveElbTags(arn string, tags map[string]string) error {
|
||||
return self.elbRequest("RemoveTags", params, &ret)
|
||||
}
|
||||
|
||||
func (self *SRegion) DescribeElbTags(arn string) (map[string]string, error) {
|
||||
func (self *SRegion) DescribeElbTags(arn string) (*AwsTags, error) {
|
||||
ret := struct {
|
||||
TagDescriptions []struct {
|
||||
ResourceArn string `xml:"ResourceArn"`
|
||||
@@ -480,7 +489,7 @@ func (self *SRegion) DescribeElbTags(arn string) (map[string]string, error) {
|
||||
}
|
||||
for _, res := range ret.TagDescriptions {
|
||||
if res.ResourceArn == arn {
|
||||
return res.AwsTags.GetTags()
|
||||
return &res.AwsTags, nil
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
@@ -547,3 +556,11 @@ func (self *SRegion) CreateLoadbalancer(opts *cloudprovider.SLoadbalancerCreateO
|
||||
}
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "after created")
|
||||
}
|
||||
|
||||
func (self *SElb) GetDescription() string {
|
||||
tags, _ := self.region.DescribeElbTags(self.LoadBalancerArn)
|
||||
if tags == nil {
|
||||
return ""
|
||||
}
|
||||
return tags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -115,3 +115,7 @@ func (self *SRegion) SyncElbBackend(backendId, serverId string, oldPort, newPort
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElbBackend) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -320,3 +320,7 @@ func (self *SRegion) GetElbBackendgroupAttributes(id string) (map[string]string,
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (self *SElbBackendGroup) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -249,3 +249,7 @@ func (self *SRegion) ListServerCertificates() ([]SElbCertificate, error) {
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SElbCertificate) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -626,3 +626,7 @@ func (self *SRegion) DeleteElbListener(id string) error {
|
||||
func (self *SRegion) UpdateRulesPriority(rules []cloudprovider.ICloudLoadbalancerListenerRule) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElbListener) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -191,3 +191,7 @@ func (self *SRegion) CreateElbListenerRule(listenerId string, opts *cloudprovide
|
||||
}
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "after created")
|
||||
}
|
||||
|
||||
func (self *SElbListenerRule) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -246,3 +246,7 @@ func (self *SRegion) GetNetwroks(ids []string, zoneId, vpcId string) ([]SNetwork
|
||||
func (self *SNetwork) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SNetwork) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -291,3 +291,7 @@ func (self *SRegion) DeleteRouteTable(rid string) error {
|
||||
ret := struct{}{}
|
||||
return self.ec2Request("DeleteRouteTable", params, &ret)
|
||||
}
|
||||
|
||||
func (self *SRoute) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -176,3 +176,7 @@ func (self *SAwsClient) GetICloudSAMLProviders() ([]cloudprovider.ICloudSAMLProv
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SAMLProvider) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -194,3 +194,7 @@ func (self *SRegion) DeleteSnapshot(id string) error {
|
||||
func (self *SSnapshot) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *SSnapshot) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -140,3 +140,7 @@ func (self *SStorage) GetMountPoint() string {
|
||||
func (self *SStorage) IsSysDiskStore() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SStorage) GetDescription() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
+4
@@ -427,3 +427,7 @@ func (region *SRegion) GetIStoragecaches() ([]cloudprovider.ICloudStoragecache,
|
||||
cache := region.getStorageCache()
|
||||
return []cloudprovider.ICloudStoragecache{cache}, nil
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+19
@@ -64,6 +64,25 @@ func (self AwsTags) GetName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self AwsTags) GetDescription() string {
|
||||
for _, tag := range self.TagSet {
|
||||
if strings.ToLower(tag.Key) == "description" {
|
||||
return tag.Value
|
||||
}
|
||||
}
|
||||
for _, tag := range self.TagList {
|
||||
if strings.ToLower(tag.Key) == "description" {
|
||||
return tag.Value
|
||||
}
|
||||
}
|
||||
for _, tag := range self.Tags {
|
||||
if strings.ToLower(tag.Key) == "description" {
|
||||
return tag.Value
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (self *AwsTags) GetTags() (map[string]string, error) {
|
||||
ret := map[string]string{}
|
||||
for _, tag := range self.TagSet {
|
||||
|
||||
+4
@@ -219,3 +219,7 @@ func (self *SVpcPeeringConnection) Delete() error {
|
||||
func (self *SVpcPeeringConnection) GetEnabled() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SVpcPeeringConnection) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -543,3 +543,7 @@ func (self *SWebAcl) GetCloudResources() ([]cloudprovider.SCloudResource, error)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SWebAcl) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -101,3 +101,7 @@ func (self *SWire) CreateINetwork(opts *cloudprovider.SNetworkCreateOptions) (cl
|
||||
}
|
||||
return network, nil
|
||||
}
|
||||
|
||||
func (self *SWire) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+4
@@ -145,3 +145,7 @@ func (self *SZone) getStorageByCategory(category string) (*SStorage, error) {
|
||||
}
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, category)
|
||||
}
|
||||
|
||||
func (self *SZone) GetDescription() string {
|
||||
return self.AwsTags.GetDescription()
|
||||
}
|
||||
|
||||
+1
-1
@@ -296,7 +296,7 @@ func (self *SClassicInstance) RebuildRoot(ctx context.Context, desc *cloudprovid
|
||||
//return self.host.zone.region.ReplaceSystemDisk(self.ID, imageId, passwd, publicKey, int32(sysSizeGB))
|
||||
}
|
||||
|
||||
func (self *SClassicInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
func (self *SClassicInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -790,7 +790,7 @@ func (region *SRegion) ReplaceSystemDisk(instance *SInstance, cpu int, memoryMb
|
||||
return strings.ToLower(newDiskId), nil
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -430,8 +430,8 @@ func (self *SInstance) UpdateInstanceType(instanceType string) error {
|
||||
return self.node.cluster.region.modifyInstanceAttribute(self.InstancesSet.InstanceId, map[string]string{"InstanceType": instanceType})
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
return self.node.cluster.region.modifyInstanceAttribute(self.InstancesSet.InstanceId, map[string]string{"InstanceName": name})
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return self.node.cluster.region.modifyInstanceAttribute(self.InstancesSet.InstanceId, map[string]string{"InstanceName": input.NAME})
|
||||
}
|
||||
|
||||
func (self *SInstance) CreateInstanceSnapshot(ctx context.Context, name string, desc string) (cloudprovider.ICloudInstanceSnapshot, error) {
|
||||
|
||||
+1
-1
@@ -526,7 +526,7 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -119,3 +119,7 @@ func (instance *SDBInstanceBase) GetIops() int {
|
||||
func (instance *SDBInstanceBase) GetDiskSizeUsedMB() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (instance *SDBInstanceBase) Update(ctx context.Context, input cloudprovider.SDBInstanceUpdateOptions) error {
|
||||
return errors.Wrap(errors.ErrNotImplemented, "DBInsatnce Update")
|
||||
}
|
||||
|
||||
+1
-1
@@ -326,7 +326,7 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+19
-6
@@ -294,8 +294,12 @@ func (svm *SVirtualMachine) rebuildDisk(ctx context.Context, disk *SVirtualDisk,
|
||||
}, false)
|
||||
}
|
||||
|
||||
func (svm *SVirtualMachine) UpdateVM(ctx context.Context, name string) error {
|
||||
return svm.DoRename(ctx, name)
|
||||
func (svm *SVirtualMachine) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
err := svm.SetConfig(ctx, input)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "set description")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: detach disk to a separate directory, so as to keep disk independent of VM
|
||||
@@ -806,9 +810,15 @@ func (svm *SVirtualMachine) GetCreatedAt() time.Time {
|
||||
}
|
||||
}
|
||||
|
||||
func (svm *SVirtualMachine) GetDescription() string {
|
||||
moVM := svm.getVirtualMachine()
|
||||
return moVM.Config.Annotation
|
||||
func (svm *SVirtualMachine) SetConfig(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
setDescTask, err := svm.getVmObj().Reconfigure(ctx, types.VirtualMachineConfigSpec{
|
||||
Name: input.NAME,
|
||||
Annotation: input.Description,
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "set task")
|
||||
}
|
||||
return setDescTask.Wait(ctx)
|
||||
}
|
||||
|
||||
func (svm *SVirtualMachine) GetExpiredAt() time.Time {
|
||||
@@ -852,7 +862,10 @@ func (svm *SVirtualMachine) fetchHardwareInfo() error {
|
||||
|
||||
if reflectutils.StructContains(devType, etherType) {
|
||||
vnic := NewVirtualNIC(svm, dev, len(svm.vnics))
|
||||
svm.vnics = append(svm.vnics, vnic)
|
||||
if len(vnic.GetIP()) > 0 {
|
||||
// only nics with ip is valid
|
||||
svm.vnics = append(svm.vnics, vnic)
|
||||
}
|
||||
} else if reflectutils.StructContains(devType, diskType) {
|
||||
svm.vdisks = append(svm.vdisks, NewVirtualDisk(svm, dev, len(svm.vdisks)))
|
||||
} else if reflectutils.StructContains(devType, vgaType) {
|
||||
|
||||
+1
-1
@@ -483,7 +483,7 @@ func (instance *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return instance.host.zone.region.Delete(instance.SelfLink)
|
||||
}
|
||||
|
||||
func (instance *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
func (instance *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -609,8 +609,8 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return cloudprovider.WaitDeleted(self, 10*time.Second, 300*time.Second) // 5minutes
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
return self.host.zone.region.UpdateVM(self.GetId(), name)
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return self.host.zone.region.UpdateVM(self.GetId(), input)
|
||||
}
|
||||
|
||||
// https://support.huaweicloud.com/usermanual-ecs/zh-cn_topic_0032380449.html
|
||||
@@ -1149,10 +1149,11 @@ func (self *SRegion) DeleteVM(instanceId string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SRegion) UpdateVM(instanceId, name string) error {
|
||||
func (self *SRegion) UpdateVM(instanceId string, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
serverObj := jsonutils.NewDict()
|
||||
serverObj.Add(jsonutils.NewString(name), "name")
|
||||
serverObj.Add(jsonutils.NewString(input.NAME), "name")
|
||||
serverObj.Add(jsonutils.NewString(input.Description), "description")
|
||||
params.Add(serverObj, "server")
|
||||
|
||||
_, err := self.ecsClient.Servers.Update(instanceId, params)
|
||||
|
||||
+36
-2
@@ -19,10 +19,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/billing"
|
||||
|
||||
billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
|
||||
@@ -527,6 +526,9 @@ func (region *SRegion) CreateIDBInstance(desc *cloudprovider.SManagedDBInstanceC
|
||||
process, _ := job.GetString("process")
|
||||
log.Debugf("create dbinstance job %s status: %s process: %s", jobId, status, process)
|
||||
if status == "Completed" {
|
||||
region.UpdateVM(instance.Id, cloudprovider.SInstanceUpdateOptions{
|
||||
Description: desc.Description,
|
||||
})
|
||||
return true, nil
|
||||
}
|
||||
if status == "Failed" {
|
||||
@@ -778,3 +780,35 @@ func (region *SRegion) RecoveryDBInstanceFromBackup(target, origin string, backu
|
||||
func (rds *SDBInstance) Renew(bc billing.SBillingCycle) error {
|
||||
return rds.region.RenewInstance(rds.Id, bc)
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) Update(ctx context.Context, input cloudprovider.SDBInstanceUpdateOptions) error {
|
||||
return rds.region.Update(rds.Id, input)
|
||||
}
|
||||
|
||||
func (region *SRegion) Update(instanceId string, input cloudprovider.SDBInstanceUpdateOptions) error {
|
||||
if len(input.NAME) > 0 {
|
||||
err := region.ModifyDBInstanceName(instanceId, input.NAME)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "update dbinstance name")
|
||||
}
|
||||
}
|
||||
err := region.ModifyDBInstanceDesc(instanceId, input.Description)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "update dbinstance name")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (region *SRegion) ModifyDBInstanceName(instanceId string, name string) error {
|
||||
params := map[string]interface{}{
|
||||
"name": name,
|
||||
}
|
||||
return region.client.dbinstanceSetName(instanceId, params)
|
||||
}
|
||||
|
||||
func (region *SRegion) ModifyDBInstanceDesc(instanceId string, desc string) error {
|
||||
params := map[string]interface{}{
|
||||
"alias": desc,
|
||||
}
|
||||
return region.client.dbinstanceSetDesc(instanceId, params)
|
||||
}
|
||||
|
||||
+12
@@ -886,3 +886,15 @@ func (self *SHuaweiClient) patchRequest(method httputils.THttpMethod, url string
|
||||
}
|
||||
return respValue, err
|
||||
}
|
||||
|
||||
func (self *SHuaweiClient) dbinstanceSetName(instanceId string, params map[string]interface{}) error {
|
||||
uri := fmt.Sprintf("https://rds.%s.myhuaweicloud.com/v3/%s/instances/%s/name", self.clientRegion, self.projectId, instanceId)
|
||||
_, err := self.request(httputils.PUT, uri, nil, params)
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SHuaweiClient) dbinstanceSetDesc(instanceId string, params map[string]interface{}) error {
|
||||
uri := fmt.Sprintf("https://rds.%s.myhuaweicloud.com/v3/%s/instances/%s/alias", self.clientRegion, self.projectId, instanceId)
|
||||
_, err := self.request(httputils.PUT, uri, nil, params)
|
||||
return err
|
||||
}
|
||||
|
||||
+5
-4
@@ -635,8 +635,8 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return cloudprovider.WaitDeleted(self, 10*time.Second, 300*time.Second) // 5minutes
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
return self.host.zone.region.UpdateVM(self.GetId(), name)
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return self.host.zone.region.UpdateVM(self.GetId(), input)
|
||||
}
|
||||
|
||||
// https://support.huaweicloud.com/usermanual-ecs/zh-cn_topic_0032380449.html
|
||||
@@ -1169,10 +1169,11 @@ func (self *SRegion) DeleteVM(instanceId string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SRegion) UpdateVM(instanceId, name string) error {
|
||||
func (self *SRegion) UpdateVM(instanceId string, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
serverObj := jsonutils.NewDict()
|
||||
serverObj.Add(jsonutils.NewString(name), "name")
|
||||
serverObj.Add(jsonutils.NewString(input.NAME), "name")
|
||||
serverObj.Add(jsonutils.NewString(input.Description), "description")
|
||||
params.Add(serverObj, "server")
|
||||
|
||||
_, err := self.ecsClient.Servers.Update(instanceId, params)
|
||||
|
||||
+1
-1
@@ -329,7 +329,7 @@ func (in *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (in *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
func (in *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -400,7 +400,7 @@ func (self *SInstance) UpdateUserData(userData string) error {
|
||||
return cloudprovider.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+56
-3
@@ -445,11 +445,11 @@ func (instance *SInstance) Refresh() error {
|
||||
return jsonutils.Update(instance, _instance)
|
||||
}
|
||||
|
||||
func (instance *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
if instance.Name != name {
|
||||
func (instance *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
if instance.Name != input.NAME {
|
||||
params := map[string]map[string]string{
|
||||
"server": {
|
||||
"name": name,
|
||||
"name": input.NAME,
|
||||
},
|
||||
}
|
||||
resource := "/servers/" + instance.Id
|
||||
@@ -463,6 +463,59 @@ func (instance *SInstance) GetHypervisor() string {
|
||||
return api.HYPERVISOR_OPENSTACK
|
||||
}
|
||||
|
||||
func (self *SInstance) SetTags(tags map[string]string, replace bool) error {
|
||||
oldTags, err := self.GetTags()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetTags")
|
||||
}
|
||||
added, removed := map[string]string{}, map[string]string{}
|
||||
for k, v := range tags {
|
||||
oldValue, ok := oldTags[k]
|
||||
if !ok {
|
||||
added[k] = v
|
||||
} else if oldValue != v {
|
||||
removed[k] = oldValue
|
||||
added[k] = v
|
||||
}
|
||||
}
|
||||
if replace {
|
||||
for k, v := range oldTags {
|
||||
newValue, ok := tags[k]
|
||||
if !ok {
|
||||
removed[k] = v
|
||||
} else if v != newValue {
|
||||
added[k] = newValue
|
||||
removed[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
for k := range removed {
|
||||
err = self.host.zone.region.DeleteTags(self.Id, k)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "DeleteTags %s", k)
|
||||
}
|
||||
}
|
||||
if len(added) > 0 {
|
||||
return self.host.zone.region.CreateTags(self.Id, added)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SRegion) DeleteTags(instanceId string, key string) error {
|
||||
resource := fmt.Sprintf("/servers/%s/metadata/%s", instanceId, key)
|
||||
_, err := self.ecsDelete(resource)
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SRegion) CreateTags(instanceId string, tags map[string]string) error {
|
||||
params := map[string]interface{}{
|
||||
"metadata": tags,
|
||||
}
|
||||
resource := fmt.Sprintf("/servers/%s/metadata", instanceId)
|
||||
_, err := self.ecsPost(resource, params)
|
||||
return err
|
||||
}
|
||||
|
||||
func (instance *SInstance) StartVM(ctx context.Context) error {
|
||||
err := instance.host.zone.region.StartVM(instance.Id)
|
||||
if err != nil {
|
||||
|
||||
+1
-1
@@ -475,7 +475,7 @@ func (self *SInstance) UpdateUserData(userData string) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -15,6 +15,7 @@
|
||||
package qcloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
@@ -61,3 +62,10 @@ func (self *SRegion) CreateIDBInstance(opts *cloudprovider.SManagedDBInstanceCre
|
||||
}
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotImplemented, "For %s", opts.Engine)
|
||||
}
|
||||
|
||||
func (rds *SMySQLInstance) Update(ctx context.Context, input cloudprovider.SDBInstanceUpdateOptions) error {
|
||||
if strings.HasPrefix(rds.InstanceId, "cdb") {
|
||||
return rds.region.Update(rds.InstanceId, input.NAME)
|
||||
}
|
||||
return errors.ErrNotImplemented
|
||||
}
|
||||
|
||||
+2
-2
@@ -453,8 +453,8 @@ func (self *SInstance) GetVNCInfo(input *cloudprovider.ServerVncInput) (*cloudpr
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
return self.host.zone.region.UpdateVM(self.InstanceId, name)
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return self.host.zone.region.UpdateVM(self.InstanceId, input.NAME)
|
||||
}
|
||||
|
||||
func (self *SInstance) DeployVM(ctx context.Context, name string, username string, password string, publicKey string, deleteKeypair bool, description string) error {
|
||||
|
||||
+12
@@ -921,3 +921,15 @@ func (self *SRegion) GetIMySQLs() ([]cloudprovider.ICloudDBInstance, error) {
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) Update(id, name string) error {
|
||||
params := map[string]string{
|
||||
"InstanceId": id,
|
||||
"InstanceName": name,
|
||||
}
|
||||
_, err := self.cdbRequest("ModifyDBInstanceName", params)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "cdbRequest")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+5
@@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/pkg/errors"
|
||||
)
|
||||
|
||||
type SDBInstance struct {
|
||||
@@ -214,3 +215,7 @@ func (self *SRegion) GetIDBInstanceById(id string) (cloudprovider.ICloudDBInstan
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (instance *SDBInstance) Update(ctx context.Context, input cloudprovider.SDBInstanceUpdateOptions) error {
|
||||
return errors.ErrNotImplemented
|
||||
}
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return cloudprovider.ErrNotSupported
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -454,8 +454,8 @@ func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
return self.host.zone.region.DeleteVM(self.GetId())
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
return self.host.zone.region.UpdateVM(self.GetId(), name)
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return self.host.zone.region.UpdateVM(self.GetId(), input.NAME)
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateUserData(userData string) error {
|
||||
|
||||
+2
-2
@@ -354,10 +354,10 @@ func (instance *SInstance) GetVNCInfo(input *cloudprovider.ServerVncInput) (*clo
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (instance *SInstance) UpdateVM(ctx context.Context, name string) error {
|
||||
func (instance *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
params := map[string]interface{}{
|
||||
"updateVmInstance": map[string]string{
|
||||
"name": name,
|
||||
"name": input.NAME,
|
||||
},
|
||||
}
|
||||
return instance.host.zone.region.UpdateVM(instance.UUID, jsonutils.Marshal(params))
|
||||
|
||||
Reference in New Issue
Block a user