Unsubvert image and flavor caching

Recent shade allows users to pass in image and flavor to create_server
by name. This results in a potential extra lookup to find the image and
flavor. Since nodepool is not using shade caching, this is causing our
nodepool-level caching to be subverted. Although an eventual project to
get nodepool to use shade caching, that's a bad scope creep for now.
Just pass in the objects themselves, which gets shade to not attempt to
look for them. In the case where we have an image_id - put it into a
dict so that shade treats it as an object passed in and not a thing that
needs to be treated like a name_or_id.

Depends-On: I4938037decf51001ab5789ee383f6c7ed34889b1
Change-Id: Ic70b19ad5baf25413e20a658163ca718dce63bee
This commit is contained in:
Monty Taylor 2016-09-01 13:41:56 -05:00
parent 362f0a0cd2
commit 919981b652
1 changed files with 6 additions and 2 deletions

View File

@ -183,9 +183,13 @@ class ProviderManager(TaskManager):
nodepool_image_name=None,
nodepool_snapshot_image_id=None):
if image_name:
image_id = self.findImage(image_name)['id']
image = self.findImage(image_name)
else:
image = {'id': image_id}
flavor = self.findFlavor(min_ram, name_filter)
create_args = dict(name=name, image=image_id, flavor=flavor['id'],
create_args = dict(name=name,
image=image,
flavor=flavor,
config_drive=config_drive)
if key_name:
create_args['key_name'] = key_name