defaults.go 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 algorithmprovider
  15. import (
  16. "yunion.io/x/pkg/util/sets"
  17. "yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates"
  18. predicateguest "yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates/guest"
  19. priorityguest "yunion.io/x/onecloud/pkg/scheduler/algorithm/priorities/guest"
  20. "yunion.io/x/onecloud/pkg/scheduler/factory"
  21. )
  22. func init() {
  23. factory.RegisterAlgorithmProvider(factory.DefaultProvider, defaultPredicates(), defaultPriorities())
  24. }
  25. func defaultPredicates() sets.String {
  26. return sets.NewString(
  27. factory.RegisterFitPredicate("a-GuestHostStatusFilter", &predicateguest.StatusPredicate{}),
  28. factory.RegisterFitPredicate("b-GuestHypervisorFilter", &predicateguest.HypervisorPredicate{}),
  29. factory.RegisterFitPredicate("c-GuestHostschedtagFilter", predicates.NewHostSchedtagPredicate()),
  30. factory.RegisterFitPredicate("d-GuestMigrateFilter", &predicateguest.MigratePredicate{}),
  31. factory.RegisterFitPredicate("e-GuestDomainFilter", &predicates.DomainPredicate{}),
  32. factory.RegisterFitPredicate("e-GuestImageFilter", &predicateguest.ImagePredicate{}),
  33. factory.RegisterFitPredicate("f-ClassMetadataFilter", &predicates.ClassMetadataPredicate{}),
  34. //factory.RegisterFitPredicate("f-GuestGroupFilter", &predicateguest.GroupPredicate{}),
  35. factory.RegisterFitPredicate("g-GuestCPUFilter", &predicateguest.CPUPredicate{}),
  36. factory.RegisterFitPredicate("h-GuestMemoryFilter", &predicateguest.MemoryPredicate{}),
  37. factory.RegisterFitPredicate("i-GuestStorageFilter", &predicateguest.StoragePredicate{}),
  38. factory.RegisterFitPredicate("j-GuestNetworkFilter", predicates.NewNetworkPredicateWithNicCounter()),
  39. factory.RegisterFitPredicate("k-GuestIsolatedDeviceFilter", &predicates.IsolatedDevicePredicate{}),
  40. factory.RegisterFitPredicate("l-GuestResourceTypeFilter", &predicates.ResourceTypePredicate{}),
  41. factory.RegisterFitPredicate("m-GuestDiskschedtagFilter", &predicates.DiskSchedtagPredicate{}),
  42. factory.RegisterFitPredicate("n-ServerSkuFilter", &predicates.InstanceTypePredicate{}),
  43. factory.RegisterFitPredicate("o-GuestNetschedtagFilter", &predicates.NetworkSchedtagPredicate{}),
  44. factory.RegisterFitPredicate("p-CloudproviderschedtagFilter", predicates.NewCloudproviderSchedtagPredicate()),
  45. factory.RegisterFitPredicate("q-CloudregionschedtagFilter", predicates.NewCloudregionSchedtagPredicate()),
  46. factory.RegisterFitPredicate("r-ZoneschedtagFilter", predicates.NewZoneSchedtagPredicate()),
  47. factory.RegisterFitPredicate("z-QuotaFilter", &predicates.SQuotaPredicate{}),
  48. )
  49. }
  50. func defaultPriorities() sets.String {
  51. return sets.NewString(
  52. factory.RegisterPriority("guest-avoid-same-host", &priorityguest.AvoidSameHostPriority{}, 1),
  53. factory.RegisterPriority("guest-lowload", &priorityguest.LowLoadPriority{}, 1),
  54. factory.RegisterPriority("guest-creating", &priorityguest.CreatingPriority{}, 1),
  55. factory.RegisterPriority("guest-capacity", &priorityguest.CapacityPriority{}, 1),
  56. factory.RegisterPriority("guest-cpunumapin", &priorityguest.CpuNumaPinPriority{}, 1),
  57. )
  58. }