From 84b0be2e12d83a48ac15b3e4f457b7e7fb465735 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Thu, 16 Mar 2017 16:59:48 +0800 Subject: simplify get_xx process using query.find() Change-Id: I2a911fc15c1456b409db840b9ae76c04a23d449d Signed-off-by: SerenaFeng --- deploy/post/glance.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'deploy/post/glance.py') diff --git a/deploy/post/glance.py b/deploy/post/glance.py index 7ea4b51d..4171c8a8 100644 --- a/deploy/post/glance.py +++ b/deploy/post/glance.py @@ -10,6 +10,7 @@ import os import glanceclient +from deploy.common import query import keystoneauth @@ -35,11 +36,7 @@ class Glance(keystoneauth.Keystoneauth): return id def get_by_name(self, name): - for image in self.list(): - if image.name == name: - return image.id - - return None + return query.find(lambda image: image.name == name, self.list()) def list(self): return self.controller.list() -- cgit 1.2.3-korg