diff options
author | Zhijiang Hu <hu.zhijiang@zte.com.cn> | 2017-03-15 14:17:31 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-03-15 14:17:31 +0000 |
commit | af66c7f4fd99ca8491fa3024832cdad0568b3047 (patch) | |
tree | b4e8a429f25ffd2ecfeb5d3b9a4dedaa7c7a91fb /deploy/post/nova.py | |
parent | a46f3e8c4ef7e09deb3d5dc2d1e6969b6375b905 (diff) | |
parent | f51cb39fda90a227b7fe80d06fc70f96a1ced128 (diff) |
Merge "create m1.micro flavor for functest"
Diffstat (limited to 'deploy/post/nova.py')
-rw-r--r-- | deploy/post/nova.py | 25 |
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) |