loadbalancer_common.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 models
  15. import (
  16. "context"
  17. "yunion.io/x/jsonutils"
  18. api "yunion.io/x/onecloud/pkg/apis/compute"
  19. "yunion.io/x/onecloud/pkg/cloudcommon/db"
  20. "yunion.io/x/onecloud/pkg/mcclient"
  21. )
  22. type SLoadbalancerStatus struct {
  23. RuntimeStatus string `width:"36" charset:"ascii" nullable:"false" default:"init" list:"user"`
  24. }
  25. type ILoadbalancerSubResourceManager interface {
  26. db.IModelManager
  27. }
  28. // TODO
  29. // notify on post create/update/delete
  30. type SLoadbalancerNotifier struct{}
  31. func (n *SLoadbalancerNotifier) PostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) {
  32. return
  33. }
  34. type SLoadbalancerLogSkipper struct{}
  35. func (lls SLoadbalancerLogSkipper) skipLog(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
  36. data, ok := query.(*jsonutils.JSONDict)
  37. if !ok {
  38. return false
  39. }
  40. if val, _ := data.GetString(api.LBAGENT_QUERY_ORIG_KEY); val != api.LBAGENT_QUERY_ORIG_VAL {
  41. return false
  42. }
  43. return true
  44. }
  45. func (lls SLoadbalancerLogSkipper) ListSkipLog(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
  46. return lls.skipLog(ctx, userCred, query)
  47. }
  48. func (lls SLoadbalancerLogSkipper) GetSkipLog(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
  49. return lls.skipLog(ctx, userCred, query)
  50. }