loadbalancermasterslavebackend.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. package aliyun
  15. import (
  16. "context"
  17. "fmt"
  18. "strings"
  19. api "yunion.io/x/cloudmux/pkg/apis/compute"
  20. "yunion.io/x/cloudmux/pkg/cloudprovider"
  21. "yunion.io/x/cloudmux/pkg/multicloud"
  22. )
  23. type SLoadbalancerMasterSlaveBackend struct {
  24. multicloud.SResourceBase
  25. AliyunTags
  26. lbbg *SLoadbalancerMasterSlaveBackendGroup
  27. ServerId string
  28. Weight int
  29. Port int
  30. ServerType string
  31. }
  32. func (backend *SLoadbalancerMasterSlaveBackend) GetName() string {
  33. return backend.ServerId
  34. }
  35. func (backend *SLoadbalancerMasterSlaveBackend) GetId() string {
  36. return fmt.Sprintf("%s/%s", backend.lbbg.MasterSlaveServerGroupId, backend.ServerId)
  37. }
  38. func (backend *SLoadbalancerMasterSlaveBackend) GetGlobalId() string {
  39. return backend.GetId()
  40. }
  41. func (backend *SLoadbalancerMasterSlaveBackend) GetStatus() string {
  42. return api.LB_STATUS_ENABLED
  43. }
  44. func (backend *SLoadbalancerMasterSlaveBackend) IsEmulated() bool {
  45. return false
  46. }
  47. func (backend *SLoadbalancerMasterSlaveBackend) Refresh() error {
  48. return nil
  49. }
  50. func (backend *SLoadbalancerMasterSlaveBackend) GetWeight() int {
  51. return backend.Weight
  52. }
  53. func (backend *SLoadbalancerMasterSlaveBackend) GetPort() int {
  54. return backend.Port
  55. }
  56. func (backend *SLoadbalancerMasterSlaveBackend) GetBackendType() string {
  57. return api.LB_BACKEND_GUEST
  58. }
  59. func (backend *SLoadbalancerMasterSlaveBackend) GetBackendRole() string {
  60. return strings.ToLower(backend.ServerType)
  61. }
  62. func (backend *SLoadbalancerMasterSlaveBackend) GetBackendId() string {
  63. return backend.ServerId
  64. }
  65. func (backend *SLoadbalancerMasterSlaveBackend) GetIpAddress() string {
  66. return ""
  67. }
  68. func (backend *SLoadbalancerMasterSlaveBackend) GetProjectId() string {
  69. return backend.lbbg.GetProjectId()
  70. }
  71. func (backend *SLoadbalancerMasterSlaveBackend) Update(ctx context.Context, opts *cloudprovider.SLoadbalancerBackend) error {
  72. return cloudprovider.ErrNotSupported
  73. }