yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/hcs/redis_account.go (about) 1 // Copyright 2019 Yunion 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package hcs 16 17 import ( 18 "fmt" 19 20 api "yunion.io/x/cloudmux/pkg/apis/compute" 21 "yunion.io/x/cloudmux/pkg/cloudprovider" 22 "yunion.io/x/cloudmux/pkg/multicloud" 23 "yunion.io/x/cloudmux/pkg/multicloud/huawei" 24 ) 25 26 type SElasticcacheAccount struct { 27 multicloud.SElasticcacheAccountBase 28 huawei.HuaweiTags 29 30 cacheDB *SElasticcache 31 } 32 33 func (self *SElasticcacheAccount) GetId() string { 34 return fmt.Sprintf("%s/root", self.cacheDB.InstanceId) 35 } 36 37 func (self *SElasticcacheAccount) GetName() string { 38 if len(self.cacheDB.AccessUser) > 0 { 39 return self.cacheDB.AccessUser 40 } 41 42 return "root" 43 } 44 45 func (self *SElasticcacheAccount) GetGlobalId() string { 46 return self.GetId() 47 } 48 49 func (self *SElasticcacheAccount) GetStatus() string { 50 return api.ELASTIC_CACHE_ACCOUNT_STATUS_AVAILABLE 51 } 52 53 func (self *SElasticcacheAccount) GetAccountType() string { 54 return api.ELASTIC_CACHE_ACCOUNT_TYPE_ADMIN 55 } 56 57 func (self *SElasticcacheAccount) GetAccountPrivilege() string { 58 return api.ELASTIC_CACHE_ACCOUNT_PRIVILEGE_WRITE 59 } 60 61 // https://support.huaweicloud.com/api-dcs/dcs-zh-api-180423031.html 62 // 未找到关闭密码的开放api, 不支持开启/关闭密码访问 63 // https://console.huaweicloud.com/dcs/rest/v2/41f6bfe48d7f4455b7754f7c1b11ae34/instances/26db46e2-c7d8-4b5e-bd36-b5278d2fe17c/password/reset 64 // new_password: "26db46e2!" 65 // no_password_access: false 66 func (self *SElasticcacheAccount) ResetPassword(input cloudprovider.SCloudElasticCacheAccountResetPasswordInput) error { 67 return nil 68 } 69 70 func (self *SElasticcacheAccount) UpdateAccount(input cloudprovider.SCloudElasticCacheAccountUpdateInput) error { 71 if input.Password != nil { 72 inputPassword := cloudprovider.SCloudElasticCacheAccountResetPasswordInput{} 73 inputPassword.NewPassword = *input.Password 74 inputPassword.OldPassword = input.OldPassword 75 inputPassword.NoPasswordAccess = input.NoPasswordAccess 76 return self.ResetPassword(inputPassword) 77 } 78 79 return nil 80 } 81 82 func (self *SElasticcacheAccount) Delete() error { 83 return cloudprovider.ErrNotSupported 84 }