Scheduling reservations (not restaurant) with python

Viewed 1365

I'm writing a python application that uses OpenStack to provide students access to a limited number of virtual machines.

Students can place reservations, either now or in the future.

I need to limit the number of virtual machines scheduled at any time to X while still allowing students to reserve vms if slots/reservations are available.

Reservation objects look like the below (sqlalchemy). I would know the start time and the length of the reservation requested, at which point I need to go through existing reservations and see if there are too many reservations in the time period requested. The *_job fields are the names of APScheduler jobs.

class Reservation(Entity):
    student = ManyToOne('Student', required=True)
    class_id = ManyToOne('Class', required=True)
    image = ManyToOne('Image', required=True)
    # openstack image id filled in once the instance is started
    instance_id = Field(UnicodeText)

    # apscheduler jobs
    stop_instance_job = Field(UnicodeText)
    start_instance_job = Field(UnicodeText)
    warn_reservation_ending_job = Field(UnicodeText)
    check_instance_job = Field(UnicodeText)

Any pointers on where to look for examples of schedule algorithms or something like that? I'm not even clear what to search for...

Thanks.

1 Answers
Related