Repository navigation
Validate endpoint connection info without saving it first - #536
mihaelabalutoiu wants to merge 3 commits into
Conversation
a4ab0a4 to
2626c4b
Compare
|
Note: The integration tests fail with: This is expected: the integration tests install Update: no longer applies — the integration tests call the new action directly over REST, so they don't depend on the client and this PR stands on its own. |
|
|
||
| endpoint_actions_resource = endpoint_actions.create_resource() | ||
| self.resources['endpoint_actions'] = endpoint_actions_resource | ||
| endpoint_path = '/{project_id}/endpoints/{id}' |
There was a problem hiding this comment.
Why remove this API? We can add a new one that validates the connection info, while still allowing an existing endpoint to be validated.
There was a problem hiding this comment.
You're right — I've added validate-connection-info as a new action on POST /endpoints/actions, and left validate-connection unchanged. Thank you!
Allow `format_keyerror_message` to describe missing attributes of a validation request body. Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
33bd47d to
f66d65a
Compare
Add a `validate-connection-info` action on `/endpoints/actions`, which validates the platform and connection info given in the request body, so an endpoint can be checked before it is saved. Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
f66d65a to
94937cb
Compare
| def _validate_connection_info(self, req, body): | ||
| context = req.environ['coriolis.context'] | ||
| context.can( | ||
| "%s:validate_connection_info" % (endpoint_policies.ENDPOINTS_POLICY_PREFIX) |
There was a problem hiding this comment.
This new policy will have to be added in the policy template as well (in coriolis-docker): https://github.com/cloudbase/coriolis-docker/blob/07179580f4cd973d5a1da855b6ecad3babedff40/coriolis_ansible/roles/coriolis/common/templates/policy.yml.j2#L14
| } | ||
| result = self.endpoints_api.validate_connection_info(**args) | ||
| ( | ||
| self.endpoints_api._rpc_conductor_client.validate_endpoint_connection_info.assert_called_once_with |
There was a problem hiding this comment.
NIT: Why is this line inside of paranthesis?
| )(*(args.values())) | ||
| self.assertEqual( | ||
| ( | ||
| self.endpoints_api._rpc_conductor_client.validate_endpoint_connection_info.return_value |
Previously, the endpoint validation API only worked on stored endpoints (
/endpoints/{id}/actions), so we had to save an endpoint before we could check its connection info. Invalid endpoints were persisted when validation failed.This PR implements the following:
format_keyerror_messageto describe missing attributes of a validation request body.validate-connection-infoaction on/endpoints/actions, which validates theplatformandconnection_infogiven in the request body, so an endpoint can be checked before it is saved.unit tests.Related PRs: coriolis-web python-coriolisclient