python-shade expose MTU setting.
The networking API v2 specification, which is implemented by openstack neutron, features an optional MTU parameter - when creating a network, this allows operators to specify the value for the maximum transmission unit value. Change-Id: I288f02551555fff3e8b350fc6d7c6ae8f60c405c
This commit is contained in:
parent
de9bc53b1b
commit
545b5aae28
6
releasenotes/notes/mtu-settings-8ce8b54d096580a2.yaml
Normal file
6
releasenotes/notes/mtu-settings-8ce8b54d096580a2.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
create_network now exposes the mtu api option in accordance to network
|
||||
v2 api. This allows the operator to adjust the given MTU value which
|
||||
is needed in various complex network deployments.
|
@ -3462,7 +3462,8 @@ class OpenStackCloud(
|
||||
def create_network(self, name, shared=False, admin_state_up=True,
|
||||
external=False, provider=None, project_id=None,
|
||||
availability_zone_hints=None,
|
||||
port_security_enabled=None):
|
||||
port_security_enabled=None,
|
||||
mtu_size=None):
|
||||
"""Create a network.
|
||||
|
||||
:param string name: Name of the network being created.
|
||||
@ -3476,6 +3477,8 @@ class OpenStackCloud(
|
||||
will be created on (admin-only).
|
||||
:param list availability_zone_hints: A list of availability zone hints.
|
||||
:param bool port_security_enabled: Enable / Disable port security
|
||||
:param int mtu_size: maximum transmission unit value to address
|
||||
fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6.
|
||||
|
||||
:returns: The network object.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
@ -3524,6 +3527,16 @@ class OpenStackCloud(
|
||||
"Parameter 'port_security_enabled' must be a bool")
|
||||
network['port_security_enabled'] = port_security_enabled
|
||||
|
||||
if mtu_size:
|
||||
if not isinstance(mtu_size, int):
|
||||
raise exc.OpenStackCloudException(
|
||||
"Parameter 'mtu_size' must be an integer.")
|
||||
if not mtu_size >= 68:
|
||||
raise exc.OpenStackCloudException(
|
||||
"Parameter 'mtu_size' must be greater than 67.")
|
||||
|
||||
network['mtu'] = mtu_size
|
||||
|
||||
data = self._network_client.post("/networks.json",
|
||||
json={'network': network})
|
||||
|
||||
@ -11239,7 +11252,7 @@ class OpenStackCloud(
|
||||
json=dict(addProjectAccess=payload),
|
||||
error_message="Unable to authorize {project} "
|
||||
"to use volume type {name}".format(
|
||||
name=name_or_id, project=project_id))
|
||||
name=name_or_id, project=project_id))
|
||||
|
||||
def remove_volume_type_access(self, name_or_id, project_id):
|
||||
"""Revoke access on a volume_type to a project.
|
||||
@ -11260,7 +11273,7 @@ class OpenStackCloud(
|
||||
json=dict(removeProjectAccess=payload),
|
||||
error_message="Unable to revoke {project} "
|
||||
"to use volume type {name}".format(
|
||||
name=name_or_id, project=project_id))
|
||||
name=name_or_id, project=project_id))
|
||||
|
||||
def set_compute_quotas(self, name_or_id, **kwargs):
|
||||
""" Set a quota in a project
|
||||
@ -11333,6 +11346,7 @@ class OpenStackCloud(
|
||||
|
||||
:returns: Munch object with the usage
|
||||
"""
|
||||
|
||||
def parse_date(date):
|
||||
try:
|
||||
return iso8601.parse_date(date)
|
||||
|
@ -250,6 +250,41 @@ class TestNetwork(base.RequestsMockTestCase):
|
||||
self.assertEqual(mock_new_network_rep, network)
|
||||
self.assert_calls()
|
||||
|
||||
def test_create_network_with_mtu(self):
|
||||
mtu_size = 1500
|
||||
mock_new_network_rep = copy.copy(self.mock_new_network_rep)
|
||||
mock_new_network_rep['mtu'] = mtu_size
|
||||
self.register_uris([
|
||||
dict(method='POST',
|
||||
uri=self.get_mock_url(
|
||||
'network', 'public', append=['v2.0', 'networks.json']),
|
||||
json={'network': mock_new_network_rep},
|
||||
validate=dict(
|
||||
json={'network': {
|
||||
'admin_state_up': True,
|
||||
'name': 'netname',
|
||||
'mtu': mtu_size}}))
|
||||
])
|
||||
network = self.cloud.create_network("netname",
|
||||
mtu_size=mtu_size
|
||||
)
|
||||
self.assertEqual(mock_new_network_rep, network)
|
||||
self.assert_calls()
|
||||
|
||||
def test_create_network_with_wrong_mtu_size(self):
|
||||
with testtools.ExpectedException(
|
||||
shade.OpenStackCloudException,
|
||||
"Parameter 'mtu_size' must be greater than 67."
|
||||
):
|
||||
self.cloud.create_network("netname", mtu_size=42)
|
||||
|
||||
def test_create_network_with_wrong_mtu_type(self):
|
||||
with testtools.ExpectedException(
|
||||
shade.OpenStackCloudException,
|
||||
"Parameter 'mtu_size' must be an integer."
|
||||
):
|
||||
self.cloud.create_network("netname", mtu_size="fourty_two")
|
||||
|
||||
def test_delete_network(self):
|
||||
network_id = "test-net-id"
|
||||
network_name = "network"
|
||||
|
Loading…
Reference in New Issue
Block a user