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