Merge "add 'check_capacity' parameter to envine service"
This commit is contained in:
commit
3eeadf178e
|
@ -1417,6 +1417,22 @@ class EngineService(service.Service):
|
|||
ctx.user = db_cluster.user
|
||||
ctx.project = db_cluster.project
|
||||
|
||||
inputs = {}
|
||||
if req.obj_attr_is_set('params') and req.params:
|
||||
if 'operation' in req.params:
|
||||
inputs['operation'] = req.params.pop('operation')
|
||||
|
||||
if 'check' in req.params:
|
||||
inputs['check'] = req.params.pop('check')
|
||||
|
||||
if 'check_capacity' in req.params:
|
||||
inputs['check_capacity'] = req.params.pop('check_capacity')
|
||||
|
||||
if len(req.params):
|
||||
keys = [str(k) for k in req.params]
|
||||
msg = _("Action parameter %s is not recognizable.") % keys
|
||||
raise exception.BadRequest(msg=msg)
|
||||
|
||||
# TODO(anyone): should check if the 'params' attribute, if set,
|
||||
# contains valid fields. This can be done by modeling the 'params'
|
||||
# attribute into a separate object.
|
||||
|
@ -1424,7 +1440,7 @@ class EngineService(service.Service):
|
|||
'name': 'cluster_recover_%s' % db_cluster.id[:8],
|
||||
'cause': consts.CAUSE_RPC,
|
||||
'status': action_mod.Action.READY,
|
||||
'inputs': req.params if req.obj_attr_is_set('params') else {}
|
||||
'inputs': inputs
|
||||
}
|
||||
action_id = action_mod.Action.create(ctx, db_cluster.id,
|
||||
consts.CLUSTER_RECOVER, **params)
|
||||
|
|
|
@ -1443,7 +1443,8 @@ class ClusterTest(base.SenlinTestCase):
|
|||
x_cluster = mock.Mock(id='CID')
|
||||
mock_find.return_value = x_cluster
|
||||
mock_action.return_value = 'ACTION_ID'
|
||||
req = orco.ClusterRecoverRequest(identity='C1', params={'foo': 'bar'})
|
||||
req = orco.ClusterRecoverRequest(identity='C1',
|
||||
params={'operation': 'RECREATE'})
|
||||
|
||||
result = self.eng.cluster_recover(self.ctx, req.obj_to_primitive())
|
||||
|
||||
|
@ -1454,7 +1455,7 @@ class ClusterTest(base.SenlinTestCase):
|
|||
name='cluster_recover_CID',
|
||||
cause=consts.CAUSE_RPC,
|
||||
status=am.Action.READY,
|
||||
inputs={'foo': 'bar'},
|
||||
inputs={'operation': 'RECREATE'},
|
||||
)
|
||||
notify.assert_called_once_with()
|
||||
|
||||
|
@ -1473,6 +1474,23 @@ class ClusterTest(base.SenlinTestCase):
|
|||
six.text_type(ex.exc_info[1]))
|
||||
mock_find.assert_called_once_with(self.ctx, 'Bogus')
|
||||
|
||||
@mock.patch.object(co.Cluster, 'find')
|
||||
def test_cluster_recover_invalid(self, mock_find):
|
||||
x_cluster = mock.Mock(id='CID')
|
||||
mock_find.return_value = x_cluster
|
||||
|
||||
req = orco.ClusterRecoverRequest(identity='Bogus',
|
||||
params={'bad': 'fake'})
|
||||
|
||||
ex = self.assertRaises(rpc.ExpectedException,
|
||||
self.eng.cluster_recover,
|
||||
self.ctx, req.obj_to_primitive())
|
||||
|
||||
self.assertEqual(exc.BadRequest, ex.exc_info[0])
|
||||
self.assertEqual("Action parameter ['bad'] is not recognizable.",
|
||||
six.text_type(ex.exc_info[1]))
|
||||
mock_find.assert_called_once_with(self.ctx, 'Bogus')
|
||||
|
||||
@mock.patch.object(am.Action, 'create')
|
||||
@mock.patch.object(co.Cluster, 'find')
|
||||
@mock.patch.object(dispatcher, 'start_action')
|
||||
|
|
Loading…
Reference in New Issue