Merge "python-shade expose MTU setting."
This commit is contained in:
commit
7eb8f8fee5
@ -3336,7 +3336,8 @@ class OpenStackCloud(_normalize.Normalizer):
|
||||
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.
|
||||
@ -3351,6 +3352,8 @@ class OpenStackCloud(_normalize.Normalizer):
|
||||
:param types.ListType 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.
|
||||
@ -3399,6 +3402,16 @@ class OpenStackCloud(_normalize.Normalizer):
|
||||
"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})
|
||||
|
||||
@ -11512,7 +11525,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
||||
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.
|
||||
@ -11533,7 +11546,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
||||
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
|
||||
@ -11609,6 +11622,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
||||
|
||||
:returns: Munch object with the usage
|
||||
"""
|
||||
|
||||
def parse_date(date):
|
||||
try:
|
||||
return iso8601.parse_date(date)
|
||||
|
@ -251,6 +251,41 @@ class TestNetwork(base.TestCase):
|
||||
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(
|
||||
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):
|
||||
network_id = "test-net-id"
|
||||
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