Skip to content

Commit

Permalink
Adding dns_domain parameter into create_network
Browse files Browse the repository at this point in the history
The Network class supports the dns_domain field. This change
adds in the ability to create & update networks with the
dns_domain set.

Change-Id: Ifa072138b616d2a12696b27e10556f92542c05cb
  • Loading branch information
StingRayZA committed May 17, 2019
1 parent e47d256 commit a3e846e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
12 changes: 10 additions & 2 deletions openstack/cloud/_network.py
Expand Up @@ -448,7 +448,7 @@ 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,
mtu_size=None):
mtu_size=None, dns_domain=None):
"""Create a network.
:param string name: Name of the network being created.
Expand All @@ -465,6 +465,8 @@ def create_network(self, name, shared=False, admin_state_up=True,
: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.
:param string dns_domain: Specify the DNS domain associated with
this network.
:returns: The network object.
:raises: OpenStackCloudException on operation error.
Expand Down Expand Up @@ -523,14 +525,18 @@ def create_network(self, name, shared=False, admin_state_up=True,

network['mtu'] = mtu_size

if dns_domain:
network['dns_domain'] = dns_domain

data = self.network.post("/networks.json", json={'network': network})

# Reset cache so the new network is picked up
self._reset_network_caches()
return self._get_and_munchify('network', data)

@_utils.valid_kwargs("name", "shared", "admin_state_up", "external",
"provider", "mtu_size", "port_security_enabled")
"provider", "mtu_size", "port_security_enabled",
"dns_domain")
def update_network(self, name_or_id, **kwargs):
"""Update a network.
Expand All @@ -545,6 +551,8 @@ def update_network(self, name_or_id, **kwargs):
:param int mtu_size: New maximum transmission unit value to address
fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6.
:param bool port_security_enabled: Enable or disable port security.
:param string dns_domain: Specify the DNS domain associated with
this network.
:returns: The updated network object.
:raises: OpenStackCloudException on operation error.
Expand Down
3 changes: 2 additions & 1 deletion openstack/tests/unit/cloud/test_network.py
Expand Up @@ -45,7 +45,8 @@ class TestNetwork(base.TestCase):
'admin_state_up': True,
'tenant_id': '861808a93da0484ea1767967c4df8a23',
'created_at': '2017-04-22T19:22:53Z',
'mtu': 0
'mtu': 0,
'dns_domain': 'sample.openstack.org.'
}

network_availability_zone_extension = {
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/dns-domain-parameter-d3acfc3287a9d632.yaml
@@ -0,0 +1,5 @@
---
features:
- |
Added dns_domain parameter into the create_network and update_network
methods.

0 comments on commit a3e846e

Please sign in to comment.