summaryrefslogtreecommitdiffstats
path: root/nova/scheduler/driver.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-20 16:34:26 +0000
committerGerrit Code Review <review@openstack.org>2013-06-20 16:34:26 +0000
commit3ab42d430d496ecf0c12d37c05f9923faf33114f (patch)
tree5bb6777e116e8487055c02c3a9de2dab3006072f /nova/scheduler/driver.py
parente72b32d02bd2a3fd283a103a04e383df0ba4db65 (diff)
parentb2c17ae891b12118b9d11bf0ecc44e77956715c8 (diff)
downloadnova-3ab42d430d496ecf0c12d37c05f9923faf33114f.tar.gz
nova-3ab42d430d496ecf0c12d37c05f9923faf33114f.tar.xz
nova-3ab42d430d496ecf0c12d37c05f9923faf33114f.zip
Merge "Initial scheduler support for instance_groups"
Diffstat (limited to 'nova/scheduler/driver.py')
-rw-r--r--nova/scheduler/driver.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py
index d5a1eedea..6a429f526 100644
--- a/nova/scheduler/driver.py
+++ b/nova/scheduler/driver.py
@@ -94,6 +94,14 @@ def instance_update_db(context, instance_uuid, extra_values=None):
values = {'host': None, 'node': None, 'scheduled_at': now}
if extra_values:
values.update(extra_values)
+ # Get the instance_group if it exists. This will be written to the
+ # system_metadata as it will be used when the VM is deleted
+ system_metadata = extra_values.get('system_metadata', None)
+ if system_metadata:
+ instance_group = system_metadata.get('instance_group', None)
+ if instance_group:
+ conductor_api.instance_group_members_add(context,
+ instance_group, [instance_uuid])
return db.instance_update(context, instance_uuid, values)
@@ -139,15 +147,17 @@ class Scheduler(object):
for service in services
if self.servicegroup_api.service_is_up(service)]
- def group_hosts(self, context, group):
- """Return the list of hosts that have VM's from the group."""
+ def instance_group_data(self, context, group_uuid):
+ """Return the the group data for the instance group."""
- # The system_metadata 'group' will be filtered
- members = db.instance_get_all_by_filters(context,
- {'deleted': False, 'group': group})
- return [member['host']
- for member in members
- if member.get('host') is not None]
+ return conductor_api.instance_group_get_all(context, group_uuid)
+
+ def instance_group_hosts(self, context, instance_group):
+ """Return the list of hosts that have VM's from the instance_group."""
+
+ instances = instance_group['instances']
+ return [instance['host'] for instance in instances
+ if instance.get('host') is not None]
def schedule_prep_resize(self, context, image, request_spec,
filter_properties, instance, instance_type,