Table Of Contents

Previous topic

API Endpoint

Next topic

Fake Drivers

This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

Scheduler

The nova.scheduler.manager Module

Scheduler Service

class SchedulerManager(scheduler_driver=None, *args, **kwargs)

Bases: nova.manager.Manager

Chooses a host to run instances on.

SchedulerManager.get_host_list(context)

Get a list of hosts from the HostManager.

SchedulerManager.get_service_capabilities(context)

Get the normalized set of capabilities for this zone.

SchedulerManager.prep_resize(context, topic, *args, **kwargs)

Tries to call schedule_prep_resize on the driver. Sets instance vm_state to ACTIVE on NoHostFound Sets vm_state to ERROR on other exceptions

SchedulerManager.run_instance(context, topic, *args, **kwargs)

Tries to call schedule_run_instance on the driver. Sets instance vm_state to ERROR on exceptions

SchedulerManager.show_host_resources(context, host)

Shows the physical/usage resource given by hosts.

Parameters:
  • context – security context
  • host – hostname
Returns:

example format is below:

{'resource':D, 'usage':{proj_id1:D, proj_id2:D}}
D: {'vcpus': 3, 'memory_mb': 2048, 'local_gb': 2048,
    'vcpus_used': 12, 'memory_mb_used': 10240,
    'local_gb_used': 64}

SchedulerManager.update_service_capabilities(context, service_name=None, host=None, capabilities=None, **kwargs)

Process a capability update from a service node.

The nova.scheduler.driver Module

Scheduler base class that all Schedulers should inherit from

class Scheduler

Bases: object

The base class that all Scheduler classes should inherit from.

Scheduler.assert_compute_node_has_enough_disk(context, instance_ref, dest, disk_over_commit)

Checks if destination host has enough disk for block migration.

Parameters:
  • context – security context
  • instance_ref – nova.db.sqlalchemy.models.Instance object
  • dest – destination host
  • disk_over_commit – if True, consider real(not virtual) disk size.
Scheduler.assert_compute_node_has_enough_memory(context, instance_ref, dest)

Checks if destination host has enough memory for live migration.

Parameters:
  • context – security context
  • instance_ref – nova.db.sqlalchemy.models.Instance object
  • dest – destination host
Scheduler.assert_compute_node_has_enough_resources(context, instance_ref, dest, block_migration, disk_over_commit)

Checks if destination host has enough resource for live migration.

Parameters:
  • context – security context
  • instance_ref – nova.db.sqlalchemy.models.Instance object
  • dest – destination host
  • block_migration – if true, block_migration.
  • disk_over_commit – if True, consider real(not virtual) disk size.
Scheduler.create_instance_db_entry(context, request_spec)

Create instance DB entry based on request_spec

Scheduler.get_host_list()

Get a list of hosts from the HostManager.

Scheduler.get_service_capabilities()

Get the normalized set of capabilities for the services.

Scheduler.hosts_up(context, topic)

Return the list of hosts that have a running service for topic.

Scheduler.mounted_on_same_shared_storage(context, instance_ref, dest)

Check if the src and dest host mount same shared storage.

At first, dest host creates temp file, and src host can see it if they mounts same shared storage. Then src host erase it.

Parameters:
  • context – security context
  • instance_ref – nova.db.sqlalchemy.models.Instance object
  • dest – destination host
Scheduler.schedule(context, topic, method, *_args, **_kwargs)

Must override schedule method for scheduler to work.

Scheduler.schedule_live_migration(context, instance_id, dest, block_migration=False, disk_over_commit=False)

Live migration scheduling method.

Parameters:
  • context
  • instance_id
  • dest – destination host
  • block_migration – if true, block_migration.
  • disk_over_commit – if True, consider real(not virtual) disk size.
Returns:

The host where instance is running currently. Then scheduler send request that host.

Scheduler.schedule_prep_resize(context, request_spec, *_args, **_kwargs)

Must override schedule_prep_resize method for scheduler to work.

Scheduler.schedule_run_instance(context, request_spec, *_args, **_kwargs)

Must override schedule_run_instance method for scheduler to work.

Scheduler.update_service_capabilities(service_name, host, capabilities)

Process a capability update from a service node.

cast_to_compute_host(context, host, method, update_db=True, **kwargs)

Cast request to a compute host queue

cast_to_host(context, topic, host, method, update_db=True, **kwargs)

Generic cast to host

cast_to_network_host(context, host, method, update_db=False, **kwargs)

Cast request to a network host queue

cast_to_volume_host(context, host, method, update_db=True, **kwargs)

Cast request to a volume host queue

encode_instance(instance, local=True)

Encode locally created instance for return via RPC

The nova.scheduler.chance Driver

Chance (Random) Scheduler implementation

class ChanceScheduler

Bases: nova.scheduler.driver.Scheduler

Implements Scheduler as a random node selector.

ChanceScheduler.schedule(context, topic, method, *_args, **kwargs)

Picks a host that is up at random.

ChanceScheduler.schedule_prep_resize(context, request_spec, *args, **kwargs)

Select a target for resize.

ChanceScheduler.schedule_run_instance(context, request_spec, *_args, **kwargs)

Create and run an instance or instances

The nova.scheduler.simple Driver

Simple Scheduler

class SimpleScheduler

Bases: nova.scheduler.chance.ChanceScheduler

Implements Naive Scheduler that tries to find least loaded host.

SimpleScheduler.schedule_create_volume(context, volume_id, *_args, **_kwargs)

Picks a host that is up and has the fewest volumes.

SimpleScheduler.schedule_run_instance(context, request_spec, *_args, **_kwargs)

Tests

The scheduler_unittest Module