diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index 9e1463e43..942b7058d 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -28,6 +28,7 @@ from neutron_lib.api.definitions import l3 from neutron_lib.api.definitions import logging from neutron_lib.api.definitions import logging_resource from neutron_lib.api.definitions import network +from neutron_lib.api.definitions import network_ip_availability from neutron_lib.api.definitions import network_mtu from neutron_lib.api.definitions import port from neutron_lib.api.definitions import port_security @@ -59,6 +60,7 @@ _ALL_API_DEFINITIONS = { logging, logging_resource, network, + network_ip_availability, network_mtu, port, port_security, diff --git a/neutron_lib/api/definitions/network_ip_availability.py b/neutron_lib/api/definitions/network_ip_availability.py new file mode 100644 index 000000000..ba732e701 --- /dev/null +++ b/neutron_lib/api/definitions/network_ip_availability.py @@ -0,0 +1,59 @@ +# Copyright 2016 GoDaddy. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ALIAS = 'network-ip-availability' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Network IP Availability' +API_PREFIX = '' +DESCRIPTION = 'Provides IP availability data for each network and subnet.' +UPDATED_TIMESTAMP = '2015-09-24T00:00:00-00:00' +RESOURCE_NAME = "network_ip_availability" +RESOURCE_PLURAL = "network_ip_availabilities" +COLLECTION_NAME = RESOURCE_PLURAL.replace('_', '-') +RESOURCE_ATTRIBUTE_MAP = { + RESOURCE_PLURAL: { + 'network_id': { + 'allow_post': False, 'allow_put': False, + 'is_visible': True + }, + 'network_name': { + 'allow_post': False, 'allow_put': False, + 'is_visible': True + }, + 'tenant_id': { + 'allow_post': False, 'allow_put': False, + 'is_visible': True + }, + 'total_ips': { + 'allow_post': False, 'allow_put': False, + 'is_visible': True + }, + 'used_ips': { + 'allow_post': False, 'allow_put': False, + 'is_visible': True + }, + 'subnet_ip_availability': { + 'allow_post': False, 'allow_put': False, + 'is_visible': True + } + # TODO(wwriverrat) Make composite attribute for subnet_ip_availability + } +} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_network_ip_availability.py b/neutron_lib/tests/unit/api/definitions/test_network_ip_availability.py new file mode 100644 index 000000000..496c2e8b8 --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_network_ip_availability.py @@ -0,0 +1,22 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from neutron_lib.api.definitions import network_ip_availability +from neutron_lib.tests.unit.api.definitions import base + + +class NetworkIPAvailabilityDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = network_ip_availability + extension_resources = (network_ip_availability.RESOURCE_PLURAL,) + extension_attributes = ('total_ips', 'used_ips', + 'subnet_ip_availability', + 'network_name',) diff --git a/releasenotes/notes/rehome-netipavail-apidef-d03558ac48b71333.yaml b/releasenotes/notes/rehome-netipavail-apidef-d03558ac48b71333.yaml new file mode 100644 index 000000000..d12fa912c --- /dev/null +++ b/releasenotes/notes/rehome-netipavail-apidef-d03558ac48b71333.yaml @@ -0,0 +1,4 @@ +--- +features: + - The ``network-ip-availability`` extension's API definition is now available + in ``neutron_lib.api.definitions.network_ip_availability``.