Neutron’s resource attributes are defined in dictionaries
in api/definitions
.
The map containing all installed resources (for core and active extensions)
is in api/attributes.py
.
Example attribute definitions for dns_name
:
'dns_name': {
'allow_post': True,
'allow_put': True,
'default': '',
'convert_to': convert_to_lowercase,
'validate': {'type:dns_name': FQDN_MAX_LEN},
'is_visible': True
},
The validate
item specifies rules for validating
the attribute.
The convert_to
item specifies rules for converting
the attribute.
Example attribute definitions for gateway_ip
:
'gateway_ip': {
'allow_post': True,
'allow_put': True,
'default': constants.ATTR_NOT_SPECIFIED,
'validate': {'type:ip_address_or_none': None},
'is_visible': True
}
Note: a default of ATTR_NOT_SPECIFIED
indicates that an attribute is not
required, but will be generated by the plugin if it is not specified.
Particularly, a value of ATTR_NOT_SPECIFIED
is different from an
attribute that has been specified with a value of None
. For example,
if gateway_ip
is omitted in a request to create a subnet, the plugin
will receive ATTR_NOT_SPECIFIED
and the default gateway IP will be
generated. However, if gateway_ip
is specified as None
, this means
that the subnet does not have a gateway IP.
The following are the defined keys for attribute maps:
|
default value of the attribute (if missing, the attribute becomes mandatory) |
|
the attribute can be used on |
|
the attribute can be used on |
|
specifies rules for validating data in the attribute |
|
transformation to apply to the value before it is returned |
|
if the value is a list, apply this transformation to the value before it is returned |
|
the attribute can be used in |
|
the attribute can be used in |
|
the attribute is returned in |
|
the attribute is required by the policy engine and should therefore be filled by the API layer even if not present in request body |
|
the attribute is actively part of the policy enforcing mechanism, ie: there might be rules which refer to this attribute |
|
Mark the attribute as a unique key. |
|
if set, if the value passed is None, it will be replaced by the |
|
if set, the |
When extending existing sub-resources, the sub-attribute map must define all
extension attributes under the parameters
object. This instructs the API
internals to add the attributes to the existing sub-resource rather than
overwrite its existing definition. For example:
SUB_RESOURCE_ATTRIBUTE_MAP = {
'existing_subresource_to_extend': {
'parameters': {
'new_attr1': {
'allow_post': False,
# etc..
}
}
}
}
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.