mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-07-02 03:14:39 +08:00
* regiondrivers: kvm: lb: make "network" an optional argument
* loadbalancernetworks: add MacAddr field for lb with eip
* apis: compute: add LOADBALANCER to EIP_ASSOCIATE_VALID_TYPES
* regiondrivers: fix typo RequestAssociat{,e}Eip
* regiondrivers: kvm: RequestAssociatEip: standalone func for each type
* regiondrivers: kvm: RequestAssociateEip: support loadbalancer
* tasks: EipAssociateTask: add support for loadbalancer
* tasks: EipAssociateTask: allow using name for referring to instance
* elasticips: PerformAssociate: validate loadbalancer condition
* tasks: EipDissociateTask: support non-managed loadbalancer
* loadbalancers: add StartSyncstatus method for EipAssociateTask
* regiondrivers: kvm: allow creation of vpc lb
* loadbalanceragents: add timestamp fields for network objects
* climc: eips: add associate type loadbalancer
* mcclient: loadbalancernetworks: add Mac_Addr column
* vpcagent: models: add loadbalancernetworks
* vpcagent: ovn: route back vpc cidr block instead of all rest
* vpcagent: ovn: add ClaimLoadbalancerNetwork()
* mcclient: models: add LoadbalancerNetwork
* mcclient: models: add Network
* lbagent: models: use IBaseManager to accomodate joint manager
* lbagent: models: add {,Loadbalancer}Networks
* lbagent: models: export a few fields
* lbagent: models: add fields for vpc lb models
* iproute2: add NewAddressEx constructor
* lbagent: add worker for vpc lb
* vendor: add github.com/coreos/go-iptables
* lbagent: apihelper: use ovn worker
* lbagent: models: use pkg/compute/models
* mcclient: models: remove lb models
* lbagent: api: use pkg/apihelper
* vpcagent: models: add lblisteners and lbacls
* vpcagent: ovn: add lbacl support
156 lines
3.5 KiB
Go
156 lines
3.5 KiB
Go
// Copyright 2019 Yunion
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package models
|
|
|
|
import (
|
|
computeapi "yunion.io/x/onecloud/pkg/apis/compute"
|
|
"yunion.io/x/onecloud/pkg/compute/models"
|
|
)
|
|
|
|
type Network struct {
|
|
*models.SNetwork
|
|
}
|
|
|
|
func (el *Network) Copy() *Network {
|
|
return &Network{
|
|
SNetwork: el.SNetwork,
|
|
}
|
|
}
|
|
|
|
type LoadbalancerNetwork struct {
|
|
*models.SLoadbalancerNetwork
|
|
|
|
Loadbalancer *Loadbalancer `json:"-"`
|
|
Network *Network `json:"-"`
|
|
}
|
|
|
|
func (el *LoadbalancerNetwork) Copy() *LoadbalancerNetwork {
|
|
return &LoadbalancerNetwork{
|
|
SLoadbalancerNetwork: el.SLoadbalancerNetwork,
|
|
}
|
|
}
|
|
|
|
type Loadbalancer struct {
|
|
*models.SLoadbalancer
|
|
|
|
LoadbalancerNetwork *LoadbalancerNetwork `json:"-"`
|
|
Listeners LoadbalancerListeners
|
|
BackendGroups LoadbalancerBackendGroups
|
|
|
|
ListenAddress string
|
|
}
|
|
|
|
func (el *Loadbalancer) Copy() *Loadbalancer {
|
|
return &Loadbalancer{
|
|
SLoadbalancer: el.SLoadbalancer,
|
|
}
|
|
}
|
|
|
|
func (lb *Loadbalancer) GetAddress() string {
|
|
if lb.NetworkType == computeapi.LB_NETWORK_TYPE_VPC {
|
|
return lb.ListenAddress
|
|
}
|
|
return lb.Address
|
|
}
|
|
|
|
type LoadbalancerListener struct {
|
|
*models.SLoadbalancerListener
|
|
|
|
loadbalancer *Loadbalancer
|
|
certificate *LoadbalancerCertificate
|
|
rules LoadbalancerListenerRules
|
|
}
|
|
|
|
func (el *LoadbalancerListener) Copy() *LoadbalancerListener {
|
|
return &LoadbalancerListener{
|
|
SLoadbalancerListener: el.SLoadbalancerListener,
|
|
}
|
|
}
|
|
|
|
type LoadbalancerListenerRule struct {
|
|
*models.SLoadbalancerListenerRule
|
|
|
|
listener *LoadbalancerListener
|
|
}
|
|
|
|
func (el *LoadbalancerListenerRule) Copy() *LoadbalancerListenerRule {
|
|
return &LoadbalancerListenerRule{
|
|
SLoadbalancerListenerRule: el.SLoadbalancerListenerRule,
|
|
}
|
|
}
|
|
|
|
type LoadbalancerBackendGroup struct {
|
|
*models.SLoadbalancerBackendGroup
|
|
|
|
Backends LoadbalancerBackends
|
|
loadbalancer *Loadbalancer
|
|
}
|
|
|
|
func (el *LoadbalancerBackendGroup) Copy() *LoadbalancerBackendGroup {
|
|
return &LoadbalancerBackendGroup{
|
|
SLoadbalancerBackendGroup: el.SLoadbalancerBackendGroup,
|
|
}
|
|
}
|
|
|
|
type LoadbalancerBackend struct {
|
|
*models.SLoadbalancerBackend
|
|
|
|
backendGroup *LoadbalancerBackendGroup
|
|
|
|
ConnectAddress string
|
|
ConnectPort int
|
|
}
|
|
|
|
func (el *LoadbalancerBackend) Copy() *LoadbalancerBackend {
|
|
return &LoadbalancerBackend{
|
|
SLoadbalancerBackend: el.SLoadbalancerBackend,
|
|
}
|
|
}
|
|
|
|
func (lbbackend *LoadbalancerBackend) GetAddressPort() (addr string, port int) {
|
|
backendGroup := lbbackend.backendGroup
|
|
if backendGroup == nil {
|
|
return
|
|
}
|
|
lb := backendGroup.loadbalancer
|
|
if lb == nil {
|
|
return
|
|
}
|
|
if lb.NetworkType == computeapi.LB_NETWORK_TYPE_VPC {
|
|
return lbbackend.ConnectAddress, lbbackend.ConnectPort
|
|
}
|
|
return lbbackend.Address, lbbackend.Port
|
|
}
|
|
|
|
type LoadbalancerAcl struct {
|
|
*models.SLoadbalancerAcl
|
|
}
|
|
|
|
func (el *LoadbalancerAcl) Copy() *LoadbalancerAcl {
|
|
return &LoadbalancerAcl{
|
|
SLoadbalancerAcl: el.SLoadbalancerAcl,
|
|
}
|
|
}
|
|
|
|
type LoadbalancerCertificate struct {
|
|
*models.SLoadbalancerCertificate
|
|
}
|
|
|
|
func (el *LoadbalancerCertificate) Copy() *LoadbalancerCertificate {
|
|
return &LoadbalancerCertificate{
|
|
SLoadbalancerCertificate: el.SLoadbalancerCertificate,
|
|
}
|
|
}
|