Merge "Add trove flavor custom constraint"
This commit is contained in:
commit
55df1256e2
@ -17,6 +17,7 @@ from troveclient.openstack.common.apiclient import exceptions
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.engine.clients import client_plugin
|
||||
from heat.engine import constraints
|
||||
|
||||
|
||||
class TroveClientPlugin(client_plugin.ClientPlugin):
|
||||
@ -108,3 +109,11 @@ class TroveClientPlugin(client_plugin.ClientPlugin):
|
||||
if flavor_id is None:
|
||||
raise exception.FlavorMissing(flavor_id=flavor)
|
||||
return flavor_id
|
||||
|
||||
|
||||
class FlavorConstraint(constraints.BaseCustomConstraint):
|
||||
|
||||
expected_exceptions = (exception.FlavorMissing,)
|
||||
|
||||
def validate_with_client(self, client, flavor):
|
||||
client.client_plugin('trove').get_flavor_id(flavor)
|
||||
|
@ -92,7 +92,10 @@ class OSDBInstance(resource.Resource):
|
||||
FLAVOR: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('Reference to a flavor for creating DB instance.'),
|
||||
required=True
|
||||
required=True,
|
||||
constraints=[
|
||||
constraints.CustomConstraint('trove.flavor')
|
||||
]
|
||||
),
|
||||
DATASTORE_TYPE: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
|
@ -31,6 +31,7 @@ from heat.engine.clients.os import glance
|
||||
from heat.engine.clients.os import keystone
|
||||
from heat.engine.clients.os import neutron
|
||||
from heat.engine.clients.os import nova
|
||||
from heat.engine.clients.os import trove
|
||||
from heat.engine import environment
|
||||
from heat.engine import resources
|
||||
from heat.engine import scheduler
|
||||
@ -191,3 +192,7 @@ class HeatTestCase(testscenarios.WithScenarios,
|
||||
def stub_PortConstraint_validate(self):
|
||||
validate = self.patchobject(neutron.PortConstraint, 'validate')
|
||||
validate.return_value = True
|
||||
|
||||
def stub_TroveFlavorConstraint_validate(self):
|
||||
validate = self.patchobject(trove.FlavorConstraint, 'validate')
|
||||
validate.return_value = True
|
||||
|
@ -102,6 +102,7 @@ class OSDBInstanceTest(common.HeatTestCase):
|
||||
self.fc = self.m.CreateMockAnything()
|
||||
self.nova = self.m.CreateMockAnything()
|
||||
self.m.StubOutWithMock(trove.TroveClientPlugin, '_create')
|
||||
self.stub_TroveFlavorConstraint_validate()
|
||||
|
||||
def _setup_test_clouddbinstance(self, name, t):
|
||||
stack_name = '%s_stack' % name
|
||||
|
@ -71,6 +71,7 @@ heat.constraints =
|
||||
cinder.snapshot = heat.engine.clients.os.cinder:VolumeSnapshotConstraint
|
||||
cinder.vtype = heat.engine.clients.os.cinder:VolumeTypeConstraint
|
||||
sahara.image = heat.engine.clients.os.sahara:ImageConstraint
|
||||
trove.flavor = heat.engine.clients.os.trove:FlavorConstraint
|
||||
|
||||
heat.stack_lifecycle_plugins =
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user