summaryrefslogtreecommitdiffstats
path: root/deploy/post/nova.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-03-14 17:53:45 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2017-03-14 18:08:07 +0800
commitf51cb39fda90a227b7fe80d06fc70f96a1ced128 (patch)
treeb1c7732e63ff476a14496b716300205cd2ba0226 /deploy/post/nova.py
parentc557362eb2a14055587feac228a4463bd96f6f4a (diff)
create m1.micro flavor for functest
Change-Id: Iacb36cb05e72b0755cec0a5bd5a6c48f3ec70c6f Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'deploy/post/nova.py')
-rw-r--r--deploy/post/nova.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/deploy/post/nova.py b/deploy/post/nova.py
new file mode 100644
index 00000000..5c356a13
--- /dev/null
+++ b/deploy/post/nova.py
@@ -0,0 +1,25 @@
+import novaclient.client
+
+import keystoneauth
+
+
+class Nova(keystoneauth.Keystoneauth):
+ def __init__(self, version='2', openrc=None):
+ super(Nova, self).__init__(openrc)
+ self.client = novaclient.client.Client(version, session=self.session)
+ self.flavors = self.client.flavors
+
+ def create_flavor(self, name, ram, vcpus, disk, is_public=True):
+ flavor = self.flavors.create(name, ram, vcpus, disk,
+ is_public=is_public)
+ 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
+
+ def list_flavors(self):
+ return self.flavors.list(detailed=True)