[openstack-dev] [Quantum][LBaaS] Specify optional Attribute in RESOURCE_ATTRIBUTE_MAP

Salvatore Orlando sorlando at nicira.com
Thu May 30 08:03:33 UTC 2013


Hi Pattabi,

Try with:

from quantum.api.v2 import attributes

def _validate_range_or_none(data, valid_values=None):
      if data:
           _validate_range(data, valid_values)

.....
'delay': {
    .....
    'default': attributes.ATTRIBUTE_NOT_SPECIFIED
    'validate': {'type:range_or_none': [1, 120]}
    .....
}
......

validators = {
     ....
     'type:range_or_none': _validate_range_or_none
     ....
}


Regards,
Salvatore



On 29 May 2013 19:52, Pattabi Ayyasami <pattabi at brocade.com> wrote:

> Hi,****
>
> ** **
>
> How do I specify an attribute as optional without having to specify a
> default value?  ****
>
> For example, how do I specify “delay” attribute is optional in the request
> without having to specify a default value of “5”? ****
>
> Is this because I also have a “validate” constraint?****
>
> ** **
>
> Snippet from loadbalancer.py in quantum/extensions.****
>
> ** **
>
> 'delay': {'allow_post': True, 'allow_put': True,****
>
>                   'default': '5',****
>
>                   'validate': {'type:range': [1, 120]},****
>
>                   'convert_to': attr.convert_to_int,****
>
>                   'is_visible': True}****
>
> ** **
>
> Regards,****
>
> Pattabi****
>
> ** **
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130530/8ca3cec4/attachment.html>


More information about the OpenStack-dev mailing list