summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2017-10-20 16:18:25 +0200
committerMonty Taylor <mordred@inaugust.com>2017-10-21 19:04:30 +0000
commit162a7a59fd11d9b269772a7b3cb0d5282865eb8f (patch)
treefa5ef11c6b9e1302f845c2b3d17fdd3120d560f5
parent9c243d40061fbb6051c1682ff0c34b7fa574e4f1 (diff)
downloados-client-config-162a7a59fd11d9b269772a7b3cb0d5282865eb8f.tar.gz
Added nat_source flag for networks.
In some more complex clouds there can not only be more than one valid network on a server that NAT can attach to, there can also be more than one valid network from which to get a NAT address. Allow flagging a network so that it can be found. Change-Id: I3d8dd6d734a1013d2d4a43e11c3538c3a345820b
-rw-r--r--doc/source/user/network-config.rst7
-rw-r--r--os_client_config/cloud_config.py7
-rw-r--r--os_client_config/config.py1
-rw-r--r--os_client_config/tests/base.py1
-rw-r--r--os_client_config/tests/test_config.py3
-rw-r--r--releasenotes/notes/nat-source-field-7c7db2a724616d59.yaml6
6 files changed, 25 insertions, 0 deletions
diff --git a/doc/source/user/network-config.rst b/doc/source/user/network-config.rst
index 0957180..c07040e 100644
--- a/doc/source/user/network-config.rst
+++ b/doc/source/user/network-config.rst
@@ -58,3 +58,10 @@ by looking for a network that has subnets that have a gateway_ip. But it's
possible to have more than one network that satisfies that condition, so the
user might want to tell programs which one to pick. There can be only one
`nat_destination` per cloud.
+
+`nat_source` is a boolean field that indicates which network floating
+ips should be requested from. It defaults to false. Normally this can be
+inferred by looking for a network that is attached to a route. But it's
+possible to have more than one network that satisfies that condition, so the
+user might want to tell programs which one to pick. There can be only one
+`nat_source` per cloud.
diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py
index 2e97629..d1a6983 100644
--- a/os_client_config/cloud_config.py
+++ b/os_client_config/cloud_config.py
@@ -581,3 +581,10 @@ class CloudConfig(object):
if net['nat_destination']:
return net['name']
return None
+
+ def get_nat_source(self):
+ """Get network used for NAT source."""
+ for net in self.config['networks']:
+ if net.get('nat_source'):
+ return net['name']
+ return None
diff --git a/os_client_config/config.py b/os_client_config/config.py
index 87b8d65..4c054bf 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -550,6 +550,7 @@ class OpenStackConfig(object):
network = dict(
name=name,
routes_externally=get_boolean(net.get('routes_externally')),
+ nat_source=get_boolean(net.get('nat_source')),
nat_destination=get_boolean(net.get('nat_destination')),
default_interface=get_boolean(net.get('default_interface')),
)
diff --git a/os_client_config/tests/base.py b/os_client_config/tests/base.py
index 9710782..e672a0b 100644
--- a/os_client_config/tests/base.py
+++ b/os_client_config/tests/base.py
@@ -102,6 +102,7 @@ USER_CONF = {
'networks': [{
'name': 'a-public',
'routes_externally': True,
+ 'nat_source': True,
}, {
'name': 'another-public',
'routes_externally': True,
diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py
index 4f2bf96..5a8a99c 100644
--- a/os_client_config/tests/test_config.py
+++ b/os_client_config/tests/test_config.py
@@ -224,6 +224,7 @@ class TestConfig(base.TestCase):
self.assertEqual(
['a-private', 'another-private', 'split-no-default'],
cc.get_internal_networks())
+ self.assertEqual('a-public', cc.get_nat_source())
self.assertEqual('another-private', cc.get_nat_destination())
self.assertEqual('another-public', cc.get_default_network())
self.assertEqual(
@@ -239,6 +240,7 @@ class TestConfig(base.TestCase):
cc = c.get_one_cloud('_test-cloud-domain-scoped_')
self.assertEqual([], cc.get_external_networks())
self.assertEqual([], cc.get_internal_networks())
+ self.assertIsNone(cc.get_nat_source())
self.assertIsNone(cc.get_nat_destination())
self.assertIsNone(cc.get_default_network())
@@ -1019,6 +1021,7 @@ class TestBackwardsCompatibility(base.TestCase):
'networks': [
{'name': 'private', 'routes_externally': False,
'nat_destination': False, 'default_interface': False,
+ 'nat_source': False,
'routes_ipv4_externally': False,
'routes_ipv6_externally': False},
]
diff --git a/releasenotes/notes/nat-source-field-7c7db2a724616d59.yaml b/releasenotes/notes/nat-source-field-7c7db2a724616d59.yaml
new file mode 100644
index 0000000..3341c9f
--- /dev/null
+++ b/releasenotes/notes/nat-source-field-7c7db2a724616d59.yaml
@@ -0,0 +1,6 @@
+---
+features:
+ - Added nat_source flag for networks. In some more complex clouds there
+ can not only be more than one valid network on a server that NAT can
+ attach to, there can also be more than one valid network from which to
+ get a NAT address. Allow flagging a network so that it can be found.