Merge "Better schema for Rackspace::AutoScale::Group image and flavor"

This commit is contained in:
Jenkins 2015-11-25 19:58:46 +00:00 committed by Gerrit Code Review
commit 3547950142
2 changed files with 21 additions and 4 deletions

View File

@ -148,12 +148,18 @@ class Group(resource.Resource):
),
LAUNCH_CONFIG_ARGS_SERVER_FLAVOR_REF: properties.Schema(
properties.Schema.STRING,
_('Flavor ID.'),
_('The ID or name of the flavor to boot onto.'),
constraints=[
constraints.CustomConstraint('nova.flavor')
],
required=True
),
LAUNCH_CONFIG_ARGS_SERVER_IMAGE_REF: properties.Schema(
properties.Schema.STRING,
_('Image ID.'),
_('The ID or name of the image to boot with.'),
constraints=[
constraints.CustomConstraint('glance.image')
],
required=True
),
LAUNCH_CONFIG_ARGS_SERVER_METADATA: properties.Schema(
@ -298,12 +304,16 @@ class Group(resource.Resource):
user_data = server_args.get(self.LAUNCH_CONFIG_ARGS_SERVER_USER_DATA)
cdrive = (server_args.get(self.LAUNCH_CONFIG_ARGS_SERVER_CDRIVE) or
bool(user_data is not None and len(user_data.strip())))
image_id = self.client_plugin('glance').get_image_id(
server_args[self.LAUNCH_CONFIG_ARGS_SERVER_IMAGE_REF])
flavor_id = self.client_plugin('nova').get_flavor_id(
server_args[self.LAUNCH_CONFIG_ARGS_SERVER_FLAVOR_REF])
return dict(
launch_config_type=launchconf[self.LAUNCH_CONFIG_TYPE],
server_name=server_args[self.GROUP_CONFIGURATION_NAME],
image=server_args[self.LAUNCH_CONFIG_ARGS_SERVER_IMAGE_REF],
flavor=server_args[self.LAUNCH_CONFIG_ARGS_SERVER_FLAVOR_REF],
image=image_id,
flavor=flavor_id,
disk_config=server_args.get(
self.LAUNCH_CONFIG_ARGS_SERVER_DISK_CONFIG),
metadata=server_args.get(self.GROUP_CONFIGURATION_METADATA),

View File

@ -18,6 +18,8 @@ import mock
from heat.common import exception
from heat.common import template_format
from heat.engine.clients.os import glance
from heat.engine.clients.os import nova
from heat.engine import resource
from heat.engine import rsrc_defn
from heat.engine import scheduler
@ -207,6 +209,11 @@ class ScalingGroupTest(common.HeatTestCase):
self.fake_auto_scale = FakeAutoScale()
self.patchobject(auto_scale.Group, 'auto_scale',
return_value=self.fake_auto_scale)
# mock nova and glance client methods to satisfy contraints
mock_im = self.patchobject(glance.GlanceClientPlugin, 'get_image_id')
mock_im.return_value = 'image-ref'
mock_fl = self.patchobject(nova.NovaClientPlugin, 'get_flavor_id')
mock_fl.return_value = 'flavor-ref'
def _setup_test_stack(self):
self.stack = utils.parse_stack(self.group_template)