Merge lp:~james-page/charm-helpers/flavor-helper into lp:charm-helpers

Proposed by James Page
Status: Merged
Merged at revision: 649
Proposed branch: lp:~james-page/charm-helpers/flavor-helper
Merge into: lp:charm-helpers
Diff against target: 28 lines (+11/-0)
1 file modified
charmhelpers/contrib/openstack/amulet/utils.py (+11/-0)
To merge this branch: bzr merge lp:~james-page/charm-helpers/flavor-helper
Reviewer Review Type Date Requested Status
Ryan Beisner (community) Approve
Review via email: mp+308307@code.launchpad.net

Description of the change

Add helper for creation of flavors by amulet tests.

To post a comment you must log in.
Revision history for this message
Ryan Beisner (1chb1n) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/amulet/utils.py'
2--- charmhelpers/contrib/openstack/amulet/utils.py 2016-10-07 18:05:08 +0000
3+++ charmhelpers/contrib/openstack/amulet/utils.py 2016-10-12 21:20:08 +0000
4@@ -28,6 +28,7 @@
5 from keystoneclient.auth.identity import v3 as keystone_id_v3
6 from keystoneclient import session as keystone_session
7 from keystoneclient.v3 import client as keystone_client_v3
8+from novaclient import exceptions
9
10 import novaclient.client as nova_client
11 import pika
12@@ -377,6 +378,16 @@
13 tenant_name=tenant,
14 auth_version='2.0')
15
16+ def create_flavor(self, nova, name, ram, vcpus, disk, flavorid="auto",
17+ ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True):
18+ """Create the specified flavor."""
19+ try:
20+ nova.flavors.find(name=name)
21+ except (exceptions.NotFound, exceptions.NoUniqueMatch):
22+ self.log.debug('Creating flavor ({})'.format(name))
23+ nova.flavors.create(name, ram, vcpus, disk, flavorid,
24+ ephemeral, swap, rxtx_factor, is_public)
25+
26 def create_cirros_image(self, glance, image_name):
27 """Download the latest cirros image and upload it to glance,
28 validate and return a resource pointer.

Subscribers

People subscribed via source and target branches