Skip to content

Commit

Permalink
Merge pull request #156 from michael-os/manage_sched_conf
Browse files Browse the repository at this point in the history
Manage sched.conf
  • Loading branch information
michael-os committed May 13, 2015
2 parents c6c51b5 + 8cf57c3 commit 4b973fa
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 20 deletions.
11 changes: 11 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,17 @@
$libvirtd_cfg = $one::params::libvirtd_cfg,
$libvirtd_source = $one::params::libvirtd_source,
$rubygems = $one::params::rubygems,
$sched_interval = $one::params::sched_interval,
$sched_max_vm = $one::params::sched_max_vm,
$sched_max_dispatch = $one::params::sched_max_dispatch,
$sched_max_host = $one::params::sched_max_host,
$sched_live_rescheds = $one::params::sched_live_rescheds,
$sched_default_policy = $one::params::sched_default_policy,
$sched_default_rank = $one::params::sched_default_rank,
$sched_default_ds_policy = $one::params::sched_default_ds_policy,
$sched_default_ds_rank = $one::params::sched_default_ds_rank,
$sched_log_system = $one::params::sched_log_system,
$sched_log_debug_level = $one::params::sched_log_debug_level,
) inherits one::params {
include one::install
include one::config
Expand Down
73 changes: 53 additions & 20 deletions manifests/oned/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,58 @@
# http://www.apache.org/licenses/LICENSE-2.0.html
#
class one::oned::config(
$hook_scripts_path = $one::hook_scripts_path,
$hook_scripts = $one::hook_scripts,
$vm_hook_scripts = $one::vm_hook_scripts,
$host_hook_scripts = $one::host_hook_scripts,
$oned_db = $one::oned_db,
$oned_db_user = $one::oned_db_user,
$oned_db_password = $one::oned_db_password,
$oned_db_host = $one::oned_db_host,
$oned_vm_submit_on_hold = $one::oned_vm_submit_on_hold,
$backup_script_path = $one::backup_script_path,
$backup_opts = $one::backup_opts,
$backup_dir = $one::backup_dir,
$backup_db = $one::backup_db,
$backup_db_user = $one::backup_db_user,
$backup_db_password = $one::backup_db_password,
$backup_db_host = $one::backup_db_host,
$backup_intervall = $one::backup_intervall,
$backup_keep = $one::backup_keep,
$debug_level = $one::debug_level,
$backend = $one::backend,
$hook_scripts_path = $one::hook_scripts_path,
$hook_scripts = $one::hook_scripts,
$vm_hook_scripts = $one::vm_hook_scripts,
$host_hook_scripts = $one::host_hook_scripts,
$oned_db = $one::oned_db,
$oned_db_user = $one::oned_db_user,
$oned_db_password = $one::oned_db_password,
$oned_db_host = $one::oned_db_host,
$oned_vm_submit_on_hold = $one::oned_vm_submit_on_hold,
$backup_script_path = $one::backup_script_path,
$backup_opts = $one::backup_opts,
$backup_dir = $one::backup_dir,
$backup_db = $one::backup_db,
$backup_db_user = $one::backup_db_user,
$backup_db_password = $one::backup_db_password,
$backup_db_host = $one::backup_db_host,
$backup_intervall = $one::backup_intervall,
$backup_keep = $one::backup_keep,
$debug_level = $one::debug_level,
$backend = $one::backend,
$sched_interval = $one::sched_interval,
$sched_max_vm = $one::sched_max_vm,
$sched_max_dispatch = $one::sched_max_dispatch,
$sched_max_host = $one::sched_max_host,
$sched_live_rescheds = $one::sched_live_rescheds,
$sched_default_policy = $one::sched_default_policy,
$sched_default_rank = $one::sched_default_rank,
$sched_default_ds_policy = $one::sched_default_ds_policy,
$sched_default_ds_rank = $one::sched_default_ds_rank,
$sched_log_system = $one::sched_log_system,
$sched_log_debug_level = $one::sched_log_debug_level,
) {

if ! member(['YES', 'NO'], $oned_vm_submit_on_hold) {
fail("oned_vm_submit_on_hold must be one of 'YES' or 'NO'. Actual value: ${oned_vm_submit_on_hold}")
}

validate_integer($sched_interval, undef, 1)
validate_integer($sched_max_vm, undef, 0)
validate_integer($sched_max_dispatch, undef, 1)
validate_integer($sched_max_host, undef, 1)
validate_integer($sched_live_rescheds, 1, 0)
validate_integer($sched_default_policy, 4, 0)
validate_string($sched_default_rank)
validate_integer($sched_default_ds_policy, 3, 0)
validate_string($sched_default_ds_rank)
if ! member(['file', 'syslog'], $sched_log_system) {
fail("sched_log_system must be one of 'file' or 'syslog'. Actual value: ${sched_log_system}")
}
validate_integer($sched_log_debug_level, 3, 0)


File {
owner => 'oneadmin',
group => 'oneadmin',
Expand All @@ -55,6 +81,13 @@
content => template('one/oned.conf.erb'),
}

file { '/etc/one/sched.conf':
ensure => 'file',
owner => 'root',
mode => '0640',
content => template('one/sched.conf.erb'),
}

file { '/usr/share/one':
ensure => 'directory',
mode => '0755',
Expand Down
13 changes: 13 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@
$backup_intervall = hiera ('one::oned::backup::intervall', '*/10')
$backup_keep = hiera ('one::oned::backup::keep', '-mtime +15')

# OpenNebula Scheduler parameters
$sched_interval = hiera ('one::oned::sched::sched_interval', 30)
$sched_max_vm = hiera ('one::oned::sched::max_vm', 5000)
$sched_max_dispatch = hiera ('one::oned::sched::max_dispatch', 30)
$sched_max_host = hiera ('one::oned::sched::max_host', 1)
$sched_live_rescheds = hiera ('one::oned::sched::live_rescheds', 0)
$sched_default_policy = hiera ('one::oned::sched::default_policy', 1)
$sched_default_rank = hiera ('one::oned::sched::default_rank', '- (RUNNING_VMS * 50 + FREE_CPU)')
$sched_default_ds_policy = hiera ('one::oned::sched::default_ds_policy', 1)
$sched_default_ds_rank = hiera ('one::oned::sched::default_ds_rank', '')
$sched_log_system = hiera ('one::oned::sched::log_system', 'file')
$sched_log_debug_level = hiera ('one::oned::sched::log_debug_level', 3)

# Data Validation

# the priv key is mandatory on the head.
Expand Down
5 changes: 5 additions & 0 deletions spec/classes/one__oned__config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
.with_owner('root') \
.with_mode('0640')
}
it { should contain_file('/etc/one/sched.conf') \
.with_ensure('file' )\
.with_owner('root') \
.with_mode('0640')
}
it { should contain_file('/usr/share/one/hooks') \
.with_ensure('directory') \
.with_mode('0750')
Expand Down
84 changes: 84 additions & 0 deletions templates/sched.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#*******************************************************************************
# OpenNebula Configuration file
#*******************************************************************************

#*******************************************************************************
# Daemon configuration attributes
#-------------------------------------------------------------------------------
# MESSAGE_SIZE: Buffer size in bytes for XML-RPC responses.
#
# 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. Use 0 to schedule all pending VMs each time.
#
# 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
#
# LIVE_RESCHEDS: Perform live (1) or cold migrations (0) when rescheduling a VM
#
# 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 using those nodes with less load
# 3 = Custom.
# - rank: Custom arithmetic exprission to rank suitable hosts based in their
# attributes
# 4 = Fixed. Hosts will be ranked according to the PRIORITY attribute found
# in the Host or Cluster template.
#
# DEFAULT_DS_SCHED: Definition of the default storage scheduling algorithm
# - policy:
# 0 = Packing. Tries to optimize storage usage by selecting the DS with
# less free space
# 1 = Striping. Tries to optimize I/O by distributing the VMs across
# datastores.
# 2 = Custom.
# - rank: Custom arithmetic exprission to rank suitable datastores based on
# their attributes
# 3 = Fixed. Datastores will be ranked according to the PRIORITY attribute
# found in the Datastore template.
#
#
# LOG: Configuration for the logging system
# - system: defines the logging system:
# file to log in the sched.log file
# syslog to use the syslog facilities
# - debug_level: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
#*******************************************************************************

MESSAGE_SIZE = 1073741824

ONED_PORT = 2633

SCHED_INTERVAL = <%= scope.lookupvar('one::sched_interval') %>

MAX_VM = <%= scope.lookupvar('one::sched_max_vm') %>
MAX_DISPATCH = <%= scope.lookupvar('one::sched_max_dispatch') %>
MAX_HOST = <%= scope.lookupvar('one::sched_max_host') %>

LIVE_RESCHEDS = <%= scope.lookupvar('one::sched_live_rescheds') %>

DEFAULT_SCHED = [
policy = <%= scope.lookupvar('one::sched_default_policy') %>,
rank = "<%= scope.lookupvar('one::sched_default_rank') %>"
]

DEFAULT_DS_SCHED = [
policy = <%= scope.lookupvar('one::sched_default_ds_policy') %>,
rank = "<%= scope.lookupvar('one::sched_default_ds_rank') %>"
]

LOG = [
system = "<%= scope.lookupvar('one::sched_log_system') %>",
debug_level = <%= scope.lookupvar('one::sched_log_debug_level') %>
]

0 comments on commit 4b973fa

Please sign in to comment.