From dc224fa34d339762f73d537d8b48839f71ccfba2 Mon Sep 17 00:00:00 2001 From: "Joseph W. Breu" Date: Wed, 30 Nov 2011 13:54:21 -0600 Subject: [PATCH] Updates simple scheduler to allow strict availability_zone scheduling This update adds strict availability_zone scheduling of new instances when an availabity_zone option is not present in the creation call. This patch does not change the expected default behavior. Previous behavior was to default the zone to None and only update the zone in the scheduler if an availability_zone was supplied. This incorrectly allowed the scheduler to place new instances created without an availability_zone onto compute nodes where the availability_zone had been changed to something other than the default of 'nova'. Setting default_schedule_zone to 'nova' will prevent new instance scheduling into availability_zones other than the default 'nova' zone. This change defaults the zone to None but allows the user to override this with the default_schedule_flag. In practice, if you have 2 availability_zones (nova, megazone) you can configure default_schedule_zone on the API node to 'nova' and any instances created will be created into the 'nova' availability_zone if one was not supplied. Instances created with an availability_zone will be created as normal into the availability_zone supplied. Change-Id: Id23bac8448ea7ce6a1e1227d046c921328dbfe33 --- Authors | 2 ++ nova/scheduler/simple.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Authors b/Authors index 848ab5443..7f312fceb 100644 --- a/Authors +++ b/Authors @@ -68,6 +68,7 @@ John Tran Jonathan Bryce Jordan Rinke Joseph Suh +Joseph W. Breu Josh Durgin Josh Kearney Josh Kleinpeter @@ -133,6 +134,7 @@ Vasiliy Shlykov Vishvananda Ishaya Vivek Y S Vladimir Popovski +William Kelly William Wolf Yoshiaki Tamura Youcef Laribi diff --git a/nova/scheduler/simple.py b/nova/scheduler/simple.py index 8f993d9df..3f56b7c0c 100644 --- a/nova/scheduler/simple.py +++ b/nova/scheduler/simple.py @@ -34,6 +34,8 @@ flags.DEFINE_integer("max_gigabytes", 10000, "maximum number of volume gigabytes to allow per host") flags.DEFINE_integer("max_networks", 1000, "maximum number of networks to allow per host") +flags.DEFINE_string('default_schedule_zone', None, + 'zone to use when user doesnt specify one') class SimpleScheduler(chance.ChanceScheduler): @@ -45,7 +47,7 @@ class SimpleScheduler(chance.ChanceScheduler): availability_zone = instance_opts.get('availability_zone') - zone, host = None, None + zone, host = FLAGS.default_schedule_zone, None if availability_zone: zone, _x, host = availability_zone.partition(':')