loadbalancermasterslavebackend.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 apsara
  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. ApsaraTags
  26. lbbg *SLoadbalancerMasterSlaveBackendGroup
  27. ServerId string
  28. Weight int
  29. Port int
  30. ServerType string
  31. DepartmentInfo
  32. }
  33. func (backend *SLoadbalancerMasterSlaveBackend) GetName() string {
  34. return backend.ServerId
  35. }
  36. func (backend *SLoadbalancerMasterSlaveBackend) GetId() string {
  37. return fmt.Sprintf("%s/%s", backend.lbbg.MasterSlaveServerGroupId, backend.ServerId)
  38. }
  39. func (backend *SLoadbalancerMasterSlaveBackend) GetGlobalId() string {
  40. return backend.GetId()
  41. }
  42. func (backend *SLoadbalancerMasterSlaveBackend) GetStatus() string {
  43. return api.LB_STATUS_ENABLED
  44. }
  45. func (backend *SLoadbalancerMasterSlaveBackend) IsEmulated() bool {
  46. return false
  47. }
  48. func (backend *SLoadbalancerMasterSlaveBackend) Refresh() error {
  49. return nil
  50. }
  51. func (backend *SLoadbalancerMasterSlaveBackend) GetWeight() int {
  52. return backend.Weight
  53. }
  54. func (backend *SLoadbalancerMasterSlaveBackend) GetPort() int {
  55. return backend.Port
  56. }
  57. func (backend *SLoadbalancerMasterSlaveBackend) GetBackendType() string {
  58. return api.LB_BACKEND_GUEST
  59. }
  60. func (backend *SLoadbalancerMasterSlaveBackend) GetBackendRole() string {
  61. return strings.ToLower(backend.ServerType)
  62. }
  63. func (backend *SLoadbalancerMasterSlaveBackend) GetBackendId() string {
  64. return backend.ServerId
  65. }
  66. func (backend *SLoadbalancerMasterSlaveBackend) GetIpAddress() string {
  67. return ""
  68. }
  69. func (backend *SLoadbalancerMasterSlaveBackend) Update(ctx context.Context, opts *cloudprovider.SLoadbalancerBackend) error {
  70. return cloudprovider.ErrNotSupported
  71. }