diff --git a/doc/source/devref/filter_scheduler.rst b/doc/source/devref/filter_scheduler.rst index 9b75ab4a440f..9efba7ed2817 100644 --- a/doc/source/devref/filter_scheduler.rst +++ b/doc/source/devref/filter_scheduler.rst @@ -266,9 +266,24 @@ Weights Filter Scheduler uses so-called **weights** during its work. The Filter Scheduler weights hosts based on the config option -``scheduler_weight_classes``, this defaults to -``nova.scheduler.weights.all_weighers``, which selects the only weigher available --- the RamWeigher. Hosts are then weighted and sorted with the largest weight winning. +`scheduler_weight_classes`, this defaults to +`nova.scheduler.weights.all_weighers`, which selects all the available weighers +in the package nova.scheduler.weights. Hosts are then weighted and sorted with +the largest weight winning. For each host, the final weight is calculated by +summing up all weigher's weight value multiplying its own weight_mutiplier: + +:: + + final_weight = 0 + for each weigher: + final_weight += weigher's weight_mutiplier * weigher's calculated weight value + +The weigher's weight_mutiplier can be set in the configuration file, e.g. + +:: + + [metrics] + weight_multiplier=1.0 Filter Scheduler finds local list of acceptable hosts by repeated filtering and weighing. Each time it chooses a host, it virtually consumes resources on it, diff --git a/etc/nova/nova.conf.sample b/etc/nova/nova.conf.sample index 6e8eb50e5a36..9164600ec1b5 100644 --- a/etc/nova/nova.conf.sample +++ b/etc/nova/nova.conf.sample @@ -2035,97 +2035,24 @@ #cinder_cross_az_attach=true -[docker] +[keymgr] # -# Options defined in nova.virt.docker.driver +# Options defined in nova.keymgr # -# Default TCP port to find the docker-registry container -# (integer value) -#registry_default_port=5042 - - -[hyperv] - -# -# Options defined in nova.virt.hyperv.pathutils -# - -# The name of a Windows share name mapped to the -# "instances_path" dir and used by the resize feature to copy -# files to the target host. If left blank, an administrative -# share will be used, looking for the same "instances_path" -# used locally (string value) -#instances_path_share= - - -# -# Options defined in nova.virt.hyperv.utilsfactory -# - -# Force V1 WMI utility classes (boolean value) -#force_hyperv_utils_v1=false - -# Force V1 volume utility class (boolean value) -#force_volumeutils_v1=false - - -# -# Options defined in nova.virt.hyperv.vif -# - -# External virtual switch Name, if not provided, the first -# external virtual switch is used (string value) -#vswitch_name= - - -# -# Options defined in nova.virt.hyperv.vmops -# - -# Required for live migration among hosts with different CPU -# features (boolean value) -#limit_cpu_features=false - -# Sets the admin password in the config drive image (boolean +# The full class name of the key manager API class (string # value) -#config_drive_inject_password=false - -# qemu-img is used to convert between different image types -# (string value) -#qemu_img_cmd=qemu-img.exe - -# Attaches the Config Drive image as a cdrom drive instead of -# a disk drive (boolean value) -#config_drive_cdrom=false - -# Enables metrics collections for an instance by using -# Hyper-V's metric APIs. Collected data can by retrieved by -# other apps and services, e.g.: Ceilometer. Requires Hyper-V -# / Windows Server 2012 and above (boolean value) -#enable_instance_metrics_collection=false - -# Enables dynamic memory allocation (ballooning) when set to a -# value greater than 1. The value expresses the ratio between -# the total RAM assigned to an instance and its startup RAM -# amount. For example a ratio of 2.0 for an instance with -# 1024MB of RAM implies 512MB of RAM allocated at startup -# (floating point value) -#dynamic_memory_ratio=1.0 +#api_class=nova.keymgr.conf_key_mgr.ConfKeyManager # -# Options defined in nova.virt.hyperv.volumeops +# Options defined in nova.keymgr.conf_key_mgr # -# The number of times to retry to attach a volume (integer +# Fixed key returned by key manager, specified in hex (string # value) -#volume_attach_retry_count=10 - -# Interval between volume attachment attempts, in seconds -# (integer value) -#volume_attach_retry_interval=5 +#fixed_key= [zookeeper] @@ -2150,6 +2077,109 @@ #sg_retry_interval=5 +[image_file_url] + +# +# Options defined in nova.image.download.file +# + +# A list of filesystems that will be configured in this file +# under the sections image_file_url: (list +# value) +#filesystems= + + +[vmware] + +# +# Options defined in nova.virt.vmwareapi.driver +# + +# URL for connection to VMware ESX/VC host. Required if +# compute_driver is vmwareapi.VMwareESXDriver or +# vmwareapi.VMwareVCDriver. (string value) +#host_ip= + +# Username for connection to VMware ESX/VC host. Used only if +# compute_driver is vmwareapi.VMwareESXDriver or +# vmwareapi.VMwareVCDriver. (string value) +#host_username= + +# Password for connection to VMware ESX/VC host. Used only if +# compute_driver is vmwareapi.VMwareESXDriver or +# vmwareapi.VMwareVCDriver. (string value) +#host_password= + +# Name of a VMware Cluster ComputeResource. Used only if +# compute_driver is vmwareapi.VMwareVCDriver. (multi valued) +#cluster_name= + +# Regex to match the name of a datastore. Used only if +# compute_driver is vmwareapi.VMwareVCDriver. (string value) +#datastore_regex= + +# The interval used for polling of remote tasks. Used only if +# compute_driver is vmwareapi.VMwareESXDriver or +# vmwareapi.VMwareVCDriver. (floating point value) +#task_poll_interval=5.0 + +# The number of times we retry on failures, e.g., socket +# error, etc. Used only if compute_driver is +# vmwareapi.VMwareESXDriver or vmwareapi.VMwareVCDriver. +# (integer value) +#api_retry_count=10 + +# VNC starting port (integer value) +#vnc_port=5900 + +# Total number of VNC ports (integer value) +#vnc_port_total=10000 + +# Whether to use linked clone (boolean value) +#use_linked_clone=true + + +# +# Options defined in nova.virt.vmwareapi.vif +# + +# Physical ethernet adapter name for vlan networking (string +# value) +#vlan_interface=vmnic0 + + +# +# Options defined in nova.virt.vmwareapi.vim +# + +# Optional VIM Service WSDL Location e.g +# http:///vimService.wsdl. Optional over-ride to +# default location for bug work-arounds (string value) +#wsdl_location= + + +# +# Options defined in nova.virt.vmwareapi.vim_util +# + +# The maximum number of ObjectContent data objects that should +# be returned in a single result. A positive value will cause +# the operation to suspend the retrieval when the count of +# objects reaches the specified maximum. The server may still +# limit the count to something less than the configured value. +# Any remaining objects may be retrieved with additional +# requests. (integer value) +#maximum_objects=100 + + +# +# Options defined in nova.virt.vmwareapi.vmops +# + +# Name of Integration Bridge (string value) +#integration_bridge=br-int + + [osapi_v3] # @@ -2169,6 +2199,246 @@ #extensions_whitelist= +[xenserver] + +# +# Options defined in nova.virt.xenapi.agent +# + +# number of seconds to wait for agent reply (integer value) +#agent_timeout=30 + +# number of seconds to wait for agent to be fully operational +# (integer value) +#agent_version_timeout=300 + +# number of seconds to wait for agent reply to resetnetwork +# request (integer value) +#agent_resetnetwork_timeout=60 + +# Specifies the path in which the xenapi guest agent should be +# located. If the agent is present, network configuration is +# not injected into the image. Used if +# compute_driver=xenapi.XenAPIDriver and flat_injected=True +# (string value) +#agent_path=usr/sbin/xe-update-networking + +# Disables the use of the XenAPI agent in any image regardless +# of what image properties are present. (boolean value) +#disable_agent=false + +# Determines if the xenapi agent should be used when the image +# used does not contain a hint to declare if the agent is +# present or not. The hint is a glance property +# "xenapi_use_agent" that has the value "true" or "false". +# Note that waiting for the agent when it is not present will +# significantly increase server boot times. (boolean value) +#use_agent_default=false + + +# +# Options defined in nova.virt.xenapi.client.session +# + +# Timeout in seconds for XenAPI login. (integer value) +#login_timeout=10 + +# Maximum number of concurrent XenAPI connections. Used only +# if compute_driver=xenapi.XenAPIDriver (integer value) +#connection_concurrent=5 + + +# +# Options defined in nova.virt.xenapi.driver +# + +# URL for connection to XenServer/Xen Cloud Platform. A +# special value of unix://local can be used to connect to the +# local unix socket. Required if +# compute_driver=xenapi.XenAPIDriver (string value) +#connection_url= + +# Username for connection to XenServer/Xen Cloud Platform. +# Used only if compute_driver=xenapi.XenAPIDriver (string +# value) +#connection_username=root + +# Password for connection to XenServer/Xen Cloud Platform. +# Used only if compute_driver=xenapi.XenAPIDriver (string +# value) +#connection_password= + +# The interval used for polling of coalescing vhds. Used only +# if compute_driver=xenapi.XenAPIDriver (floating point value) +#vhd_coalesce_poll_interval=5.0 + +# Ensure compute service is running on host XenAPI connects +# to. (boolean value) +#check_host=true + +# Max number of times to poll for VHD to coalesce. Used only +# if compute_driver=xenapi.XenAPIDriver (integer value) +#vhd_coalesce_max_attempts=5 + +# Base path to the storage repository (string value) +#sr_base_path=/var/run/sr-mount + +# iSCSI Target Host (string value) +#target_host= + +# iSCSI Target Port, 3260 Default (string value) +#target_port=3260 + +# IQN Prefix (string value) +#iqn_prefix=iqn.2010-10.org.openstack + +# Used to enable the remapping of VBD dev (Works around an +# issue in Ubuntu Maverick) (boolean value) +#remap_vbd_dev=false + +# Specify prefix to remap VBD dev to (ex. /dev/xvdb -> +# /dev/sdb) (string value) +#remap_vbd_dev_prefix=sd + + +# +# Options defined in nova.virt.xenapi.image.bittorrent +# + +# Base URL for torrent files. (string value) +#torrent_base_url= + +# Probability that peer will become a seeder. (1.0 = 100%) +# (floating point value) +#torrent_seed_chance=1.0 + +# Number of seconds after downloading an image via BitTorrent +# that it should be seeded for other peers. (integer value) +#torrent_seed_duration=3600 + +# Cached torrent files not accessed within this number of +# seconds can be reaped (integer value) +#torrent_max_last_accessed=86400 + +# Beginning of port range to listen on (integer value) +#torrent_listen_port_start=6881 + +# End of port range to listen on (integer value) +#torrent_listen_port_end=6891 + +# Number of seconds a download can remain at the same progress +# percentage w/o being considered a stall (integer value) +#torrent_download_stall_cutoff=600 + +# Maximum number of seeder processes to run concurrently +# within a given dom0. (-1 = no limit) (integer value) +#torrent_max_seeder_processes_per_host=1 + + +# +# Options defined in nova.virt.xenapi.pool +# + +# To use for hosts with different CPUs (boolean value) +#use_join_force=true + + +# +# Options defined in nova.virt.xenapi.vif +# + +# Name of Integration Bridge used by Open vSwitch (string +# value) +#ovs_integration_bridge=xapi1 + + +# +# Options defined in nova.virt.xenapi.vm_utils +# + +# Cache glance images locally. `all` will cache all images, +# `some` will only cache images that have the image_property +# `cache_in_nova=True`, and `none` turns off caching entirely +# (string value) +#cache_images=all + +# Compression level for images, e.g., 9 for gzip -9. Range is +# 1-9, 9 being most compressed but most CPU intensive on dom0. +# (integer value) +#image_compression_level= + +# Default OS type (string value) +#default_os_type=linux + +# Time to wait for a block device to be created (integer +# value) +#block_device_creation_timeout=10 + +# Maximum size in bytes of kernel or ramdisk images (integer +# value) +#max_kernel_ramdisk_size=16777216 + +# Filter for finding the SR to be used to install guest +# instances on. To use the Local Storage in default +# XenServer/XCP installations set this flag to other-config +# :i18n-key=local-storage. To select an SR with a different +# matching criteria, you could set it to other- +# config:my_favorite_sr=true. On the other hand, to fall back +# on the Default SR, as displayed by XenCenter, set this flag +# to: default-sr:true (string value) +#sr_matching_filter=default-sr:true + +# Whether to use sparse_copy for copying data on a resize down +# (False will use standard dd). This speeds up resizes down +# considerably since large runs of zeros won't have to be +# rsynced (boolean value) +#sparse_copy=true + +# Maximum number of retries to unplug VBD (integer value) +#num_vbd_unplug_retries=10 + +# Whether or not to download images via Bit Torrent +# (all|some|none). (string value) +#torrent_images=none + +# Name of network to use for booting iPXE ISOs (string value) +#ipxe_network_name= + +# URL to the iPXE boot menu (string value) +#ipxe_boot_menu_url= + +# Name and optionally path of the tool used for ISO image +# creation (string value) +#ipxe_mkisofs_cmd=mkisofs + + +# +# Options defined in nova.virt.xenapi.vmops +# + +# number of seconds to wait for instance to go to running +# state (integer value) +#running_timeout=60 + +# The XenAPI VIF driver using XenServer Network APIs. (string +# value) +#vif_driver=nova.virt.xenapi.vif.XenAPIBridgeDriver + +# Dom0 plugin driver used to handle image uploads. (string +# value) +#image_upload_handler=nova.virt.xenapi.image.glance.GlanceStore + + +[rpc_notifier2] + +# +# Options defined in nova.openstack.common.notifier.rpc_notifier2 +# + +# AMQP topic(s) used for OpenStack notifications (list value) +#topics=notifications + + [conductor] # @@ -2189,239 +2459,6 @@ #workers= -[keymgr] - -# -# Options defined in nova.keymgr -# - -# The full class name of the key manager API class (string -# value) -#api_class=nova.keymgr.conf_key_mgr.ConfKeyManager - - -# -# Options defined in nova.keymgr.conf_key_mgr -# - -# Fixed key returned by key manager, specified in hex (string -# value) -#fixed_key= - - -[cells] - -# -# Options defined in nova.cells.manager -# - -# Cells communication driver to use (string value) -#driver=nova.cells.rpc_driver.CellsRPCDriver - -# Number of seconds after an instance was updated or deleted -# to continue to update cells (integer value) -#instance_updated_at_threshold=3600 - -# Number of instances to update per periodic task run (integer -# value) -#instance_update_num_instances=1 - - -# -# Options defined in nova.cells.messaging -# - -# Maximum number of hops for cells routing. (integer value) -#max_hop_count=10 - -# Cells scheduler to use (string value) -#scheduler=nova.cells.scheduler.CellsScheduler - - -# -# Options defined in nova.cells.opts -# - -# Enable cell functionality (boolean value) -#enable=false - -# the topic cells nodes listen on (string value) -#topic=cells - -# Manager for cells (string value) -#manager=nova.cells.manager.CellsManager - -# name of this cell (string value) -#name=nova - -# Key/Multi-value list with the capabilities of the cell (list -# value) -#capabilities=hypervisor=xenserver;kvm,os=linux;windows - -# Seconds to wait for response from a call to a cell. (integer -# value) -#call_timeout=60 - -# Percentage of cell capacity to hold in reserve. Affects both -# memory and disk utilization (floating point value) -#reserve_percent=10.0 - -# Type of cell: api or compute (string value) -#cell_type=compute - -# Number of seconds after which a lack of capability and -# capacity updates signals the child cell is to be treated as -# a mute. (integer value) -#mute_child_interval=300 - -# Seconds between bandwidth updates for cells. (integer value) -#bandwidth_update_interval=600 - - -# -# Options defined in nova.cells.rpc_driver -# - -# Base queue name to use when communicating between cells. -# Various topics by message type will be appended to this. -# (string value) -#rpc_driver_queue_base=cells.intercell - - -# -# Options defined in nova.cells.scheduler -# - -# Filter classes the cells scheduler should use. An entry of -# "nova.cells.filters.all_filters"maps to all cells filters -# included with nova. (list value) -#scheduler_filter_classes=nova.cells.filters.all_filters - -# Weigher classes the cells scheduler should use. An entry of -# "nova.cells.weights.all_weighers"maps to all cell weighers -# included with nova. (list value) -#scheduler_weight_classes=nova.cells.weights.all_weighers - -# How many retries when no cells are available. (integer -# value) -#scheduler_retries=10 - -# How often to retry in seconds when no cells are available. -# (integer value) -#scheduler_retry_delay=2 - - -# -# Options defined in nova.cells.state -# - -# Seconds between getting fresh cell info from db. (integer -# value) -#db_check_interval=60 - -# Configuration file from which to read cells configuration. -# If given, overrides reading cells from the database. (string -# value) -#cells_config= - - -# -# Options defined in nova.cells.weights.mute_child -# - -# Multiplier used to weigh mute children. (The value should -# be negative.) (floating point value) -#mute_weight_multiplier=-10.0 - -# Weight value assigned to mute children. (The value should -# be positive.) (floating point value) -#mute_weight_value=1000.0 - - -# -# Options defined in nova.cells.weights.ram_by_instance_type -# - -# Multiplier used for weighing ram. Negative numbers mean to -# stack vs spread. (floating point value) -#ram_weight_multiplier=10.0 - - -[database] - -# -# Options defined in nova.openstack.common.db.api -# - -# The backend to use for db (string value) -#backend=sqlalchemy - -# Enable the experimental use of thread pooling for all DB API -# calls (boolean value) -#use_tpool=false - - -# -# Options defined in nova.openstack.common.db.sqlalchemy.session -# - -# The SQLAlchemy connection string used to connect to the -# database (string value) -#connection=sqlite:////nova/openstack/common/db/$sqlite_db - -# The SQLAlchemy connection string used to connect to the -# slave database (string value) -#slave_connection= - -# timeout before idle sql connections are reaped (integer -# value) -#idle_timeout=3600 - -# Minimum number of SQL connections to keep open in a pool -# (integer value) -#min_pool_size=1 - -# Maximum number of SQL connections to keep open in a pool -# (integer value) -#max_pool_size= - -# maximum db connection retries during startup. (setting -1 -# implies an infinite retry count) (integer value) -#max_retries=10 - -# interval between retries of opening a sql connection -# (integer value) -#retry_interval=10 - -# If set, use this value for max_overflow with sqlalchemy -# (integer value) -#max_overflow= - -# Verbosity of SQL debugging information. 0=None, -# 100=Everything (integer value) -#connection_debug=0 - -# Add python stack traces to SQL as comment strings (boolean -# value) -#connection_trace=false - -# If set, use this value for pool_timeout with sqlalchemy -# (integer value) -#pool_timeout= - - -[image_file_url] - -# -# Options defined in nova.image.download.file -# - -# A list of filesystems that will be configured in this file -# under the sections image_file_url: (list -# value) -#filesystems= - - [libvirt] # @@ -2663,6 +2700,364 @@ #qemu_allowed_storage_drivers= +[metrics] + +# +# Options defined in nova.scheduler.weights.metrics +# + +# Multiplier used for weighing metrics. (floating point value) +#weight_multiplier=1.0 + +# How the metrics are going to be weighed. This should be in +# the form of "=, =, ...", where +# is one of the metric to be weighed, and is +# the corresponding ratio. So for "name1=1.0, name2=-1.0" The +# final weight would be name1.value * 1.0 + name2.value * +# -1.0. (list value) +#weight_setting= + + +[ssl] + +# +# Options defined in nova.openstack.common.sslutils +# + +# CA certificate file to use to verify connecting clients +# (string value) +#ca_file= + +# Certificate file to use when starting the server securely +# (string value) +#cert_file= + +# Private key file to use when starting the server securely +# (string value) +#key_file= + + +[matchmaker_ring] + +# +# Options defined in nova.openstack.common.rpc.matchmaker_ring +# + +# Matchmaker ring file (JSON) (string value) +#ringfile=/etc/oslo/matchmaker_ring.json + + +[spice] + +# +# Options defined in nova.spice +# + +# location of spice html5 console proxy, in the form +# "http://127.0.0.1:6082/spice_auto.html" (string value) +#html5proxy_base_url=http://127.0.0.1:6082/spice_auto.html + +# IP address on which instance spice server should listen +# (string value) +#server_listen=127.0.0.1 + +# the address to which proxy clients (like nova- +# spicehtml5proxy) should connect (string value) +#server_proxyclient_address=127.0.0.1 + +# enable spice related features (boolean value) +#enabled=false + +# enable spice guest agent support (boolean value) +#agent_enabled=true + +# keymap for spice (string value) +#keymap=en-us + + +[hyperv] + +# +# Options defined in nova.virt.hyperv.pathutils +# + +# The name of a Windows share name mapped to the +# "instances_path" dir and used by the resize feature to copy +# files to the target host. If left blank, an administrative +# share will be used, looking for the same "instances_path" +# used locally (string value) +#instances_path_share= + + +# +# Options defined in nova.virt.hyperv.utilsfactory +# + +# Force V1 WMI utility classes (boolean value) +#force_hyperv_utils_v1=false + +# Force V1 volume utility class (boolean value) +#force_volumeutils_v1=false + + +# +# Options defined in nova.virt.hyperv.vif +# + +# External virtual switch Name, if not provided, the first +# external virtual switch is used (string value) +#vswitch_name= + + +# +# Options defined in nova.virt.hyperv.vmops +# + +# Required for live migration among hosts with different CPU +# features (boolean value) +#limit_cpu_features=false + +# Sets the admin password in the config drive image (boolean +# value) +#config_drive_inject_password=false + +# qemu-img is used to convert between different image types +# (string value) +#qemu_img_cmd=qemu-img.exe + +# Attaches the Config Drive image as a cdrom drive instead of +# a disk drive (boolean value) +#config_drive_cdrom=false + +# Enables metrics collections for an instance by using +# Hyper-V's metric APIs. Collected data can by retrieved by +# other apps and services, e.g.: Ceilometer. Requires Hyper-V +# / Windows Server 2012 and above (boolean value) +#enable_instance_metrics_collection=false + +# Enables dynamic memory allocation (ballooning) when set to a +# value greater than 1. The value expresses the ratio between +# the total RAM assigned to an instance and its startup RAM +# amount. For example a ratio of 2.0 for an instance with +# 1024MB of RAM implies 512MB of RAM allocated at startup +# (floating point value) +#dynamic_memory_ratio=1.0 + + +# +# Options defined in nova.virt.hyperv.volumeops +# + +# The number of times to retry to attach a volume (integer +# value) +#volume_attach_retry_count=10 + +# Interval between volume attachment attempts, in seconds +# (integer value) +#volume_attach_retry_interval=5 + + +[database] + +# +# Options defined in nova.openstack.common.db.api +# + +# The backend to use for db (string value) +#backend=sqlalchemy + +# Enable the experimental use of thread pooling for all DB API +# calls (boolean value) +#use_tpool=false + + +# +# Options defined in nova.openstack.common.db.sqlalchemy.session +# + +# The SQLAlchemy connection string used to connect to the +# database (string value) +#connection=sqlite:////nova/openstack/common/db/$sqlite_db + +# The SQLAlchemy connection string used to connect to the +# slave database (string value) +#slave_connection= + +# timeout before idle sql connections are reaped (integer +# value) +#idle_timeout=3600 + +# Minimum number of SQL connections to keep open in a pool +# (integer value) +#min_pool_size=1 + +# Maximum number of SQL connections to keep open in a pool +# (integer value) +#max_pool_size= + +# maximum db connection retries during startup. (setting -1 +# implies an infinite retry count) (integer value) +#max_retries=10 + +# interval between retries of opening a sql connection +# (integer value) +#retry_interval=10 + +# If set, use this value for max_overflow with sqlalchemy +# (integer value) +#max_overflow= + +# Verbosity of SQL debugging information. 0=None, +# 100=Everything (integer value) +#connection_debug=0 + +# Add python stack traces to SQL as comment strings (boolean +# value) +#connection_trace=false + +# If set, use this value for pool_timeout with sqlalchemy +# (integer value) +#pool_timeout= + + +[cells] + +# +# Options defined in nova.cells.manager +# + +# Cells communication driver to use (string value) +#driver=nova.cells.rpc_driver.CellsRPCDriver + +# Number of seconds after an instance was updated or deleted +# to continue to update cells (integer value) +#instance_updated_at_threshold=3600 + +# Number of instances to update per periodic task run (integer +# value) +#instance_update_num_instances=1 + + +# +# Options defined in nova.cells.messaging +# + +# Maximum number of hops for cells routing. (integer value) +#max_hop_count=10 + +# Cells scheduler to use (string value) +#scheduler=nova.cells.scheduler.CellsScheduler + + +# +# Options defined in nova.cells.opts +# + +# Enable cell functionality (boolean value) +#enable=false + +# the topic cells nodes listen on (string value) +#topic=cells + +# Manager for cells (string value) +#manager=nova.cells.manager.CellsManager + +# name of this cell (string value) +#name=nova + +# Key/Multi-value list with the capabilities of the cell (list +# value) +#capabilities=hypervisor=xenserver;kvm,os=linux;windows + +# Seconds to wait for response from a call to a cell. (integer +# value) +#call_timeout=60 + +# Percentage of cell capacity to hold in reserve. Affects both +# memory and disk utilization (floating point value) +#reserve_percent=10.0 + +# Type of cell: api or compute (string value) +#cell_type=compute + +# Number of seconds after which a lack of capability and +# capacity updates signals the child cell is to be treated as +# a mute. (integer value) +#mute_child_interval=300 + +# Seconds between bandwidth updates for cells. (integer value) +#bandwidth_update_interval=600 + + +# +# Options defined in nova.cells.rpc_driver +# + +# Base queue name to use when communicating between cells. +# Various topics by message type will be appended to this. +# (string value) +#rpc_driver_queue_base=cells.intercell + + +# +# Options defined in nova.cells.scheduler +# + +# Filter classes the cells scheduler should use. An entry of +# "nova.cells.filters.all_filters"maps to all cells filters +# included with nova. (list value) +#scheduler_filter_classes=nova.cells.filters.all_filters + +# Weigher classes the cells scheduler should use. An entry of +# "nova.cells.weights.all_weighers"maps to all cell weighers +# included with nova. (list value) +#scheduler_weight_classes=nova.cells.weights.all_weighers + +# How many retries when no cells are available. (integer +# value) +#scheduler_retries=10 + +# How often to retry in seconds when no cells are available. +# (integer value) +#scheduler_retry_delay=2 + + +# +# Options defined in nova.cells.state +# + +# Seconds between getting fresh cell info from db. (integer +# value) +#db_check_interval=60 + +# Configuration file from which to read cells configuration. +# If given, overrides reading cells from the database. (string +# value) +#cells_config= + + +# +# Options defined in nova.cells.weights.mute_child +# + +# Multiplier used to weigh mute children. (The value should +# be negative.) (floating point value) +#mute_weight_multiplier=-10.0 + +# Weight value assigned to mute children. (The value should +# be positive.) (floating point value) +#mute_weight_value=1000.0 + + +# +# Options defined in nova.cells.weights.ram_by_instance_type +# + +# Multiplier used for weighing ram. Negative numbers mean to +# stack vs spread. (floating point value) +#ram_weight_multiplier=10.0 + + [baremetal] # @@ -2828,16 +3223,6 @@ #iscsi_iqn_prefix=iqn.2010-10.org.openstack.baremetal -[rpc_notifier2] - -# -# Options defined in nova.openstack.common.notifier.rpc_notifier2 -# - -# AMQP topic(s) used for OpenStack notifications (list value) -#topics=notifications - - [matchmaker_redis] # @@ -2854,253 +3239,15 @@ #password= -[xenserver] +[docker] # -# Options defined in nova.virt.xenapi.agent +# Options defined in nova.virt.docker.driver # -# number of seconds to wait for agent reply (integer value) -#agent_timeout=30 - -# number of seconds to wait for agent to be fully operational +# Default TCP port to find the docker-registry container # (integer value) -#agent_version_timeout=300 - -# number of seconds to wait for agent reply to resetnetwork -# request (integer value) -#agent_resetnetwork_timeout=60 - -# Specifies the path in which the xenapi guest agent should be -# located. If the agent is present, network configuration is -# not injected into the image. Used if -# compute_driver=xenapi.XenAPIDriver and flat_injected=True -# (string value) -#agent_path=usr/sbin/xe-update-networking - -# Disables the use of the XenAPI agent in any image regardless -# of what image properties are present. (boolean value) -#disable_agent=false - -# Determines if the xenapi agent should be used when the image -# used does not contain a hint to declare if the agent is -# present or not. The hint is a glance property -# "xenapi_use_agent" that has the value "true" or "false". -# Note that waiting for the agent when it is not present will -# significantly increase server boot times. (boolean value) -#use_agent_default=false - - -# -# Options defined in nova.virt.xenapi.client.session -# - -# Timeout in seconds for XenAPI login. (integer value) -#login_timeout=10 - -# Maximum number of concurrent XenAPI connections. Used only -# if compute_driver=xenapi.XenAPIDriver (integer value) -#connection_concurrent=5 - - -# -# Options defined in nova.virt.xenapi.driver -# - -# URL for connection to XenServer/Xen Cloud Platform. A -# special value of unix://local can be used to connect to the -# local unix socket. Required if -# compute_driver=xenapi.XenAPIDriver (string value) -#connection_url= - -# Username for connection to XenServer/Xen Cloud Platform. -# Used only if compute_driver=xenapi.XenAPIDriver (string -# value) -#connection_username=root - -# Password for connection to XenServer/Xen Cloud Platform. -# Used only if compute_driver=xenapi.XenAPIDriver (string -# value) -#connection_password= - -# The interval used for polling of coalescing vhds. Used only -# if compute_driver=xenapi.XenAPIDriver (floating point value) -#vhd_coalesce_poll_interval=5.0 - -# Ensure compute service is running on host XenAPI connects -# to. (boolean value) -#check_host=true - -# Max number of times to poll for VHD to coalesce. Used only -# if compute_driver=xenapi.XenAPIDriver (integer value) -#vhd_coalesce_max_attempts=5 - -# Base path to the storage repository (string value) -#sr_base_path=/var/run/sr-mount - -# iSCSI Target Host (string value) -#target_host= - -# iSCSI Target Port, 3260 Default (string value) -#target_port=3260 - -# IQN Prefix (string value) -#iqn_prefix=iqn.2010-10.org.openstack - -# Used to enable the remapping of VBD dev (Works around an -# issue in Ubuntu Maverick) (boolean value) -#remap_vbd_dev=false - -# Specify prefix to remap VBD dev to (ex. /dev/xvdb -> -# /dev/sdb) (string value) -#remap_vbd_dev_prefix=sd - - -# -# Options defined in nova.virt.xenapi.image.bittorrent -# - -# Base URL for torrent files. (string value) -#torrent_base_url= - -# Probability that peer will become a seeder. (1.0 = 100%) -# (floating point value) -#torrent_seed_chance=1.0 - -# Number of seconds after downloading an image via BitTorrent -# that it should be seeded for other peers. (integer value) -#torrent_seed_duration=3600 - -# Cached torrent files not accessed within this number of -# seconds can be reaped (integer value) -#torrent_max_last_accessed=86400 - -# Beginning of port range to listen on (integer value) -#torrent_listen_port_start=6881 - -# End of port range to listen on (integer value) -#torrent_listen_port_end=6891 - -# Number of seconds a download can remain at the same progress -# percentage w/o being considered a stall (integer value) -#torrent_download_stall_cutoff=600 - -# Maximum number of seeder processes to run concurrently -# within a given dom0. (-1 = no limit) (integer value) -#torrent_max_seeder_processes_per_host=1 - - -# -# Options defined in nova.virt.xenapi.pool -# - -# To use for hosts with different CPUs (boolean value) -#use_join_force=true - - -# -# Options defined in nova.virt.xenapi.vif -# - -# Name of Integration Bridge used by Open vSwitch (string -# value) -#ovs_integration_bridge=xapi1 - - -# -# Options defined in nova.virt.xenapi.vm_utils -# - -# Cache glance images locally. `all` will cache all images, -# `some` will only cache images that have the image_property -# `cache_in_nova=True`, and `none` turns off caching entirely -# (string value) -#cache_images=all - -# Compression level for images, e.g., 9 for gzip -9. Range is -# 1-9, 9 being most compressed but most CPU intensive on dom0. -# (integer value) -#image_compression_level= - -# Default OS type (string value) -#default_os_type=linux - -# Time to wait for a block device to be created (integer -# value) -#block_device_creation_timeout=10 - -# Maximum size in bytes of kernel or ramdisk images (integer -# value) -#max_kernel_ramdisk_size=16777216 - -# Filter for finding the SR to be used to install guest -# instances on. To use the Local Storage in default -# XenServer/XCP installations set this flag to other-config -# :i18n-key=local-storage. To select an SR with a different -# matching criteria, you could set it to other- -# config:my_favorite_sr=true. On the other hand, to fall back -# on the Default SR, as displayed by XenCenter, set this flag -# to: default-sr:true (string value) -#sr_matching_filter=default-sr:true - -# Whether to use sparse_copy for copying data on a resize down -# (False will use standard dd). This speeds up resizes down -# considerably since large runs of zeros won't have to be -# rsynced (boolean value) -#sparse_copy=true - -# Maximum number of retries to unplug VBD (integer value) -#num_vbd_unplug_retries=10 - -# Whether or not to download images via Bit Torrent -# (all|some|none). (string value) -#torrent_images=none - -# Name of network to use for booting iPXE ISOs (string value) -#ipxe_network_name= - -# URL to the iPXE boot menu (string value) -#ipxe_boot_menu_url= - -# Name and optionally path of the tool used for ISO image -# creation (string value) -#ipxe_mkisofs_cmd=mkisofs - - -# -# Options defined in nova.virt.xenapi.vmops -# - -# number of seconds to wait for instance to go to running -# state (integer value) -#running_timeout=60 - -# The XenAPI VIF driver using XenServer Network APIs. (string -# value) -#vif_driver=nova.virt.xenapi.vif.XenAPIBridgeDriver - -# Dom0 plugin driver used to handle image uploads. (string -# value) -#image_upload_handler=nova.virt.xenapi.image.glance.GlanceStore - - -[ssl] - -# -# Options defined in nova.openstack.common.sslutils -# - -# CA certificate file to use to verify connecting clients -# (string value) -#ca_file= - -# Certificate file to use when starting the server securely -# (string value) -#cert_file= - -# Private key file to use when starting the server securely -# (string value) -#key_file= +#registry_default_port=5042 [trusted_computing] @@ -3221,135 +3368,6 @@ #scheduler= -[matchmaker_ring] - -# -# Options defined in nova.openstack.common.rpc.matchmaker_ring -# - -# Matchmaker ring file (JSON) (string value) -#ringfile=/etc/oslo/matchmaker_ring.json - - -[vmware] - -# -# Options defined in nova.virt.vmwareapi.driver -# - -# URL for connection to VMware ESX/VC host. Required if -# compute_driver is vmwareapi.VMwareESXDriver or -# vmwareapi.VMwareVCDriver. (string value) -#host_ip= - -# Username for connection to VMware ESX/VC host. Used only if -# compute_driver is vmwareapi.VMwareESXDriver or -# vmwareapi.VMwareVCDriver. (string value) -#host_username= - -# Password for connection to VMware ESX/VC host. Used only if -# compute_driver is vmwareapi.VMwareESXDriver or -# vmwareapi.VMwareVCDriver. (string value) -#host_password= - -# Name of a VMware Cluster ComputeResource. Used only if -# compute_driver is vmwareapi.VMwareVCDriver. (multi valued) -#cluster_name= - -# Regex to match the name of a datastore. Used only if -# compute_driver is vmwareapi.VMwareVCDriver. (string value) -#datastore_regex= - -# The interval used for polling of remote tasks. Used only if -# compute_driver is vmwareapi.VMwareESXDriver or -# vmwareapi.VMwareVCDriver. (floating point value) -#task_poll_interval=5.0 - -# The number of times we retry on failures, e.g., socket -# error, etc. Used only if compute_driver is -# vmwareapi.VMwareESXDriver or vmwareapi.VMwareVCDriver. -# (integer value) -#api_retry_count=10 - -# VNC starting port (integer value) -#vnc_port=5900 - -# Total number of VNC ports (integer value) -#vnc_port_total=10000 - -# Whether to use linked clone (boolean value) -#use_linked_clone=true - - -# -# Options defined in nova.virt.vmwareapi.vif -# - -# Physical ethernet adapter name for vlan networking (string -# value) -#vlan_interface=vmnic0 - - -# -# Options defined in nova.virt.vmwareapi.vim -# - -# Optional VIM Service WSDL Location e.g -# http:///vimService.wsdl. Optional over-ride to -# default location for bug work-arounds (string value) -#wsdl_location= - - -# -# Options defined in nova.virt.vmwareapi.vim_util -# - -# The maximum number of ObjectContent data objects that should -# be returned in a single result. A positive value will cause -# the operation to suspend the retrieval when the count of -# objects reaches the specified maximum. The server may still -# limit the count to something less than the configured value. -# Any remaining objects may be retrieved with additional -# requests. (integer value) -#maximum_objects=100 - - -# -# Options defined in nova.virt.vmwareapi.vmops -# - -# Name of Integration Bridge (string value) -#integration_bridge=br-int - - -[spice] - -# -# Options defined in nova.spice -# - -# location of spice html5 console proxy, in the form -# "http://127.0.0.1:6082/spice_auto.html" (string value) -#html5proxy_base_url=http://127.0.0.1:6082/spice_auto.html - -# IP address on which instance spice server should listen -# (string value) -#server_listen=127.0.0.1 - -# the address to which proxy clients (like nova- -# spicehtml5proxy) should connect (string value) -#server_proxyclient_address=127.0.0.1 - -# enable spice related features (boolean value) -#enabled=false - -# enable spice guest agent support (boolean value) -#agent_enabled=true - -# keymap for spice (string value) -#keymap=en-us - - [keystone_authtoken] # diff --git a/nova/exception.py b/nova/exception.py index a7508c75c758..164cfd8cc942 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -960,6 +960,11 @@ class FlavorExtraSpecsNotFound(NotFound): "key %(extra_specs_key)s.") +class ComputeHostMetricNotFound(NotFound): + msg_fmt = _("Metric %(name)s could not be found on the compute " + "host node %(host)s.%(node)s.") + + class FileNotFound(NotFound): msg_fmt = _("File %(file_path)s could not be found.") diff --git a/nova/scheduler/weights/metrics.py b/nova/scheduler/weights/metrics.py new file mode 100644 index 000000000000..89d87591c0d0 --- /dev/null +++ b/nova/scheduler/weights/metrics.py @@ -0,0 +1,94 @@ +# Copyright (c) 2011 OpenStack Foundation +# All Rights Reserved. +# +# 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. + +""" +Metrics Weigher. Weigh hosts by their metrics. + +This weigher can compute the weight based on the compute node host's various +metrics. The to-be weighed metrics and their weighing ratio are specified +in the configuration file as the followings: + + metrics_weight_setting = name1=1.0, name2=-1.0 + + The final weight would be name1.value * 1.0 + name2.value * -1.0. +""" + +from oslo.config import cfg + +from nova import exception +from nova.openstack.common.gettextutils import _ +from nova.openstack.common import log as logging +from nova.scheduler import weights + +metrics_weight_opts = [ + cfg.FloatOpt('weight_multiplier', + default=1.0, + help='Multiplier used for weighing metrics.'), + cfg.ListOpt('weight_setting', + default=[], + help='How the metrics are going to be weighed. This ' + 'should be in the form of "=, ' + '=, ...", where is one ' + 'of the metric to be weighed, and is ' + 'the corresponding ratio. So for "name1=1.0, ' + 'name2=-1.0" The final weight would be ' + 'name1.value * 1.0 + name2.value * -1.0.'), +] + +CONF = cfg.CONF +CONF.register_opts(metrics_weight_opts, group='metrics') + +LOG = logging.getLogger(__name__) + + +class MetricsWeigher(weights.BaseHostWeigher): + def __init__(self): + self._parse_setting() + + def _parse_setting(self): + self.setting = [] + bad = [] + for item in CONF.metrics.weight_setting: + try: + (name, ratio) = item.split('=') + ratio = float(ratio) + except ValueError: + name = None + ratio = None + if name and ratio is not None: + self.setting.append((name, ratio)) + else: + bad.append(item) + if bad: + LOG.error(_("Ignoring the invalid elements of" + " metrics_weight_setting: %s"), + ",".join(bad)) + + def _weight_multiplier(self): + """Override the weight multiplier.""" + return CONF.metrics.weight_multiplier + + def _weigh_object(self, host_state, weight_properties): + value = 0.0 + + for (name, ratio) in self.setting: + try: + value += host_state.metrics[name].value * ratio + except KeyError: + raise exception.ComputeHostMetricNotFound( + host=host_state.host, + node=host_state.nodename, + name=name) + return value diff --git a/nova/tests/scheduler/fakes.py b/nova/tests/scheduler/fakes.py index 8ed23d897a40..6d020c760391 100644 --- a/nova/tests/scheduler/fakes.py +++ b/nova/tests/scheduler/fakes.py @@ -20,6 +20,7 @@ import mox from nova.compute import vm_states from nova import db +from nova.openstack.common import jsonutils from nova.scheduler import filter_scheduler from nova.scheduler import host_manager @@ -53,6 +54,77 @@ COMPUTE_NODES = [ dict(id=5, local_gb=1024, memory_mb=1024, vcpus=1, service=None), ] +COMPUTE_NODES_METRICS = [ + dict(id=1, local_gb=1024, memory_mb=1024, vcpus=1, + disk_available_least=512, free_ram_mb=512, vcpus_used=1, + free_disk_mb=512, local_gb_used=0, updated_at=None, + service=dict(host='host1', disabled=False), + hypervisor_hostname='node1', host_ip='127.0.0.1', + hypervisor_version=0, + metrics=jsonutils.dumps([{'name': 'foo', + 'value': 512, + 'timestamp': None, + 'source': 'host1' + }, + {'name': 'bar', + 'value': 1.0, + 'timestamp': None, + 'source': 'host1' + }, + ])), + dict(id=2, local_gb=2048, memory_mb=2048, vcpus=2, + disk_available_least=1024, free_ram_mb=1024, vcpus_used=2, + free_disk_mb=1024, local_gb_used=0, updated_at=None, + service=dict(host='host2', disabled=True), + hypervisor_hostname='node2', host_ip='127.0.0.1', + hypervisor_version=0, + metrics=jsonutils.dumps([{'name': 'foo', + 'value': 1024, + 'timestamp': None, + 'source': 'host2' + }, + {'name': 'bar', + 'value': 2.0, + 'timestamp': None, + 'source': 'host2' + }, + ])), + dict(id=3, local_gb=4096, memory_mb=4096, vcpus=4, + disk_available_least=3072, free_ram_mb=3072, vcpus_used=1, + free_disk_mb=3072, local_gb_used=0, updated_at=None, + service=dict(host='host3', disabled=False), + hypervisor_hostname='node3', host_ip='127.0.0.1', + hypervisor_version=0, + metrics=jsonutils.dumps([{'name': 'foo', + 'value': 3072, + 'timestamp': None, + 'source': 'host3' + }, + {'name': 'bar', + 'value': 1.0, + 'timestamp': None, + 'source': 'host3' + }, + ])), + dict(id=4, local_gb=8192, memory_mb=8192, vcpus=8, + disk_available_least=8192, free_ram_mb=8192, vcpus_used=0, + free_disk_mb=8192, local_gb_used=0, updated_at=None, + service=dict(host='host4', disabled=False), + hypervisor_hostname='node4', host_ip='127.0.0.1', + hypervisor_version=0, + metrics=jsonutils.dumps([{'name': 'foo', + 'value': 8192, + 'timestamp': None, + 'source': 'host4' + }, + {'name': 'bar', + 'value': 0, + 'timestamp': None, + 'source': 'host4' + }, + ])), +] + INSTANCES = [ dict(root_gb=512, ephemeral_gb=0, memory_mb=512, vcpus=1, host='host1', node='node1'), diff --git a/nova/tests/scheduler/test_weights.py b/nova/tests/scheduler/test_weights.py index 7495edaccefd..dfbe3d6f2d7a 100644 --- a/nova/tests/scheduler/test_weights.py +++ b/nova/tests/scheduler/test_weights.py @@ -17,6 +17,8 @@ Tests For Scheduler weights. """ from nova import context +from nova import exception +from nova.openstack.common.fixture import mockpatch from nova.scheduler import weights from nova import test from nova.tests import matchers @@ -34,13 +36,17 @@ class TestWeighedHost(test.NoDBTestCase): def test_all_weighers(self): classes = weights.all_weighers() class_names = [cls.__name__ for cls in classes] - self.assertEqual(len(classes), 1) + self.assertEqual(len(classes), 2) self.assertIn('RAMWeigher', class_names) + self.assertIn('MetricsWeigher', class_names) class RamWeigherTestCase(test.NoDBTestCase): def setUp(self): super(RamWeigherTestCase, self).setUp() + self.useFixture(mockpatch.Patch( + 'nova.db.compute_node_get_all', + return_value=fakes.COMPUTE_NODES)) self.host_manager = fakes.FakeHostManager() self.weight_handler = weights.HostWeightHandler() self.weight_classes = self.weight_handler.get_matching_classes( @@ -54,12 +60,7 @@ class RamWeigherTestCase(test.NoDBTestCase): def _get_all_hosts(self): ctxt = context.get_admin_context() - fakes.mox_host_manager_db_calls(self.mox, ctxt) - self.mox.ReplayAll() - host_states = self.host_manager.get_all_host_states(ctxt) - self.mox.VerifyAll() - self.mox.ResetAll() - return host_states + return self.host_manager.get_all_host_states(ctxt) def test_default_of_spreading_first(self): hostinfo_list = self._get_all_hosts() @@ -101,3 +102,110 @@ class RamWeigherTestCase(test.NoDBTestCase): weighed_host = self._get_weighed_host(hostinfo_list) self.assertEqual(weighed_host.weight, 8192 * 2) self.assertEqual(weighed_host.obj.host, 'host4') + + +class MetricsWeigherTestCase(test.NoDBTestCase): + def setUp(self): + super(MetricsWeigherTestCase, self).setUp() + self.useFixture(mockpatch.Patch( + 'nova.db.compute_node_get_all', + return_value=fakes.COMPUTE_NODES_METRICS)) + self.host_manager = fakes.FakeHostManager() + self.weight_handler = weights.HostWeightHandler() + self.weight_classes = self.weight_handler.get_matching_classes( + ['nova.scheduler.weights.metrics.MetricsWeigher']) + + def _get_weighed_host(self, hosts, setting, weight_properties=None): + if not weight_properties: + weight_properties = {} + self.flags(weight_setting=setting, group='metrics') + return self.weight_handler.get_weighed_objects(self.weight_classes, + hosts, weight_properties)[0] + + def _get_all_hosts(self): + ctxt = context.get_admin_context() + return self.host_manager.get_all_host_states(ctxt) + + def _do_test(self, settings, expected_weight, expected_host): + hostinfo_list = self._get_all_hosts() + weighed_host = self._get_weighed_host(hostinfo_list, settings) + self.assertEqual(weighed_host.weight, expected_weight) + self.assertEqual(weighed_host.obj.host, expected_host) + + def test_single_resource(self): + # host1: foo=512 + # host2: foo=1024 + # host3: foo=3072 + # host4: foo=8192 + # so, host4 should win: + setting = ['foo=1'] + self._do_test(setting, 8192, 'host4') + + def test_multiple_resource(self): + # host1: foo=512, bar=1 + # host2: foo=1024, bar=2 + # host3: foo=3072, bar=1 + # host4: foo=8192, bar=0 + # so, host2 should win: + setting = ['foo=0.0001', 'bar=1'] + self._do_test(setting, 2.1024, 'host2') + + def test_single_resourcenegtive_ratio(self): + # host1: foo=512 + # host2: foo=1024 + # host3: foo=3072 + # host4: foo=8192 + # so, host1 should win: + setting = ['foo=-1'] + self._do_test(setting, -512, 'host1') + + def test_multiple_resource_missing_ratio(self): + # host1: foo=512, bar=1 + # host2: foo=1024, bar=2 + # host3: foo=3072, bar=1 + # host4: foo=8192, bar=0 + # so, host4 should win: + setting = ['foo=0.0001', 'bar'] + self._do_test(setting, 0.8192, 'host4') + + def test_multiple_resource_wrong_ratio(self): + # host1: foo=512, bar=1 + # host2: foo=1024, bar=2 + # host3: foo=3072, bar=1 + # host4: foo=8192, bar=0 + # so, host4 should win: + setting = ['foo=0.0001', 'bar = 2.0t'] + self._do_test(setting, 0.8192, 'host4') + + def _check_parsing_result(self, weigher, setting, results): + self.flags(weight_setting=setting, group='metrics') + weigher._parse_setting() + self.assertTrue(len(results) == len(weigher.setting)) + for item in results: + self.assertTrue(item in weigher.setting) + + def test_parse_setting(self): + weigher = self.weight_classes[0]() + self._check_parsing_result(weigher, + ['foo=1'], + [('foo', 1.0)]) + self._check_parsing_result(weigher, + ['foo=1', 'bar=-2.1'], + [('foo', 1.0), ('bar', -2.1)]) + self._check_parsing_result(weigher, + ['foo=a1', 'bar=-2.1'], + [('bar', -2.1)]) + self._check_parsing_result(weigher, + ['foo', 'bar=-2.1'], + [('bar', -2.1)]) + self._check_parsing_result(weigher, + ['=5', 'bar=-2.1'], + [('bar', -2.1)]) + + def test_metric_not_found(self): + setting = ['foo=1', 'zot=2'] + self.assertRaises(exception.ComputeHostMetricNotFound, + self._do_test, + setting, + 8192, + 'host4')