Add net config override

Adds the ability to override the os-net-config data for the undercloud.
In some cases, a single bridge with a single physical interface may not
be sufficient for all cases. This will allow for more advanced
customization of the undercloud networking.

The path to a custom os-net-config json template can be specificed in
undercloud.conf with the net_config_override option.

Change-Id: I1fdc62d61eb5d2ea7e9418e40aa8c07173169d35
This commit is contained in:
James Slagle 2016-04-14 07:43:06 -04:00
parent dac21d6bc6
commit f52a3af42b
4 changed files with 65 additions and 35 deletions

View File

@ -181,6 +181,16 @@ _opts = [
'to custom configure services beyond what '
'undercloud.conf provides')
),
cfg.StrOpt('net_config_override',
default='',
help=('Path to network config override template. If set, this '
'template will be used to configure the networking via '
'os-net-config. Must be in json format. '
'Templated tags can be used within the '
'template, see '
'instack-undercloud/elements/undercloud-stack-config/'
'net-config.json.template for example tags')
),
cfg.StrOpt('inspection_interface',
default='br-ctlplane',
deprecated_name='discovery_interface',
@ -859,6 +869,21 @@ def _generate_environment(instack_root):
return instack_env
def _get_template_path(template):
local_template_path = os.path.join(
os.path.dirname(__file__),
'..',
'templates',
template)
installed_template_path = os.path.join(
'/usr/share/instack-undercloud/templates',
template)
if os.path.exists(local_template_path):
return local_template_path
else:
return installed_template_path
def _generate_init_data(instack_env):
context = instack_env.copy()
@ -872,20 +897,17 @@ def _generate_init_data(instack_env):
else:
hiera_entry = ''
if CONF.net_config_override:
net_config_json = open(CONF.net_config_override).read()
else:
net_config_json = \
open(_get_template_path('net-config.json.template')).read()
context['HIERADATA_OVERRIDE'] = hiera_entry
renderer = pystache.Renderer()
local_template_path = os.path.join(
os.path.dirname(__file__),
'..',
'templates',
'config.json.template')
installed_template_path = \
'/usr/share/instack-undercloud/templates/config.json.template'
if os.path.exists(local_template_path):
template = local_template_path
else:
template = installed_template_path
partials = {'net_config': net_config_json}
renderer = pystache.Renderer(partials=partials)
template = _get_template_path('config.json.template')
with open(template) as f:
config_json = renderer.render(f.read(), context)

View File

@ -24,29 +24,7 @@
"runbench": "{{DISCOVERY_RUNBENCH}}"
},
"os_net_config": {
"network_config": [
{
"type": "ovs_bridge",
"name": "br-ctlplane",
"ovs_extra": [
"br-set-external-id br-ctlplane bridge-id br-ctlplane"
],
"members": [
{
"type": "interface",
"name": "{{LOCAL_INTERFACE}}",
"primary": "true",
"mtu": {{LOCAL_MTU}}
}
],
"addresses": [
{
"ip_netmask": "{{PUBLIC_INTERFACE_IP}}"
}
],
"mtu": {{LOCAL_MTU}}
}
]
{{> net_config}}
},
"keystone": {
"host": "{{LOCAL_IP}}"

View File

@ -0,0 +1,23 @@
"network_config": [
{
"type": "ovs_bridge",
"name": "br-ctlplane",
"ovs_extra": [
"br-set-external-id br-ctlplane bridge-id br-ctlplane"
],
"members": [
{
"type": "interface",
"name": "{{LOCAL_INTERFACE}}",
"primary": "true",
"mtu": {{LOCAL_MTU}}
}
],
"addresses": [
{
"ip_netmask": "{{PUBLIC_INTERFACE_IP}}"
}
],
"mtu": {{LOCAL_MTU}}
}
]

View File

@ -82,6 +82,13 @@
# what undercloud.conf provides (string value)
#hieradata_override =
# Path to network config override template. If set, this template will
# be used to configure the networking via os-net-config. Templated
# tags can be used within the template, see instack-
# undercloud/elements/undercloud-stack-config/net-config.json.template
# for example tags (string value)
#net_config_override =
# Network interface on which inspection dnsmasq will listen. If in
# doubt, use the default value. (string value)
# Deprecated group/name - [DEFAULT]/discovery_interface