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.RPC_API_VERSION = '2.2'
SchedulerManager.create_volume(context, volume_id, snapshot_id, reservations=None, image_id=None)
SchedulerManager.live_migration(context, instance, dest, block_migration, disk_over_commit)
SchedulerManager.prep_resize(context, image, request_spec, filter_properties, instance, instance_type, reservations)

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, request_spec, admin_password, injected_files, requested_networks, is_first_time, filter_properties)

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, host, capabilities)

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.hosts_up(context, topic)

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

Scheduler.schedule_create_volume(context, volume_id, snapshot_id, image_id)
Scheduler.schedule_live_migration(context, instance, dest, block_migration, disk_over_commit)

Live migration scheduling method.

Parameters:
  • context
  • instance – instance dict
  • 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, image, request_spec, filter_properties, instance, instance_type, reservations)

Must override schedule_prep_resize method for scheduler to work.

Scheduler.schedule_run_instance(context, request_spec, admin_password, injected_files, requested_networks, is_first_time, filter_properties)

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, **kwargs)

Cast request to a compute host queue

cast_to_host(context, topic, host, method, **kwargs)

Generic cast to host

cast_to_network_host(context, host, method, **kwargs)

Cast request to a network host queue

cast_to_volume_host(context, host, method, **kwargs)

Cast request to a volume host queue

encode_instance(instance, local=True)

Encode locally created instance for return via RPC

handle_schedule_error(context, ex, instance_uuid, request_spec)
instance_update_db(context, instance_uuid, host)

Set the host and scheduled_at fields of an Instance.

Returns:An Instance with the updated fields set properly.

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_create_volume(context, volume_id, snapshot_id, image_id)

Picks a host that is up at random.

ChanceScheduler.schedule_prep_resize(context, image, request_spec, filter_properties, instance, instance_type, reservations)

Select a target for resize.

ChanceScheduler.schedule_run_instance(context, request_spec, admin_password, injected_files, requested_networks, is_first_time, filter_properties)

Create and run an instance or instances

The nova.scheduler.simple Driver

Simple Scheduler - for Volumes

Note: Deprecated in Folsom. Will be removed along with nova-volumes

class SimpleScheduler

Bases: nova.scheduler.chance.ChanceScheduler

Implements Naive Scheduler that tries to find least loaded host.

SimpleScheduler.schedule_create_volume(context, volume_id, snapshot_id, image_id)

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

SimpleScheduler.schedule_run_instance(context, request_spec, admin_password, injected_files, requested_networks, is_first_time, filter_properties)

Tests

The scheduler_unittest Module