mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-30 17:13:08 +08:00
fix: vpc distributes static routes (#25211)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -46,6 +46,7 @@ type IModelSet interface {
|
||||
NewModel() db.IModel
|
||||
AddModel(db.IModel)
|
||||
Copy() IModelSet
|
||||
IncludeDetails() bool
|
||||
}
|
||||
|
||||
type IDBModelSet interface {
|
||||
@@ -107,7 +108,7 @@ func syncModelSets(mssOld IModelSets, s *mcclient.ClientSession, opt *Options) (
|
||||
ModelSet: msNew,
|
||||
BatchListSize: opt.ListBatchSize,
|
||||
|
||||
IncludeDetails: opt.IncludeDetails,
|
||||
IncludeDetails: msNew.IncludeDetails(),
|
||||
IncludeEmulated: includeEmulated,
|
||||
InCludeOtherCloudEnv: opt.IncludeOtherCloudEnv,
|
||||
})
|
||||
@@ -134,7 +135,7 @@ func SyncDBModelSets(mssOld IModelSets, s *mcclient.ClientSession, opt *Options)
|
||||
ModelSet: msNew,
|
||||
BatchListSize: opt.ListBatchSize,
|
||||
|
||||
IncludeDetails: opt.IncludeDetails,
|
||||
IncludeDetails: msNew.IncludeDetails(),
|
||||
IncludeEmulated: includeEmulated,
|
||||
InCludeOtherCloudEnv: opt.IncludeOtherCloudEnv,
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ func (set ProxyEndpoints) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set ProxyEndpoints) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ms ProxyEndpoints) joinForwards(subEntries Forwards) bool {
|
||||
correct := true
|
||||
for _, subEntry := range subEntries {
|
||||
@@ -88,3 +92,7 @@ func (set Forwards) Copy() apihelper.IModelSet {
|
||||
}
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Forwards) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -59,6 +59,10 @@ func (set Networks) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Networks) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set LoadbalancerNetworks) ModelManager() modulebase.IBaseManager {
|
||||
return &modules.Loadbalancernetworks
|
||||
}
|
||||
@@ -82,6 +86,10 @@ func (set LoadbalancerNetworks) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set LoadbalancerNetworks) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set LoadbalancerNetworks) JoinLoadbalancers(entries Loadbalancers) bool {
|
||||
for mKey, m := range set {
|
||||
lbId := m.LoadbalancerId
|
||||
@@ -150,6 +158,10 @@ func (set Loadbalancers) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Loadbalancers) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ms Loadbalancers) JoinListeners(subEntries LoadbalancerListeners) bool {
|
||||
for _, m := range ms {
|
||||
m.Listeners = LoadbalancerListeners{}
|
||||
@@ -225,6 +237,10 @@ func (set LoadbalancerListeners) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set LoadbalancerListeners) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ms LoadbalancerListeners) JoinListenerRules(subEntries LoadbalancerListenerRules) bool {
|
||||
for _, m := range ms {
|
||||
m.rules = LoadbalancerListenerRules{}
|
||||
@@ -311,6 +327,10 @@ func (set LoadbalancerListenerRules) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set LoadbalancerListenerRules) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type OrderedLoadbalancerListenerRuleList []*LoadbalancerListenerRule
|
||||
|
||||
func (lst OrderedLoadbalancerListenerRuleList) Len() int {
|
||||
@@ -375,6 +395,10 @@ func (set LoadbalancerBackendGroups) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set LoadbalancerBackendGroups) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ms LoadbalancerBackendGroups) JoinBackends(subEntries LoadbalancerBackends) bool {
|
||||
for _, m := range ms {
|
||||
m.Backends = LoadbalancerBackends{}
|
||||
@@ -425,6 +449,10 @@ func (set LoadbalancerBackends) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set LoadbalancerBackends) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set LoadbalancerAcls) ModelManager() modulebase.IBaseManager {
|
||||
return &modules.LoadbalancerAcls
|
||||
}
|
||||
@@ -451,6 +479,10 @@ func (set LoadbalancerAcls) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set LoadbalancerAcls) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set LoadbalancerCertificates) ModelManager() modulebase.IBaseManager {
|
||||
return &modules.LoadbalancerCertificates
|
||||
}
|
||||
@@ -476,3 +508,7 @@ func (set LoadbalancerCertificates) Copy() apihelper.IModelSet {
|
||||
}
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set LoadbalancerCertificates) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -129,6 +129,10 @@ func (s Servers) Copy() apihelper.IModelSet {
|
||||
return s
|
||||
}
|
||||
|
||||
func (set Servers) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Servers) GetResType() string {
|
||||
return monitor.METRIC_RES_TYPE_GUEST
|
||||
}
|
||||
@@ -150,6 +154,10 @@ func (h Hosts) Copy() apihelper.IModelSet {
|
||||
return h
|
||||
}
|
||||
|
||||
func (set Hosts) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (h Hosts) ModelManager() modulebase.IBaseManager {
|
||||
return &compute.Hosts
|
||||
}
|
||||
@@ -189,6 +197,10 @@ func (r Rds) Copy() apihelper.IModelSet {
|
||||
return r
|
||||
}
|
||||
|
||||
func (set Rds) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (r Rds) GetResType() string {
|
||||
return monitor.METRIC_RES_TYPE_RDS
|
||||
}
|
||||
@@ -214,6 +226,10 @@ func (r Redis) Copy() apihelper.IModelSet {
|
||||
return r
|
||||
}
|
||||
|
||||
func (set Redis) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (r Redis) GetResType() string {
|
||||
return monitor.METRIC_RES_TYPE_REDIS
|
||||
}
|
||||
@@ -239,6 +255,10 @@ func (o Oss) Copy() apihelper.IModelSet {
|
||||
return o
|
||||
}
|
||||
|
||||
func (set Oss) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (o Oss) GetResType() string {
|
||||
return monitor.METRIC_RES_TYPE_OSS
|
||||
}
|
||||
@@ -265,6 +285,10 @@ func (a Accounts) Copy() apihelper.IModelSet {
|
||||
return a
|
||||
}
|
||||
|
||||
func (set Accounts) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (a Accounts) GetResType() string {
|
||||
return monitor.METRIC_RES_TYPE_CLOUDACCOUNT
|
||||
}
|
||||
@@ -290,6 +314,10 @@ func (s Storages) Copy() apihelper.IModelSet {
|
||||
return s
|
||||
}
|
||||
|
||||
func (set Storages) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Storages) GetResType() string {
|
||||
return monitor.METRIC_RES_TYPE_STORAGE
|
||||
}
|
||||
@@ -321,6 +349,10 @@ func (d Domains) Copy() apihelper.IModelSet {
|
||||
return d
|
||||
}
|
||||
|
||||
func (set Domains) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (d Domains) GetResType() string {
|
||||
return monitor.METRIC_RES_TYPE_DOMAIN
|
||||
}
|
||||
@@ -346,6 +378,10 @@ func (p Projects) Copy() apihelper.IModelSet {
|
||||
return p
|
||||
}
|
||||
|
||||
func (set Projects) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p Projects) GetResType() string {
|
||||
return monitor.METRIC_RES_TYPE_TENANT
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ func (el *Wire) Copy() *Wire {
|
||||
type Network struct {
|
||||
compute_models.SNetwork
|
||||
|
||||
Routes [][]string `json:"routes"`
|
||||
|
||||
Vpc *Vpc `json:"-"`
|
||||
Wire *Wire `json:"-"`
|
||||
Guestnetworks Guestnetworks `json:"-"`
|
||||
@@ -77,6 +79,7 @@ type Network struct {
|
||||
func (el *Network) Copy() *Network {
|
||||
return &Network{
|
||||
SNetwork: el.SNetwork,
|
||||
Routes: el.Routes,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,10 @@ func (set Vpcs) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Vpcs) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Vpcs) ModelParamFilter() jsonutils.JSONObject {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString("OneCloud"), "provider")
|
||||
@@ -188,6 +192,10 @@ func (set Wires) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Wires) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Wires) IncludeEmulated() bool {
|
||||
return true
|
||||
}
|
||||
@@ -237,6 +245,10 @@ func (set Guests) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Guests) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Guests) ModelParamFilter() jsonutils.JSONObject {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString("OneCloud"), "provider")
|
||||
@@ -352,6 +364,10 @@ func (set Hosts) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Hosts) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Hosts) ModelParamFilter() jsonutils.JSONObject {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewString("OneCloud"), "provider")
|
||||
@@ -389,6 +405,10 @@ func (set Networks) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Networks) IncludeDetails() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (ms Networks) joinGuestnetworks(subEntries Guestnetworks) bool {
|
||||
for _, m := range ms {
|
||||
m.Guestnetworks = Guestnetworks{}
|
||||
@@ -506,6 +526,10 @@ func (set Guestnetworks) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Guestnetworks) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Guestnetworks) joinGuests(subEntries Guests) bool {
|
||||
for _, gn := range set {
|
||||
gId := gn.GuestId
|
||||
@@ -626,6 +650,10 @@ func (set Guestnetworksecgroups) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Guestnetworksecgroups) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Guestnetworksecgroups) joinSecurityGroups(subEntries SecurityGroups) bool {
|
||||
for _, gns := range set {
|
||||
key := gns.SecgroupId
|
||||
@@ -663,6 +691,10 @@ func (set NetworkAddresses) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set NetworkAddresses) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set SecurityGroups) ModelManager() mcclient_modulebase.IBaseManager {
|
||||
return &mcclient_modules.SecGroups
|
||||
}
|
||||
@@ -688,6 +720,10 @@ func (set SecurityGroups) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set SecurityGroups) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ms SecurityGroups) joinSecurityGroupRules(subEntries SecurityGroupRules) bool {
|
||||
for _, m := range ms {
|
||||
m.SecurityGroupRules = SecurityGroupRules{}
|
||||
@@ -740,6 +776,10 @@ func (set SecurityGroupRules) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set SecurityGroupRules) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Guestsecgroups) ModelManager() mcclient_modulebase.IBaseManager {
|
||||
return &mcclient_modules.Serversecgroups
|
||||
}
|
||||
@@ -765,6 +805,10 @@ func (set Guestsecgroups) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Guestsecgroups) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Guestsecgroups) joinSecurityGroups(subEntries SecurityGroups) bool {
|
||||
for _, el := range set {
|
||||
secgroupId := el.SecgroupId
|
||||
@@ -835,6 +879,10 @@ func (set Elasticips) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Elasticips) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set DnsZones) ModelManager() mcclient_modulebase.IBaseManager {
|
||||
return &mcclient_modules.DnsZones
|
||||
}
|
||||
@@ -860,6 +908,10 @@ func (set DnsZones) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set DnsZones) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ms DnsZones) joinRecords(subEntries DnsRecords) bool {
|
||||
correct := true
|
||||
for _, subEntry := range subEntries {
|
||||
@@ -900,6 +952,10 @@ func (set DnsRecords) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set DnsRecords) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set RouteTables) ModelManager() mcclient_modulebase.IBaseManager {
|
||||
return &mcclient_modules.RouteTables
|
||||
}
|
||||
@@ -925,6 +981,10 @@ func (set RouteTables) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set RouteTables) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Groupguests) ModelManager() mcclient_modulebase.IBaseManager {
|
||||
return &mcclient_modules.InstanceGroupGuests
|
||||
}
|
||||
@@ -951,6 +1011,10 @@ func (set Groupguests) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Groupguests) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set LoadbalancerNetworks) ModelManager() mcclient_modulebase.IBaseManager {
|
||||
return &mcclient_modules.Loadbalancernetworks
|
||||
}
|
||||
@@ -977,6 +1041,10 @@ func (set LoadbalancerNetworks) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set LoadbalancerNetworks) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Groupnetworks) ModelManager() mcclient_modulebase.IBaseManager {
|
||||
return &mcclient_modules.InstancegroupNetworks
|
||||
}
|
||||
@@ -1003,6 +1071,10 @@ func (set Groupnetworks) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Groupnetworks) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Groupnetworks) joinElasticips(subEntries Elasticips) bool {
|
||||
correct := true
|
||||
for _, gn := range set {
|
||||
@@ -1055,6 +1127,10 @@ func (set Groups) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set Groups) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set Groups) joinGroupnetworks(subEntries Groupnetworks, networks Networks) bool {
|
||||
ret := true
|
||||
for _, gn := range subEntries {
|
||||
@@ -1155,6 +1231,10 @@ func (set LoadbalancerListeners) Copy() apihelper.IModelSet {
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set LoadbalancerListeners) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (set LoadbalancerListeners) joinLoadbalancerAcls(subEntries LoadbalancerAcls) bool {
|
||||
for _, m := range set {
|
||||
if m.AclStatus != computeapis.LB_BOOL_ON {
|
||||
@@ -1194,3 +1274,7 @@ func (set LoadbalancerAcls) Copy() apihelper.IModelSet {
|
||||
}
|
||||
return setCopy
|
||||
}
|
||||
|
||||
func (set LoadbalancerAcls) IncludeDetails() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -516,6 +516,20 @@ func generateDhcpOptions(ctx context.Context, guestnetwork *agentmodels.Guestnet
|
||||
}
|
||||
{
|
||||
routes := []string{}
|
||||
if len(network.Routes) > 0 {
|
||||
for i := range network.Routes {
|
||||
if len(network.Routes[i]) > 0 {
|
||||
if network.Routes[i][0] == "0.0.0.0/0" || network.Routes[i][0] == mdIp {
|
||||
continue
|
||||
}
|
||||
if len(network.Routes[i]) == 2 {
|
||||
routes = append(routes, network.Routes[i][0], network.Routes[i][1])
|
||||
} else if len(network.Routes[i]) == 1 {
|
||||
routes = append(routes, network.Routes[i][0], "0.0.0.0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if guestnetwork.IsDefault {
|
||||
dhcpopts.Options["router"] = network.GuestGateway
|
||||
routes = append(routes,
|
||||
|
||||
Reference in New Issue
Block a user