# # 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. from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova.scheduler import filters LOG = logging.getLogger(__name__) disk_allocation_ratio_opt = cfg.FloatOpt("disk_allocation_ratio", default=1.0, help="virtual disk to physical disk allocation ratio") CONF = cfg.CONF CONF.register_opt(disk_allocation_ratio_opt) class DiskFilter(filters.BaseHostFilter): """Disk Filter with over subscription flag.""" def host_passes(self, host_state, filter_properties): """Filter based on disk usage.""" instance_type = filter_properties.get('instance_type') requested_disk = 1024 * (instance_type['root_gb'] + instance_type['ephemeral_gb']) free_disk_mb = host_state.free_disk_mb
vmwareapi_opts = [ cfg.StrOpt('vmwareapi_host_ip', default=None, help='URL for connection to VMWare ESX host.Required if ' 'connection_type is vmwareapi.'), cfg.StrOpt('vmwareapi_host_username', default=None, help='Username for connection to VMWare ESX host. ' 'Used only if connection_type is vmwareapi.'), cfg.StrOpt('vmwareapi_host_password', default=None, help='Password for connection to VMWare ESX host. ' 'Used only if connection_type is vmwareapi.'), cfg.FloatOpt('vmwareapi_task_poll_interval', default=5.0, help='The interval used for polling of remote tasks. ' 'Used only if connection_type is vmwareapi'), cfg.FloatOpt('vmwareapi_api_retry_count', default=10, help='The number of times we retry on failures, e.g., ' 'socket error, etc. ' 'Used only if connection_type is vmwareapi'), cfg.StrOpt('vmwareapi_vlan_interface', default='vmnic0', help='Physical ethernet adapter name for vlan networking'), ] FLAGS = flags.FLAGS FLAGS.register_opts(vmwareapi_opts) TIME_BETWEEN_API_CALL_RETRIES = 2.0
help='URL for connection to XenServer/Xen Cloud Platform. ' 'Required if connection_type=xenapi.'), cfg.StrOpt('xenapi_connection_username', default='root', help='Username for connection to XenServer/Xen Cloud Platform. ' 'Used only if connection_type=xenapi.'), cfg.StrOpt('xenapi_connection_password', default=None, help='Password for connection to XenServer/Xen Cloud Platform. ' 'Used only if connection_type=xenapi.'), cfg.IntOpt('xenapi_connection_concurrent', default=5, help='Maximum number of concurrent XenAPI connections. ' 'Used only if connection_type=xenapi.'), cfg.FloatOpt('xenapi_vhd_coalesce_poll_interval', default=5.0, help='The interval used for polling of coalescing vhds. ' 'Used only if connection_type=xenapi.'), cfg.IntOpt('xenapi_vhd_coalesce_max_attempts', default=5, help='Max number of times to poll for VHD to coalesce. ' 'Used only if connection_type=xenapi.'), cfg.StrOpt('xenapi_agent_path', default='usr/sbin/xe-update-networking', help='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 connection_type=xenapi and flat_injected=True'), cfg.StrOpt('xenapi_sr_base_path', default='/var/run/sr-mount', help='Base path to the storage repository'), cfg.StrOpt('target_host', default=None, help='iSCSI Target Host'),
help='URL for connection to XenServer/Xen Cloud Platform. ' 'Required if compute_driver=xenapi.XenAPIDriver'), cfg.StrOpt('xenapi_connection_username', default='root', help='Username for connection to XenServer/Xen Cloud Platform. ' 'Used only if compute_driver=xenapi.XenAPIDriver'), cfg.StrOpt('xenapi_connection_password', default=None, help='Password for connection to XenServer/Xen Cloud Platform. ' 'Used only if compute_driver=xenapi.XenAPIDriver'), cfg.IntOpt('xenapi_connection_concurrent', default=5, help='Maximum number of concurrent XenAPI connections. ' 'Used only if compute_driver=xenapi.XenAPIDriver'), cfg.FloatOpt('xenapi_vhd_coalesce_poll_interval', default=5.0, help='The interval used for polling of coalescing vhds. ' 'Used only if compute_driver=xenapi.XenAPIDriver'), cfg.BoolOpt('xenapi_check_host', default=True, help='Ensure compute service is running on host XenAPI ' 'connects to.'), cfg.IntOpt('xenapi_vhd_coalesce_max_attempts', default=5, help='Max number of times to poll for VHD to coalesce. ' 'Used only if compute_driver=xenapi.XenAPIDriver'), cfg.StrOpt('xenapi_sr_base_path', default='/var/run/sr-mount', help='Base path to the storage repository'), cfg.StrOpt('target_host', default=None, help='iSCSI Target Host'),
create other weight modules. """ from nova import exception from nova.openstack.common import cfg from nova.openstack.common import importutils from nova.openstack.common import log as logging LOG = logging.getLogger(__name__) least_cost_opts = [ cfg.ListOpt('least_cost_functions', default=None, help='Which cost functions the LeastCostScheduler should use'), cfg.FloatOpt('noop_cost_fn_weight', default=1.0, help='How much weight to give the noop cost function'), cfg.FloatOpt('compute_fill_first_cost_fn_weight', default=None, help='How much weight to give the fill-first cost function. ' 'A negative value will reverse behavior: ' 'e.g. spread-first'), ] CONF = cfg.CONF CONF.register_opts(least_cost_opts) def noop_cost_fn(host_state, weight_properties): """Return a pre-weight cost of 1 for each host.""" return 1
default=None, help='URL for connection to VMWare ESX host.Required if ' 'compute_driver is vmwareapi.VMWareESXDriver.'), cfg.StrOpt('vmwareapi_host_username', default=None, help='Username for connection to VMWare ESX host. ' 'Used only if compute_driver is ' 'vmwareapi.VMWareESXDriver.'), cfg.StrOpt('vmwareapi_host_password', default=None, help='Password for connection to VMWare ESX host. ' 'Used only if compute_driver is ' 'vmwareapi.VMWareESXDriver.'), cfg.FloatOpt('vmwareapi_task_poll_interval', default=5.0, help='The interval used for polling of remote tasks. ' 'Used only if compute_driver is ' 'vmwareapi.VMWareESXDriver.'), cfg.IntOpt('vmwareapi_api_retry_count', default=10, help='The number of times we retry on failures, e.g., ' 'socket error, etc. ' 'Used only if compute_driver is ' 'vmwareapi.VMWareESXDriver.'), cfg.StrOpt('vmwareapi_vlan_interface', default='vmnic0', help='Physical ethernet adapter name for vlan networking'), ] CONF = cfg.CONF CONF.register_opts(vmwareapi_opts)
# # 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. from nova import flags from nova import log as logging from nova.openstack.common import cfg from nova.scheduler import filters LOG = logging.getLogger(__name__) ram_allocation_ratio_opt = cfg.FloatOpt( "ram_allocation_ratio", default=1.5, help="virtual ram to physical ram allocation ratio") FLAGS = flags.FLAGS FLAGS.register_opt(ram_allocation_ratio_opt) class RamFilter(filters.BaseHostFilter): """Ram Filter with over subscription flag""" def host_passes(self, host_state, filter_properties): """Only return hosts with sufficient available RAM.""" instance_type = filter_properties.get('instance_type') requested_ram = instance_type['memory_mb'] free_ram_mb = host_state.free_ram_mb total_usable_ram_mb = host_state.total_usable_ram_mb used_ram_mb = total_usable_ram_mb - free_ram_mb
vmwareapi_opts = [ cfg.StrOpt('vmwareapi_host_ip', default=None, help='URL for connection to VMWare ESX host.Required if ' 'connection_type is vmwareapi.'), cfg.StrOpt('vmwareapi_host_username', default=None, help='Username for connection to VMWare ESX host. ' 'Used only if connection_type is vmwareapi.'), cfg.StrOpt('vmwareapi_host_password', default=None, help='Password for connection to VMWare ESX host. ' 'Used only if connection_type is vmwareapi.'), cfg.FloatOpt('vmwareapi_task_poll_interval', default=5.0, help='The interval used for polling of remote tasks. ' 'Used only if connection_type is vmwareapi'), cfg.IntOpt('vmwareapi_api_retry_count', default=10, help='The number of times we retry on failures, e.g., ' 'socket error, etc. ' 'Used only if connection_type is vmwareapi'), cfg.StrOpt('vmwareapi_vlan_interface', default='vmnic0', help='Physical ethernet adapter name for vlan networking'), ] FLAGS = flags.FLAGS FLAGS.register_opts(vmwareapi_opts) TIME_BETWEEN_API_CALL_RETRIES = 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. from nova import flags from nova import log as logging from nova.openstack.common import cfg from nova.scheduler import filters LOG = logging.getLogger(__name__) cpu_allocation_ratio_opt = cfg.FloatOpt( 'cpu_allocation_ratio', default=16.0, help='Virtual CPU to Physical CPU allocation ratio') FLAGS = flags.FLAGS FLAGS.register_opt(cpu_allocation_ratio_opt) class CoreFilter(filters.BaseHostFilter): """CoreFilter filters based on CPU core utilization.""" def host_passes(self, host_state, filter_properties): """Return True if host has sufficient CPU cores.""" instance_type = filter_properties.get('instance_type') if host_state.topic != 'compute' or not instance_type: return True if not host_state.vcpus_total:
# under the License. """ RAM Weigher. Weigh hosts by their RAM usage. The default is to spread instances across all hosts evenly. If you prefer stacking, you can set the 'ram_weight_multiplier' option to a negative number and the weighing has the opposite effect of the default. """ from nova.openstack.common import cfg from nova.scheduler import weights ram_weight_opts = [ cfg.FloatOpt('ram_weight_multiplier', default=1.0, help='Multiplier used for weighing ram. Negative ' 'numbers mean to stack vs spread.'), ] CONF = cfg.CONF CONF.register_opts(ram_weight_opts) class RAMWeigher(weights.BaseHostWeigher): def _weight_multiplier(self): """Override the weight multiplier.""" return CONF.ram_weight_multiplier def _weigh_object(self, host_state, weight_properties): """Higher weights win. We want spreading to be the default.""" return host_state.free_ram_mb
'Required if connection_type=xenapi.'), cfg.StrOpt('xenapi_connection_username', default='root', help='Username for connection to XenServer/Xen Cloud Platform. ' 'Used only if connection_type=xenapi.'), cfg.StrOpt('xenapi_connection_password', default=None, help='Password for connection to XenServer/Xen Cloud Platform. ' 'Used only if connection_type=xenapi.'), cfg.IntOpt('xenapi_connection_concurrent', default=5, help='Maximum number of concurrent XenAPI connections. ' 'Used only if connection_type=xenapi.'), cfg.FloatOpt('xenapi_task_poll_interval', default=0.5, help='The interval used for polling of remote tasks ' '(Async.VM.start, etc). ' 'Used only if connection_type=xenapi.'), cfg.FloatOpt('xenapi_vhd_coalesce_poll_interval', default=5.0, help='The interval used for polling of coalescing vhds. ' 'Used only if connection_type=xenapi.'), cfg.IntOpt('xenapi_vhd_coalesce_max_attempts', default=5, help='Max number of times to poll for VHD to coalesce. ' 'Used only if connection_type=xenapi.'), cfg.StrOpt('xenapi_agent_path', default='usr/sbin/xe-update-networking', help='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. '
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ Tests For Least Cost functions. """ from nova import context from nova.openstack.common import cfg from nova.scheduler import weights from nova.scheduler.weights import least_cost from nova import test from nova.tests.scheduler import fakes test_least_cost_opts = [ cfg.FloatOpt('compute_fake_weigher1_weight', default=2.0, help='How much weight to give the fake_weigher1 function'), cfg.FloatOpt('compute_fake_weigher2_weight', default=1.0, help='How much weight to give the fake_weigher2 function'), ] CONF = cfg.CONF CONF.import_opt('least_cost_functions', 'nova.scheduler.weights.least_cost') CONF.import_opt('compute_fill_first_cost_fn_weight', 'nova.scheduler.weights.least_cost') CONF.register_opts(test_least_cost_opts) def compute_fake_weigher1(hostinfo, options): return hostinfo.free_ram_mb + 10000
is then selected for provisioning. """ from nova import flags from nova import log as logging from nova.openstack.common import cfg LOG = logging.getLogger(__name__) least_cost_opts = [ cfg.ListOpt( 'least_cost_functions', default=['nova.scheduler.least_cost.compute_fill_first_cost_fn'], help='Which cost functions the LeastCostScheduler should use'), cfg.FloatOpt('noop_cost_fn_weight', default=1.0, help='How much weight to give the noop cost function'), cfg.FloatOpt('compute_fill_first_cost_fn_weight', default=1.0, help='How much weight to give the fill-first cost function'), ] FLAGS = flags.FLAGS FLAGS.register_opts(least_cost_opts) # TODO(sirp): Once we have enough of these rules, we can break them out into a # cost_functions.py file (perhaps in a least_cost_scheduler directory) class WeightedHost(object): """Reduced set of information about a host that has been weighed.