update scheduler to use image-traits

Update the scheduler to take into account the traits specified
as part of the image properties. The required traits from the
image are added to the resource request along with the traits
and resources from the flavor.

This change does not handle rebuilding of the instance, this
will come as part of a follow on patch.

Added unit and functional tests

Change-Id: I3e00080a6b557c6a27634b1dc04fc589f0da0bc2
Implements: blueprint glance-image-traits
This commit is contained in:
Arvind Nadendla 2018-04-02 15:38:33 -07:00
parent 4d0430e221
commit 919b72a2bd

View File

@ -1511,6 +1511,7 @@ class CinderFixtureNewAttachFlow(fixtures.Fixture):
# This represents a bootable image-backed volume to test
# boot-from-volume scenarios.
IMAGE_BACKED_VOL = '6ca404f3-d844-4169-bb96-bc792f37de98'
IMAGE_WITH_TRAITS_BACKED_VOL = '6194fc02-c60e-4a01-a8e5-600798208b5f'
def __init__(self, test):
super(CinderFixtureNewAttachFlow, self).__init__()
@ -1589,14 +1590,23 @@ class CinderFixtureNewAttachFlow(fixtures.Fixture):
}
# Check for our special image-backed volume.
if volume_id == self.IMAGE_BACKED_VOL:
if (volume_id == self.IMAGE_BACKED_VOL or
volume_id == self.IMAGE_WITH_TRAITS_BACKED_VOL):
# Make it a bootable volume.
volume['bootable'] = True
# Add the image_id metadata.
volume['volume_image_metadata'] = {
# There would normally be more image metadata in here...
'image_id': '155d900f-4e14-4e4c-a73d-069cbf4541e6'
}
if volume_id == self.IMAGE_BACKED_VOL:
# Add the image_id metadata.
volume['volume_image_metadata'] = {
# There would normally be more image metadata in here.
'image_id': '155d900f-4e14-4e4c-a73d-069cbf4541e6'
}
elif volume_id == self.IMAGE_WITH_TRAITS_BACKED_VOL:
# Add the image_id metadata with traits.
volume['volume_image_metadata'] = {
'image_id': '155d900f-4e14-4e4c-a73d-069cbf4541e6',
"container_format": "ami",
"trait:HW_CPU_X86_SGX": "required",
}
return volume