Debian Codegraph @

neutron_lib/api/definitions/dns.py

raw
1 # All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 from neutron_lib.api import converters as convert
16 from neutron_lib.api.definitions import l3
17 from neutron_lib.api.definitions import network
18 from neutron_lib.api.definitions import port
19 from neutron_lib.api import validators
20 from neutron_lib.api.validators import dns as dns_validator
21 from neutron_lib.db import constants
22
23 # The alias of the extension.
24 ALIAS = 'dns-integration'
25
26 # Whether or not this extension is simply signaling behavior to the user
27 # or it actively modifies the attribute map (mandatory).
28 IS_SHIM_EXTENSION = False
29
30 # Whether the extension is marking the adoption of standardattr model for
31 # legacy resources, or introducing new standardattr attributes. False or
32 # None if the standardattr model is adopted since the introduction of
33 # resource extension (mandatory).
34 # If this is True, the alias for the extension should be prefixed with
35 # 'standard-attr-'.
36 IS_STANDARD_ATTR_EXTENSION = False
37
38 # The name of the extension (mandatory).
39 NAME = 'DNS Integration'
40
41 # A prefix for API resources. An empty prefix means that the API is going
42 # to be exposed at the v2/ level as any other core resource (mandatory).
43 API_PREFIX = ''
44
45 # The description of the extension (mandatory).
46 DESCRIPTION = "Provides integration with DNS."
47
48 # A timestamp of when the extension was introduced (mandatory).
49 UPDATED_TIMESTAMP = "2015-08-15T18:00:00-00:00"
50
51 DNSNAME = 'dns_name'
52 DNSDOMAIN = 'dns_domain'
53 DNSASSIGNMENT = 'dns_assignment'
54
55 validators.add_validator('dns_host_name', dns_validator.validate_dns_name)
56 validators.add_validator('fip_dns_host_name',
57 dns_validator.validate_fip_dns_name)
58 validators.add_validator('dns_domain_name',
59 dns_validator.validate_dns_domain)
60
61 # The resource attribute map for the extension. It is effectively the
62 # bulk of the API contract alongside ACTION_MAP (mandatory).
63 RESOURCE_ATTRIBUTE_MAP = {
64 port.COLLECTION_NAME: {
65 DNSNAME: {'allow_post': True, 'allow_put': True,
66 'default': '',
67 'convert_to': convert.convert_string_to_case_insensitive,
68 'validate': {'type:dns_host_name':
69 constants.FQDN_FIELD_SIZE},
70 'is_visible': True},
71 DNSASSIGNMENT: {'allow_post': False, 'allow_put': False,
72 'is_visible': True},
73 },
74 l3.FLOATINGIPS: {
75 DNSNAME: {'allow_post': True, 'allow_put': False,
76 'default': '',
77 'convert_to': convert.convert_string_to_case_insensitive,
78 'validate': {'type:fip_dns_host_name':
79 constants.FQDN_FIELD_SIZE},
80 'is_visible': True},
81 DNSDOMAIN: {'allow_post': True, 'allow_put': False,
82 'default': '',
83 'convert_to': convert.convert_string_to_case_insensitive,
84 'validate': {'type:dns_domain_name':
85 constants.FQDN_FIELD_SIZE},
86 'is_visible': True},
87 },
88 network.COLLECTION_NAME: {
89 DNSDOMAIN: {'allow_post': True, 'allow_put': True,
90 'default': '',
91 'convert_to': convert.convert_string_to_case_insensitive,
92 'validate': {'type:dns_domain_name':
93 constants.FQDN_FIELD_SIZE},
94 'is_visible': True},
95 },
96 }
97
98 # The subresource attribute map for the extension. It adds child resources
99 # to main extension's resource. The subresource map must have a parent and
100 # a parameters entry. If an extension does not need such a map, None can
101 # be specified (mandatory). For example:
102 SUB_RESOURCE_ATTRIBUTE_MAP = {}
103
104 # The action map: it associates verbs with methods to be performed on
105 # the API resource (mandatory).
106 ACTION_MAP = {}
107
108 # The action status: it associates response statuses with methods to be
109 # performed on the API resource (mandatory).
110 ACTION_STATUS = {}
111
112 # The list of required extensions (mandatory).
113 REQUIRED_EXTENSIONS = [l3.ALIAS]
114
115 # The list of optional extensions (mandatory).
116 OPTIONAL_EXTENSIONS = []