policy validate cann't work when create a policy
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
senlin |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
When I create a loadbalancer policy with an invalid subnet,but it's also create successfully.
Then I see the senlin code with policy create,"policy = self._validate_
" in the policy_
def policy_create(self, ctx, req):
"""Create a policy with the given name and spec.
:param ctx: An instance of the request context.
:param req: An instance of the PolicyCreateReq
:return: A dictionary containing the details of the policy object
"""
name = req.name
if CONF.name_unique:
if policy_
msg = _("A policy named '%(name)s' already exists."
policy = self._validate_
return policy.to_dict()
def _validate_
"""Validate a policy.
:param context: An instance of the request context.
:param spec: A dictionary containing the spec for the policy.
:param name: The name of the policy to be validated.
:param validate_props: Whether to validate the value of property.
:return: Validated policy object.
"""
type_name, version = schema.
type_str = "-".join(
plugin = environment.
kwargs = {
'user': context.user,
}
if name is None:
name = 'validated_policy'
policy = plugin(name, spec, **kwargs)
try:
except exception.
msg = six.text_type(ex)
raise exception.
return policy
def validate(self, context, validate_
if not validate_props:
return True
nc = self.network(
# validate pool subnet
name_or_id = self.pool_
try:
except exc.InternalError:
msg = _("The specified %(key)s '%(value)s' could not be found."
raise exc.InvalidSpec
# validate VIP subnet
name_or_id = self.vip_
try:
except exc.InternalError:
msg = _("The specified %(key)s '%(value)s' could not be found."
raise exc.InvalidSpec
Reviewed: https:/ /review. openstack. org/503502 /git.openstack. org/cgit/ openstack/ senlin/ commit/ ?id=914a46eff07 aa44c7d802fe70b 1a58a38bc514c6
Committed: https:/
Submitter: Jenkins
Branch: master
commit 914a46eff07aa44 c7d802fe70b1a58 a38bc514c6
Author: TingtingYu <yu_qearl@163.com>
Date: Wed Sep 13 10:09:43 2017 +0800
fix the bug that policy validate cannot work when creatting a policy
It can be created successfully when I create a policy with an props,so that the policy validate() cannot validate deeply.
invalid subnet. And I find the default value is False of the parameter
validate_
To fix the bug, I change the validate_props from False to True in the
code of policy_create().
Change-Id: I727b3a0d74ff69 d8cd797b8a5af8d 6f40a8f5fb9
Closes-Bug: 1716812