summaryrefslogtreecommitdiffstats
path: root/deploy/post/nova.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-03-16 16:59:48 +0800
committerSerena Feng <feng.xiaowei@zte.com.cn>2017-03-23 06:26:26 +0000
commit84b0be2e12d83a48ac15b3e4f457b7e7fb465735 (patch)
tree420116aae0aa45dd6864b29da96b7be7838b0ae9 /deploy/post/nova.py
parent8eeced263cd35000623a69243766f0970055da69 (diff)
simplify get_xx process using query.find()
Change-Id: I2a911fc15c1456b409db840b9ae76c04a23d449d Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'deploy/post/nova.py')
-rw-r--r--deploy/post/nova.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/deploy/post/nova.py b/deploy/post/nova.py
index 0ab42e27..6f5eae91 100644
--- a/deploy/post/nova.py
+++ b/deploy/post/nova.py
@@ -8,6 +8,7 @@
##############################################################################
import novaclient.client
+from deploy.common import query
import keystoneauth
@@ -23,11 +24,8 @@ class Nova(keystoneauth.Keystoneauth):
return flavor.id
def get_flavor_by_name(self, name):
- for flavor in self.list_flavors():
- if flavor.name == name:
- return flavor.id
-
- return None
+ return query.find(lambda flavor: flavor.name == name,
+ self.list_flavors())
def list_flavors(self):
return self.flavors.list(detailed=True)