yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/aliyun/loadbalancermasterslavebackend.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 aliyun 16 17 import ( 18 "context" 19 "fmt" 20 "strings" 21 22 api "yunion.io/x/cloudmux/pkg/apis/compute" 23 "yunion.io/x/cloudmux/pkg/cloudprovider" 24 "yunion.io/x/cloudmux/pkg/multicloud" 25 ) 26 27 type SLoadbalancerMasterSlaveBackend struct { 28 multicloud.SResourceBase 29 AliyunTags 30 lbbg *SLoadbalancerMasterSlaveBackendGroup 31 32 ServerId string 33 Weight int 34 Port int 35 ServerType string 36 } 37 38 func (backend *SLoadbalancerMasterSlaveBackend) GetName() string { 39 return backend.ServerId 40 } 41 42 func (backend *SLoadbalancerMasterSlaveBackend) GetId() string { 43 return fmt.Sprintf("%s/%s", backend.lbbg.MasterSlaveServerGroupId, backend.ServerId) 44 } 45 46 func (backend *SLoadbalancerMasterSlaveBackend) GetGlobalId() string { 47 return backend.GetId() 48 } 49 50 func (backend *SLoadbalancerMasterSlaveBackend) GetStatus() string { 51 return api.LB_STATUS_ENABLED 52 } 53 54 func (backend *SLoadbalancerMasterSlaveBackend) IsEmulated() bool { 55 return false 56 } 57 58 func (backend *SLoadbalancerMasterSlaveBackend) Refresh() error { 59 return nil 60 } 61 62 func (backend *SLoadbalancerMasterSlaveBackend) GetWeight() int { 63 return backend.Weight 64 } 65 66 func (backend *SLoadbalancerMasterSlaveBackend) GetPort() int { 67 return backend.Port 68 } 69 70 func (backend *SLoadbalancerMasterSlaveBackend) GetBackendType() string { 71 return api.LB_BACKEND_GUEST 72 } 73 74 func (backend *SLoadbalancerMasterSlaveBackend) GetBackendRole() string { 75 return strings.ToLower(backend.ServerType) 76 } 77 78 func (backend *SLoadbalancerMasterSlaveBackend) GetBackendId() string { 79 return backend.ServerId 80 } 81 82 func (backend *SLoadbalancerMasterSlaveBackend) GetIpAddress() string { 83 return "" 84 } 85 86 func (backend *SLoadbalancerMasterSlaveBackend) GetProjectId() string { 87 return backend.lbbg.GetProjectId() 88 } 89 90 func (backend *SLoadbalancerMasterSlaveBackend) SyncConf(ctx context.Context, port, weight int) error { 91 return cloudprovider.ErrNotSupported 92 }