| 1 |
# Copyright (c) 2017 IBM |
| 2 |
# All Rights Reserved. |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 |
# not use this file except in compliance with the License. You may obtain |
| 6 |
# a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations |
| 14 |
# under the License. |
| 15 |
|
| 16 |
from neutron_lib.api import converters as convert |
| 17 |
from neutron_lib.api.definitions import dns |
| 18 |
from neutron_lib.api.definitions import port |
| 19 |
from neutron_lib.db import constants |
| 20 |
|
| 21 |
|
| 22 |
# The alias of the extension. |
| 23 |
ALIAS = 'dns-domain-ports' |
| 24 |
|
| 25 |
# Whether or not this extension is simply signaling behavior to the user |
| 26 |
# or it actively modifies the attribute map (mandatory). |
| 27 |
IS_SHIM_EXTENSION = False |
| 28 |
|
| 29 |
# Whether the extension is marking the adoption of standardattr model for |
| 30 |
# legacy resources, or introducing new standardattr attributes. False or |
| 31 |
# None if the standardattr model is adopted since the introduction of |
| 32 |
# resource extension (mandatory). |
| 33 |
# If this is True, the alias for the extension should be prefixed with |
| 34 |
# 'standard-attr-'. |
| 35 |
IS_STANDARD_ATTR_EXTENSION = False |
| 36 |
|
| 37 |
# The name of the extension (mandatory). |
| 38 |
NAME = 'dns_domain for ports' |
| 39 |
|
| 40 |
# The description of the extension (mandatory). |
| 41 |
DESCRIPTION = "Allows the DNS domain to be specified for a network port." |
| 42 |
|
| 43 |
# A timestamp of when the extension was introduced (mandatory). |
| 44 |
UPDATED_TIMESTAMP = "2017-04-24T10:00:00-00:00" |
| 45 |
|
| 46 |
# The specific resources and/or attributes for the extension (optional). |
| 47 |
# In case of simple extensions, with single resource, the string constants |
| 48 |
# RESOURCE_NAME and COLLECTION_NAME can be used, otherwise string literals |
| 49 |
# can be used instead. |
| 50 |
|
| 51 |
# The name of the resource introduced or being extended |
| 52 |
# (in case it is defined by another extension, or it is |
| 53 |
# a core resource). |
| 54 |
RESOURCE_NAME = port.RESOURCE_NAME |
| 55 |
|
| 56 |
# The plural for the resource introduced or being extended |
| 57 |
# (in case it is defined by another extension, or it is a |
| 58 |
# core resource). |
| 59 |
COLLECTION_NAME = port.COLLECTION_NAME |
| 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 |
COLLECTION_NAME: { |
| 65 |
dns.DNSDOMAIN: {'allow_post': True, 'allow_put': True, |
| 66 |
'default': '', |
| 67 |
'convert_to': |
| 68 |
convert.convert_string_to_case_insensitive, |
| 69 |
'validate': {'type:dns_domain_name': |
| 70 |
constants.FQDN_FIELD_SIZE}, |
| 71 |
'is_visible': True}, |
| 72 |
}, |
| 73 |
} |
| 74 |
|
| 75 |
# The subresource attribute map for the extension. |
| 76 |
SUB_RESOURCE_ATTRIBUTE_MAP = { |
| 77 |
} |
| 78 |
|
| 79 |
# The action map |
| 80 |
ACTION_MAP = { |
| 81 |
} |
| 82 |
|
| 83 |
# The action status |
| 84 |
ACTION_STATUS = { |
| 85 |
} |
| 86 |
|
| 87 |
# The list of required extensions (mandatory). |
| 88 |
REQUIRED_EXTENSIONS = [dns.ALIAS] |
| 89 |
|
| 90 |
# The list of optional extensions (mandatory). |
| 91 |
OPTIONAL_EXTENSIONS = [ |
| 92 |
] |