// Creates a scheduler from the configuration file func (f *ConfigFactory) CreateFromConfig(policy schedulerapi.Policy) (*scheduler.Config, error) { glog.V(2).Infof("Creating scheduler from configuration: %v", policy) // validate the policy configuration if err := validation.ValidatePolicy(policy); err != nil { return nil, err } predicateKeys := sets.NewString() for _, predicate := range policy.Predicates { glog.V(2).Infof("Registering predicate: %s", predicate.Name) predicateKeys.Insert(RegisterCustomFitPredicate(predicate)) } priorityKeys := sets.NewString() for _, priority := range policy.Priorities { glog.V(2).Infof("Registering priority: %s", priority.Name) priorityKeys.Insert(RegisterCustomPriorityFunction(priority)) } extenders := make([]algorithm.SchedulerExtender, 0) if len(policy.ExtenderConfigs) != 0 { for ii := range policy.ExtenderConfigs { glog.V(2).Infof("Creating extender with config %+v", policy.ExtenderConfigs[ii]) if extender, err := scheduler.NewHTTPExtender(&policy.ExtenderConfigs[ii], policy.APIVersion); err != nil { return nil, err } else { extenders = append(extenders, extender) } } } return f.CreateFromKeys(predicateKeys, priorityKeys, extenders) }
func main() { plugin_url_ptr := flag.String("Scheduler Plugin", "http://192.168.3.2"+rest.PluginRestPort, "Scheduler Plugin url:port") flag.Parse() fmt.Println("Scheduler Plugin running at ", *plugin_url_ptr) //used for testing old version //rest.K8s2Plugin(*plugin_url_ptr) //extender, err := scheduler.NewHTTPExtender(&policy.ExtenderConfigs[ii], policy.APIVersion) var config schedulerapi.ExtenderConfig config.URLPrefix = "http://192.168.3.2:8084" config.FilterVerb = "filter" config.PrioritizeVerb = "prioritize" config.Weight = 1 config.EnableHttps = false config.TLSConfig = nil config.HTTPTimeout = DefaultExtenderTimeout scheduler.NewHTTPExtender(&config, rest.APIVERSION) extenderRequst(*plugin_url_ptr) }