Browse Source
Previously, the snap set up a bridge using the default 10.20.20.0/24 network upon install. If there was a good reason not to use this network (e.g., it already exists and is being used for another purpose), MicroStack, and the host machine, could wind up in a broken state. This PR delays setting up the bridge until after we have given an operator a chance to override the default settings. This has been manually tested. To test, do the following: 1) Checkout the code, and run tox -e build 2) Run tools/make-a-microstack.sh 3) snapctl set config.network.ext-cidr and config.network.ext-gateway 4) Run microstack_init 5) Exit the snap shell and run microstack.launch Change-Id: I9e268495f313b29d9781d80a2468fc0a1a450aa0 Closes-Bug: https://bugs.launchpad.net/microstack/+bug/1851521changes/48/693948/1
6 changed files with 93 additions and 47 deletions
@ -0,0 +1,10 @@
|
||||
#!/bin/bash |
||||
|
||||
set -e |
||||
|
||||
if ! [ "$(snapctl get initialized)" == "true" ]; then |
||||
echo "Microstack not yet initliazed. Waiting to start." |
||||
exit 0; |
||||
fi |
||||
|
||||
exec $@ |
@ -0,0 +1,52 @@
|
||||
from init.config import Env, log |
||||
from init.questions.question import Question |
||||
from init.shell import check, check_output |
||||
|
||||
_env = Env().get_env() |
||||
|
||||
|
||||
class ExtGateway(Question): |
||||
"""Possibly override default ext gateway.""" |
||||
|
||||
_type = 'string' |
||||
_question = 'External Gateway' |
||||
config_key = 'config.network.ext-gateway' |
||||
|
||||
def yes(self, answer): |
||||
clustered = check_output('snapctl', 'get', 'config.clustered') |
||||
if clustered.lower() != 'true': |
||||
check('snapctl', 'set', 'config.network.control-ip={}'.format( |
||||
answer)) |
||||
check('snapctl', 'set', 'config.network.compute-ip={}'.format( |
||||
answer)) |
||||
_env['control_ip'] = _env['compute_ip'] = answer |
||||
else: |
||||
_env['control_ip'] = check_output('snapctl', 'get', |
||||
'config.network.control-ip') |
||||
_env['compute_ip'] = check_output('snapctl', 'get', |
||||
'config.network.compute-ip') |
||||
|
||||
|
||||
class ExtCidr(Question): |
||||
"""Possibly override the cidr.""" |
||||
|
||||
_type = 'string' |
||||
_question = 'External Ip Range' |
||||
config_key = 'config.network.ext-cidr' |
||||
|
||||
def yes(self, answer): |
||||
_env['extcidr'] = answer |
||||
|
||||
|
||||
class IpForwarding(Question): |
||||
"""Possibly setup IP forwarding.""" |
||||
|
||||
_type = 'boolean' # Auto for now, to maintain old behavior. |
||||
_question = 'Do you wish to setup ip forwarding? (recommended)' |
||||
config_key = 'config.host.ip-forwarding' |
||||
|
||||
def yes(self, answer: str) -> None: |
||||
"""Use sysctl to setup ip forwarding.""" |
||||
log.info('Setting up ipv4 forwarding...') |
||||
|
||||
check('sysctl', 'net.ipv4.ip_forward=1') |
Loading…
Reference in new issue