loadbalancerbackend.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 azure
  15. import (
  16. "context"
  17. "strings"
  18. "yunion.io/x/pkg/errors"
  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 SLoadbalancerBackend struct {
  24. multicloud.SResourceBase
  25. AzureTags
  26. lbbg *SLoadbalancerBackendGroup
  27. PrivateIPAddress string
  28. LoadBalancerBackendAddresses []string
  29. }
  30. func (self *SLoadbalancerBackend) GetId() string {
  31. return self.PrivateIPAddress + strings.Join(self.LoadBalancerBackendAddresses, ",")
  32. }
  33. func (self *SLoadbalancerBackend) GetName() string {
  34. return self.PrivateIPAddress + strings.Join(self.LoadBalancerBackendAddresses, ",")
  35. }
  36. func (self *SLoadbalancerBackend) GetGlobalId() string {
  37. return strings.ToLower(self.GetId())
  38. }
  39. func (self *SLoadbalancerBackend) GetStatus() string {
  40. return api.LB_STATUS_ENABLED
  41. }
  42. func (self *SLoadbalancerBackend) GetProjectId() string {
  43. return ""
  44. }
  45. func (self *SLoadbalancerBackend) GetWeight() int {
  46. return 0
  47. }
  48. func (self *SLoadbalancerBackend) GetPort() int {
  49. return 0
  50. }
  51. func (self *SLoadbalancerBackend) GetBackendType() string {
  52. return api.LB_BACKEND_IP
  53. }
  54. func (self *SLoadbalancerBackend) GetBackendRole() string {
  55. return api.LB_BACKEND_ROLE_DEFAULT
  56. }
  57. func (self *SLoadbalancerBackend) GetBackendId() string {
  58. return ""
  59. }
  60. func (self *SLoadbalancerBackend) GetIpAddress() string {
  61. return self.PrivateIPAddress + strings.Join(self.LoadBalancerBackendAddresses, ",")
  62. }
  63. func (self *SLoadbalancerBackend) Update(ctx context.Context, opts *cloudprovider.SLoadbalancerBackend) error {
  64. return errors.Wrap(cloudprovider.ErrNotImplemented, "Update")
  65. }