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
8eb788af07
commit
a1fc820a2f
@ -3336,7 +3336,8 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
def create_network(self, name, shared=False, admin_state_up=True,
|
def create_network(self, name, shared=False, admin_state_up=True,
|
||||||
external=False, provider=None, project_id=None,
|
external=False, provider=None, project_id=None,
|
||||||
availability_zone_hints=None,
|
availability_zone_hints=None,
|
||||||
port_security_enabled=None):
|
port_security_enabled=None,
|
||||||
|
mtu_size=None):
|
||||||
"""Create a network.
|
"""Create a network.
|
||||||
|
|
||||||
:param string name: Name of the network being created.
|
:param string name: Name of the network being created.
|
||||||
@ -3351,6 +3352,8 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
:param types.ListType availability_zone_hints: A list of availability
|
:param types.ListType availability_zone_hints: A list of availability
|
||||||
zone hints.
|
zone hints.
|
||||||
:param bool port_security_enabled: Enable / Disable port security
|
: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.
|
:returns: The network object.
|
||||||
:raises: OpenStackCloudException on operation error.
|
:raises: OpenStackCloudException on operation error.
|
||||||
@ -3399,6 +3402,16 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
"Parameter 'port_security_enabled' must be a bool")
|
"Parameter 'port_security_enabled' must be a bool")
|
||||||
network['port_security_enabled'] = port_security_enabled
|
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",
|
data = self._network_client.post("/networks.json",
|
||||||
json={'network': network})
|
json={'network': network})
|
||||||
|
|
||||||
@ -11548,6 +11561,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
|
|
||||||
:returns: Munch object with the usage
|
:returns: Munch object with the usage
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def parse_date(date):
|
def parse_date(date):
|
||||||
try:
|
try:
|
||||||
return iso8601.parse_date(date)
|
return iso8601.parse_date(date)
|
||||||
|
@ -251,6 +251,41 @@ class TestNetwork(base.TestCase):
|
|||||||
self.assertEqual(mock_new_network_rep, network)
|
self.assertEqual(mock_new_network_rep, network)
|
||||||
self.assert_calls()
|
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(
|
||||||
|
openstack.cloud.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(
|
||||||
|
openstack.cloud.OpenStackCloudException,
|
||||||
|
"Parameter 'mtu_size' must be an integer."
|
||||||
|
):
|
||||||
|
self.cloud.create_network("netname", mtu_size="fourty_two")
|
||||||
|
|
||||||
def test_delete_network(self):
|
def test_delete_network(self):
|
||||||
network_id = "test-net-id"
|
network_id = "test-net-id"
|
||||||
network_name = "network"
|
network_name = "network"
|
||||||
|
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.
|
Loading…
Reference in New Issue
Block a user