Change network info indication to a generic list
Networks can have more information than just internal or external. Notably, if you have two private networks and you're trying to assign floating ips, you need to know which network should be the recipient. This should be backwards compatible with existing external_network and internal_network options. Change-Id: I0d469339ba00486683fcd3ce2995002fa0a576d1
This commit is contained in:
parent
9d49a7a873
commit
278a761df6
12
README.rst
12
README.rst
@ -289,12 +289,16 @@ region.
|
||||
regions:
|
||||
- name: ams01
|
||||
values:
|
||||
external_network: inap-17037-WAN1654
|
||||
internal_network: inap-17037-LAN4820
|
||||
networks:
|
||||
- name: inap-17037-WAN1654
|
||||
routes_externally: true
|
||||
- name: inap-17037-LAN6745
|
||||
- name: nyj01
|
||||
values:
|
||||
external_network: inap-17037-WAN7752
|
||||
internal_network: inap-17037-LAN6745
|
||||
networks:
|
||||
- name: inap-17037-WAN1654
|
||||
routes_externally: true
|
||||
- name: inap-17037-LAN6745
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
@ -477,6 +477,7 @@ class OpenStackConfig(object):
|
||||
cloud = self._fix_backwards_auth_plugin(cloud)
|
||||
cloud = self._fix_backwards_project(cloud)
|
||||
cloud = self._fix_backwards_interface(cloud)
|
||||
cloud = self._fix_backwards_networks(cloud)
|
||||
cloud = self._handle_domain_id(cloud)
|
||||
return cloud
|
||||
|
||||
@ -485,6 +486,29 @@ class OpenStackConfig(object):
|
||||
or 'project_id' in cloud['auth']
|
||||
or 'project_name' in cloud['auth'])
|
||||
|
||||
def _fix_backwards_networks(self, cloud):
|
||||
# Leave the external_network and internal_network keys in the
|
||||
# dict because consuming code might be expecting them.
|
||||
networks = cloud.get('networks', [])
|
||||
for key in ('external_network', 'internal_network'):
|
||||
external = key.startswith('external')
|
||||
if key in cloud and 'networks' in cloud:
|
||||
raise exceptions.OpenStackConfigException(
|
||||
"Both {key} and networks were specified in the config."
|
||||
" Please remove {key} from the config and use the network"
|
||||
" list to configure network behavior.".format(key=key))
|
||||
if key in cloud:
|
||||
warnings.warn(
|
||||
"{key} is deprecated. Please replace with an entry in"
|
||||
" a dict inside of the networks list with name: {name}"
|
||||
" and routes_externally: {external}".format(
|
||||
key=key, name=cloud[key], external=external))
|
||||
networks.append(dict(
|
||||
name=cloud[key],
|
||||
routes_externally=external))
|
||||
cloud['networks'] = networks
|
||||
return cloud
|
||||
|
||||
def _handle_domain_id(self, cloud):
|
||||
# Allow people to just specify domain once if it's the same
|
||||
mappings = {
|
||||
|
@ -753,3 +753,34 @@ class TestBackwardsCompatibility(base.TestCase):
|
||||
}
|
||||
}
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test_backwards_network_fail(self):
|
||||
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
|
||||
vendor_files=[self.vendor_yaml])
|
||||
cloud = {
|
||||
'external_network': 'public',
|
||||
'networks': [
|
||||
{'name': 'private', 'routes_externally': False},
|
||||
]
|
||||
}
|
||||
self.assertRaises(
|
||||
exceptions.OpenStackConfigException,
|
||||
c._fix_backwards_networks, cloud)
|
||||
|
||||
def test_backwards_network(self):
|
||||
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
|
||||
vendor_files=[self.vendor_yaml])
|
||||
cloud = {
|
||||
'external_network': 'public',
|
||||
'internal_network': 'private',
|
||||
}
|
||||
result = c._fix_backwards_networks(cloud)
|
||||
expected = {
|
||||
'external_network': 'public',
|
||||
'internal_network': 'private',
|
||||
'networks': [
|
||||
{'name': 'public', 'routes_externally': True},
|
||||
{'name': 'private', 'routes_externally': False},
|
||||
]
|
||||
}
|
||||
self.assertEqual(expected, result)
|
||||
|
11
releasenotes/notes/network-list-e6e9dafdd8446263.yaml
Normal file
11
releasenotes/notes/network-list-e6e9dafdd8446263.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
features:
|
||||
- Support added for configuring metadata about networks
|
||||
for a cloud in a list of dicts, rather than in the
|
||||
external_network and internal_network entries. The dicts
|
||||
support a name and a routes_externally field, as well as
|
||||
any other arbitrary metadata needed by consuming
|
||||
applications.
|
||||
deprecations:
|
||||
- external_network and internal_network are deprecated and
|
||||
should be replaced with the list of network dicts.
|
Loading…
x
Reference in New Issue
Block a user