]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Expose Rest Api access to mtu attributes
authorPradeep Kilambi <pkilambi@cisco.com>
Tue, 10 Feb 2015 22:42:20 +0000 (14:42 -0800)
committerPradeep Kilambi <pkilambi@cisco.com>
Tue, 17 Mar 2015 18:07:11 +0000 (18:07 +0000)
Exposing Read only access to mtu attributes via the network
api calls so GET operations can be performed. Tied in the
mtu attribute with create network call and use the config
default. Also included unit tests to cover default and
override config case for segment_mtu attribute.

Partially Implements: blueprint mtu-selection-and-advertisement

Change-Id: I811c288bdd96691a96d1721eb29354c0911edf3a

neutron/api/v2/attributes.py
neutron/common/constants.py
neutron/db/db_base_plugin_v2.py
neutron/tests/unit/test_db_plugin.py

index 34d55b03cb926602fa9c545a7b26cc5cf8b0656d..8235e000fdfef792a97123028a642c4785df3490 100644 (file)
@@ -692,6 +692,8 @@ RESOURCE_ATTRIBUTE_MAP = {
                            'is_visible': True},
         'status': {'allow_post': False, 'allow_put': False,
                    'is_visible': True},
+        'mtu': {'allow_post': False, 'allow_put': False,
+                'is_visible': True},
         'tenant_id': {'allow_post': True, 'allow_put': False,
                       'validate': {'type:string': None},
                       'required_by_policy': True,
index 774d920d919f50b9e778ce397e558d9298e322c5..f9f5a9a3742e9cea01d185a85d6bb1aea0461ac3 100644 (file)
@@ -168,3 +168,6 @@ RPC_NAMESPACE_SECGROUP = None
 RPC_NAMESPACE_DVR = None
 # RPC interface for reporting state back to the plugin
 RPC_NAMESPACE_STATE = None
+
+# Default network MTU value when not configured
+DEFAULT_NETWORK_MTU = 0
index 73db078b82a5bd9088c98b7007c60089542a48ed..8950da5b41f7e2bbeebb2b5803a47ffd0bc3cfd8 100644 (file)
@@ -781,6 +781,7 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
                'name': network['name'],
                'tenant_id': network['tenant_id'],
                'admin_state_up': network['admin_state_up'],
+               'mtu': network.get('mtu', constants.DEFAULT_NETWORK_MTU),
                'status': network['status'],
                'shared': network['shared'],
                'subnets': [subnet['id']
@@ -869,6 +870,7 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
                     'id': n.get('id') or uuidutils.generate_uuid(),
                     'name': n['name'],
                     'admin_state_up': n['admin_state_up'],
+                    'mtu': n.get('mtu', constants.DEFAULT_NETWORK_MTU),
                     'shared': n['shared'],
                     'status': n.get('status', constants.NET_STATUS_ACTIVE)}
             network = models_v2.Network(**args)
index d0b4f4bcabbd971a335fae2827e63fb3dd1f419c..ccc57d08c8fa33d1a7c5ccaa88963a3a2d9ec8b6 100644 (file)
@@ -2026,6 +2026,12 @@ class TestNetworksV2(NeutronDbPluginV2TestCase):
         self.assertEqual(ctx_manager.exception.code,
                          webob.exc.HTTPForbidden.code)
 
+    def test_create_network_default_mtu(self):
+        name = 'net1'
+        with self.network(name=name) as net:
+            self.assertEqual(net['network']['mtu'],
+                             constants.DEFAULT_NETWORK_MTU)
+
     def test_update_network(self):
         with self.network() as network:
             data = {'network': {'name': 'a_brand_new_name'}}