diff --git a/src/nebula/NebulaTemplate.cc b/src/nebula/NebulaTemplate.cc index 92ae4292f5..e0d2c590c8 100644 --- a/src/nebula/NebulaTemplate.cc +++ b/src/nebula/NebulaTemplate.cc @@ -75,7 +75,6 @@ const char * OpenNebulaTemplate::conf_name="oned.conf"; void OpenNebulaTemplate::set_conf_default() { - ostringstream os; SingleAttribute * attribute; VectorAttribute * vattribute; string value; diff --git a/src/scheduler/etc/sched.conf b/src/scheduler/etc/sched.conf new file mode 100644 index 0000000000..a35db8e55d --- /dev/null +++ b/src/scheduler/etc/sched.conf @@ -0,0 +1,51 @@ +#******************************************************************************* +# OpenNebula Configuration file +#******************************************************************************* + +#******************************************************************************* +# Daemon configuration attributes +#------------------------------------------------------------------------------- +# ONED_PORT: Port to connect to the OpenNebula daemon (oned) +# +# SCHED_INTERVAL: Seconds between two scheduling actions +# +# MAX_VM: Maximum number of Virtual Machines scheduled in each scheduling +# action +# +# MAX_DISPATCH: Maximum number of Virtual Machines actually dispatched to a +# host in each scheduling action +# +# MAX_HOST: Maximum number of Virtual Machines dispatched to a given host in +# each scheduling action +# +# DEFAULT_SCHED: Definition of the default scheduling algorithm +# - policy: +# 0 = Packing. Heuristic that minimizes the number of hosts in use by +# packing the VMs in the hosts to reduce VM fragmentation +# 1 = Striping. Heuristic that tries to maximize resources available for +# the VMs by spreading the VMs in the hosts +# 2 = Load-aware. Heuristic that tries to maximize resources available for +# the VMs by usingthose nodes with less load +# 3 = Custom. +# - rank: Custom arithmetic exprission to rank suitable hosts based in their +# attributes +#******************************************************************************* + +ONED_PORT = 2633 + +SCHED_INTERVAL = 30 + +MAX_VM = 300 + +MAX_DISPATCH = 30 + +MAX_HOST = 1 + +DEFAULT_SCHED = [ + policy = 1 +] + +#DEFAULT_SCHED = [ +# policy = 3, +# rank = "- (RUNNING_VMS / 8 + FREE_CPU)" +#] diff --git a/src/scheduler/include/SchedulerTemplate.h b/src/scheduler/include/SchedulerTemplate.h new file mode 100644 index 0000000000..abda60ddc2 --- /dev/null +++ b/src/scheduler/include/SchedulerTemplate.h @@ -0,0 +1,45 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */ +/* */ +/* 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. */ +/* -------------------------------------------------------------------------- */ + +#ifndef SCHEDULER_TEMPLATE_H_ +#define SCHEDULER_TEMPLATE_H_ + +#include "NebulaTemplate.h" + + +class SchedulerTemplate : public NebulaTemplate +{ +public: + + SchedulerTemplate(const string& etc_location, const string& _var_location): + NebulaTemplate(etc_location, conf_name) + {}; + + ~SchedulerTemplate(){}; + +private: + /** + * Name for the configuration file, oned.conf + */ + static const char * conf_name; + + /** + * Sets the defaults value for the template + */ + void set_conf_default(); +}; + +#endif /*SCHEDULER_TEMPLATE_H_*/ diff --git a/src/scheduler/src/sched/SConstruct b/src/scheduler/src/sched/SConstruct index e66ebfacf2..076e86e9d7 100644 --- a/src/scheduler/src/sched/SConstruct +++ b/src/scheduler/src/sched/SConstruct @@ -21,7 +21,7 @@ import os lib_name='scheduler_sched' -source_files=['Scheduler.cc'] +source_files=['Scheduler.cc' , 'SchedulerTemplate.cc'] # Build library sched_env.StaticLibrary(lib_name, source_files) diff --git a/src/scheduler/src/sched/SchedulerTemplate.cc b/src/scheduler/src/sched/SchedulerTemplate.cc new file mode 100644 index 0000000000..2d5f1d2e15 --- /dev/null +++ b/src/scheduler/src/sched/SchedulerTemplate.cc @@ -0,0 +1,82 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */ +/* */ +/* 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. */ +/* -------------------------------------------------------------------------- */ + +#include "NebulaTemplate.h" + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +const char * OpenNebulaTemplate::conf_name="sched.conf"; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void OpenNebulaTemplate::set_conf_default() +{ + SingleAttribute * attribute; + VectorAttribute * vattribute; + string value; + +/* +#******************************************************************************* +# Daemon configuration attributes +#------------------------------------------------------------------------------- +# ONED_PORT +# SCHED_INTERVAL +# MAX_VM +# MAX_DISPATCH +# MAX_HOST +# DEFAULT_SCHED +#------------------------------------------------------------------------------- +*/ + // ONED_PORT + value = "2633"; + + attribute = new SingleAttribute("ONED_PORT",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + + // SCHED_INTERVAL + value = "30"; + + attribute = new SingleAttribute("SCHED_INTERVAL",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + + // MAX_VM + value = "300"; + + attribute = new SingleAttribute("MAX_VM",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + + // MAX_DISPATCH + value = "30"; + + attribute = new SingleAttribute("MAX_DISPATCH",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + + //MAX_HOST + value = "1"; + + attribute = new SingleAttribute("MAX_HOST",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + + //DEFAULT_SCHED [0: Packing, 1: Striping, 2: Load-aware, or 3:Custom] + map vvalue; + vvalue.insert(make_pair("POLICY","packing")); + + vattribute = new VectorAttribute("DEFAULT_SCHED",vvalue); + conf_default.insert(make_pair(attribute->name(),vattribute)); +} +